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