ATLAS Offline Software
Loading...
Searching...
No Matches
GenerateMenuMT.GenerateMenuMT Class Reference
Inheritance diagram for GenerateMenuMT.GenerateMenuMT:
Collaboration diagram for GenerateMenuMT.GenerateMenuMT:

Public Member Functions

 __init__ (self)
 getRequiredSignatures (theslice)
 setChainFilter (self, f)
 getChainDicts (self, flags)
 importSignaturesToGenerate (self)
 generateChains (self, flags)
 generateAllChainConfigs (self, flags)
 getChainsFromMenu (self, flags)
 resolveEmptySteps (self, chainConfigs)
 generatePrescales (self, flags)
 __call__ (cls, *args, **kwargs)
 clear (cls)

Public Attributes

str base_menu_name = ''
str|None prescale_set_name = None
dict chainsInMenu = {}
list allChainsForAlignment = []
list chainDicts = []
list combinationsInMenu = []
 alignmentGroupsToAlign = set()
dict configLengthDict = {}
bool signaturesOverwritten = False
 L1Prescales = None
 HLTPrescales = None
 chainFilter = None
list availableSignatures = []
dict sigDicts = {}
dict chainDefModule = {}
dict defaultFlagsForSignature = {}

Static Protected Attributes

dict _instances = {}

Private Member Functions

 __generateChainConfig (self, flags, mainChainDict)

Detailed Description

Singleton class for the Trigger Menu

Definition at line 87 of file GenerateMenuMT.py.

Constructor & Destructor Documentation

◆ __init__()

GenerateMenuMT.GenerateMenuMT.__init__ ( self)

Definition at line 89 of file GenerateMenuMT.py.

89 def __init__(self):
90 self.base_menu_name: str = ''
91 self.prescale_set_name: str | None = None
92
93 self.chainsInMenu = {} # signature : [chains]
94
95 self.allChainsForAlignment = []
96 self.chainDicts = []
97 self.combinationsInMenu = []
98 self.alignmentGroupsToAlign = set()
99 self.configLengthDict = {}
100
101 self.signaturesOverwritten = False
102 self.L1Prescales = None
103 self.HLTPrescales = None
104
105 self.chainFilter = None
106 self.availableSignatures = []
107
108 self.sigDicts = {}
109
110 self.chainDefModule = {} # Generate[SIG]ChainDefs module for each SIGnature
111 self.defaultFlagsForSignature = {}
112
113
STL class.

Member Function Documentation

◆ __call__()

GenerateMenuMT.Singleton.__call__ ( cls,
* args,
** kwargs )
inherited

Definition at line 78 of file GenerateMenuMT.py.

78 def __call__(cls, *args, **kwargs):
79 if cls not in cls._instances:
80 cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
81 return cls._instances[cls]
82

◆ __generateChainConfig()

GenerateMenuMT.GenerateMenuMT.__generateChainConfig ( self,
flags,
mainChainDict )
private
# Assembles the chain configuration and returns a chain object with (name, L1see and list of ChainSteps)

Definition at line 409 of file GenerateMenuMT.py.

409 def __generateChainConfig(self, flags, mainChainDict):
410 """
411 # Assembles the chain configuration and returns a chain object with (name, L1see and list of ChainSteps)
412 """
413
414 from TriggerMenuMT.HLT.Config.Utility.ChainDictTools import splitInterSignatureChainDict
415 from TriggerMenuMT.HLT.Config.Utility.ComboHypoHandling import addTopoInfo, comboConfigurator, topoLegIndices, anomdetWPIndices, topo3VarLegIndices
416 from TriggerMenuMT.HLT.Config.Utility.ChainMerging import mergeChainDefs
417 from TriggerMenuMT.HLT.CommonSequences import EventBuildingSequences, TLABuildingSequences
418
419 # split the the chainDictionaries for each chain and print them in a pretty way
420 chainDicts = splitInterSignatureChainDict(mainChainDict)
421
422 if log.isEnabledFor(logging.DEBUG):
423 import pprint
424 pp = pprint.PrettyPrinter(indent=4, depth=8)
425 log.debug('dictionary is: %s', pp.pformat(chainDicts))
426
427 # Loop over all chainDicts and send them off to their respective assembly code
428 listOfChainConfigs = []
429 perSig_lengthOfChainConfigs = []
430
431 for chainPartDict in chainDicts:
432 chainPartConfig = None
433 currentSig = chainPartDict['signature']
434 currentAlignGroup = None
435 if len(chainPartDict['chainParts']) == 1:
436 currentAlignGroup = chainPartDict['chainParts'][0]['alignmentGroup']
437
438 chainName = chainPartDict['chainName']
439 log.debug('Checking chainDict for chain %s in signature %s, alignment group %s' , chainName, currentSig, currentAlignGroup)
440
441 if currentSig in self.availableSignatures:
442 try:
443 log.debug("[__generateChainConfigs] Trying to get chain config for %s", currentSig)
444 if currentSig in self.defaultFlagsForSignature:
445 sigFlags = self.defaultFlagsForSignature[currentSig]
446 else:
447 try:
448 sigFlags = self.chainDefModule[currentSig].prepareDefaultSignatureFlags(flags)
449 except AttributeError:
450 log.debug("prepareDefaultSignatureFlags not present")
451 sigFlags = flags
452 except Exception as e:
453 log.error(f"Unexpected error invoking prepareDefaultSignatureFlags {e}")
454 sigFlags = flags
455
456 self.defaultFlagsForSignature[currentSig] = sigFlags
457
458 if currentSig in ['Electron', 'Photon', 'Muon', 'Tau', 'Bphysics'] :
459 chainPartConfig, perSig_lengthOfChainConfigs = self.chainDefModule[currentSig].generateChainConfigs(sigFlags, chainPartDict, perSig_lengthOfChainConfigs)
460 else:
461 chainPartConfig = self.chainDefModule[currentSig].generateChainConfigs(sigFlags, chainPartDict)
462 if currentSig == 'Test' and isinstance(chainPartConfig, tuple):
463 chainPartConfig = chainPartConfig[0]
464 except Exception:
465 log.error('[__generateChainConfigs] Problems creating ChainDef for chain %s ', chainName)
466 log.error('[__generateChainConfigs] I am in chain part\n %s ', chainPartDict)
467 log.exception('[__generateChainConfigs] Full chain dictionary is\n %s ', mainChainDict)
468 raise Exception('[__generateChainConfigs] Stopping menu generation. Please investigate the exception shown above.')
469 else:
470 log.error('Chain %s cannot be generated - Signature "%s" not available', chainPartDict['chainName'], currentSig)
471 log.error('Available signature(s): %s', self.availableSignatures)
472 raise Exception('Stopping the execution. Please correct the configuration.')
473
474 log.debug("Chain %s \n chain config: %s",chainPartDict['chainName'],chainPartConfig)
475
476 listOfChainConfigs.append(chainPartConfig)
477 log.debug("[__generateChainConfigs] adding to the perSig_lengthOfChainConfigs list (%s, %s)",chainPartConfig.nSteps,chainPartConfig.alignmentGroups)
478 perSig_lengthOfChainConfigs.append((chainPartConfig.nSteps,chainPartConfig.alignmentGroups))
479
480 # this will be a list of lists for inter-sig combined chains and a list with one
481 # multi-element list for intra-sig combined chains
482 # here, we flatten it accordingly (works for both cases!)
483 lengthOfChainConfigs = []
484 for nSteps, aGrps in perSig_lengthOfChainConfigs:
485 if len(nSteps) != len(aGrps):
486 log.error("Chain part has %s steps and %s alignment groups - these don't match!",nSteps,aGrps)
487 else:
488 for a,b in zip(nSteps,aGrps):
489 lengthOfChainConfigs.append((a,b))
490
491
492 # This part is to deal with combined chains between different signatures
493 try:
494 if len(listOfChainConfigs) == 0:
495 raise Exception('[__generateChainConfigs] No Chain Configuration found for {0}'.format(mainChainDict['chainName']))
496 else:
497 if len(listOfChainConfigs)>1:
498 log.debug("Merging strategy from dictionary: %s", mainChainDict["mergingStrategy"])
499 theChainConfig, perSig_lengthOfChainConfigs = mergeChainDefs(listOfChainConfigs, mainChainDict, perSig_lengthOfChainConfigs)
500 lengthOfChainConfigs = []
501 for nSteps, aGrps in perSig_lengthOfChainConfigs:
502 if len(nSteps) != len(aGrps):
503 log.error("Post-merged chain part has %s steps and %s alignment groups - these don't match!",nSteps,aGrps)
504 else:
505 for a,b in zip(nSteps,aGrps):
506 lengthOfChainConfigs.append((a,b))
507 else:
508 theChainConfig = listOfChainConfigs[0]
509
510 for topoID in range(len(mainChainDict['extraComboHypos'])):
511 thetopo = mainChainDict['extraComboHypos'][topoID].strip(string.digits).rstrip(topoLegIndices)
512
513
514 if "anomdet" in thetopo:
515 thetopo = thetopo.rstrip(anomdetWPIndices)
516
517 if "masswiso" in thetopo:
518 thetopo = thetopo.rstrip(topo3VarLegIndices)
519
520 theChainConfig.addTopo((comboConfigurator[thetopo],thetopo))
521
522 # Now we know where the topos should go, we can insert them in the right steps
523 if len(theChainConfig.topoMap) > 0:
524 log.debug("Trying to add extra ComboHypoTool for %s",mainChainDict['extraComboHypos'])
525 addTopoInfo(theChainConfig,mainChainDict,listOfChainConfigs,lengthOfChainConfigs)
526 except RuntimeError:
527 log.error('[__generateChainConfigs] Problems creating ChainDef for chain %s ', chainName)
528 log.error('[__generateChainConfigs] I am in the extraComboHypos section, for %s ', mainChainDict['extraComboHypos'])
529 log.exception('[__generateChainConfigs] Full chain dictionary is\n %s ', mainChainDict)
530 raise Exception('[__generateChainConfigs] Stopping menu generation. Please investigate the exception shown above.')
531 except AttributeError:
532 raise Exception('[__generateChainConfigs] Stopping menu generation. Please investigate the exception shown above.')
533
534 # Configure event building strategy
535 eventBuildType = mainChainDict['eventBuildType']
536 TLAEventBuildTypes = ('PhysicsTLA', 'FTagPEBTLA', 'EgammaPEBTLA', 'DarkJetPEBTLA')
537 if eventBuildType:
538 try:
539 if any(ebtype in eventBuildType for ebtype in TLAEventBuildTypes):
540 log.debug("Adding TLA Step for chain %s", mainChainDict['chainName'])
541 TLABuildingSequences.addTLAStep(flags, theChainConfig, mainChainDict)
542 log.debug('Configuring event building sequence %s for chain %s', eventBuildType, mainChainDict['chainName'])
543 EventBuildingSequences.addEventBuildingSequence(flags, theChainConfig, eventBuildType, mainChainDict)
544 except TypeError as ex:
545 log.error(ex)
546 raise Exception('[__generateChainConfigs] Stopping menu generation for EventBuilding/TLA sequences. Please investigate the exception shown above.')
547
548 log.debug('[__generateChainConfigs] lengthOfChainConfigs %s, ChainConfigs %s ', lengthOfChainConfigs, theChainConfig)
549 return theChainConfig,lengthOfChainConfigs
550
551

