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 def EDMVersion(flags):
146 """Determine Trigger EDM version based on the input file."""
147 _log = logging.getLogger('TriggerConfigFlags.EDMVersion')
148
149 default_version = -1
150
151 if flags.Input.Format is Format.BS:
152 _log.debug("Input format is ByteStream")
153
154 if not any(flags.Input.Files) and flags.Common.isOnline:
155 _log.info("Online reconstruction, no input file. Return default EDMVersion=%d", default_version)
156 return default_version
157 try:
158 from TrigEDMConfig.Utils import getEDMVersionFromBS
159 except ImportError:
160 log.error("Failed to import TrigEDMConfig, analysing ByteStream files is not possible in this release!")
161 raise
162
163
164 version = getEDMVersionFromBS(flags.Input.Files[0])
165
166 return version if version is not None else default_version
167
168 else:
169
170 _log.debug("Input format is POOL -- determine from input file collections")
171 collections = flags.Input.Collections
172 if "HLTResult_EF" in collections:
173 _log.info("Determined EDMVersion to be 1, because HLTResult_EF found in POOL file")
174 return 1
175 elif "TrigNavigation" in collections:
176 _log.info("Determined EDMVersion to be 2, because TrigNavigation found in POOL file")
177 return 2
178 elif any("HLTNav_Summary" in s for s in collections):
179 if flags.GeoModel.Run >= LHCPeriod.Run4:
180 _log.info("Determined EDMVersion to be 4, because HLTNav_Summary.* found in POOL file and GeoModel.Run >= 4")
181 return 4
182 else:
183 _log.info("Determined EDMVersion to be 3, because HLTNav_Summary.* found in POOL file")
184 return 3
185 elif flags.Trigger.doHLT or flags.Trigger.doLVL1:
186 if flags.GeoModel.Run >= LHCPeriod.Run4:
187 _log.info("Determined EDMVersion to be 4, because we're now running the trigger and GeoModel.Run >= 4")
188 return 4
189 else:
190 _log.info("Determined EDMVersion to be 3, because we're now running the trigger")
191 return 3
192 elif not flags.Input.Collections:
193
194
195 _log.warning("All input files seem to be empty, cannot determine EDM version. Guessing EDMVersion=3")
196 return 3
197
198 _log.info("Could not determine EDM version from the input file. Return default EDMVersion=%d",
199 default_version)
200 return default_version
201
202 flags.addFlag('Trigger.EDMVersion', lambda prevFlags: EDMVersion(prevFlags),
203 help='Trigger EDM version (determined by input file or set to the version to be produced)')
204
205 flags.addFlag('Trigger.doEDMVersionConversion', False,
206 help='convert Run-1&2 EDM to Run-3 EDM')
207
208 flags.addFlag('Trigger.doxAODConversion', True,
209 help=('convert Run-1 EDM to xAOD'))
210
211 flags.addFlag('Trigger.doOnlineNavigationCompactification', True,
212 help='enable trigger Navigation compactification into a single collection')
213
214 flags.addFlag('Trigger.doNavigationSlimming', True,
215 help='enable Navigation slimming for RAWtoXYZ or AODtoDAOD transforms')
216
217 flags.addFlag('Trigger.derivationsExtraChains', [],
218 help='list of chains which should be considered for trigger-matching in addition to those from the TriggerAPI when running derivations')
219
220
221 flags.addFlag('Trigger.CostMonitoring.doCostMonitoring', True,
222 help='enable cost monitoring')
223
224 flags.addFlag('Trigger.CostMonitoring.chain', 'HLT_noalg_CostMonDS_L1All',
225 help='Cost monitoring chain name')
226
227 flags.addFlag('Trigger.CostMonitoring.outputCollection', 'HLT_TrigCostContainer',
228 help='Cost monitoring output collection name')
229
230 flags.addFlag('Trigger.CostMonitoring.monitorAllEvents', False,
231 help='enable Cost monitoring for all events')
232
233 flags.addFlag('Trigger.CostMonitoring.monitorROBs', True,
234 help='enable Cost monitoring of ROB accesses')
235
236
237 flags.addFlag('Trigger.L1.doMuon', True,
238 help='enable L1Muon ByteStream conversion/simulation')
239
240 flags.addFlag('Trigger.L1.doMuonTopoInputs', True,
241 help='enable ByteStream conversion/simulation of MUCTPI Topo TOBs')
242
243 flags.addFlag('Trigger.L1.doCalo', True,
244 help='enable L1Calo ByteStream conversion/simulation')
245
246 flags.addFlag('Trigger.L1.doCaloInputs', lambda prevFlags:
247 prevFlags.Trigger.L1.doCalo and prevFlags.Trigger.enableL1CaloPhase1 and not prevFlags.Trigger.doHLT,
248 help='enable L1Calo Input ([ejg]Towers) ByteStream conversion/simulation')
249
250 flags.addFlag('Trigger.L1.doeFex', lambda prevFlags:
251 prevFlags.Trigger.L1.doCalo and prevFlags.Trigger.enableL1CaloPhase1,
252 help='enable eFEX ByteStream conversion/simulation')
253
254 flags.addFlag('Trigger.L1.Menu.doeFexBDTTau', True,
255 help='set BDT tau algorithm as the active one for eFEX when constructing L1 menus')
256
257 flags.addFlag('Trigger.L1.dojFex', lambda prevFlags:
258 prevFlags.Trigger.L1.doCalo and prevFlags.Trigger.enableL1CaloPhase1,
259 help='enable jFEX ByteStream conversion/simulation')
260
261 flags.addFlag('Trigger.L1.dogFex', lambda prevFlags:
262 prevFlags.Trigger.L1.doCalo and prevFlags.Trigger.enableL1CaloPhase1,
263 help='enable gFEX ByteStream conversion/simulation')
264
265 flags.addFlag('Trigger.L1.L1CaloSuperCellContainerName', lambda prevFlags:
266 "EmulatedSCell" if prevFlags.GeoModel.Run is LHCPeriod.Run2 else "SCell",
267 help='name of SuperCell container')
268
269 flags.addFlag('Trigger.L1.doTopo', True,
270 help='enable L1Topo ByteStream conversion/simulation (steering both legacy and phase-1 Topo)')
271
272 flags.addFlag('Trigger.L1.doTopoPhase1', lambda prevFlags:
273 prevFlags.Trigger.L1.doTopo and prevFlags.Trigger.enableL1CaloPhase1,
274 help='control Phase-I L1Topo simulation even if L1.doTopo is True')
275
276 flags.addFlag('Trigger.L1.doGlobal', lambda prevFlags: prevFlags.GeoModel.Run >= LHCPeriod.Run4,
277 help='enable L0Global ByteStream conversion/simulation')
278
279 flags.addFlag('Trigger.L1.doCTP', True,
280 help='enable CTP ByteStream conversion/simulation')
281
282 flags.addFlag('Trigger.L1.Menu.doHeavyIonTobThresholds', lambda prevFlags:
283 'HI' in prevFlags.Trigger.triggerMenuSetup,
284 help='modify min-pt-to-Topo threshold for TOBs to HI values')
285
286 flags.addFlag('Trigger.L1.errorOnMissingTOB', True,
287 help='Set to true to enable strict-mode which will generate an ERROR on missing (non-overflow) TOB events in HLT-seeding from L1')
288
289
290 flags.addFlag('Trigger.Online.partitionName', os.getenv('TDAQ_PARTITION') or '',
291 help='partition name used to determine online vs offline BS result writing')
292
293 flags.addFlag('Trigger.Online.isPartition', lambda prevFlags: len(prevFlags.Trigger.Online.partitionName)>0,
294 help='check if job is running in a partition (i.e. partition name is not empty)')
295
296 flags.addFlag('Trigger.Online.EFInterface.Files', [])
297 flags.addFlag('Trigger.Online.EFInterface.OutputFileName', '')
298 flags.addFlag('Trigger.Online.EFInterface.LoopFiles', False)
299 flags.addFlag('Trigger.Online.EFInterface.NumEvents', -1)
300 flags.addFlag('Trigger.Online.EFInterface.SkipEvents', 0)
301 flags.addFlag('Trigger.Online.EFInterface.RunNumber', 0)
302 flags.addFlag('Trigger.Online.EFInterface.T0ProjectTag', '')
303 flags.addFlag('Trigger.Online.EFInterface.BeamType', 0)
304 flags.addFlag('Trigger.Online.EFInterface.BeamEnergy', 0)
305 flags.addFlag('Trigger.Online.EFInterface.TriggerType', 0)
306 flags.addFlag('Trigger.Online.EFInterface.Stream', '')
307 flags.addFlag('Trigger.Online.EFInterface.Lumiblock', 0)
308 flags.addFlag('Trigger.Online.EFInterface.DetMask', '00000000000000000000000000000000')
309 flags.addFlag('Trigger.Online.EFInterface.LibraryName', 'TrigDFEmulator',
310 help='Name of the EFDF interface shared library to load')
311
312 flags.addFlag('Trigger.Online.useOnlineWebdaqHistSvc', False,
313 help='use online Webdaq HistSvc')
314
315 flags.addFlag('Trigger.Online.BFieldAutoConfig', True,
316 help='auto-configure magnetic field from currents in IS')
317
318 flags.addFlag('Trigger.writeBS', False,
319 help='enable bytestream writing of trigger information')
320
321 flags.addFlag('Trigger.doTransientByteStream', lambda prevFlags:
322 bool(prevFlags.Input.Format is Format.POOL and prevFlags.Trigger.doCalo),
323 help='create transient BS (for running on MC RDO with clients that require BS inputs)')
324
325 flags.addFlag('Trigger.AODEDMSet', lambda flags: 'AODSLIM' if flags.Input.isMC else 'AODFULL',
326 help='list of EDM objects to be written to AOD')
327
328 flags.addFlag('Trigger.ESDEDMSet', 'ESD',
329 help='list of EDM objects to be written to ESD')
330
331 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." )
332
333 flags.addFlag('Trigger.ExtraEDMList', [],
334 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.')
335
336 def __availableRecoMetadata(flags):
337 systems = ['L1','HLT']
338
339 if not any(flags.Input.Files) and flags.Common.isOnline:
340 return systems
341
342 elif flags.Trigger.doHLT:
343 raise RuntimeError('Trigger.availableRecoMetadata is ill-defined if Trigger.doHLT==True')
344
345 elif flags.Input.Format is Format.BS:
346 from TrigConfigSvc.TriggerConfigAccess import getKeysFromConditions
347 keys = getKeysFromConditions(flags.Input.RunNumbers[0], lbNr = 1, flags = flags)
348 return ( (['L1'] if 'LVL1PSK' in keys else []) +
349 (['HLT'] if 'HLTPSK' in keys else []) )
350
351 else:
352 return systems if flags.Trigger.triggerConfig == 'INFILE' else []
353
354 flags.addFlag('Trigger.availableRecoMetadata', lambda flags: __availableRecoMetadata(flags),
355 help="list of enabled trigger sub-systems in reconstruction: ['L1,'HLT']")
356
357 flags.addFlag("Trigger.decodeHLT", True,
358 help='enable decoding of HLT trigger decision/result in reconstruction')
359
360 flags.addFlag("Trigger.DecisionMakerValidation.Execute", True,
361 help='run trigger decision validation algorithm in reconstruction')
362
363 flags.addFlag("Trigger.DecisionMakerValidation.ErrorMode", True,
364 help='emit an ERROR (or WARNING) in case of trigger decision validation failure')
365
366
367 def __triggerConfig(flags):
368 _log = logging.getLogger('TriggerConfigFlags.triggerConfig')
369 if flags.Common.isOnline and not flags.Trigger.doHLT:
370
371 _log.debug("Autoconfigured default value for running reconstruction inside Point 1: 'DB'")
372 return 'DB'
373 elif flags.Input.Format is Format.BS:
374 from glob import glob
375 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'))
376 if flags.Trigger.doHLT:
377
378 _log.debug("Autoconfigured default value for running the trigger on data: 'FILE'")
379 return 'FILE'
380 elif hasLocal:
381
382
383
384 _log.debug("Autoconfigured default value for running reconstruction with a pre-supplied set of trigger configuration JSON files: 'FILE'")
385 return 'FILE'
386 elif flags.GeoModel.Run >= LHCPeriod.Run3:
387
388 _log.debug("Autoconfigured default value for reconstruction of Run 3 data: 'DB'")
389 return 'DB'
390 else:
391
392 _log.debug("Autoconfigured default value for reconstruction of Run 1 or Run 2 data: 'FILE'")
393 return 'FILE'
394 else:
395 from AthenaConfiguration.AutoConfigFlags import GetFileMD
396 md = GetFileMD(flags.Input.Files)
397
398
399 hasTrigMeta = ("metadata_items" in md and any(('TriggerMenu' in key) for key in md["metadata_items"]))
400 if hasTrigMeta:
401
402 _log.debug("Autoconfigured default value to read trigger configuration data from the input file: 'INFILE'")
403 return 'INFILE'
404 else:
405
406 _log.debug("Autoconfigured default value to read trigger configuration data from disk for MC production: 'FILE'")
407 return 'FILE'
408
409 flags.addFlag('Trigger.triggerConfig', lambda flags: __triggerConfig(flags),
410 help='Trigger configuration source (https://twiki.cern.ch/twiki/bin/view/Atlas/TriggerConfigFlag)')
411
412 flags.addFlag('Trigger.useCrest', lambda prevFlags: prevFlags.IOVDb.UseCREST,
413 help='Flag enables trigger configuration database access through CREST')
414
415 flags.addFlag('Trigger.crestServer', lambda prevFlags: prevFlags.IOVDb.DBConnection,
416 help='CREST server to access trigger configuration')
417
418 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',
419 help='name of the trigger menu')
420
421 flags.addFlag('Trigger.generateMenuDiagnostics', False,
422 help='print debug output from control flow generation')
423
424 flags.addFlag('Trigger.fastMenuGeneration', True,
425 help='avoid re-merging CAs that were already seen once')
426
427 flags.addFlag('Trigger.disableCPS', False,
428 help='disable coherent prescale sets (for testing with small menu)')
429
430 flags.addFlag('Trigger.enableEndOfEventProcessing', True,
431 help='enable execution of extra algorithms for accepted events')
432
433 flags.addFlag('Trigger.doCFEmulationTest', False,
434 help='enable run Control Flow Emulation test')
435
436
437
438
439 if doTriggerRecoFlags:
440 flags.join( createTriggerRecoFlags() )
441
442
443 flags.Trigger.disableCPS = lambda prevFlags: prevFlags.Trigger.selectChains or len(prevFlags.Trigger.enabledSignatures)==1
444
445 return flags
446
447