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, Optional[str] prescale_set='__auto__')
 __call__ (cls, *args, **kwargs)
 clear (cls)

Public Attributes

str base_menu_name = ''
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 88 of file GenerateMenuMT.py.

Constructor & Destructor Documentation

◆ __init__()

GenerateMenuMT.GenerateMenuMT.__init__ ( self)

Definition at line 90 of file GenerateMenuMT.py.

90 def __init__(self):
91 self.base_menu_name: str = ''
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 79 of file GenerateMenuMT.py.

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

◆ __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 406 of file GenerateMenuMT.py.

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

◆ clear()

GenerateMenuMT.Singleton.clear ( cls)
inherited

Definition at line 84 of file GenerateMenuMT.py.

84 def clear(cls):
85 cls._instances.clear()
86
87
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,
Optional[str] prescale_set = '__auto__' )
Add prescales for disabling items (e.g. MC production)

Definition at line 588 of file GenerateMenuMT.py.

588 def generatePrescales(self, flags, prescale_set: Optional[str] = '__auto__'):
589 '''Add prescales for disabling items (e.g. MC production)'''
590
591 menu_name = flags.Trigger.triggerMenuSetup
592 if prescale_set == '__auto__':
593 if menu_name.endswith('_prescale'):
594 # Get the prescale set name from the Menu
595 prescale_set = menu_name.removeprefix(f'{self.base_menu_name}_').removesuffix('_prescale')
596 else:
597 prescale_set = None
598
599 if prescale_set:
600 from TriggerMenuMT.HLT.Menu.MenuPrescaleConfig import menu_prescale_set_gens
601 if prescale_set not in menu_prescale_set_gens:
602 raise RuntimeError(f'Unknown menu prescale set for menu {flags.Trigger.triggerMenuSetup}')
603
604 gen = menu_prescale_set_gens[prescale_set]
605 else:
606 from TriggerMenuMT.HLT.Config.Utility.MenuPrescaleSet import AutoPrescaleSetGen
607 gen = AutoPrescaleSetGen()
608
609 # Generate prescale set
610 log.info(f'Generating automatic prescale set: {prescale_set}')
611 ps_set = gen.generate(flags, store=True)
612 self.L1Prescales = ps_set.l1_prescales
613 self.HLTPrescales = ps_set.hlt_prescales
614
615
616

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

◆ 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 549 of file GenerateMenuMT.py.

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

◆ 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 78 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 91 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.

◆ 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: