ATLAS Offline Software
LArSCRecoTestSkeleton.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 import sys
4 import os
5 
6 from PyJobTransforms.CommonRunArgsToFlags import commonRunArgsToFlags
7 from PyJobTransforms.TransformUtils import processPreExec, processPreInclude, processPostExec, processPostInclude
8 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
9 
10 def fromRunArgs(runArgs):
11 
12  from AthenaCommon.Logging import logging
13  mlog_SCD = logging.getLogger( 'LArSCRecoTestSkeleton' )
14 
15  from AthenaConfiguration.AllConfigFlags import initConfigFlags
16  flags=initConfigFlags()
17 
18  from LArCafJobs.LArSCDumperFlags import addSCDumpFlags
19  addSCDumpFlags(flags)
20  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
21  addLArCalibFlags(flags, True)
22 
23  commonRunArgsToFlags(runArgs, flags)
24 
25  processPreInclude(runArgs, flags)
26  processPreExec(runArgs, flags)
27 
28  flags.Input.Files=runArgs.inputBSFile
29  flags.LArSCDump.outputNtup=runArgs.outputNTUP_SCRecoFile
30 
31  # real geom not working yet
32  flags.LArSCDump.doGeom=False
33 
34  flags.LArSCDump.doBC=True
35 
36  from LArConditionsCommon.LArRunFormat import getLArDTInfoForRun
37  try:
38  runinfo=getLArDTInfoForRun(flags.Input.RunNumbers[0], connstring="COOLONL_LAR/CONDBR2")
39  except Exception:
40  mlog_SCD.warning("Could not get DT run info, using defaults !")
41  flags.LArSCDump.doEt=True
42  flags.LArSCDump.nSamples=5
43  flags.LArSCDump.nEt=1
44  SCKey="SC_ET"
45  flags.LArSCDump.digitsKey="SC_ADC_BAS"
46  else:
47  flags.LArSCDump.digitsKey=""
48  for i in range(0,len(runinfo.streamTypes())):
49  if runinfo.streamTypes()[i] == "SelectedEnergy":
50  SCKey = "SC_ET_ID"
51  flags.LArSCDump.doEt=True
52  flags.LArSCDump.nEt=runinfo.streamLengths()[i]
53  elif runinfo.streamTypes()[i] == "Energy":
54  SCKey = "SC_ET"
55  flags.LArSCDump.doEt=True
56  flags.LArSCDump.nEt=runinfo.streamLengths()[i]
57  elif runinfo.streamTypes()[i] == "RawADC":
58  flags.LArSCDump.digitsKey="SC"
59  flags.LArSCDump.nSamples=runinfo.streamLengths()[i]
60  elif runinfo.streamTypes()[i] == "ADC":
61  flags.LArSCDump.digitsKey="SC_ADC_BAS"
62  flags.LArSCDump.nSamples=runinfo.streamLengths()[i]
63 
64  finally:
65  flags.LArSCDump.doRawChan=True
66 
67  print("Autoconfigured: ",flags.LArSCDump.nEt, flags.LArSCDump.nSamples)
68  # To respect --athenaopts
69  flags.fillFromArgs()
70 
71  flags.lock()
72 
73  cfg=MainServicesCfg(flags)
74 
75  #Setup cabling
76  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg, LArOnOffIdMappingSCCfg
77  cfg.merge(LArOnOffIdMappingCfg(flags))
78  cfg.merge(LArOnOffIdMappingSCCfg(flags))
79 
80  from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBSCCfg
81  cfg.merge(LArElecCalibDBSCCfg(flags, condObjs=["Ramp","DAC2uA", "Pedestal", "uA2MeV", "MphysOverMcal", "OFC", "Shape", "HVScaleCorr"]))
82 
83  from TrigConfigSvc.TrigConfigSvcCfg import BunchGroupCondAlgCfg
84  cfg.merge( BunchGroupCondAlgCfg( flags ) )
85 
86 
87  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
88  cfg.merge(LArGMCfg(flags))
89 
90  if flags.LArSCDump.doBC:
91  from LArBadChannelTool.LArBadChannelConfig import LArBadChannelCfg
92  cfg.merge(LArBadChannelCfg(flags, isSC=True))
93 
94 
95  from LArByteStream.LArRawDataReadingConfig import LArRawDataReadingCfg
96  cfg.merge(LArRawDataReadingCfg(flags))
97 
98  from LArROD.LArRawChannelBuilderAlgConfig import LArRawChannelBuilderAlgCfg
99  cfg.merge(LArRawChannelBuilderAlgCfg(flags))
100 
101  from LArByteStream.LArRawSCDataReadingConfig import LArRawSCDataReadingCfg
102  SCData_acc = LArRawSCDataReadingCfg(flags)
103  SCData_acc.OutputLevel=3
104  cfg.merge(SCData_acc)
105 
106  from AthenaConfiguration.ComponentFactory import CompFactory
107  larLATOMEBuilderAlg=CompFactory.LArLATOMEBuilderAlg("LArLATOMEBuilderAlg",LArDigitKey=flags.LArSCDump.digitsKey, isADCBas="BAS" in flags.LArSCDump.digitsKey, nEnergies = flags.LArSCDump.nSamples - 3, startEnergy=runArgs.startSampleShift)
108  cfg.addEventAlgo(larLATOMEBuilderAlg)
109 
110  cfg.addEventAlgo(CompFactory.LArSC2NtupleEB("LArSC2NtupleEB", isSC=True, AddBadChannelInfo=flags.LArSCDump.doBC, BadChanKey="LArBadChannelSC",
111  OffId=flags.LArSCDump.doOfflineId, AddHash=flags.LArSCDump.doHash, AddCalib=flags.LArSCDump.doCalib, RealGeometry=flags.LArSCDump.doGeom, ExpandId=flags.LArSCDump.expandId, # from LArCond2NtupleBase
112  FillBCID=flags.LArSCDump.doBCID, EnergyContainerKey=SCKey,
113  scNet=flags.LArSCDump.nEt, EnergyCut=runArgs.energyCut,
114  RecoContainerKey="SC_ET_RECO", RawChanContainerKey="LArRawChannels",
115  OutputLevel=3))
116 
117  if os.path.exists(flags.LArSCDump.outputNtup):
118  os.remove(flags.LArSCDump.outputNtup)
119  cfg.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+flags.LArSCDump.outputNtup+"' OPT='NEW'" ]))
120  cfg.setAppProperty("HistogramPersistency","ROOT")
121 
122 
123  processPostInclude(runArgs, flags, cfg)
124  processPostExec(runArgs, flags, cfg)
125 
126  #example how to dump the stores
127  #cfg.getService("StoreGateSvc").Dump=True
128  #from AthenaCommon.Constants import DEBUG
129  #cfg.getService("MessageSvc").OutputLevel=DEBUG
130  # Run the final accumulator
131  sc = cfg.run()
132  sys.exit(not sc.isSuccess())
python.TransformUtils.processPreExec
def processPreExec(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:41
LArCablingConfig.LArOnOffIdMappingSCCfg
def LArOnOffIdMappingSCCfg(configFlags)
Definition: LArCablingConfig.py:65
python.TransformUtils.processPostExec
def processPostExec(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:50
python.LArBadChannelConfig.LArBadChannelCfg
def LArBadChannelCfg(configFlags, tag=None, isSC=False)
Definition: LArBadChannelConfig.py:8
python.LArRawChannelBuilderAlgConfig.LArRawChannelBuilderAlgCfg
def LArRawChannelBuilderAlgCfg(flags, **kwargs)
Definition: LArRawChannelBuilderAlgConfig.py:9
python.LArRawSCDataReadingConfig.LArRawSCDataReadingCfg
def LArRawSCDataReadingCfg(configFlags, **kwargs)
Definition: LArRawSCDataReadingConfig.py:8
python.TransformUtils.processPostInclude
def processPostInclude(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:69
python.TransformUtils.processPreInclude
def processPreInclude(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:62
python.BunchGroupCondAlgConfig.BunchGroupCondAlgCfg
def BunchGroupCondAlgCfg(flags)
Definition: BunchGroupCondAlgConfig.py:14
LArSCRecoTestSkeleton.fromRunArgs
def fromRunArgs(runArgs)
Definition: LArSCRecoTestSkeleton.py:10
python.LArRunFormat.getLArDTInfoForRun
def getLArDTInfoForRun(run, quiet=False, connstring="COOLONL_LAR/CONDBR2")
Definition: LArRunFormat.py:114
LArRunFormat
LArSCDumperFlags.addSCDumpFlags
def addSCDumpFlags(flags)
Definition: LArSCDumperFlags.py:3
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.CommonRunArgsToFlags.commonRunArgsToFlags
def commonRunArgsToFlags(runArgs, configFlags)
Definition: CommonRunArgsToFlags.py:12
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
python.LArRawDataReadingConfig.LArRawDataReadingCfg
def LArRawDataReadingCfg(configFlags, **kwargs)
Definition: LArRawDataReadingConfig.py:10
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.LArElecCalibDBConfig.LArElecCalibDBSCCfg
def LArElecCalibDBSCCfg(flags, condObjs, sqlite=None)
Definition: LArElecCalibDBConfig.py:126
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3