◆ clear()

GenerateMenuMT.Singleton.clear ( cls)
inherited

Definition at line 83 of file GenerateMenuMT.py.

83 def clear(cls):
84 cls._instances.clear()
85
86
void clear()
Empty the pool.

◆ generateAllChainConfigs()

GenerateMenuMT.GenerateMenuMT.generateAllChainConfigs ( self,
flags )
== Obtains chain configs for all chains in menu

Definition at line 253 of file GenerateMenuMT.py.

253 def generateAllChainConfigs(self, flags):
254 """
255 == Obtains chain configs for all chains in menu
256 """
257
258 from TriggerMenuMT.HLT.Config.Utility.MenuAlignmentTools import MenuAlignment
259 from TriggerMenuMT.HLT.CommonSequences import EventBuildingSequences, TLABuildingSequences
260
261 # get all chain names from menu
262 log.info("Will now get chains from the menu")
263 self.getChainsFromMenu(flags)
264
265 # decoding of the chain name
266 log.info("Will now get chain dictionaries for each chain")
267 self.getChainDicts(flags)
268
269 if flags.Trigger.disableCPS:
270 log.warning('Removing all CPS group because the flag Trigger.disableCPS is set')
271 for chainDict in self.chainDicts:
272 chainDict['groups'] = [g for g in chainDict['groups'] if not g.startswith('RATE:CPS_')]
273
274 #import the necessary signatures
275 log.debug("Importing the necessary signatures")
276 self.importSignaturesToGenerate()
277
278 log.info("Will now generate the chain configuration for each chain")
279 self.generateChains(flags)
280
281 log.info("Will now calculate the alignment parameters")
282 #dict of signature: set it belongs to
283 #e.g. {'Electron': ['Electron','Muon','Photon']}
284 menuAlignment = MenuAlignment(self.combinationsInMenu,
285 self.alignmentGroupsToAlign,
286 self.configLengthDict)
287 menuAlignment.analyse_combinations()
288
289 # alignmentGroups_to_align = menuAlignment.groupsToAlign
290 # lengthOfChainConfigs = self.configLengthDict
291 # combinationsInMenu = menuAlignment.combinationsInMenu
292 # alignmentGroup_sets_to_align = menuAlignment.setsToAlign
293
294 log.info('Aligning the following signatures: %s',sorted(menuAlignment.sets_to_align))
295 log.debug('Length of each of the alignment groups: %s',self.configLengthDict)
296
297 chainConfigs = []
298
299 for chainDict,chainConfig,lengthOfChainConfigs in self.allChainsForAlignment:
300
301 # start by ordering electron, photon, muon by having e+mu, g+mu, e+g chains
302 # desired ordering: electron, photon, muon, tau, jet, met, b-jet
303
304 # lengthOfChainConfigs is something like this: [(4, 'Photon'), (5, 'Muon')]
305 # needs to match up with the maximum number of steps in a signature in the menu (length_of_configs)
306 # start with electron! Only need to add post-steps for combined electron chains if the max length in a combined chain
307 # is greater than the number of electron steps combined chain. Assume that the max length of an electron chain occurs
308 # in a combined chain.
309
310 log.debug("[generateAllChainConfigs] chain %s has config lengths %s and alignment groups %s", chainDict['chainName'], lengthOfChainConfigs, chainDict['alignmentGroups'])
311
312 alignmentGroups = chainDict['alignmentGroups']
313
314 #parallel-merged single-signature chains or single signature chains. Anything that needs no splitting!
315 if len(set(alignmentGroups)) == 1:
316 alignedChainConfig = menuAlignment.single_align(chainDict, chainConfig)
317 HLTMenuConfig.registerChain( chainDict )
318 chainConfigs.append( alignedChainConfig )
319
320 elif len(alignmentGroups) >= 2:
321 alignedChainConfig = menuAlignment.multi_align(chainDict, chainConfig, lengthOfChainConfigs)
322 HLTMenuConfig.registerChain( chainDict )
323 chainConfigs.append( alignedChainConfig )
324
325 else:
326 log.error("Menu can't deal with combined chains with more than two alignmentGroups at the moment. oops...")
327 raise NotImplementedError("more than three alignment groups still needs implementing in ChainMerging.py, ATR-22206")
328
329 if not HLTMenuConfig.isChainRegistered(chainDict['chainName']):
330 log.error("Chain %s has not been registered in the menu!", chainDict['chainName'])
331 import pprint
332 pp = pprint.PrettyPrinter(indent=4, depth=8)
333 log.error('The chain dictionary is: %s', pp.pformat(chainDict))
334 raise Exception("Please fix the menu or the chain.")
335
336 # align event building sequences
337 log.info("[generateAllChainConfigs] general alignment complete, will now align TLA chains")
338 TLABuildingSequences.alignTLASteps(chainConfigs, HLTMenuConfig.dicts())
339 log.info("[generateAllChainConfigs] general and TLA alignment complete, will now align PEB chains")
340 EventBuildingSequences.alignEventBuildingSteps(chainConfigs, HLTMenuConfig.dicts())
341
342 log.info("[generateAllChainConfigs] all chain configurations have been generated.")
343 return chainConfigs
344
345

◆ generateChains()

GenerateMenuMT.GenerateMenuMT.generateChains ( self,
flags )

Definition at line 213 of file GenerateMenuMT.py.

213 def generateChains(self, flags):
214 all_chains = []
215 combinations_in_menu = []
216 alignmentGroups_to_align = set()
217 length_of_configs = {}
218
219 nchainDicts = len(self.chainDicts)
220 notify_increment = max(int(nchainDicts / 10),1)
221 for ichainDict, chainDict in enumerate(self.chainDicts):
222 log.debug("Next: getting chain configuration for chain %s ", chainDict['chainName'])
223 if ichainDict % notify_increment==0:
224 log.info("Generating HLT chain %d / %d", ichainDict+1, nchainDicts)
225 chainConfig,lengthOfChainConfigs = self.__generateChainConfig(flags, chainDict)
226 all_chains += [(chainDict,chainConfig,lengthOfChainConfigs)]
227
228 #update the alignment group length dictionary if we have a longer number of steps
229 #or the signature isn't registered in the dictionary yet
230 for config_length, config_grp in lengthOfChainConfigs:
231 if config_grp in length_of_configs:
232 if config_length > length_of_configs[config_grp]:
233 length_of_configs[config_grp] = config_length
234 else:
235 length_of_configs[config_grp] = config_length
236
237 # find the chains that contain more than one alignment group, to keep track
238 # of what combinations do we need to deal with.
239 # we're using sets here so we don't end up with duplicates
240 if len(set(chainDict['alignmentGroups'])) > 1:
241 combinations_in_menu += [list(set(chainDict['alignmentGroups']))]
242 for align_group in list(set(chainDict['alignmentGroups'])):
243 alignmentGroups_to_align.update([align_group])
244
245 self.allChainsForAlignment = all_chains
246 self.combinationsInMenu = combinations_in_menu
247 self.alignmentGroupsToAlign = alignmentGroups_to_align
248 self.configLengthDict = length_of_configs
249
250 return
251
252
#define max(a, b)
Definition cfImp.cxx:41

◆ generatePrescales()

GenerateMenuMT.GenerateMenuMT.generatePrescales ( self,
flags )
Add prescales for disabling items (e.g. MC production)

Definition at line 591 of file GenerateMenuMT.py.

591 def generatePrescales(self, flags):
592 '''Add prescales for disabling items (e.g. MC production)'''
593 log.info(f'Generating automatic prescale set: {self.prescale_set_name}')
594
595 if self.prescale_set_name is not None:
596 from TriggerMenuMT.HLT.Menu.MenuPrescaleConfig import menu_prescale_set_gens
597 gen = menu_prescale_set_gens[self.prescale_set_name]
598 else:
599 from TriggerMenuMT.HLT.Config.Utility.MenuPrescaleSet import AutoPrescaleSetGen
600 gen = AutoPrescaleSetGen()
601
602 # Generate prescale set
603 ps_set = gen.generate(flags, store=True)
604 self.L1Prescales = ps_set.l1_prescales
605 self.HLTPrescales = ps_set.hlt_prescales
606
607
608

◆ getChainDicts()

GenerateMenuMT.GenerateMenuMT.getChainDicts ( self,
flags )

Definition at line 151 of file GenerateMenuMT.py.

151 def getChainDicts(self, flags):
152
153 def validSignature(currentSig, chainSig):
154 """Check if chain is assigned to the correct signature"""
155 reqd = GenerateMenuMT.getRequiredSignatures(currentSig)
156 isValid = chainSig.issubset( reqd )
157 log.debug("Chain signatures: %s, required signatures: %s",chainSig,reqd)
158 if not isValid:
159 log.error("Chain signatures %s not a subset of required signatures %s",set(chainSig),reqd)
160 return isValid
161
162 from TriggerMenuMT.HLT.Config.Utility.DictFromChainName import dictFromChainName
163
164 chainCounter = 0
165 invalid = False
166 for sig, chains in self.chainsInMenu.items():
167 for chain in chains:
168 log.debug("Now processing chain: %s from signature %s", chain, sig)
169 chainCounter += 1
170 chainDict = dictFromChainName(flags, chain)
171 chainDict['chainCounter'] = chainCounter
172 chainDict['prescale'] = 1 # set default chain prescale
173
174 # Pick out the folder and subsignature directories to import
175 for sigfo, subsig in chainDict['sigDicts'].items():
176 if sigfo not in self.sigDicts:
177 self.sigDicts[sigfo] = subsig
178 else:
179 for ss in subsig:
180 if ss not in self.sigDicts[sigfo]:
181 self.sigDicts[sigfo].append(ss)
182
183 self.chainDicts.append(chainDict)
184
185 if not validSignature(sig, set(chainDict['signatures'])):
186 invalid=True
187 log.error('Chain %s assigned to signature %s but creates %s',
188 chainDict['chainName'], sig, set(chainDict['signatures']))
189 if invalid:
190 raise RuntimeError('Incorrect assignment of chains to slices -- see preceding messages.')
191

