ATLAS Offline Software
Loading...
Searching...
No Matches
NavConverterConfig.py
Go to the documentation of this file.
2# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3#
4
5from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6from AthenaConfiguration.ComponentFactory import CompFactory
7# from AthenaCommon.Constants import DEBUG # uncomment for the easy usage while testing with DEBUG
8from AthenaCommon.Logging import logging
9log = logging.getLogger("NavConverterConfig")
10
11
12def NavConverterCfg(flags, chainsList = [], runTheChecker = False):
13 """Configures Run 1/2 to Run 3 navigation conversion algorithm for all triggers"""
14 if len(chainsList) == 0:
15 log.info("Chains list is empty, the conversion will happen for all chains, but no validation will be performed")
16 log.info("The later is enabled when an explicit chain list is provided")
17
18 acc = ComponentAccumulator()
19
20 if flags.Trigger.EDMVersion >= 3:
21 return acc
22
23 if not flags.Trigger.doEDMVersionConversion:
24 return acc
25
26 from TrigDecisionTool.TrigDecisionToolConfig import TrigDecisionToolCfg, getRun3NavigationContainerFromInput
27 tdt = acc.getPrimaryAndMerge(TrigDecisionToolCfg(flags))
28
29 r2ToR3OutputName = getRun3NavigationContainerFromInput(flags)
30
31 cnvAlg = CompFactory.Run2ToRun3TrigNavConverterV2("TrigRun2ToRun3NavConverter") #, OutputLevel = 2)
32 cnvAlg.TrigDecisionTool = tdt
33 cnvAlg.TrigNavReadKey = ""
34 cnvAlg.TrigConfigSvc = tdt.TrigConfigSvc
35 cnvAlg.OutputNavKey = r2ToR3OutputName
36 from OutputStreamAthenaPool.OutputStreamConfig import addToAOD, addToESD
37 collections = [f"xAOD::TrigCompositeContainer#{r2ToR3OutputName}", f"xAOD::TrigCompositeAuxContainer#{r2ToR3OutputName}Aux."]
38 acc.merge(addToAOD(flags, collections))
39 acc.merge(addToESD(flags, collections))
40
41 cnvAlg.Rois = ["initialRoI","forID","forID1","forID2","forMS","forSA","forTB","forMT","forCB"]
42
43 from TrigEDMConfig.TriggerEDM import getTriggerEDMList
44 edm = getTriggerEDMList(flags, "AODCONV")
45
46 def cleanKey(type, name):
47 return name.replace("HLT_", "", 1).replace(type.replace("::", "__"), "", 1).replace("_", "", 1)
48 types = []
49 for type, keys in edm.items():
50
51 for key in keys:
52 types.append(type+"#"+cleanKey(type, key))
53
54 log.info("Assuming these collections are relevant for trigger: %s", " ".join(types))
55 cnvAlg.Collections = types
56 cnvAlg.Chains = chainsList
57 log.debug("Chains configured for conversion: %s", cnvAlg.Chains)
58 cnvAlg.doCompression = True # set True for compression
59 acc.addEventAlgo(cnvAlg)
60
61 if runTheChecker:
62 checker = CompFactory.Trig.NavigationTesterAlg(FailOnDifference = False, TrigDecisionTool = tdt) #, OutputLevel = 2)
63 checker.RetrievalToolRun2Nav = CompFactory.Trig.IParticleRetrievalTool()
64
65 # in conversion job Run2 TDT is setup as default, we need to setup an alternative to access Run 3 format
66 run3tdt = CompFactory.Trig.TrigDecisionTool("Run3TrigDecisionTool",
67 HLTSummary = r2ToR3OutputName,
68 NavigationFormat = 'TrigComposite',
69 AcceptMultipleInstance=True,
70 TrigConfigSvc = tdt.TrigConfigSvc) #, OutputLevel = 2)
71 acc.addPublicTool(run3tdt)
72 checker.RetrievalToolRun3Nav = CompFactory.Trig.R3IParticleRetrievalTool(
73 TrigDecisionTool = run3tdt) #, OutputLevel = 1)
74 checker.Chains = chainsList
75 checker.TrigDecisionToolRun3 = run3tdt
76 checker.TrigDecisionToolRun2 = tdt
77
78 acc.addEventAlgo(checker)
79
80 return acc
81
82
83if __name__ == "__main__":
84 # this is only config test, actual tests are in share/testTrigR2... scripts
85 from AthenaConfiguration.AllConfigFlags import initConfigFlags
86 from AthenaConfiguration.TestDefaults import defaultTestFiles
87 flags = initConfigFlags()
88 flags.Input.Files = defaultTestFiles.AOD_RUN2_DATA
89 flags.Trigger.doEDMVersionConversion = True
90 flags.lock()
91
92 acc = NavConverterCfg(flags)
93 acc.printConfig(withDetails=True, summariseProps=True)
94 acc.wasMerged()
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:312
NavConverterCfg(flags, chainsList=[], runTheChecker=False)