5 from AthenaConfiguration.ComponentFactory
import CompFactory
6 from AthenaConfiguration.Enums
import Format
9 if __name__ ==
'__main__':
12 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
13 from AthenaCommon.Logging
import logging
18 parser = argparse.ArgumentParser(prog=
'python -m L1CaloFEXTools.L1CaloFEXToolsConfig',
19 description=
"""Decorator tool for FEX towers athena script.\n\n
20 Example: python -m L1CaloFEXTools.L1CaloFEXToolsConfig --filesInput "data22*" --evtMax 10 --outputs eTOBs """)
21 parser.add_argument(
'--evtMax',type=int,default=-1,help=
"number of events")
22 parser.add_argument(
'--filesInput',nargs=
'+',help=
"input files",required=
True)
23 parser.add_argument(
'--skipEvents',type=int,default=0,help=
"number of events to skip")
24 parser.add_argument(
'--outputLevel',default=
"WARNING",choices={
'INFO',
'WARNING',
'DEBUG',
'VERBOSE'})
25 parser.add_argument(
'--outputs',nargs=
'+',choices={
"jFex",
"eFex",
"gFex",
"legacy",
"data",
"emulated",
"TOBs"},required=
True, help=
"What data to decode and output.")
26 args = parser.parse_args()
29 log = logging.getLogger(
'L1CaloFEXToolsConfig')
30 log.setLevel(logging.DEBUG)
32 from AthenaCommon
import Constants
33 algLogLevel = getattr(Constants,args.outputLevel)
36 if any([
"data" in f
for f
in args.filesInput]):
37 flags.Trigger.triggerConfig=
'DB'
39 flags.Exec.OutputLevel = algLogLevel
40 flags.Exec.MaxEvents = args.evtMax
41 flags.Exec.SkipEvents = args.skipEvents
42 flags.Input.Files = [file
for x
in args.filesInput
for file
in glob.glob(x)]
43 flags.Concurrency.NumThreads = 1
44 flags.Concurrency.NumConcurrentEvents = 1
46 if not flags.Input.isMC:
47 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
48 flags.GeoModel.AtlasVersion = defaultGeometryTags.autoconfigure(flags)
50 if any([
"data" in f
for f
in args.filesInput]):
52 flags.Output.AODFileName =
"AOD."+(s.split(
"/")[-1]).
split(
'_SFO')[0]+
"pool.root"
54 flags.Output.AODFileName =
'AOD.pool.root'
56 flags.Trigger.EDMVersion = 3
57 flags.Trigger.doLVL1 =
True
58 flags.Trigger.enableL1CaloPhase1 =
True
61 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorsFromList
67 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
71 from TriggerJobOpts.TriggerByteStreamConfig
import ByteStreamReadCfg
75 from TrigConfigSvc.TrigConfigSvcCfg
import L1ConfigSvcCfg
84 auxType = edmType.replace(
'Container',
'AuxContainer')
85 return [f
'{edmType}#{edmName}', f
'{auxType}#{edmName}Aux.']
89 Add 'Sim' to the standard handle path
99 from L1CaloFEXSim.L1CaloFEXSimCfg
import ReadSCellFromByteStreamCfg,TriggerTowersInputCfg
107 if "eFex" in args.outputs:
112 eFEXInputs = CompFactory.LVL1.eTowerMakerFromSuperCells(
'eTowerMakerFromSuperCells')
113 eFEXInputs.eSuperCellTowerMapperTool = CompFactory.LVL1.eSuperCellTowerMapper(
'eSuperCellTowerMapper')
114 eFEX = CompFactory.LVL1.eFEXDriver(
'eFEXDriver')
115 eFEX.eFEXSysSimTool = CompFactory.LVL1.eFEXSysSim(
'eFEXSysSimTool')
116 eFEX.eFEXSysSimTool.eFEXSimTool = CompFactory.LVL1.eFEXSim(
'eFEXSimTool')
117 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool = CompFactory.LVL1.eFEXFPGA(
'eFEXFPGATool')
118 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool.eFEXegAlgoTool = CompFactory.LVL1.eFEXegAlgo(
'eFEXegAlgoTool',dmCorr=
False)
121 eFEX.eFEXSysSimTool.Key_eFexEMOutputContainer =
getSimHandle( eFEX.eFEXSysSimTool.Key_eFexEMOutputContainer )
122 eFEX.eFEXSysSimTool.Key_eFexTauOutputContainer =
getSimHandle( eFEX.eFEXSysSimTool.Key_eFexTauOutputContainer)
124 outputEDM +=
addEDM(
'xAOD::eFexEMRoIContainer' ,
'L1_eEMRoISim' )
125 outputEDM +=
addEDM(
'xAOD::eFexTauRoIContainer',
'L1_eTauRoISim')
128 eFEX.eFEXSysSimTool.Key_eFexEMxTOBOutputContainer =
getSimHandle( eFEX.eFEXSysSimTool.Key_eFexEMxTOBOutputContainer )
129 eFEX.eFEXSysSimTool.Key_eFexTauxTOBOutputContainer =
getSimHandle( eFEX.eFEXSysSimTool.Key_eFexTauxTOBOutputContainer)
131 outputEDM +=
addEDM(
'xAOD::eFexEMRoIContainer' ,
'L1_eEMxRoISim' )
132 outputEDM +=
addEDM(
'xAOD::eFexTauRoIContainer',
'L1_eTauxRoISim')
134 acc.addEventAlgo(eFEXInputs, sequenceName=
'AthAlgSeq')
135 acc.addEventAlgo(eFEX, sequenceName=
'AthAlgSeq')
140 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import eFexByteStreamToolCfg
143 flags,
'eFexBSDecoder',TOBs=
'eTOBs',xTOBs=
'exTOBs'))
145 decoderTools += [eFexTool]
146 maybeMissingRobs += eFexTool.ROBIDs
148 outputEDM +=
addEDM(
'xAOD::eFexEMRoIContainer' ,
'L1_eEMRoI' )
149 outputEDM +=
addEDM(
'xAOD::eFexTauRoIContainer',
'L1_eTauRoI' )
150 outputEDM +=
addEDM(
'xAOD::eFexEMRoIContainer' ,
'L1_eEMxRoI' )
151 outputEDM +=
addEDM(
'xAOD::eFexTauRoIContainer',
'L1_eTauxRoI')
154 if "jFex" in args.outputs:
156 if "TOBs" in args.outputs:
165 from L1CaloFEXCond.L1CaloFEXCondConfig
import jFexDBConfig
169 jFEXInputs = CompFactory.LVL1.jTowerMakerFromJfexTowers(
'jTowerMakerFromJfexTowers')
170 jFEXInputs.IsMC = flags.Input.isMC
171 jFEXInputs.jSuperCellTowerMapperTool = CompFactory.LVL1.jSuperCellTowerMapper(
'jSuperCellTowerMapper')
172 jFEXInputs.jSuperCellTowerMapperTool.SCellMasking =
not flags.Input.isMC
174 jFEX = CompFactory.LVL1.jFEXDriver(
'jFEXDriver')
175 jFEX.jFEXSysSimTool = CompFactory.LVL1.jFEXSysSim(
'jFEXSysSimTool')
178 jFEX.jFEXSysSimTool.Key_jFexSRJetOutputContainer =
getSimHandle( jFEX.jFEXSysSimTool.Key_jFexSRJetOutputContainer)
179 jFEX.jFEXSysSimTool.Key_jFexLRJetOutputContainer =
getSimHandle( jFEX.jFEXSysSimTool.Key_jFexLRJetOutputContainer)
180 jFEX.jFEXSysSimTool.Key_jFexTauOutputContainer =
getSimHandle( jFEX.jFEXSysSimTool.Key_jFexTauOutputContainer )
181 jFEX.jFEXSysSimTool.Key_jFexSumETOutputContainer =
getSimHandle( jFEX.jFEXSysSimTool.Key_jFexSumETOutputContainer)
182 jFEX.jFEXSysSimTool.Key_jFexMETOutputContainer =
getSimHandle( jFEX.jFEXSysSimTool.Key_jFexMETOutputContainer )
183 jFEX.jFEXSysSimTool.Key_jFexFwdElOutputContainer =
getSimHandle( jFEX.jFEXSysSimTool.Key_jFexFwdElOutputContainer)
185 outputEDM +=
addEDM(
'xAOD::jFexSRJetRoIContainer',
'L1_jFexSRJetRoISim')
186 outputEDM +=
addEDM(
'xAOD::jFexLRJetRoIContainer',
'L1_jFexLRJetRoISim')
187 outputEDM +=
addEDM(
'xAOD::jFexTauRoIContainer' ,
'L1_jFexTauRoISim' )
188 outputEDM +=
addEDM(
'xAOD::jFexFwdElRoIContainer',
'L1_jFexFwdElRoISim')
189 outputEDM +=
addEDM(
'xAOD::jFexSumETRoIContainer',
'L1_jFexSumETRoISim')
190 outputEDM +=
addEDM(
'xAOD::jFexMETRoIContainer' ,
'L1_jFexMETRoISim' )
194 jFEX.jFEXSysSimTool.Key_xTobOutKey_jJ =
getSimHandle( jFEX.jFEXSysSimTool.Key_xTobOutKey_jJ )
195 jFEX.jFEXSysSimTool.Key_xTobOutKey_jLJ =
getSimHandle( jFEX.jFEXSysSimTool.Key_xTobOutKey_jLJ )
196 jFEX.jFEXSysSimTool.Key_xTobOutKey_jTau =
getSimHandle( jFEX.jFEXSysSimTool.Key_xTobOutKey_jTau)
197 jFEX.jFEXSysSimTool.Key_xTobOutKey_jEM =
getSimHandle( jFEX.jFEXSysSimTool.Key_xTobOutKey_jEM )
199 outputEDM +=
addEDM(
'xAOD::jFexSRJetRoIContainer',
'L1_jFexSRJetxRoISim' )
200 outputEDM +=
addEDM(
'xAOD::jFexLRJetRoIContainer',
'L1_jFexLRJetxRoISim' )
201 outputEDM +=
addEDM(
'xAOD::jFexTauRoIContainer' ,
'L1_jFexTauxRoISim' )
202 outputEDM +=
addEDM(
'xAOD::jFexFwdElRoIContainer',
'L1_jFexFwdElxRoISim' )
204 acc.addEventAlgo(jFEXInputs, sequenceName=
'AthAlgSeq')
205 acc.addEventAlgo(jFEX, sequenceName=
'AthAlgSeq')
211 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import jFexRoiByteStreamToolCfg
214 decoderTools += [jFexRoiByteStreamTool]
215 maybeMissingRobs += jFexRoiByteStreamTool.ROBIDs
217 outputEDM +=
addEDM(
'xAOD::jFexSRJetRoIContainer',
'L1_jFexSRJetRoI')
218 outputEDM +=
addEDM(
'xAOD::jFexLRJetRoIContainer',
'L1_jFexLRJetRoI')
219 outputEDM +=
addEDM(
'xAOD::jFexTauRoIContainer' ,
'L1_jFexTauRoI' )
220 outputEDM +=
addEDM(
'xAOD::jFexFwdElRoIContainer',
'L1_jFexFwdElRoI')
221 outputEDM +=
addEDM(
'xAOD::jFexSumETRoIContainer',
'L1_jFexSumETRoI')
222 outputEDM +=
addEDM(
'xAOD::jFexMETRoIContainer' ,
'L1_jFexMETRoI' )
226 flags,
'jFexBSDecoderTool_xtobs', writeBS=
False, xTOBs=
True))
228 decoderTools += [jFexxRoiByteStreamTool]
229 maybeMissingRobs += jFexxRoiByteStreamTool.ROBIDs
231 outputEDM +=
addEDM(
'xAOD::jFexSRJetRoIContainer',
'L1_jFexSRJetxRoI')
232 outputEDM +=
addEDM(
'xAOD::jFexLRJetRoIContainer',
'L1_jFexLRJetxRoI')
233 outputEDM +=
addEDM(
'xAOD::jFexTauRoIContainer' ,
'L1_jFexTauxRoI' )
234 outputEDM +=
addEDM(
'xAOD::jFexFwdElRoIContainer',
'L1_jFexFwdElxRoI')
235 outputEDM +=
addEDM(
'xAOD::jFexSumETRoIContainer',
'L1_jFexSumETxRoI')
236 outputEDM +=
addEDM(
'xAOD::jFexMETRoIContainer' ,
'L1_jFexMETxRoI' )
238 if "data" in args.outputs:
242 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import jFexInputByteStreamToolCfg
244 for module_id
in inputjFexTool.ROBIDs:
245 maybeMissingRobs.append(module_id)
247 decoderTools += [inputjFexTool]
250 outputEDM +=
addEDM(
'xAOD::jFexTowerContainer', inputjFexTool.jTowersWriteKey.Path)
254 from L1CaloFEXAlgos.L1CaloFEXAlgosConfig
import L1CalojFEXDecoratorCfg
256 acc.merge(DecoratorAlgo)
258 if "emulated" in args.outputs:
262 from L1CaloFEXAlgos.FexEmulatedTowersConfig
import jFexEmulatedTowersCfg
265 acc.merge(jFEXEmulatorAlgo)
268 outputEDM +=
addEDM(
'xAOD::jFexTowerContainer',
"L1_jFexEmulatedTowers")
271 if "gFex" in args.outputs:
276 gFEXInputs = CompFactory.LVL1.gTowerMakerFromGfexTowers(
'gTowerMakerFromGfexTowers')
277 gFEXInputs.IsMC = flags.Input.isMC
278 gFEXInputs.gSuperCellTowerMapperTool = CompFactory.LVL1.gSuperCellTowerMapper(
'gSuperCellTowerMapper')
279 gFEXInputs.gSuperCellTowerMapperTool.SCellMasking =
not flags.Input.isMC
281 gFEXInputs50 = CompFactory.LVL1.gTowerMakerFromGfexTowers(
'gTowerMakerFromGfexTowers50')
282 gFEXInputs50.InputDataTowers =
"L1_gFexDataTowers50"
283 gFEXInputs50.MyGTowers =
"gTower50Container"
284 gFEXInputs50.IsMC = flags.Input.isMC
285 gFEXInputs50.gSuperCellTowerMapperTool = CompFactory.LVL1.gSuperCellTowerMapper(
'gSuperCellTowerMapper50')
286 gFEXInputs50.gSuperCellTowerMapperTool.SCellMasking =
not flags.Input.isMC
288 gFEX = CompFactory.LVL1.gFEXDriver(
'gFEXDriver')
289 gFEX.gFEXSysSimTool = CompFactory.LVL1.gFEXSysSim(
'gFEXSysSimTool')
292 gFEX.gFEXSysSimTool.Key_gFexSRJetOutputContainer =
getSimHandle( gFEX.gFEXSysSimTool.Key_gFexSRJetOutputContainer )
293 gFEX.gFEXSysSimTool.Key_gFexLRJetOutputContainer =
getSimHandle( gFEX.gFEXSysSimTool.Key_gFexLRJetOutputContainer )
294 gFEX.gFEXSysSimTool.Key_gFexRhoOutputContainer =
getSimHandle( gFEX.gFEXSysSimTool.Key_gFexRhoOutputContainer )
295 gFEX.gFEXSysSimTool.Key_gScalarEJwojOutputContainer =
getSimHandle( gFEX.gFEXSysSimTool.Key_gScalarEJwojOutputContainer )
296 gFEX.gFEXSysSimTool.Key_gMETComponentsJwojOutputContainer =
getSimHandle( gFEX.gFEXSysSimTool.Key_gMETComponentsJwojOutputContainer )
297 gFEX.gFEXSysSimTool.Key_gMHTComponentsJwojOutputContainer =
getSimHandle( gFEX.gFEXSysSimTool.Key_gMHTComponentsJwojOutputContainer )
298 gFEX.gFEXSysSimTool.Key_gMSTComponentsJwojOutputContainer =
getSimHandle( gFEX.gFEXSysSimTool.Key_gMSTComponentsJwojOutputContainer )
299 gFEX.gFEXSysSimTool.Key_gMETComponentsNoiseCutOutputContainer =
getSimHandle( gFEX.gFEXSysSimTool.Key_gMETComponentsNoiseCutOutputContainer)
300 gFEX.gFEXSysSimTool.Key_gMETComponentsRmsOutputContainer =
getSimHandle( gFEX.gFEXSysSimTool.Key_gMETComponentsRmsOutputContainer )
301 gFEX.gFEXSysSimTool.Key_gScalarENoiseCutOutputContainer =
getSimHandle( gFEX.gFEXSysSimTool.Key_gScalarENoiseCutOutputContainer )
302 gFEX.gFEXSysSimTool.Key_gScalarERmsOutputContainer =
getSimHandle( gFEX.gFEXSysSimTool.Key_gScalarERmsOutputContainer )
304 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer' ,
'L1_gFexRhoRoISim' )
305 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer' ,
'L1_gFexSRJetRoISim' )
306 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer' ,
'L1_gFexLRJetRoISim' )
307 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gScalarEJwojSim' )
308 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMETComponentsJwojSim' )
309 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMHTComponentsJwojSim' )
310 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMSTComponentsJwojSim' )
311 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMETComponentsNoiseCutSim')
312 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gScalarENoiseCutSim' )
313 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gScalarERmsSim' )
314 outputEDM +=
addEDM(
'xAOD::gFexTowerContainer',
'L1_gFexTriggerTowers' )
316 acc.addEventAlgo(gFEXInputs, sequenceName=
'AthAlgSeq')
317 acc.addEventAlgo(gFEXInputs50, sequenceName=
'AthAlgSeq')
318 acc.addEventAlgo(gFEX, sequenceName=
'AthAlgSeq')
324 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import gFexByteStreamToolCfg
326 decoderTools += [gFexTool]
328 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer' ,
'L1_gFexRhoRoI' )
329 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer' ,
'L1_gFexSRJetRoI' )
330 outputEDM +=
addEDM(
'xAOD::gFexJetRoIContainer' ,
'L1_gFexLRJetRoI' )
331 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gScalarEJwoj' )
332 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMETComponentsJwoj' )
333 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMHTComponentsJwoj' )
334 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMSTComponentsJwoj' )
335 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gMETComponentsNoiseCut')
336 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gScalarENoiseCut' )
337 outputEDM +=
addEDM(
'xAOD::gFexGlobalRoIContainer',
'L1_gScalarERms' )
342 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import gFexInputByteStreamToolCfg
344 decoderTools += [gFexInputTool]
345 outputEDM +=
addEDM(
'xAOD::gFexTowerContainer' ,
'L1_gFexDataTowers' )
348 from L1CaloFEXAlgos.L1CaloFEXAlgosConfig
import L1CaloGTowerDecoratorCfg
350 acc.merge(DecoratorAlgo)
352 if "legacy" in args.outputs:
354 from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig
import RoIBResultByteStreamToolCfg
356 decoderTools += [roibResultTool]
358 from libpyeformat_helper
import SourceIdentifier, SubDetector
360 for module_id
in roibResultTool.L1TopoModuleIds:
361 maybeMissingRobs.append(
int(SourceIdentifier(SubDetector.TDAQ_CALO_TOPO_PROC, module_id)))
363 for module_id
in roibResultTool.JetModuleIds:
364 maybeMissingRobs.append(
int(SourceIdentifier(SubDetector.TDAQ_CALO_JET_PROC_ROI, module_id)))
366 for module_id
in roibResultTool.EMModuleIds:
367 maybeMissingRobs.append(
int(SourceIdentifier(SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI, module_id)))
370 from AnalysisTriggerAlgs.AnalysisTriggerAlgsConfig
import RoIBResultToxAODCfg
372 acc.merge(xRoIBResultAcc)
376 outputEDM += [
'ROIB::RoIBResult#*']
378 outputEDM +=
addEDM(
'xAOD::JetEtRoI' ,
'LVL1JetEtRoI')
379 outputEDM +=
addEDM(
'xAOD::JetRoIContainer' ,
'LVL1JetRoIs')
380 outputEDM +=
addEDM(
'xAOD::EmTauRoIContainer',
'LVL1EmTauRoIs')
382 outputEDM += [
"xAOD::EnergySumRoI#LVL1EnergySumRoI",
"xAOD::EnergySumRoIAuxInfo#LVL1EnergySumRoIAux."]
385 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder", DecoderTools=decoderTools, MaybeMissingROBs=maybeMissingRobs)
386 acc.addEventAlgo(decoderAlg, sequenceName=
'AthAlgSeq')
392 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
395 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
398 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
401 acc.getEventAlgo(
"EventInfoTagBuilder").PropagateInput = (flags.Input.Format != Format.BS)
403 if acc.run().isFailure():