ATLAS Offline Software
Loading...
Searching...
No Matches
python.TriggerRecoConfig Namespace Reference

Functions

 TriggerRecoCfg (flags)
 TriggerRecoCfgData (flags)
 TriggerRecoCfgMC (flags)
 TriggerMetadataWriterCfg (flags)
 TriggerEDMCfg (flags)
 Run2Run1NavigationSlimmingCfg (flags)
 Run2BSExtractionCfg (flags)
 Run3TriggerBSUnpackingCfg (flags)

Variables

 log = logging.getLogger('TriggerRecoConfig')
 flags = initConfigFlags()
 args = flags.fillFromArgs()
 Files
 MaxEvents
 AtlasVersion
 acc = MainServicesCfg(flags)
 withDetails

Function Documentation

◆ Run2BSExtractionCfg()

Run2BSExtractionCfg ( flags)
Configures Trigger data from BS extraction 

Definition at line 246 of file TriggerRecoConfig.py.

246def Run2BSExtractionCfg( flags ):
247 """Configures Trigger data from BS extraction """
248 from SGComps.AddressRemappingConfig import InputRenameCfg
249
250 acc = ComponentAccumulator()
251 extr = CompFactory.TrigBSExtraction()
252 robIDMap = {} # map of result keys and their ROB ID
253
254 # Add fictional output to ensure data dependency in AthenaMT
255 extr.ExtraOutputs.add(("TrigBSExtractionOutput", "StoreGateSvc+TrigBSExtractionOutput"))
256
257 if flags.Trigger.decodeHLT:
258 from TrigEDMConfig.TriggerEDM import getEDMLibraries, getPreregistrationList, getClassesToIgnore
259 serialiserTool = CompFactory.TrigTSerializer()
260 acc.addPublicTool(serialiserTool)
261 extr.Navigation = CompFactory.HLT.Navigation("Navigation")
262 extr.Navigation.Dlls = getEDMLibraries()
263 extr.Navigation.ClassesToPreregister = getPreregistrationList(flags.Trigger.EDMVersion, flags.Trigger.doxAODConversion)
264 extr.Navigation.ClassesFromPayloadIgnore = getClassesToIgnore(flags)
265
266 from eformat import helper as efh
267
268 if flags.Trigger.EDMVersion == 1:
269 raise RuntimeError("Run-1 trigger reconstruction is no longer supported")
270 else:
271 acc.merge(InputRenameCfg("HLT::HLTResult", "HLTResult_HLT", "HLTResult_HLT_BS"))
272 robIDMap["HLTResult_HLT_BS"] = efh.SourceIdentifier(efh.SubDetector.TDAQ_HLT, 0).code()
273 extr.HLTResultKeyIn = "HLTResult_HLT_BS"
274 extr.HLTResultKeyOut = "HLTResult_HLT"
275
276 # Configure Run-2 DataScouting
277 if flags.Trigger.EDMVersion == 2:
278 stream = flags.Input.TriggerStream
279 if stream.startswith('calibration_DataScouting_'):
280 ds_tag = '_'.join(stream.split('_')[1:3]) # e.g. DataScouting_05
281 ds_id = int(stream.split('_')[2]) # e.g. 05
282 acc.merge(InputRenameCfg("HLT::HLTResult", ds_tag, ds_tag+"_BS"))
283 robIDMap[ds_tag+"_BS"] = efh.SourceIdentifier(efh.SubDetector.TDAQ_HLT, ds_id).code()
284 extr.DSResultKeysIn += [ ds_tag+"_BS" ]
285 extr.DSResultKeysOut += [ ds_tag ]
286
287 else:
288 log.info("Will not schedule real HLT bytestream extraction, instead EDM gap filling is running")
289 # if data doesn't have HLT info set HLTResult keys as empty strings to avoid warnings
290 # but the extraction algorithm must run
291 extr.HLTResultKeyIn = ""
292 extr.HLTResultKeyOut = ""
293
294 HLTResults = [ f"HLT::HLTResult/{k}" for k in robIDMap ]
295 acc.addService( CompFactory.ByteStreamAddressProviderSvc( TypeNames = HLTResults) )
296
297 from TrigEDMConfig.TriggerEDM import getTPList
298 acc.addPublicTool( CompFactory.TrigSerTPTool(TPMap = getTPList((flags.Trigger.EDMVersion))) )
299
300 acc.addPublicTool( CompFactory.TrigSerializeConvHelper(doTP = True) )
301
302 acc.addPublicTool( CompFactory.HLT.HLTResultByteStreamTool(HLTResultRobIdMap = robIDMap))
303
304 acc.addEventAlgo(extr)
305
306 return acc
307
308

◆ Run2Run1NavigationSlimmingCfg()

Run2Run1NavigationSlimmingCfg ( flags)
Configures legacy Run1/2 navigation slimming

Definition at line 200 of file TriggerRecoConfig.py.

200def Run2Run1NavigationSlimmingCfg(flags):
201 """Configures legacy Run1/2 navigation slimming"""
202 acc = ComponentAccumulator()
203
204 if flags.Trigger.decodeHLT is False:
205 log.debug("Run2Run1NavigationSlimmingCfg: Nothing to do as Trigger.decodeHLT is False")
206 return acc
207
208 if flags.Trigger.doNavigationSlimming is False:
209 log.debug("Run2Run1NavigationSlimmingCfg: Nothing to do as Trigger.doNavigationSlimming is False")
210 return acc
211
212 if flags.Trigger.EDMVersion >= 3:
213 log.debug("Run2Run1NavigationSlimmingCfg: Nothing to do for EDMVersion >= 3.")
214 return acc
215
216 if flags.Trigger.ExtraEDMList:
217 log.warning("Run2Run1NavigationSlimmingCfg: ExtraEDMList only works for Run 3 and beyond")
218
219 def _flatten(edm):
220 return list(y.split('-')[0] for x in edm.values() for y in x)
221 from TrigNavTools.TrigNavToolsConfig import TrigNavigationThinningSvcCfg
222
223 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
224
225 if flags.Output.doWriteAOD:
226 _TriggerAODList = getTriggerEDMList(flags, key=flags.Trigger.AODEDMSet)
227 thinningSvc = acc.getPrimaryAndMerge(TrigNavigationThinningSvcCfg(flags,
228 {'name' : 'HLTNav_StreamAOD',
229 'mode' : 'cleanup_noreload',
230 'result' : 'HLTResult_HLT',
231 'features' : _flatten(_TriggerAODList)}))
232 acc.merge(OutputStreamCfg(flags, "AOD", trigNavThinningSvc = thinningSvc))
233
234 if flags.Output.doWriteESD:
235 _TriggerESDList = getTriggerEDMList(flags, key=flags.Trigger.ESDEDMSet)
236 thinningSvc = acc.getPrimaryAndMerge(TrigNavigationThinningSvcCfg(flags,
237 {'name' : 'HLTNav_StreamESD',
238 'mode' : 'cleanup_noreload',
239 'result' : 'HLTResult_HLT',
240 'features' : _flatten(_TriggerESDList)}))
241 acc.merge(OutputStreamCfg(flags, "ESD", trigNavThinningSvc = thinningSvc))
242
243 return acc
244
245

◆ Run3TriggerBSUnpackingCfg()

Run3TriggerBSUnpackingCfg ( flags)
Configures conversions BS -> HLTResultMT -> Collections 

Definition at line 309 of file TriggerRecoConfig.py.

