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  from AthenaConfiguration.TestDefaults import defaultGeometryTags
29  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
30  flags.Input.Files=runArgs.inputBSFile
31  flags.LArSCDump.outputNtup=runArgs.outputNTUP_SCRecoFile
32 
33  # real geom not working yet
34  flags.LArSCDump.doGeom=False
35 
36  flags.LArSCDump.doBC=True
37 
38  from LArConditionsCommon.LArRunFormat import getLArDTInfoForRun
39  try:
40  runinfo=getLArDTInfoForRun(flags.Input.RunNumbers[0], connstring="COOLONL_LAR/CONDBR2")
41  except Exception:
42  mlog_SCD.warning("Could not get DT run info, using defaults !")
43  flags.LArSCDump.doEt=True
44  flags.LArSCDump.nSamples=5
45  flags.LArSCDump.nEt=1
46  SCKey="SC_ET"
47  flags.LArSCDump.digitsKey="SC_ADC_BAS"
48  fw=5
49  else:
50  fw=runinfo.FWversion()
51  flags.LArSCDump.digitsKey=""
52  for i in range(0,len(runinfo.streamTypes())):
53  if runinfo.streamTypes()[i] == "SelectedEnergy":
54  SCKey = "SC_ET_ID"
55  flags.LArSCDump.doEt=True
56  flags.LArSCDump.nEt=runinfo.streamLengths()[i]
57  elif runinfo.streamTypes()[i] == "Energy":
58  SCKey = "SC_ET"
59  flags.LArSCDump.doEt=True
60  flags.LArSCDump.nEt=runinfo.streamLengths()[i]
61  elif runinfo.streamTypes()[i] == "RawADC":
62  flags.LArSCDump.digitsKey="SC"
63  flags.LArSCDump.nSamples=runinfo.streamLengths()[i]
64  elif runinfo.streamTypes()[i] == "ADC":
65  flags.LArSCDump.digitsKey="SC_ADC_BAS"
66  flags.LArSCDump.nSamples=runinfo.streamLengths()[i]
67 
68  finally:
69  flags.LArSCDump.doRawChan=True
70 
71  print("Autoconfigured: ",flags.LArSCDump.nEt, flags.LArSCDump.nSamples)
72  # To respect --athenaopts
73  flags.fillFromArgs()
74 
75  flags.lock()
76 
77  cfg=MainServicesCfg(flags)
78 
79  #Setup cabling
80  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg, LArOnOffIdMappingSCCfg
81  cfg.merge(LArOnOffIdMappingCfg(flags))
82  cfg.merge(LArOnOffIdMappingSCCfg(flags))
83 
84  from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBSCCfg
85  cfg.merge(LArElecCalibDBSCCfg(flags, condObjs=["Ramp","DAC2uA", "Pedestal", "uA2MeV", "MphysOverMcal", "OFC", "Shape", "HVScaleCorr"]))
86 
87  from TrigConfigSvc.TrigConfigSvcCfg import BunchGroupCondAlgCfg
88  cfg.merge( BunchGroupCondAlgCfg( flags ) )
89 
90 
91  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
92  cfg.merge(LArGMCfg(flags))
93 
94  if fw==6:
95  from IOVDbSvc.IOVDbSvcConfig import addOverride
96  cfg.merge(addOverride(flags,"/LAR/Identifier/LatomeMapping","LARIdentifierLatomeMapping-fw6"))
97 
98  if flags.LArSCDump.doBC:
99  from LArBadChannelTool.LArBadChannelConfig import LArBadChannelCfg
100  cfg.merge(LArBadChannelCfg(flags, isSC=True))
101 
102 
103  from LArByteStream.LArRawDataReadingConfig import LArRawDataReadingCfg
104  cfg.merge(LArRawDataReadingCfg(flags))
105 
106  from LArROD.LArRawChannelBuilderAlgConfig import LArRawChannelBuilderAlgCfg
107  cfg.merge(LArRawChannelBuilderAlgCfg(flags))
108 
109  from LArByteStream.LArRawSCDataReadingConfig import LArRawSCDataReadingCfg
110  SCData_acc = LArRawSCDataReadingCfg(flags)
111  SCData_acc.OutputLevel=3
112  cfg.merge(SCData_acc)
113 
114  from AthenaConfiguration.ComponentFactory import CompFactory
115  larLATOMEBuilderAlg=CompFactory.LArLATOMEBuilderAlg("LArLATOMEBuilderAlg",LArDigitKey=flags.LArSCDump.digitsKey, isADCBas="BAS" in flags.LArSCDump.digitsKey, nEnergies = flags.LArSCDump.nSamples - 3, startEnergy=runArgs.startSampleShift)
116  cfg.addEventAlgo(larLATOMEBuilderAlg)
117 
118  cfg.addEventAlgo(CompFactory.LArSC2NtupleEB("LArSC2NtupleEB", isSC=True, AddBadChannelInfo=flags.LArSCDump.doBC, BadChanKey="LArBadChannelSC",
119  OffId=flags.LArSCDump.doOfflineId, AddHash=flags.LArSCDump.doHash, AddCalib=flags.LArSCDump.doCalib, RealGeometry=flags.LArSCDump.doGeom, ExpandId=flags.LArSCDump.expandId, # from LArCond2NtupleBase
120  FillBCID=flags.LArSCDump.doBCID, EnergyContainerKey=SCKey,
121  scNet=flags.LArSCDump.nEt, EnergyCut=runArgs.energyCut,
122  RecoContainerKey="SC_ET_RECO", RawChanContainerKey="LArRawChannels",
123  OutputLevel=3))
124 
125  if os.path.exists(flags.LArSCDump.outputNtup):
126  os.remove(flags.LArSCDump.outputNtup)
127  cfg.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+flags.LArSCDump.outputNtup+"' OPT='NEW'" ]))
128  cfg.setAppProperty("HistogramPersistency","ROOT")
129 
130 
131  processPostInclude(runArgs, flags, cfg)
132  processPostExec(runArgs, flags, cfg)
133 
134  #example how to dump the stores
135  #cfg.getService("StoreGateSvc").Dump=True
136  #from AthenaCommon.Constants import DEBUG
137  #cfg.getService("MessageSvc").OutputLevel=DEBUG
138  # Run the final accumulator
139  sc = cfg.run()
140  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.LArRawDataReadingConfig.LArRawDataReadingCfg
def LArRawDataReadingCfg(flags, **kwargs)
Definition: LArRawDataReadingConfig.py:11
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.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:152
LArRunFormat
LArSCDumperFlags.addSCDumpFlags
def addSCDumpFlags(flags)
Definition: LArSCDumperFlags.py:3
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
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
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.IOVDbSvcConfig.addOverride
def addOverride(flags, folder, tag, tagType="tag", db=None)
Definition: IOVDbSvcConfig.py:238
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.LArElecCalibDBConfig.LArElecCalibDBSCCfg
def LArElecCalibDBSCCfg(flags, condObjs, sqlite=None)
Definition: LArElecCalibDBConfig.py:126
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3
python.LArRawSCDataReadingConfig.LArRawSCDataReadingCfg
def LArRawSCDataReadingCfg(configFlags, ROBList=None, name="LArRawSCDataReadingAlg", **kwargs)
Definition: LArRawSCDataReadingConfig.py:8