Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes | List of all members
GenerateMenuMT.GenerateMenuMT Class Reference
Inheritance diagram for GenerateMenuMT.GenerateMenuMT:
Collaboration diagram for GenerateMenuMT.GenerateMenuMT:

Public Member Functions

def __init__ (self)
 
def getRequiredSignatures (theslice)
 
def setChainFilter (self, f)
 
def getChainDicts (self, flags)
 
def importSignaturesToGenerate (self)
 
def generateChains (self, flags)
 
def generateAllChainConfigs (self, flags)
 
def getChainsFromMenu (self, flags)
 
def resolveEmptySteps (self, chainConfigs)
 
def generatePrescales (self, flags, Optional[str] prescale_set='__auto__')
 
def __call__ (cls, *args, **kwargs)
 
def clear (cls)
 

Public Attributes

 chainsInMenu
 
 allChainsForAlignment
 
 chainDicts
 
 combinationsInMenu
 
 alignmentGroupsToAlign
 
 configLengthDict
 
 signaturesOverwritten
 
 L1Prescales
 
 HLTPrescales
 
 chainFilter
 
 availableSignatures
 
 sigDicts
 
 chainDefModule
 
 base_menu_name
 

Private Member Functions

def __generateChainConfig (self, flags, mainChainDict)
 

Static Private Attributes

 _instances
 

Detailed Description

Singleton class for the Trigger Menu

Definition at line 63 of file GenerateMenuMT.py.

Constructor & Destructor Documentation

◆ __init__()

def GenerateMenuMT.GenerateMenuMT.__init__ (   self)

Definition at line 65 of file GenerateMenuMT.py.

65  def __init__(self):
66  self.base_menu_name: str = ''
67 
68  self.chainsInMenu = {} # signature : [chains]
69 
70  self.allChainsForAlignment = []
71  self.chainDicts = []
72  self.combinationsInMenu = []
73  self.alignmentGroupsToAlign = set()
74  self.configLengthDict = {}
75 
76  self.signaturesOverwritten = False
77  self.L1Prescales = None
78  self.HLTPrescales = None
79 
80  self.chainFilter = None
81  self.availableSignatures = []
82 
83  self.sigDicts = {}
84 
85  self.chainDefModule = {} # Generate[SIG]ChainDefs module for each SIGnature
86 
87 

Member Function Documentation

◆ __call__()

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

Definition at line 54 of file GenerateMenuMT.py.

54  def __call__(cls, *args, **kwargs):
55  if cls not in cls._instances:
56  cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
57  return cls._instances[cls]
58 

◆ __generateChainConfig()

def 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 371 of file GenerateMenuMT.py.

371  def __generateChainConfig(self, flags, mainChainDict):
372  """
373  # Assembles the chain configuration and returns a chain object with (name, L1see and list of ChainSteps)
374  """
375 
376  from TriggerMenuMT.HLT.Config.Utility.ChainDictTools import splitInterSignatureChainDict
377  from TriggerMenuMT.HLT.Config.Utility.ComboHypoHandling import addTopoInfo, comboConfigurator, topoLegIndices, anomdetWPIndices
378  from TriggerMenuMT.HLT.Config.Utility.ChainMerging import mergeChainDefs
379  from TriggerMenuMT.HLT.CommonSequences import EventBuildingSequences, TLABuildingSequences
380 
381  # split the the chainDictionaries for each chain and print them in a pretty way
382  chainDicts = splitInterSignatureChainDict(mainChainDict)
383 
384  if log.isEnabledFor(logging.DEBUG):
385  import pprint
386  pp = pprint.PrettyPrinter(indent=4, depth=8)
387  log.debug('dictionary is: %s', pp.pformat(chainDicts))
388 
389  # Loop over all chainDicts and send them off to their respective assembly code
390  listOfChainConfigs = []
391  perSig_lengthOfChainConfigs = []
392 
393  for chainPartDict in chainDicts:
394  chainPartConfig = None
395  currentSig = chainPartDict['signature']
396  currentAlignGroup = None
397  if len(chainPartDict['chainParts']) == 1:
398  currentAlignGroup = chainPartDict['chainParts'][0]['alignmentGroup']
399 
400  chainName = chainPartDict['chainName']
401  log.debug('Checking chainDict for chain %s in signature %s, alignment group %s' , chainName, currentSig, currentAlignGroup)
402 
403  if currentSig in self.availableSignatures:
404  try:
405  log.debug("[__generateChainConfigs] Trying to get chain config for %s", currentSig)
406  if currentSig in ['Electron', 'Photon', 'Muon', 'Tau', 'Bphysics'] :
407  chainPartConfig, perSig_lengthOfChainConfigs = self.chainDefModule[currentSig].generateChainConfigs(flags, chainPartDict, perSig_lengthOfChainConfigs)
408  else:
409  chainPartConfig = self.chainDefModule[currentSig].generateChainConfigs(flags, chainPartDict)
410  if currentSig == 'Test' and isinstance(chainPartConfig, tuple):
411  chainPartConfig = chainPartConfig[0]
412  except Exception:
413  log.error('[__generateChainConfigs] Problems creating ChainDef for chain %s ', chainName)
414  log.error('[__generateChainConfigs] I am in chain part\n %s ', chainPartDict)
415  log.exception('[__generateChainConfigs] Full chain dictionary is\n %s ', mainChainDict)
416  raise Exception('[__generateChainConfigs] Stopping menu generation. Please investigate the exception shown above.')
417  else:
418  log.error('Chain %s cannot be generated - Signature "%s" not available', chainPartDict['chainName'], currentSig)
419  log.error('Available signature(s): %s', self.availableSignatures)
420  raise Exception('Stopping the execution. Please correct the configuration.')
421 
422  log.debug("Chain %s \n chain config: %s",chainPartDict['chainName'],chainPartConfig)
423 
424  listOfChainConfigs.append(chainPartConfig)
425  log.debug("[__generateChainConfigs] adding to the perSig_lengthOfChainConfigs list (%s, %s)",chainPartConfig.nSteps,chainPartConfig.alignmentGroups)
426  perSig_lengthOfChainConfigs.append((chainPartConfig.nSteps,chainPartConfig.alignmentGroups))
427 
428  # this will be a list of lists for inter-sig combined chains and a list with one
429  # multi-element list for intra-sig combined chains
430  # here, we flatten it accordingly (works for both cases!)
431  lengthOfChainConfigs = []
432  for nSteps, aGrps in perSig_lengthOfChainConfigs:
433  if len(nSteps) != len(aGrps):
434  log.error("Chain part has %s steps and %s alignment groups - these don't match!",nSteps,aGrps)
435  else:
436  for a,b in zip(nSteps,aGrps):
437  lengthOfChainConfigs.append((a,b))
438 
439 
440  # This part is to deal with combined chains between different signatures
441  try:
442  if len(listOfChainConfigs) == 0:
443  raise Exception('[__generateChainConfigs] No Chain Configuration found for {0}'.format(mainChainDict['chainName']))
444  else:
445  if len(listOfChainConfigs)>1:
446  log.debug("Merging strategy from dictionary: %s", mainChainDict["mergingStrategy"])
447  theChainConfig, perSig_lengthOfChainConfigs = mergeChainDefs(listOfChainConfigs, mainChainDict, perSig_lengthOfChainConfigs)
448  lengthOfChainConfigs = []
449  for nSteps, aGrps in perSig_lengthOfChainConfigs:
450  if len(nSteps) != len(aGrps):
451  log.error("Post-merged chain part has %s steps and %s alignment groups - these don't match!",nSteps,aGrps)
452  else:
453  for a,b in zip(nSteps,aGrps):
454  lengthOfChainConfigs.append((a,b))
455  else:
456  theChainConfig = listOfChainConfigs[0]
457 
458  for topoID in range(len(mainChainDict['extraComboHypos'])):
459  thetopo = mainChainDict['extraComboHypos'][topoID].strip(string.digits).rstrip(topoLegIndices)
460 
461 
462  if "anomdet" in thetopo:
463  thetopo = thetopo.rstrip(anomdetWPIndices)
464 
465  theChainConfig.addTopo((comboConfigurator[thetopo],thetopo))
466 
467  # Now we know where the topos should go, we can insert them in the right steps
468  if len(theChainConfig.topoMap) > 0:
469  log.debug("Trying to add extra ComboHypoTool for %s",mainChainDict['extraComboHypos'])
470  addTopoInfo(theChainConfig,mainChainDict,listOfChainConfigs,lengthOfChainConfigs)
471  except RuntimeError:
472  log.error('[__generateChainConfigs] Problems creating ChainDef for chain %s ', chainName)
473  log.error('[__generateChainConfigs] I am in the extraComboHypos section, for %s ', mainChainDict['extraComboHypos'])
474  log.exception('[__generateChainConfigs] Full chain dictionary is\n %s ', mainChainDict)
475  raise Exception('[__generateChainConfigs] Stopping menu generation. Please investigate the exception shown above.')
476  except AttributeError:
477  raise Exception('[__generateChainConfigs] Stopping menu generation. Please investigate the exception shown above.')
478 
479  # Configure event building strategy
480  eventBuildType = mainChainDict['eventBuildType']
481  if eventBuildType:
482  try:
483  if 'PhysicsTLA' in eventBuildType:
484  log.debug("Adding TLA Step for chain %s", mainChainDict['chainName'])
485  TLABuildingSequences.addTLAStep(flags, theChainConfig, mainChainDict)
486  log.debug('Configuring event building sequence %s for chain %s', eventBuildType, mainChainDict['chainName'])
487  EventBuildingSequences.addEventBuildingSequence(flags, theChainConfig, eventBuildType, mainChainDict)
488  except TypeError as ex:
489  log.error(ex)
490  raise Exception('[__generateChainConfigs] Stopping menu generation for EventBuilding/TLA sequences. Please investigate the exception shown above.')
491 
492  log.debug('[__generateChainConfigs] lengthOfChainConfigs %s, ChainConfigs %s ', lengthOfChainConfigs, theChainConfig)
493  return theChainConfig,lengthOfChainConfigs
494 
495 

◆ clear()

def GenerateMenuMT.Singleton.clear (   cls)
inherited

Definition at line 59 of file GenerateMenuMT.py.

59  def clear(cls):
60  cls._instances.clear()
61 
62 

◆ generateAllChainConfigs()

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

Definition at line 227 of file GenerateMenuMT.py.

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

◆ generateChains()

def GenerateMenuMT.GenerateMenuMT.generateChains (   self,
  flags 
)

Definition at line 187 of file GenerateMenuMT.py.

187  def generateChains(self, flags):
188  all_chains = []
189  combinations_in_menu = []
190  alignmentGroups_to_align = set()
191  length_of_configs = {}
192 
193  nchainDicts = len(self.chainDicts)
194  notify_increment = max(int(nchainDicts / 10),1)
195  for ichainDict, chainDict in enumerate(self.chainDicts):
196  log.debug("Next: getting chain configuration for chain %s ", chainDict['chainName'])
197  if ichainDict % notify_increment==0:
198  log.info("Generating HLT chain %d / %d", ichainDict+1, nchainDicts)
199  chainConfig,lengthOfChainConfigs = self.__generateChainConfig(flags, chainDict)
200  all_chains += [(chainDict,chainConfig,lengthOfChainConfigs)]
201 
202  #update the alignment group length dictionary if we have a longer number of steps
203  #or the signature isn't registered in the dictionary yet
204  for config_length, config_grp in lengthOfChainConfigs:
205  if config_grp in length_of_configs:
206  if config_length > length_of_configs[config_grp]:
207  length_of_configs[config_grp] = config_length
208  else:
209  length_of_configs[config_grp] = config_length
210 
211  # find the chains that contain more than one alignment group, to keep track
212  # of what combinations do we need to deal with.
213  # we're using sets here so we don't end up with duplicates
214  if len(set(chainDict['alignmentGroups'])) > 1:
215  combinations_in_menu += [list(set(chainDict['alignmentGroups']))]
216  for align_group in list(set(chainDict['alignmentGroups'])):
217  alignmentGroups_to_align.update([align_group])
218 
219  self.allChainsForAlignment = all_chains
220  self.combinationsInMenu = combinations_in_menu
221  self.alignmentGroupsToAlign = alignmentGroups_to_align
222  self.configLengthDict = length_of_configs
223 
224  return
225 
226 

◆ generatePrescales()

def GenerateMenuMT.GenerateMenuMT.generatePrescales (   self,
  flags,
Optional[str]   prescale_set = '__auto__' 
)
Add prescales for disabling items (e.g. MC production)

Definition at line 535 of file GenerateMenuMT.py.

535  def generatePrescales(self, flags, prescale_set: Optional[str] = '__auto__'):
536  '''Add prescales for disabling items (e.g. MC production)'''
537 
538  menu_name = flags.Trigger.triggerMenuSetup
539  if prescale_set == '__auto__':
540  if menu_name.endswith('_prescale'):
541  # Get the prescale set name from the Menu
542  prescale_set = menu_name.removeprefix(f'{self.base_menu_name}_').removesuffix('_prescale')
543  else:
544  prescale_set = None
545 
546  if prescale_set:
547  from TriggerMenuMT.HLT.Menu.MenuPrescaleConfig import menu_prescale_set_gens
548  if prescale_set not in menu_prescale_set_gens:
549  raise RuntimeError(f'Unknown menu prescale set for menu {flags.Trigger.triggerMenuSetup}')
550 
551  gen = menu_prescale_set_gens[prescale_set]
552  else:
553  from TriggerMenuMT.HLT.Config.Utility.MenuPrescaleSet import AutoPrescaleSetGen
554  gen = AutoPrescaleSetGen()
555 
556  # Generate prescale set
557  log.info(f'Generating automatic prescale set: {prescale_set}')
558  ps_set = gen.generate(flags, store=True)
559  self.L1Prescales = ps_set.l1_prescales
560  self.HLTPrescales = ps_set.hlt_prescales
561 
562 
563 

◆ getChainDicts()

def GenerateMenuMT.GenerateMenuMT.getChainDicts (   self,
  flags 
)

Definition at line 125 of file GenerateMenuMT.py.

125  def getChainDicts(self, flags):
126 
127  def validSignature(currentSig, chainSig):
128  """Check if chain is assigned to the correct signature"""
129  reqd = GenerateMenuMT.getRequiredSignatures(currentSig)
130  isValid = chainSig.issubset( reqd )
131  log.debug("Chain signatures: %s, required signatures: %s",chainSig,reqd)
132  if not isValid:
133  log.error("Chain signatures %s not a subset of required signatures %s",set(chainSig),reqd)
134  return isValid
135 
136  from TriggerMenuMT.HLT.Config.Utility.DictFromChainName import dictFromChainName
137 
138  chainCounter = 0
139  invalid = False
140  for sig, chains in self.chainsInMenu.items():
141  for chain in chains:
142  log.debug("Now processing chain: %s from signature %s", chain, sig)
143  chainCounter += 1
144  chainDict = dictFromChainName(flags, chain)
145  chainDict['chainCounter'] = chainCounter
146  chainDict['prescale'] = 1 # set default chain prescale
147 
148  # Pick out the folder and subsignature directories to import
149  for sigfo, subsig in chainDict['sigDicts'].items():
150  if sigfo not in self.sigDicts:
151  self.sigDicts[sigfo] = subsig
152  else:
153  for ss in subsig:
154  if ss not in self.sigDicts[sigfo]:
155  self.sigDicts[sigfo].append(ss)
156 
157  self.chainDicts.append(chainDict)
158 
159  if not validSignature(sig, set(chainDict['signatures'])):
160  invalid=True
161  log.error('Chain %s assigned to signature %s but creates %s',
162  chainDict['chainName'], sig, set(chainDict['signatures']))
163  if invalid:
164  raise RuntimeError('Incorrect assignment of chains to slices -- see preceding messages.')
165 

◆ getChainsFromMenu()

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

Definition at line 320 of file GenerateMenuMT.py.

320  def getChainsFromMenu(self, flags):
321  """
322  == Returns the list of chain names that are in the menu
323  """
324 
325  self.base_menu_name = re.match(r'\w*_v\d*', flags.Trigger.triggerMenuSetup).group(0)
326  log.info(f'Menu name: {flags.Trigger.triggerMenuSetup}')
327  log.debug('Base menu name: %s', self.base_menu_name)
328 
329  # Generate the list of chains from the basic menu (terminated in a version number)
330  try:
331  menu_module = importlib.import_module(f'TriggerMenuMT.HLT.Menu.{self.base_menu_name}')
332  except Exception as e:
333  log.fatal(f'Failed to import menu module "{self.base_menu_name}" inferred from menu "{flags.Trigger.triggerMenuSetup}"')
334  raise e
335 
336  # Load Menu
337  self.chainsInMenu = menu_module.setupMenu()
338 
339  # Filter chains if requested
340  if self.chainFilter is not None:
341  self.signaturesOverwritten = True
342 
343  # Verify that if the chain filter has lists of chains
344  # they are all in the menu
345  chainsToCheck = []
346  if hasattr(self.chainFilter,'selectChains'):
347  chainsToCheck += self.chainFilter.selectChains
348  if hasattr(self.chainFilter,'disableChains'):
349  chainsToCheck += self.chainFilter.disableChains
350  for chain in chainsToCheck:
351  inMenu = False
352  for signame in self.chainsInMenu:
353  if chain in [c.name for c in self.chainsInMenu[signame]]:
354  inMenu = True
355  break
356  if not inMenu:
357  raise RuntimeError(f'Request to enable/disable chain {chain} that is not in menu')
358 
359  for signame in self.chainsInMenu:
360  self.chainsInMenu[signame] = [c for c in self.chainsInMenu[signame]
361  if self.chainFilter(signame, c.name)]
362 
363  if not self.chainsInMenu:
364  log.warning("There seem to be no chains in the menu - please check")
365  elif log.isEnabledFor(logging.DEBUG):
366  import pprint
367  log.debug("The following chains were found in the menu:")
368  pprint.pprint(self.chainsInMenu)
369 
370 

◆ getRequiredSignatures()

def GenerateMenuMT.GenerateMenuMT.getRequiredSignatures (   theslice)

Definition at line 89 of file GenerateMenuMT.py.

89  def getRequiredSignatures(theslice):
90  allSigs = allSignatures()
91  signatureDeps = {sig:[sig] for sig in allSigs}
92  # Special cases
93  signatureDeps.update({
94  # Bjet always requires jet
95  'Bjet': ['Bjet','Jet'],
96  # Egamma contains two signatures
97  'Egamma': ['Electron','Photon'],
98  'Combined': combinedSignatures(),
99  })
100  return set(signatureDeps[theslice]+defaultSignatures()) # always allow streamers
101 
102 

◆ importSignaturesToGenerate()

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

Definition at line 166 of file GenerateMenuMT.py.

166  def importSignaturesToGenerate(self):
167  """check if all the signature files can be imported and then import them"""
168 
169  for sig, subSigs in self.sigDicts.items():
170  try:
171  for ss in subSigs:
172  import_module = 'TriggerMenuMT.HLT.' + sig +'.Generate' + ss + 'ChainDefs'
173  self.chainDefModule[ss] = importlib.import_module(import_module)
174 
175  if ss not in self.availableSignatures:
176  self.availableSignatures.append(ss)
177 
178  except ImportError:
179  log.exception('Problems when importing ChainDef generating code for %s', sig)
180  import traceback
181  traceback.print_exc()
182 
183  log.info('Available signature(s) for chain generation: %s', self.availableSignatures)
184 
185  return
186 

◆ resolveEmptySteps()

def GenerateMenuMT.GenerateMenuMT.resolveEmptySteps (   self,
  chainConfigs 
)

Definition at line 496 of file GenerateMenuMT.py.

496  def resolveEmptySteps(self,chainConfigs):
497  max_steps = max([len(cc.steps) for cc in chainConfigs], default=0)
498  steps_are_empty = [True for i in range(0,max_steps)]
499  emptySteps = []
500  for cc in chainConfigs:
501  for istep, the_step in enumerate(cc.steps):
502  if not the_step.isEmpty:
503  steps_are_empty[istep] = False
504  else:
505  emptySteps.append(the_step)
506 
507  log.debug("Are there any fully empty steps? %s", steps_are_empty)
508  log.debug("The empty step(s) and associated chain(s) are: %s", emptySteps)
509  empty_step_indices = [i for i,is_empty in enumerate(steps_are_empty) if is_empty]
510 
511  if len(empty_step_indices) == 0:
512  return chainConfigs
513 
514  special_test_menu = self.chainFilter and ( getattr(self.chainFilter, "selectChains", False) or \
515  getattr(self.chainFilter, "disableChains", False) or \
516  getattr(self.chainFilter, "disabledSignatures", False) or \
517  getattr(self.chainFilter, "enabledSignatures", False) )
518 
519 
520  if len(self.availableSignatures) != 1 and not special_test_menu:
521  raise Exception("[resolveEmptySteps] Please find the reason for this empty step and resolve it / remove it from the menu: %s", emptySteps)
522 
523  log.info("Will now delete steps %s (indexed from zero)",empty_step_indices)
524 
525  for cc in chainConfigs:
526  new_steps = []
527  #only add non-empty steps to the new steps list!
528  for istep,step in enumerate(cc.steps):
529  if istep not in empty_step_indices:
530  new_steps += [step]
531  cc.steps = new_steps
532 
533  return chainConfigs
534 

◆ setChainFilter()

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

   This can be any callable object taking two
   arguments for signature and chain name 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 103 of file GenerateMenuMT.py.

103  def setChainFilter(self, f):
104  """Set chain filter for menu generation.
105 
106  This can be any callable object taking two
107  arguments for signature and chain name and returning a boolean.
108  E.g. to only generate Egamma chains:
109  menu.setChainFilter(lambda slice,chain : slice=='Egamma').
110 
111  In the special case that f is a functor with the list attributes
112  selectChains and/or disableChains, the contents will be explicitly
113  checked to be in the menu.
114  """
115  fname = f.__class__.__name__ if isinstance(f,object) else f.__name__
116  import inspect
117  if len(inspect.signature(f).parameters)!=2:
118  log.error('%s is not a valid chain filter. Function/callable needs take two arguments '
119  'for signature and chain name and return a boolean', fname)
120  else:
121  log.info('Setting chain filter to: %s', f)
122  self.chainFilter = f
123 
124 

Member Data Documentation

◆ _instances

GenerateMenuMT.Singleton._instances
staticprivateinherited

Definition at line 53 of file GenerateMenuMT.py.

◆ alignmentGroupsToAlign

GenerateMenuMT.GenerateMenuMT.alignmentGroupsToAlign

Definition at line 73 of file GenerateMenuMT.py.

◆ allChainsForAlignment

GenerateMenuMT.GenerateMenuMT.allChainsForAlignment

Definition at line 70 of file GenerateMenuMT.py.

◆ availableSignatures

GenerateMenuMT.GenerateMenuMT.availableSignatures

Definition at line 81 of file GenerateMenuMT.py.

◆ base_menu_name

GenerateMenuMT.GenerateMenuMT.base_menu_name

Definition at line 325 of file GenerateMenuMT.py.

◆ chainDefModule

GenerateMenuMT.GenerateMenuMT.chainDefModule

Definition at line 85 of file GenerateMenuMT.py.

◆ chainDicts

GenerateMenuMT.GenerateMenuMT.chainDicts

Definition at line 71 of file GenerateMenuMT.py.

◆ chainFilter

GenerateMenuMT.GenerateMenuMT.chainFilter

Definition at line 80 of file GenerateMenuMT.py.

◆ chainsInMenu

GenerateMenuMT.GenerateMenuMT.chainsInMenu

Definition at line 68 of file GenerateMenuMT.py.

◆ combinationsInMenu

GenerateMenuMT.GenerateMenuMT.combinationsInMenu

Definition at line 72 of file GenerateMenuMT.py.

◆ configLengthDict

GenerateMenuMT.GenerateMenuMT.configLengthDict

Definition at line 74 of file GenerateMenuMT.py.

◆ HLTPrescales

GenerateMenuMT.GenerateMenuMT.HLTPrescales

Definition at line 78 of file GenerateMenuMT.py.

◆ L1Prescales

GenerateMenuMT.GenerateMenuMT.L1Prescales

Definition at line 77 of file GenerateMenuMT.py.

◆ sigDicts

GenerateMenuMT.GenerateMenuMT.sigDicts

Definition at line 83 of file GenerateMenuMT.py.

◆ signaturesOverwritten

GenerateMenuMT.GenerateMenuMT.signaturesOverwritten

Definition at line 76 of file GenerateMenuMT.py.


The documentation for this class was generated from the following file:
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
GenerateMenuMT.allSignatures
def allSignatures()
Definition: GenerateMenuMT.py:32
vtune_athena.format
format
Definition: vtune_athena.py:14
GenerateMenuMT.defaultSignatures
def defaultSignatures()
Definition: GenerateMenuMT.py:23
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
DictFromChainName.dictFromChainName
def dictFromChainName(flags, chainInfo)
Definition: DictFromChainName.py:630
ComboHypoHandling.addTopoInfo
def addTopoInfo(theChainConfig, mainChainDict, listOfChainDefs, lengthOfChainConfigs)
Definition: ComboHypoHandling.py:216
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
GenerateMenuMT.combinedSignatures
def combinedSignatures()
Definition: GenerateMenuMT.py:17
python.LArMinBiasAlgConfig.int
int
Definition: LArMinBiasAlgConfig.py:59
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
ChainMerging.mergeChainDefs
def mergeChainDefs(listOfChainDefs, chainDict, perSig_lengthOfChainConfigs=None)
Definition: ChainMerging.py:15
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
ChainDictTools.splitInterSignatureChainDict
def splitInterSignatureChainDict(chainDict)
Definition: ChainDictTools.py:9
python.HLT.Bjet.GenerateBjetChainDefs.generateChainConfigs
def generateChainConfigs(flags, chainDict)
Definition: GenerateBjetChainDefs.py:13