ATLAS Offline Software
AnalysisTriggerAlgsConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from AthenaConfiguration.Enums import Format
6 from AthenaCommon.Logging import logging
7 _log = logging.getLogger('AnalysisTriggerAlgsConfig.py')
8 
9 def RoIBResultToxAODCfg(flags):
10  if flags.Trigger.enableL1MuonPhase1 and not flags.Trigger.enableL1CaloLegacy:
11  # No Run-2 L1 RoIs -> nothing to covert to xAOD -> don't add RoIBResultToxAOD
12  _log.debug('Not adding RoIBResultToxAOD because no Run-2 L1 system is enabled by flags')
13  return ComponentAccumulator(), []
14 
15  acc = ComponentAccumulator()
16  alg = CompFactory.RoIBResultToxAOD('RoIBResultToxAOD')
17  alg.DoMuon = flags.Detector.EnableMuon and not flags.Trigger.enableL1MuonPhase1
18  alg.DoCalo = flags.Detector.EnableCalo and flags.Trigger.enableL1CaloLegacy
19 
20  if flags.Input.Format is Format.POOL:
21  if str(alg.xAODKeyMuon) in flags.Input.Collections:
22  _log.debug('L1Muon xAOD already in the input file, setting RoIBResultToxAOD.DoMuon=False')
23  alg.DoMuon = False
24  allCaloOutputs = [k.Path for k in [alg.xAODKeyEmTau, alg.xAODKeyEsum, alg.xAODKeyJetEt, alg.xAODKeyJet]]
25  if all([k in flags.Input.Collections for k in allCaloOutputs]):
26  _log.debug('L1Calo xAOD already in the input file, setting RoIBResultToxAOD.DoCalo=False')
27  alg.DoCalo = False
28 
29  if not alg.DoMuon and not alg.DoCalo:
30  _log.debug('Not adding RoIBResultToxAOD because both DoMuon and DoCalo properties are False')
31  return ComponentAccumulator(), []
32 
33  if flags.Input.Format is Format.BS:
34  from TrigT1CaloByteStream.LVL1CaloRun2ByteStreamConfig import LVL1CaloRun2ReadBSCfg
35  acc.merge(LVL1CaloRun2ReadBSCfg(flags, forRoIBResultToxAOD=True))
36 
37  # Create output list to return for use by the caller
38  outputList = []
39  if alg.DoMuon:
40  outputList += [
41  (alg.xAODKeyMuon.Type, alg.xAODKeyMuon.Path)
42  ]
43  from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
44  acc.merge(MuonGeoModelCfg(flags))
45  # RPC
46  from MuonConfig.MuonCablingConfig import RPCCablingConfigCfg
47  acc.merge(RPCCablingConfigCfg(flags))
48  #TGC
49  from MuonConfig.MuonCablingConfig import TGCCablingConfigCfg
50  acc.merge(TGCCablingConfigCfg(flags))
51 
52  if alg.DoCalo:
53  outputList += [
54  (alg.xAODKeyEmTau.Type, alg.xAODKeyEmTau.Path),
55  (alg.xAODKeyEsum.Type, alg.xAODKeyEsum.Path),
56  (alg.xAODKeyJetEt.Type, alg.xAODKeyJetEt.Path),
57  (alg.xAODKeyJet.Type, alg.xAODKeyJet.Path)
58  ]
59  from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg
60  acc.merge(L1ConfigSvcCfg(flags))
61 
62  acc.addEventAlgo(alg)
63 
64  return acc, outputList
65 
66 
67 if __name__ == "__main__":
68  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
69  from AthenaConfiguration.AllConfigFlags import initConfigFlags
70  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultTestFiles, defaultGeometryTags
71  flags = initConfigFlags()
72  flags.Input.Files = defaultTestFiles.RAW_RUN2
73  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
74  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
75  flags.Exec.MaxEvents = 20
76  flags.fillFromArgs()
77  flags.lock()
78 
79  topCA = MainServicesCfg(flags)
80  from TriggerJobOpts.TriggerByteStreamConfig import ByteStreamReadCfg
81  topCA.merge(ByteStreamReadCfg(flags))
82  from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig import L1TriggerByteStreamDecoderCfg
83  topCA.merge(L1TriggerByteStreamDecoderCfg(flags))
84  ca, output = RoIBResultToxAODCfg(flags)
85  topCA.merge(ca)
86  status = topCA.run()
87  if status.isFailure():
88  import sys
89  sys.exit(-1)
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.MuonCablingConfig.TGCCablingConfigCfg
def TGCCablingConfigCfg(flags)
Definition: MuonCablingConfig.py:86
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
AnalysisTriggerAlgsConfig.RoIBResultToxAODCfg
def RoIBResultToxAODCfg(flags)
Definition: AnalysisTriggerAlgsConfig.py:9
LVL1CaloRun2ByteStreamConfig.LVL1CaloRun2ReadBSCfg
def LVL1CaloRun2ReadBSCfg(flags, forRoIBResultToxAOD=False)
Definition: LVL1CaloRun2ByteStreamConfig.py:121
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:67
python.TrigConfigSvcCfg.L1ConfigSvcCfg
def L1ConfigSvcCfg(flags)
Definition: TrigConfigSvcCfg.py:198
python.MuonCablingConfig.RPCCablingConfigCfg
def RPCCablingConfigCfg(flags)
Definition: MuonCablingConfig.py:33
python.MuonGeometryConfig.MuonGeoModelCfg
def MuonGeoModelCfg(flags)
Definition: MuonGeometryConfig.py:28
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
TrigT1ResultByteStreamConfig.L1TriggerByteStreamDecoderCfg
def L1TriggerByteStreamDecoderCfg(flags, returnEDM=False)
Definition: TrigT1ResultByteStreamConfig.py:132