◆ getChainsFromMenu()

GenerateMenuMT.GenerateMenuMT.getChainsFromMenu ( self,
flags )
== Returns the list of chain names that are in the menu

Definition at line 346 of file GenerateMenuMT.py.

346 def getChainsFromMenu(self, flags):
347 """
348 == Returns the list of chain names that are in the menu
349 """
350
351 log.info(f'Menu name: {flags.Trigger.triggerMenuSetup}')
352
353 # Get the base menu name (without prescale set suffix)
354 from TriggerMenuMT.HLT.Config.Utility.MenuPrescaleSet import AutoPrescaleSetGen
355 self.base_menu_name, self.prescale_set_name = AutoPrescaleSetGen.split_menu_name(flags.Trigger.triggerMenuSetup)
356 log.debug('Base menu name: %s', self.base_menu_name)
357
358 # Generate the list of chains from the basic menu (terminated in a version number)
359 try:
360 menu_module = importlib.import_module(f'TriggerMenuMT.HLT.Menu.{self.base_menu_name}')
361 except Exception as e:
362 log.fatal(f'Failed to import menu module "{self.base_menu_name}" inferred from menu "{flags.Trigger.triggerMenuSetup}"')
363 raise e
364
365 # Load Menu
366 self.chainsInMenu = menu_module.setupMenu()
367
368 # Temporary HLT->EF migration helper block.
369 # Replaces EF_ with HLT_ just after the menu is read, before it is processed any further.
370 if flags.Trigger.useHLTPrefixForRun4:
371 import dataclasses
372 for grp in self.chainsInMenu:
373 for i, chn in enumerate(self.chainsInMenu[grp]):
374 if chn.name.startswith("EF_"):
375 self.chainsInMenu[grp][i] = dataclasses.replace(chn, name="HLT_" + chn.name[3:])
376
377 # Filter chains if requested
378 if self.chainFilter is not None:
379 self.signaturesOverwritten = True
380
381 # Verify that if the chain filter has lists of chains
382 # they are all in the menu
383 chainsToCheck = []
384 if hasattr(self.chainFilter,'selectChains'):
385 chainsToCheck += self.chainFilter.selectChains
386 if hasattr(self.chainFilter,'disableChains'):
387 chainsToCheck += self.chainFilter.disableChains
388 for chain in chainsToCheck:
389 inMenu = False
390 for signame in self.chainsInMenu:
391 if chain in [c.name for c in self.chainsInMenu[signame]]:
392 inMenu = True
393 break
394 if not inMenu:
395 raise RuntimeError(f'Request to enable/disable chain {chain} that is not in menu')
396
397 for signame in self.chainsInMenu:
398 self.chainsInMenu[signame] = [c for c in self.chainsInMenu[signame]
399 if self.chainFilter(signame, c)]
400
401 if not self.chainsInMenu:
402 log.warning("There seem to be no chains in the menu - please check")
403 elif log.isEnabledFor(logging.DEBUG):
404 import pprint
405 log.debug("The following chains were found in the menu:")
406 pprint.pprint(self.chainsInMenu)
407
408

◆ getRequiredSignatures()

GenerateMenuMT.GenerateMenuMT.getRequiredSignatures ( theslice)

Definition at line 115 of file GenerateMenuMT.py.

115 def getRequiredSignatures(theslice):
116 allSigs = allSignatures()
117 signatureDeps = {sig:[sig] for sig in allSigs}
118 # Special cases
119 signatureDeps.update({
120 # Bjet always requires jet
121 'Bjet': ['Bjet','Jet'],
122 # Egamma contains two signatures
123 'Egamma': ['Electron','Photon'],
124 'Combined': combinedSignatures(),
125 })
126 return set(signatureDeps[theslice]+defaultSignatures()) # always allow streamers
127
128

◆ importSignaturesToGenerate()

GenerateMenuMT.GenerateMenuMT.importSignaturesToGenerate ( self)
check if all the signature files can be imported and then import them

Definition at line 192 of file GenerateMenuMT.py.

192 def importSignaturesToGenerate(self):
193 """check if all the signature files can be imported and then import them"""
194
195 for sig, subSigs in self.sigDicts.items():
196 try:
197 for ss in subSigs:
198 import_module = 'TriggerMenuMT.HLT.' + sig +'.Generate' + ss + 'ChainDefs'
199 self.chainDefModule[ss] = importlib.import_module(import_module)
200
201 if ss not in self.availableSignatures:
202 self.availableSignatures.append(ss)
203
204 except ImportError:
205 log.exception('Problems when importing ChainDef generating code for %s', sig)
206 import traceback
207 traceback.print_exc()
208
209 log.info('Available signature(s) for chain generation: %s', self.availableSignatures)
210
211 return
212

◆ resolveEmptySteps()

GenerateMenuMT.GenerateMenuMT.resolveEmptySteps ( self,
chainConfigs )

Definition at line 552 of file GenerateMenuMT.py.

552 def resolveEmptySteps(self,chainConfigs):
553 max_steps = max([len(cc.steps) for cc in chainConfigs], default=0)
554 steps_are_empty = [True for i in range(0,max_steps)]
555 emptySteps = []
556 for cc in chainConfigs:
557 for istep, the_step in enumerate(cc.steps):
558 if not the_step.isEmpty:
559 steps_are_empty[istep] = False
560 else:
561 emptySteps.append(the_step)
562
563 log.debug("Are there any fully empty steps? %s", steps_are_empty)
564 log.debug("The empty step(s) and associated chain(s) are: %s", emptySteps)
565 empty_step_indices = [i for i,is_empty in enumerate(steps_are_empty) if is_empty]
566
567 if len(empty_step_indices) == 0:
568 return chainConfigs
569
570 special_test_menu = self.chainFilter and ( getattr(self.chainFilter, "selectChains", False) or \
571 getattr(self.chainFilter, "disableChains", False) or \
572 getattr(self.chainFilter, "disabledSignatures", False) or \
573 getattr(self.chainFilter, "enabledSignatures", False) )
574
575
576 if len(self.availableSignatures) != 1 and not special_test_menu:
577 raise Exception("[resolveEmptySteps] Please find the reason for this empty step and resolve it / remove it from the menu: %s", emptySteps)
578
579 log.info("Will now delete steps %s (indexed from zero)",empty_step_indices)
580
581 for cc in chainConfigs:
582 new_steps = []
583 #only add non-empty steps to the new steps list!
584 for istep,step in enumerate(cc.steps):
585 if istep not in empty_step_indices:
586 new_steps += [step]
587 cc.steps = new_steps
588
589 return chainConfigs
590

◆ setChainFilter()