309def Run3TriggerBSUnpackingCfg(flags):
310 """Configures conversions BS -> HLTResultMT -> Collections """
311 acc = ComponentAccumulator()
312
313 if flags.Trigger.decodeHLT is False:
314 log.debug("Run3TriggerBSUnpackingCfg: Nothing to do as Trigger.decodeHLT is False")
315 return acc
316
317 from AthenaCommon.CFElements import seqAND
318 from TrigEDMConfig.DataScoutingInfo import (
319 getDataScoutingStreams, getDataScoutingTypeFromStream,
320 getFullHLTResultID, getDataScoutingResultID,
321 )
322 from TriggerJobOpts.TriggerConfig import triggerEDMGapFillerCfg
323 from TrigDecisionTool.TrigDecisionToolConfig import getRun3NavigationContainerFromInput
324 ids_to_decode = []
325
326 # Map the trigger stream to the event building type
327 if flags.Input.TriggerStream in getDataScoutingStreams():
328 dstype = getDataScoutingTypeFromStream(flags.Input.TriggerStream)
329 # If writing a Data Scouting EDM format, only decode that ID
330 log.info(f'Configuring BS decoding/deserialisation of HLT result for \'{dstype}\' only')
331 ids_to_decode = [getDataScoutingResultID(dstype)]
332 id_to_deserialise = {dstype: getDataScoutingResultID(dstype)}
333 else:
334 # Set up to read the full HLT result ID
335 ids_to_decode = [getFullHLTResultID()]
336 id_to_deserialise = {'': getFullHLTResultID()}
337
338 # In addition, decode any available IDs. We need to check which streams were active in the file.
339 log.debug('Configuring BS decoding of all HLT results and deserialisation of full HLT')
340 partialHLT_streams = [
341 stream for stream in getDataScoutingStreams() if stream.split('_')[1] in flags.Input.ProcessingTags
342 ]
343 partialHLT_dstypes = [
344 getDataScoutingTypeFromStream(stream) for stream in partialHLT_streams
345 ]
346 partialHLT_dsids = [
347 getDataScoutingResultID(dstype) for dstype in partialHLT_dstypes
348 ]
349 log.debug(f'Configuring BS decoding and deserialisation of all HLT results: full HLT + {partialHLT_dstypes}')
350
351 ids_to_decode += partialHLT_dsids
352 # A bit ugly but avoid importing the actual dict to ensure we never modify it
353 id_to_deserialise.update({
354 dstype:dsid for dstype,dsid in zip(partialHLT_dstypes, partialHLT_dsids)
355 })
356
357 decoder = CompFactory.HLTResultMTByteStreamDecoderAlg(ModuleIdsToDecode=ids_to_decode)
358 acc.addSequence(seqAND("HLTDecodingSeq"))
359 acc.addEventAlgo( decoder, "HLTDecodingSeq")
360 for dstype, id in id_to_deserialise.items():
361 deserialiser = CompFactory.TriggerEDMDeserialiserAlg(
362 f"TrigDeserialiser{dstype}",
363 ModuleID=id,
364 )
365 # Full HLT result also has slimmed navigation summary
366 if dstype == '':
367 deserialiser.ExtraOutputs.add(('xAOD::TrigCompositeContainer' , 'StoreGateSvc+DummyForGapFiller'))
368 else:
369 deserialiser.SkipDuplicateRecords = True
370 deserialiser.PermitMissingModule = True
371 acc.addEventAlgo( deserialiser, "HLTDecodingSeq")
372
373 if dstype=='':
374 # Create empty EDM collections for types not created online
375 # Add output dependency on Navigation to enforce ordering
376 gapFiller = triggerEDMGapFillerCfg(
377 flags, edmSet=['BS'],
378 extraInputs=[('xAOD::TrigCompositeContainer' , 'StoreGateSvc+DummyForGapFiller')],
379 extraOutputs=[(
380 'xAOD::TrigCompositeContainer',
381 'StoreGateSvc+'+getRun3NavigationContainerFromInput(flags)
382 )])
383 else:
384 # Create empty EDM collections for types not created online
385 gapFiller = triggerEDMGapFillerCfg(flags, edmSet=[dstype])
386 acc.merge( gapFiller, "HLTDecodingSeq" )
387
388 log.debug("Configured HLT result BS decoding sequence")
389 return acc
390
391

◆ TriggerEDMCfg()

TriggerEDMCfg ( flags)
Configures which trigger collections are recorded

Definition at line 145 of file TriggerRecoConfig.py.

145def TriggerEDMCfg(flags):
146 """Configures which trigger collections are recorded"""
147 acc = ComponentAccumulator()
148
149 # Check if we have anything to do
150 if flags.Output.doWriteESD is False and flags.Output.doWriteAOD is False:
151 log.debug("TriggerEDMCfg: Nothing to do as both Output.doWriteAOD and Output.doWriteESD are False")
152 return acc
153
154 # standard collections & metadata
155 # TODO consider unifying with TriggerConfig.triggerPOOLOutputCfg - there the assumption is that Run3
156 # metadata
157 menuMetadata = ["xAOD::TriggerMenuJsonContainer#*", "xAOD::TriggerMenuJsonAuxContainer#*",]
158 if flags.Trigger.EDMVersion in [1,2]:
159 menuMetadata += ['xAOD::TriggerMenuAuxContainer#*', 'xAOD::TriggerMenuContainer#*',]
160 # Add LVL1 collections (for Run-3 they are part of the "regular" EDM lists)
161 from TrigEDMConfig.TriggerEDM import getLvl1ESDList, getLvl1AODList
162 acc.merge(addToESD(flags, edmDictToList(getLvl1ESDList())))
163 acc.merge(addToAOD(flags, edmDictToList(getLvl1AODList())))
164
165 edmVersion = max(2, flags.Trigger.EDMVersion)
166 _TriggerESDList = getTriggerEDMList(flags, key=flags.Trigger.ESDEDMSet, runVersion=edmVersion)
167 _TriggerAODList = getTriggerEDMList(flags, key=flags.Trigger.AODEDMSet, runVersion=edmVersion)
168 log.debug("ESD EDM list: %s", _TriggerESDList)
169 log.debug("AOD EDM list: %s", _TriggerAODList)
170
171 # Highlight what is in AOD list but not in ESD list, as this can cause
172 # the "different number of entries in branch" problem, when it is in the
173 # AOD list but the empty container per event is not created
174 # Just compares keys of dicts, which are the class names, not their string keys in StoreGate
175 not_in = [ element for element in _TriggerAODList if element not in _TriggerESDList ]
176 if (len(not_in)>0):
177 log.warning("In AOD list but not in ESD list: ")
178 log.warning(not_in)
179 else:
180 log.info("AOD list is subset of ESD list - good.")
181
182 # there is internal gating in addTo* if AOD or ESD do not need to be written out
183 acc.merge(addToESD(flags, edmDictToList(_TriggerESDList), MetadataItemList = menuMetadata))
184 acc.merge(addToAOD(flags, edmDictToList(_TriggerAODList), MetadataItemList = menuMetadata))
185
186 log.info("AOD content set according to the AODEDMSet flag: %s and EDM version %d", flags.Trigger.AODEDMSet, flags.Trigger.EDMVersion)
187 # navigation for Run 3
188 if flags.Trigger.EDMVersion == 3 and not flags.Trigger.doOnlineNavigationCompactification and not flags.Trigger.doNavigationSlimming:
189 nav = ['xAOD::TrigCompositeContainer#HLTNav*', 'xAOD::TrigCompositeAuxContainer#HLTNav*',]
190 acc.merge(addToAOD(flags, nav))
191 acc.merge(addToESD(flags, nav))
192
193 # RoIs
194 if flags.Output.doWriteAOD and flags.Trigger.EDMVersion == 2:
195 from TrigRoiConversion.TrigRoiConversionConfig import RoiWriterCfg
196 acc.merge(RoiWriterCfg(flags))
197
198 return acc
199
#define max(a, b)
Definition cfImp.cxx:41

◆ TriggerMetadataWriterCfg()

TriggerMetadataWriterCfg ( flags)
Sets up access to HLT, L1, BGRP, Monitoring, HLT PS and L1 PS JSON files from 'FILE' or 'DB', writes JSON to metaStore and keys to eventStore

Definition at line 134 of file TriggerRecoConfig.py.

134def TriggerMetadataWriterCfg(flags):
135 """Sets up access to HLT, L1, BGRP, Monitoring, HLT PS and L1 PS JSON files from 'FILE' or 'DB', writes JSON to metaStore and keys to eventStore"""
136 acc = ComponentAccumulator()
137 keyWriterOutput = ""
138 if flags.Trigger.triggerConfig != 'INFILE':
139 acc.merge( TrigConfigSvcCfg(flags) )
140 keyWriterTool = CompFactory.TrigConf.KeyWriterTool("KeyWriterToolOffline")
141 keyWriterOutput = str(keyWriterTool.ConfKeys)
142 acc.addEventAlgo( CompFactory.TrigConf.xAODMenuWriter("xAODMenuWriter", KeyWriterTool = keyWriterTool) )
143 return acc, keyWriterOutput
144

◆ TriggerRecoCfg()

TriggerRecoCfg ( flags)

Definition at line 17 of file TriggerRecoConfig.py.

17def TriggerRecoCfg(flags):
18 if flags.Input.isMC:
19 return TriggerRecoCfgMC(flags)
20 else:
21 return TriggerRecoCfgData(flags)
22

◆ TriggerRecoCfgData()

TriggerRecoCfgData ( flags)
Configures trigger data decoding
Run 3 data:
HLTResultMTByteStreamDecoderAlg -> TriggerEDMDeserialiserAlg

Run 2 data:
TrigBSExtraction -> TrigDecisionMaker -> DecisionConv to xAOD -> NavigationConv to xAOD

Run 1 data:
not supported anymore

Definition at line 23 of file TriggerRecoConfig.py.

23def TriggerRecoCfgData(flags):
24 """
25 Configures trigger data decoding
26 Run 3 data:
27 HLTResultMTByteStreamDecoderAlg -> TriggerEDMDeserialiserAlg
28
29 Run 2 data:
30 TrigBSExtraction -> TrigDecisionMaker -> DecisionConv to xAOD -> NavigationConv to xAOD
31
32 Run 1 data:
33 not supported anymore
34 """
35 log.debug("TriggerRecoCfgData: Preparing the trigger handling of reconstruction of data")
36 acc = ComponentAccumulator()
37 acc.merge( ByteStreamReadCfg(flags) )
38 if flags.Trigger.L1.doMuon or flags.Trigger.L1.doCalo or flags.Trigger.L1.doTopo or flags.Trigger.L1.doCTP:
39 acc.merge( L1TriggerByteStreamDecoderCfg(flags) )
40
41 metadataAcc, _ = TriggerMetadataWriterCfg(flags)
42 acc.merge( metadataAcc )
43
44 # Run 3+
45 if flags.Trigger.EDMVersion >= 3:
46 acc.merge(Run3TriggerBSUnpackingCfg(flags))
47
48 from TrigDecisionMaker.TrigDecisionMakerConfig import Run3DecisionMakerCfg
49 acc.merge(Run3DecisionMakerCfg(flags))
50
51 if flags.Trigger.doNavigationSlimming:
52 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import TrigNavSlimmingMTCfg
53 acc.merge(TrigNavSlimmingMTCfg(flags))
54
55 # Run 2
56 elif flags.Trigger.EDMVersion == 2:
57 acc.merge( Run2BSExtractionCfg(flags) )
58
59 from TrigDecisionMaker.TrigDecisionMakerConfig import Run1Run2DecisionMakerCfg
60 acc.merge (Run1Run2DecisionMakerCfg(flags) )
61
62 acc.merge(Run2Run1NavigationSlimmingCfg(flags))
63 # Run 1
64 elif flags.Trigger.EDMVersion == 1:
65 raise RuntimeError("Run-1 trigger reconstruction is no longer supported")
66 else:
67 raise RuntimeError("Invalid EDMVersion=%s " % flags.Trigger.EDMVersion)
68
69 # Legacy L1Calo, L1Topo reco
70 if flags.Trigger.enableL1CaloLegacy:
71 from AnalysisTriggerAlgs.AnalysisTriggerAlgsConfig import RoIBResultToxAODCfg
72 xRoIBResultAcc, _ = RoIBResultToxAODCfg(flags)
73 acc.merge( xRoIBResultAcc )
74
75 if flags.Input.Format is Format.BS and flags.Input.DataYear < 2024:
76 from L1TopoByteStream.L1TopoByteStreamConfig import L1TopoRawDataContainerBSCnvCfg
77 acc.merge( L1TopoRawDataContainerBSCnvCfg(flags) )
78 topoEDM = ['xAOD::L1TopoRawDataContainer#L1TopoRawData',
79 'xAOD::L1TopoRawDataAuxContainer#L1TopoRawDataAux.']
80 acc.merge(addToESD(flags, topoEDM))
81 acc.merge(addToAOD(flags, topoEDM))
82
83 acc.merge(TriggerEDMCfg(flags))
84
85 return acc
86

◆ TriggerRecoCfgMC()

TriggerRecoCfgMC ( flags)
Configures trigger MC handing during reconstruction
Note that a lot of the T0 handling of the trigger output for data is bundled into
the RDO to RDO_TRIG sub-step for MC, hence there is much less to do here for MC.
Notably: the xAOD::TrigDecision and all metadata should already be in the RDO_TRIG.

Run 3 MC:
Propagation of Run 3 HLT collections from input RDO_TRIG to output POOL files.
Execution of Run-3 reconstruction-level trigger navigation slimming.

Run 2 MC:
Propagation of Run 2 HLT collections from input RDO_TRIG to output POOL files.
Execution of Run 2 style reconstruction-level trigger navigation slimming.
Optional conversion of Run 2 navigation to Run 3 navigation.
Optional execution of Run 3 reconstruction-level trigger navigation slimming on conversion output.

Run 1 MC:
No current workflows are able to run the Run 1 trigger MC simulation. Unsupported.

Definition at line 87 of file TriggerRecoConfig.py.

87def TriggerRecoCfgMC(flags):
88 """
89 Configures trigger MC handing during reconstruction
90 Note that a lot of the T0 handling of the trigger output for data is bundled into
91 the RDO to RDO_TRIG sub-step for MC, hence there is much less to do here for MC.
92 Notably: the xAOD::TrigDecision and all metadata should already be in the RDO_TRIG.
93
94 Run 3 MC:
95 Propagation of Run 3 HLT collections from input RDO_TRIG to output POOL files.
96 Execution of Run-3 reconstruction-level trigger navigation slimming.
97
98 Run 2 MC:
99 Propagation of Run 2 HLT collections from input RDO_TRIG to output POOL files.
100 Execution of Run 2 style reconstruction-level trigger navigation slimming.
101 Optional conversion of Run 2 navigation to Run 3 navigation.
102 Optional execution of Run 3 reconstruction-level trigger navigation slimming on conversion output.
103
104 Run 1 MC:
105 No current workflows are able to run the Run 1 trigger MC simulation. Unsupported.
106 """
107
108 # Check for currently unsupported operational modes, these may be supported in the future if needed
109 if flags.Input.Format is Format.BS:
110 log.warning("TriggerRecoCfgMC does not currently support MC files encoded as bytestream. Switching off handling of trigger inputs.")
111 return ComponentAccumulator()
112 if flags.Trigger.EDMVersion == 1:
113 log.warning("TriggerRecoCfgMC does not currently support MC files with Run 1 trigger payload. Switching off handling of trigger inputs.")
114 return ComponentAccumulator()
115
116 log.debug("TriggerRecoCfgMC: Preparing the trigger handling of reconstruction of MC")
117 acc = ComponentAccumulator()
118
119 # This will kick into action for Run 2 (Run-1 gets blocked above)
120 acc.merge(Run2Run1NavigationSlimmingCfg(flags))
121
122 # This may kick into action for Run 2, based on flags.Trigger.doEDMVersionConversion
123 from TrigNavTools.NavConverterConfig import NavConverterCfg
124 acc.merge(NavConverterCfg(flags))
125
126 # This will kick into action for Run 3, and may for Run 2 if based on the navigation conversion above
127 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import TrigNavSlimmingMTCfg
128 acc.merge(TrigNavSlimmingMTCfg(flags))
129
130 acc.merge(TriggerEDMCfg(flags))
131
132 return acc
133

Variable Documentation

◆ acc

python.TriggerRecoConfig.acc = MainServicesCfg(flags)

Definition at line 418 of file TriggerRecoConfig.py.

◆ args

python.TriggerRecoConfig.args = flags.fillFromArgs()

Definition at line 398 of file TriggerRecoConfig.py.

◆ AtlasVersion

python.TriggerRecoConfig.AtlasVersion

Definition at line 414 of file TriggerRecoConfig.py.

◆ Files

python.TriggerRecoConfig.Files

Definition at line 402 of file TriggerRecoConfig.py.

◆ flags

python.TriggerRecoConfig.flags = initConfigFlags()

Definition at line 397 of file TriggerRecoConfig.py.

◆ log

python.TriggerRecoConfig.log = logging.getLogger('TriggerRecoConfig')

Definition at line 14 of file TriggerRecoConfig.py.

◆ MaxEvents

python.TriggerRecoConfig.MaxEvents

Definition at line 403 of file TriggerRecoConfig.py.

◆ withDetails

python.TriggerRecoConfig.withDetails

Definition at line 421 of file TriggerRecoConfig.py.