26def createTriggerFlags(doTriggerRecoFlags):
27 flags = AthConfigFlags()
28
29 flags.addFlag('Trigger.doLVL1', lambda prevFlags: (prevFlags.Input.isMC and prevFlags.Trigger.doHLT),
30 help='enable L1 simulation')
31
32 flags.addFlag('Trigger.doHLT', False,
33 help='run HLT selection algorithms')
34
35 flags.addFlag("Trigger.forceEnableAllChains", lambda prevFlags: prevFlags.GeoModel.Run >= LHCPeriod.Run4,
36 help='always enable all configured chains (for testing). Currently enabled by default for Run 4.')
37
38 flags.addFlag("Trigger.disableL1ConsistencyChecker", False,
39 help='force disabling the L1 ConsistencyChecker')
40
41 flags.addFlag('Trigger.enableL0Muon',
42 lambda prevFlags: prevFlags.GeoModel.Run >= LHCPeriod.Run4,
43 help='enable Run-4+ L0 Muon simulation or decoding')
44
45 flags.addFlag('Trigger.enableL1MuonPhase1', lambda prevFlags:
46 (not prevFlags.Trigger.enableL0Muon) and
47 prevFlags.Trigger.EDMVersion >= 3 or prevFlags.Detector.EnableMM or prevFlags.Detector.EnablesTGC,
48 help='enable Run-3 LVL1 muon decoding')
49
50 flags.addFlag('Trigger.enableL1CaloPhase1', lambda prevFlags:
51 prevFlags.Trigger.EDMVersion >= 3 or prevFlags.GeoModel.Run >= LHCPeriod.Run3,
52 help='enable Phase-1 LVL1 calo simulation and/or decoding for Run-3+')
53
54 flags.addFlag('Trigger.enableL1TopoDump', False,
55 help='enable L1Topo simulation to write inputs to txt file')
56
57 flags.addFlag('Trigger.enableL1TopoBWSimulation', True,
58 help='enable bitwise L1Topo simulation')
59
60
61 flags.addFlag('Trigger.enableL1CaloLegacy', lambda prevFlags:
62 len(prevFlags.Input.Files) > 0 and prevFlags.Input.Format is Format.BS and prevFlags.Reco.EnableTrigger and getDataYear(prevFlags)<2024,
63 help='enable Legacy L1Calo simulation and/or decoding')
64
65
66 flags.addFlag('Trigger.L0MuonSim.doEmulation',
67 lambda prevFlags: prevFlags.Trigger.enableL0Muon and
68 prevFlags.Input.isMC and
69 'TruthParticleContainer' in prevFlags.Input.Collections,
70 help='Emulate the L0Muon trigger TOBs from smeared truth muon particles')
71
72
73 flags.addFlag('Trigger.L1MuonSim.EmulateNSW', False,
74 help='enable emulation tool for NSW-TGC coincidence')
75
76 flags.addFlag('Trigger.L1MuonSim.doMMTrigger', True,
77 help='enable NSW MM trigger')
78
79 flags.addFlag('Trigger.L1MuonSim.doPadTrigger', True,
80 help='enable NSW sTGC pad trigger')
81
82 flags.addFlag('Trigger.L1MuonSim.doStripTrigger', False,
83 help='enable NSW sTGC strip trigger')
84
85 flags.addFlag('Trigger.L1MuonSim.WriteNSWDebugNtuple', False,
86 help='enable Storing NSW debug Ntuple')
87
88 flags.addFlag('Trigger.L1MuonSim.WriteMMBranches', False,
89 help='enable storing of Micromega branches in NSW debug Ntuple')
90
91 flags.addFlag('Trigger.L1MuonSim.WritesTGCBranches', False,
92 help='enable storing of TGC branches in NSW debug Ntuple')
93
94 flags.addFlag('Trigger.L1MuonSim.NSWVetoMode', True,
95 help='enable the veto mode of the NSW-TGC coincidence')
96
97 flags.addFlag('Trigger.L1MuonSim.doBIS78', True,
98 help='enable TGC-RPC BIS78 coincidence')
99
100 flags.addFlag('Trigger.L1MuonSim.CondDBOffline', 'OFLCOND-MC16-SDR-RUN2-04',
101 help='offline CondDB tag for RPC/TGC coincidence window in rerunLVL1 on data')
102
103 flags.addFlag('Trigger.L1MuonSim.RPCNBX', lambda prevFlags:
104 8 if prevFlags.Input.isMC else 4,
105 help='Number of bunch crossings in RPC readout')
106
107 flags.addFlag('Trigger.L1MuonSim.RPCNBCZ', lambda prevFlags:
108 3 if prevFlags.Input.isMC else 1,
109 help='Nominal BC for RPC readout')
110
111
112
113 flags.addFlag('Trigger.doID', True,
114 help='enable Inner Detector')
115
116 flags.addFlag('Trigger.doMuon', True,
117 help='enable muon systems')
118
119 flags.addFlag('Trigger.doCalo', True,
120 help='enable calorimeters')
121
122 flags.addFlag('Trigger.doZDC', False,
123 help='enable ZDC system')
124
125 flags.addFlag('Trigger.ZdcLUT', 'TrigT1ZDC/zdcRun3T1LUT_v2_08_08_2023.json',
126 help='path to Run3 ZDC LUT')
127
128
129 flags.addFlag('Trigger.doTRT', False)
130
131
132 flags.addFlag('Trigger.TRT.TTCMultiplicity', 4)
133
134
135 flags.addFlag('Trigger.TRT.maskedChipsFile', 'TrigT1TRT/fastORmaskedChips.json')
136
137
138 flags.addFlag('Trigger.doValidationMonitoring', False,
139 help='enable additional validation histograms')
140
141 flags.addFlag('Trigger.doRuntimeNaviVal', False,
142 help=('Check validity of each Decision objects in the entire decision tree (CPU expensive). '
143 'Also enable per-step decision printouts.'))
144
145
146 flags.addFlag('Trigger.doPerLegFeatureCounts', True)
147
148 def EDMVersion(flags):
149 """Determine Trigger EDM version based on the input file."""
150 _log = logging.getLogger('TriggerConfigFlags.EDMVersion')
151
152 default_version = -1
153
154 if flags.Input.Format is Format.BS:
155 _log.debug("Input format is ByteStream")
156
157 if not any(flags.Input.Files) and flags.Common.isOnline:
158 _log.info("Online reconstruction, no input file. Return default EDMVersion=%d", default_version)
159 return default_version
160 try:
161 from TrigEDMConfig.Utils import getEDMVersionFromBS
162 except ImportError:
163 log.error("Failed to import TrigEDMConfig, analysing ByteStream files is not possible in this release!")
164 raise
165
166
167 version = getEDMVersionFromBS(flags.Input.Files[0])
168
169 return version if version is not None else default_version
170
171 else:
172
173 _log.debug("Input format is POOL -- determine from input file collections")
174 collections = flags.Input.Collections
175 if "HLTResult_EF" in collections:
176 _log.info("Determined EDMVersion to be 1, because HLTResult_EF found in POOL file")
177 return 1
178 elif "TrigNavigation" in collections:
179 _log.info("Determined EDMVersion to be 2, because TrigNavigation found in POOL file")
180 return 2
181 elif any("HLTNav_Summary" in s for s in collections):
182 if flags.GeoModel.Run >= LHCPeriod.Run4:
183 _log.info("Determined EDMVersion to be 4, because HLTNav_Summary.* found in POOL file and GeoModel.Run >= 4")
184 return 4
185 else:
186 _log.info("Determined EDMVersion to be 3, because HLTNav_Summary.* found in POOL file")
187 return 3
188 elif flags.Trigger.doHLT or flags.Trigger.doLVL1:
189 if flags.GeoModel.Run >= LHCPeriod.Run4:
190 _log.info("Determined EDMVersion to be 4, because we're now running the trigger and GeoModel.Run >= 4")
191 return 4
192 else:
193 _log.info("Determined EDMVersion to be 3, because we're now running the trigger")
194 return 3
195 elif not flags.Input.Collections:
196
197
198 _log.warning("All input files seem to be empty, cannot determine EDM version. Guessing EDMVersion=3")
199 return 3
200
201 _log.info("Could not determine EDM version from the input file. Return default EDMVersion=%d",
202 default_version)
203 return default_version
204
205 flags.addFlag('Trigger.EDMVersion', lambda prevFlags: EDMVersion(prevFlags),
206 help='Trigger EDM version (determined by input file or set to the version to be produced)')
207
208 flags.addFlag('Trigger.doEDMVersionConversion', False,
209 help='convert Run-1&2 EDM to Run-3 EDM')
210
211 flags.addFlag('Trigger.doxAODConversion', True,
212 help=('convert Run-1 EDM to xAOD'))
213
214 flags.addFlag('Trigger.useHLTPrefixForRun4', False,
215 help=('Temporarily re-applies HLT_ as the common chain prefix in Run 4 menus, instead of EF_. For use in transition period.'))
216
217 flags.addFlag('Trigger.doOnlineNavigationCompactification', True,
218 help='enable trigger Navigation compactification into a single collection')
219
220 flags.addFlag('Trigger.doNavigationSlimming', True,
221 help='enable Navigation slimming for RAWtoXYZ or AODtoDAOD transforms')
222
223 flags.addFlag('Trigger.derivationsExtraChains', [],
224 help='list of chains which should be considered for trigger-matching in addition to those from the TriggerAPI when running derivations')
225
226
227 flags.addFlag('Trigger.CostMonitoring.doCostMonitoring', True,
228 help='enable cost monitoring')
229
230 flags.addFlag('Trigger.CostMonitoring.chain', 'HLT_noalg_CostMonDS_L1All',
231 help='Cost monitoring chain name')
232
233 flags.addFlag('Trigger.CostMonitoring.outputCollection', 'HLT_TrigCostContainer',
234 help='Cost monitoring output collection name')
235
236 flags.addFlag('Trigger.CostMonitoring.monitorAllEvents', False,
237 help='enable Cost monitoring for all events')
238
239 flags.addFlag('Trigger.CostMonitoring.monitorROBs', True,
240 help='enable Cost monitoring of ROB accesses')
241
242
243 flags.addFlag('Trigger.L1.doMuon', True,
244 help='enable L1Muon ByteStream conversion/simulation')
245
246 flags.addFlag('Trigger.L1.doMuonTopoInputs', True,
247 help='enable ByteStream conversion/simulation of MUCTPI Topo TOBs')
248
249 flags.addFlag('Trigger.L1.doCalo', True,
250 help='enable L1Calo ByteStream conversion/simulation')
251
252 flags.addFlag('Trigger.L1.doCaloInputs', lambda prevFlags:
253 prevFlags.Trigger.L1.doCalo and prevFlags.Trigger.enableL1CaloPhase1 and not prevFlags.Trigger.doHLT,
254 help='enable L1Calo Input ([ejg]Towers) ByteStream conversion/simulation')
255
256 flags.addFlag('Trigger.L1.doeFex', lambda prevFlags:
257 prevFlags.Trigger.L1.doCalo and prevFlags.Trigger.enableL1CaloPhase1,
258 help='enable eFEX ByteStream conversion/simulation')
259
260 flags.addFlag('Trigger.L1.Menu.doeFexBDTTau', True,
261 help='set BDT tau algorithm as the active one for eFEX when constructing L1 menus')
262
263 flags.addFlag('Trigger.L1.dojFex', lambda prevFlags:
264 prevFlags.Trigger.L1.doCalo and prevFlags.Trigger.enableL1CaloPhase1,
265 help='enable jFEX ByteStream conversion/simulation')
266
267 flags.addFlag('Trigger.L1.dogFex', lambda prevFlags:
268 prevFlags.Trigger.L1.doCalo and prevFlags.Trigger.enableL1CaloPhase1,
269 help='enable gFEX ByteStream conversion/simulation')
270
271 flags.addFlag('Trigger.L1.L1CaloSuperCellContainerName', lambda prevFlags:
272 "EmulatedSCell" if prevFlags.GeoModel.Run is LHCPeriod.Run2 else "SCell",
273 help='name of SuperCell container')
274
275 flags.addFlag('Trigger.L1.doTopo', True,
276 help='enable L1Topo ByteStream conversion/simulation (steering both legacy and phase-1 Topo)')
277
278 flags.addFlag('Trigger.L1.doTopoPhase1', lambda prevFlags:
279 prevFlags.Trigger.L1.doTopo and prevFlags.Trigger.enableL1CaloPhase1,
280 help='control Phase-I L1Topo simulation even if L1.doTopo is True')
281
282 flags.addFlag('Trigger.L1.doGlobal', lambda prevFlags: prevFlags.GeoModel.Run >= LHCPeriod.Run4,
283 help='enable L0Global ByteStream conversion/simulation')
284
285 flags.addFlag('Trigger.L1.doCTP', True,
286 help='enable CTP ByteStream conversion/simulation')
287
288 flags.addFlag('Trigger.L1.Menu.doHeavyIonTobThresholds', lambda prevFlags:
289 'HI' in prevFlags.Trigger.triggerMenuSetup,
290 help='modify min-pt-to-Topo threshold for TOBs to HI values')
291
292 flags.addFlag('Trigger.L1.errorOnMissingTOB', True,
293 help='Set to true to enable strict-mode which will generate an ERROR on missing (non-overflow) TOB events in HLT-seeding from L1')
294
295
296 flags.addFlag('Trigger.Online.partitionName', os.getenv('TDAQ_PARTITION') or '',
297 help='partition name used to determine online vs offline BS result writing')
298
299 flags.addFlag('Trigger.Online.isPartition', lambda prevFlags: len(prevFlags.Trigger.Online.partitionName)>0,
300 help='check if job is running in a partition (i.e. partition name is not empty)')
301
302 flags.addFlag('Trigger.Online.EFInterface.Files', [])
303 flags.addFlag('Trigger.Online.EFInterface.OutputFileName', '')
304 flags.addFlag('Trigger.Online.EFInterface.LoopFiles', False)
305 flags.addFlag('Trigger.Online.EFInterface.NumEvents', -1)
306 flags.addFlag('Trigger.Online.EFInterface.SkipEvents', 0)
307 flags.addFlag('Trigger.Online.EFInterface.RunNumber', 0)
308 flags.addFlag('Trigger.Online.EFInterface.T0ProjectTag', '')
309 flags.addFlag('Trigger.Online.EFInterface.BeamType', 0)
310 flags.addFlag('Trigger.Online.EFInterface.BeamEnergy', 0)
311 flags.addFlag('Trigger.Online.EFInterface.TriggerType', 0)
312 flags.addFlag('Trigger.Online.EFInterface.Stream', '')
313 flags.addFlag('Trigger.Online.EFInterface.Lumiblock', 0)
314 flags.addFlag('Trigger.Online.EFInterface.DetMask', '00000000000000000000000000000000')
315 flags.addFlag('Trigger.Online.EFInterface.LibraryName', 'TrigDFEmulator',
316 help='Name of the EFDF interface shared library to load')
317
318 flags.addFlag('Trigger.Online.useOnlineWebdaqHistSvc', False,
319 help='use online Webdaq HistSvc')
320
321 flags.addFlag('Trigger.Online.BFieldAutoConfig', True,
322 help='auto-configure magnetic field from currents in IS')
323
324 flags.addFlag('Trigger.writeBS', False,
325 help='enable bytestream writing of trigger information')
326
327 flags.addFlag('Trigger.doTransientByteStream', lambda prevFlags:
328 bool(prevFlags.Input.Format is Format.POOL and prevFlags.Trigger.doCalo),
329 help='create transient BS (for running on MC RDO with clients that require BS inputs)')
330
331 flags.addFlag('Trigger.AODEDMSet', lambda flags: 'AODSLIM' if flags.Input.isMC else 'AODFULL',
332 help='list of EDM objects to be written to AOD')
333
334 flags.addFlag('Trigger.ESDEDMSet', 'ESD',
335 help='list of EDM objects to be written to ESD')
336
337 flags.addFlag('Trigger.addRun3LowMuEDM', lambda prevFlags: "pp_lowMu_run3" in prevFlags.Trigger.triggerMenuSetup, help="Specify whether to add dedicated low mu EDM. Default is dependent on the menu setup." )
338
339 flags.addFlag('Trigger.ExtraEDMList', [],
340 help='list of extra EDM objects to be stored (for testing). Supported features: Add new items. Add extra decorations to existing Aux. Add additional output targets.')
341
342 def __availableRecoMetadata(flags):
343 systems = ['L1','HLT']
344
345 if not any(flags.Input.Files) and flags.Common.isOnline:
346 return systems
347
348 elif flags.Trigger.doHLT:
349 raise RuntimeError('Trigger.availableRecoMetadata is ill-defined if Trigger.doHLT==True')
350
351 elif flags.Input.Format is Format.BS:
352 from TrigConfigSvc.TriggerConfigAccess import getKeysFromConditions
353 keys = getKeysFromConditions(flags.Input.RunNumbers[0], lbNr = 1, flags = flags)
354 return ( (['L1'] if 'LVL1PSK' in keys else []) +
355 (['HLT'] if 'HLTPSK' in keys else []) )
356
357 else:
358 return systems if flags.Trigger.triggerConfig == 'INFILE' else []
359
360 flags.addFlag('Trigger.availableRecoMetadata', lambda flags: __availableRecoMetadata(flags),
361 help="list of enabled trigger sub-systems in reconstruction: ['L1,'HLT']")
362
363 flags.addFlag("Trigger.decodeHLT", True,
364 help='enable decoding of HLT trigger decision/result in reconstruction')
365
366 flags.addFlag("Trigger.DecisionMakerValidation.Execute", True,
367 help='run trigger decision validation algorithm in reconstruction')
368
369 flags.addFlag("Trigger.DecisionMakerValidation.ErrorMode", True,
370 help='emit an ERROR (or WARNING) in case of trigger decision validation failure')
371
372
373 def __triggerConfig(flags):
374 _log = logging.getLogger('TriggerConfigFlags.triggerConfig')
375 if flags.Common.isOnline and not flags.Trigger.doHLT:
376
377 _log.debug("Autoconfigured default value for running reconstruction inside Point 1: 'DB'")
378 return 'DB'
379 elif flags.Input.Format is Format.BS:
380 from glob import glob
381 hasLocal = bool(glob('HLTMenu*.json') and glob('L1Menu*.json') and glob('HLTPrescales*.json') and glob('L1Prescales*.json') and glob('HLTMonitoring*.json') and glob('BunchGroupSet*.json'))
382 if flags.Trigger.doHLT:
383
384 _log.debug("Autoconfigured default value for running the trigger on data: 'FILE'")
385 return 'FILE'
386 elif hasLocal:
387
388
389
390 _log.debug("Autoconfigured default value for running reconstruction with a pre-supplied set of trigger configuration JSON files: 'FILE'")
391 return 'FILE'
392 elif flags.GeoModel.Run >= LHCPeriod.Run3:
393
394 _log.debug("Autoconfigured default value for reconstruction of Run 3 data: 'DB'")
395 return 'DB'
396 else:
397
398 _log.debug("Autoconfigured default value for reconstruction of Run 1 or Run 2 data: 'FILE'")
399 return 'FILE'
400 else:
401 from AthenaConfiguration.AutoConfigFlags import GetFileMD
402 md = GetFileMD(flags.Input.Files)
403
404
405 hasTrigMeta = ("metadata_items" in md and any(('TriggerMenu' in key) for key in md["metadata_items"]))
406 if hasTrigMeta:
407
408 _log.debug("Autoconfigured default value to read trigger configuration data from the input file: 'INFILE'")
409 return 'INFILE'
410 else:
411
412 _log.debug("Autoconfigured default value to read trigger configuration data from disk for MC production: 'FILE'")
413 return 'FILE'
414
415 flags.addFlag('Trigger.triggerConfig', lambda flags: __triggerConfig(flags),
416 help='Trigger configuration source (https://twiki.cern.ch/twiki/bin/view/Atlas/TriggerConfigFlag)')
417
418 flags.addFlag('Trigger.useCrest', lambda prevFlags: prevFlags.IOVDb.UseCREST,
419 help='Flag enables trigger configuration database access through CREST')
420
421 flags.addFlag('Trigger.crestServer', lambda prevFlags: prevFlags.IOVDb.DBConnection,
422 help='CREST server to access trigger configuration')
423
424 flags.addFlag('Trigger.triggerMenuSetup', lambda flags: 'MC_pp_run3_v1_BulkMCProd_prescale' if flags.GeoModel.Run is LHCPeriod.Run3 else 'MC_pp_run4_v1_BulkMCProd_prescale',
425 help='name of the trigger menu')
426
427 flags.addFlag('Trigger.generateMenuDiagnostics', False,
428 help='print debug output from control flow generation')
429
430 flags.addFlag('Trigger.fastMenuGeneration', True,
431 help='avoid re-merging CAs that were already seen once')
432
433 flags.addFlag('Trigger.disableCPS', False,
434 help='disable coherent prescale sets (for testing with small menu)')
435
436 flags.addFlag('Trigger.enableEndOfEventProcessing', True,
437 help='enable execution of extra algorithms for accepted events')
438
439 flags.addFlag('Trigger.doCFEmulationTest', False,
440 help='enable run Control Flow Emulation test')
441
442
443
444
445 if doTriggerRecoFlags:
446 flags.join( createTriggerRecoFlags() )
447
448
449 flags.Trigger.disableCPS = lambda prevFlags: prevFlags.Trigger.selectChains or len(prevFlags.Trigger.enabledSignatures)==1
450
451 return flags
452
453