GenerateMenuMT.GenerateMenuMT.setChainFilter ( self,
f )
Set chain filter for menu generation.

   This can be any callable object taking two
   arguments for signature and chain object and returning a boolean.
   E.g. to only generate Egamma chains:
        menu.setChainFilter(lambda slice,chain : slice=='Egamma').

   In the special case that f is a functor with the list attributes
   selectChains and/or disableChains, the contents will be explicitly
   checked to be in the menu.

Definition at line 129 of file GenerateMenuMT.py.

129 def setChainFilter(self, f):
130 """Set chain filter for menu generation.
131
132 This can be any callable object taking two
133 arguments for signature and chain object and returning a boolean.
134 E.g. to only generate Egamma chains:
135 menu.setChainFilter(lambda slice,chain : slice=='Egamma').
136
137 In the special case that f is a functor with the list attributes
138 selectChains and/or disableChains, the contents will be explicitly
139 checked to be in the menu.
140 """
141 fname = f.__class__.__name__ if isinstance(f,object) else f.__name__
142 import inspect
143 if len(inspect.signature(f).parameters)!=2:
144 log.error('%s is not a valid chain filter. Function/callable needs take two arguments '
145 'for signature and chain name and return a boolean', fname)
146 else:
147 log.info('Setting chain filter to: %s', f)
148 self.chainFilter = f
149
150

Member Data Documentation

◆ _instances

dict GenerateMenuMT.Singleton._instances = {}
staticprotectedinherited

Definition at line 77 of file GenerateMenuMT.py.

◆ alignmentGroupsToAlign

GenerateMenuMT.GenerateMenuMT.alignmentGroupsToAlign = set()

Definition at line 98 of file GenerateMenuMT.py.

◆ allChainsForAlignment

list GenerateMenuMT.GenerateMenuMT.allChainsForAlignment = []

Definition at line 95 of file GenerateMenuMT.py.

◆ availableSignatures

GenerateMenuMT.GenerateMenuMT.availableSignatures = []

Definition at line 106 of file GenerateMenuMT.py.

◆ base_menu_name

GenerateMenuMT.GenerateMenuMT.base_menu_name = ''

Definition at line 90 of file GenerateMenuMT.py.

◆ chainDefModule

dict GenerateMenuMT.GenerateMenuMT.chainDefModule = {}

Definition at line 110 of file GenerateMenuMT.py.

◆ chainDicts

GenerateMenuMT.GenerateMenuMT.chainDicts = []

Definition at line 96 of file GenerateMenuMT.py.

◆ chainFilter

GenerateMenuMT.GenerateMenuMT.chainFilter = None

Definition at line 105 of file GenerateMenuMT.py.

◆ chainsInMenu

GenerateMenuMT.GenerateMenuMT.chainsInMenu = {}

Definition at line 93 of file GenerateMenuMT.py.

◆ combinationsInMenu

list GenerateMenuMT.GenerateMenuMT.combinationsInMenu = []

Definition at line 97 of file GenerateMenuMT.py.

◆ configLengthDict

GenerateMenuMT.GenerateMenuMT.configLengthDict = {}

Definition at line 99 of file GenerateMenuMT.py.

◆ defaultFlagsForSignature

dict GenerateMenuMT.GenerateMenuMT.defaultFlagsForSignature = {}

Definition at line 111 of file GenerateMenuMT.py.

◆ HLTPrescales

GenerateMenuMT.GenerateMenuMT.HLTPrescales = None

Definition at line 103 of file GenerateMenuMT.py.

◆ L1Prescales

GenerateMenuMT.GenerateMenuMT.L1Prescales = None

Definition at line 102 of file GenerateMenuMT.py.

◆ prescale_set_name

str | None GenerateMenuMT.GenerateMenuMT.prescale_set_name = None

Definition at line 91 of file GenerateMenuMT.py.

◆ sigDicts

dict GenerateMenuMT.GenerateMenuMT.sigDicts = {}

Definition at line 108 of file GenerateMenuMT.py.

◆ signaturesOverwritten

bool GenerateMenuMT.GenerateMenuMT.signaturesOverwritten = False

Definition at line 101 of file GenerateMenuMT.py.


The documentation for this class was generated from the following file: