ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
MenuComponents.ChainStep Class Reference
Inheritance diagram for MenuComponents.ChainStep:
Collaboration diagram for MenuComponents.ChainStep:

Public Member Functions

def __init__ (self, name, SequenceGens=None, chainDicts=None, comboHypoCfg=ComboHypoCfg, comboToolConfs=None, isEmpty=False, createsGhostLegs=False)
 
def createSequences (self)
 
def setChainPartIndices (self)
 
def getLegIds (self)
 
def addComboHypoTools (self, tool)
 
def getComboHypoFncName (self)
 
def makeCombo (self)
 
def createComboHypoTools (self, flags, chainName)
 
def getChainLegs (self)
 
def getChainNames (self)
 
def __repr__ (self)
 

Public Attributes

 name
 
 sequences
 
 sequenceGens
 
 comboHypoCfg
 
 comboToolConfs
 
 nLegs
 
 stepDicts
 
 isEmpty
 
 onlyJets
 
 legIds
 
 combo
 

Detailed Description

Class to describe one step of a chain; 
a step is described by a list of ChainDicts and a list of sequence generators;
a step can have one leg (single) or more legs (combined);
not-empty steps have one sequence and one ChainDict per leg;
empty steps have zero legs, while chainDict len is not zero; 
legID is taken from the ChainDict;

Definition at line 591 of file MenuComponents.py.

Constructor & Destructor Documentation

◆ __init__()

def MenuComponents.ChainStep.__init__ (   self,
  name,
  SequenceGens = None,
  chainDicts = None,
  comboHypoCfg = ComboHypoCfg,
  comboToolConfs = None,
  isEmpty = False,
  createsGhostLegs = False 
)

Definition at line 600 of file MenuComponents.py.

600  def __init__(self, name, SequenceGens = None, chainDicts = None, comboHypoCfg = ComboHypoCfg , comboToolConfs = None, isEmpty = False, createsGhostLegs = False):
601 
602  # default mutable values must be initialized to None
603  if SequenceGens is None: SequenceGens = []
604  if comboToolConfs is None: comboToolConfs = []
605 
606  assert chainDicts is not None,"Error building a ChainStep without chainDicts"
607 
608  self.name = name
609  self.sequences = []
610  self.sequenceGens = SequenceGens
611  self.comboHypoCfg = comboHypoCfg
612  self.comboToolConfs = list(comboToolConfs)
613  self.nLegs = len (self.sequenceGens)
614  self.stepDicts = chainDicts # one dict per leg
615  self.isEmpty = isEmpty
616 
617  # sanity check on inputs, excluding empty steps
618  if not self.isEmpty:
619  log.debug("Building step %s for chain %s: Dict len=%d, nLegs=%i", name, chainDicts[0]['chainName'], len(chainDicts), self.nLegs )
620  if len(chainDicts) != self.nLegs:
621  log.error("[ChainStep] SequenceGens: %s",self.sequenceGens)
622  log.error("[ChainStep] chainDicts: %s",self.stepDicts)
623  log.error("[ChainStep] n.legs: %i",self.nLegs)
624  raise RuntimeError("[ChainStep] Tried to configure a ChainStep %s with %i legs and %i dictionaries. These lists must have the same size" % (name, self.nLegs, len(chainDicts)) )
625 
626 
627  for iseq, seq in enumerate(self.sequenceGens):
628  if not isinstance(seq, functools.partial):
629  log.error("[ChainStep] %s SequenceGens verification failed, sequence %d is not partial function, likely ChainBase.getStep function was not used", self.name, iseq)
630  log.error("[ChainStep] It rather seems to be of type %s trying to print it", type(seq))
631  raise RuntimeError("Sequence is not packaged in a tuple, see error message above" )
632 
633  self.onlyJets = False
634  sig_set = None
635  if len(chainDicts) > 0 and 'signature' in chainDicts[0]:
636  sig_set = set([step['signature'] for step in chainDicts])
637  if len(sig_set) == 1 and ('Jet' in sig_set or 'Bjet' in sig_set):
638  self.onlyJets = True
639  if len(sig_set) == 2 and ('Jet' in sig_set and 'Bjet' in sig_set):
640  self.onlyJets = True
641 
642 
643 
644  if not self.isEmpty:
645  self.setChainPartIndices()
646  self.legIds = self.getLegIds()
647  self.makeCombo()
648 

Member Function Documentation

◆ __repr__()

def MenuComponents.ChainStep.__repr__ (   self)

Definition at line 732 of file MenuComponents.py.

732  def __repr__(self):
733  if len(self.sequenceGens) == 0:
734  return "\n--- ChainStep %s ---\n is Empty, ChainDict = %s "%(self.name, ' '.join(map(str, [dic['chainName'] for dic in self.stepDicts])) )
735 
736  repr_string= "\n--- ChainStep %s ---\n , nLegs = %s ChainDict = %s \n + MenuSequenceGens = %s "%\
737  (self.name, self.nLegs,
738  ' '.join(map(str, [dic['chainName'] for dic in self.stepDicts])),
739  ' '.join(map(str, [seq.func.__name__ for seq in self.sequenceGens]) ))
740 
741  if self.combo is not None:
742  repr_string += "\n + ComboHypo = %s" % self.combo.Alg.name
743  if len(self.comboToolConfs)>0:
744  repr_string +=", ComboHypoTools = %s" %(' '.join(map(str, [tool.__name__ for tool in self.comboToolConfs])))
745  repr_string += "\n"
746  return repr_string
747 
748 

◆ addComboHypoTools()

def MenuComponents.ChainStep.addComboHypoTools (   self,
  tool 
)

Definition at line 688 of file MenuComponents.py.

688  def addComboHypoTools(self, tool):
689  #this function does not add tools, it just adds one tool. do not pass it a list!
690  self.comboToolConfs.append(tool)
691 

◆ createComboHypoTools()

def MenuComponents.ChainStep.createComboHypoTools (   self,
  flags,
  chainName 
)

Definition at line 718 of file MenuComponents.py.

718  def createComboHypoTools(self, flags, chainName):
719  chainDict = HLTMenuConfig.getChainDictFromChainName(chainName)
720  self.combo.createComboHypoTools(flags, chainDict, self.comboToolConfs)
721 

◆ createSequences()

def MenuComponents.ChainStep.createSequences (   self)
creation of this step sequences with instantiation of the CAs

Definition at line 649 of file MenuComponents.py.

649  def createSequences(self):
650  """ creation of this step sequences with instantiation of the CAs"""
651  log.debug("creating sequences for step %s", self.name)
652  for seq in self.sequenceGens:
653  self.sequences.append(seq()) # create the sequences
654 
655 

◆ getChainLegs()

def MenuComponents.ChainStep.getChainLegs (   self)
This is extrapolating the chain legs from the step dictionaries

Definition at line 722 of file MenuComponents.py.

722  def getChainLegs(self):
723  """ This is extrapolating the chain legs from the step dictionaries"""
724  legs = [part['chainName'] for part in self.stepDicts]
725  return legs
726 

◆ getChainNames()

def MenuComponents.ChainStep.getChainNames (   self)

Definition at line 727 of file MenuComponents.py.

727  def getChainNames(self):
728  if self.combo is not None:
729  return list(self.combo.getChains())
730  return self.getChainLegs()
731 

◆ getComboHypoFncName()

def MenuComponents.ChainStep.getComboHypoFncName (   self)

Definition at line 692 of file MenuComponents.py.

692  def getComboHypoFncName(self):
693  return self.comboHypoCfg.__name__ if isinstance(self.comboHypoCfg, types.FunctionType) else self.comboHypoCfg
694 
695 

◆ getLegIds()

def MenuComponents.ChainStep.getLegIds (   self)
get the gelId from the step dictionary for multi-leg chains

Definition at line 672 of file MenuComponents.py.

672  def getLegIds(self):
673  """ get the gelId from the step dictionary for multi-leg chains"""
674  if self.nLegs <= 1: # single leg or empty steps
675  return [0]
676  leg_ids = []
677  for istep,step_dict in enumerate(self.stepDicts):
678  if step_dict['chainName'][0:3] != 'leg':
679  if self.onlyJets:
680  leg_ids += [istep]
681  else:
682  log.error("[getLegIds] step %s for chain %s has %i dictionaries but no leg IDs? ",self.name, step_dict['chainName'], self.nLegs)
683  raise Exception("[getLegIds] cannot extract leg IDs, exiting.")
684  else:
685  leg_ids += [int(step_dict['chainName'][3:6])]
686  return leg_ids
687 

◆ makeCombo()

def MenuComponents.ChainStep.makeCombo (   self)
Configure the Combo Hypo Alg and generate the corresponding function, without instantiation which is done in createSequences() 

Definition at line 696 of file MenuComponents.py.

696  def makeCombo(self):
697  """ Configure the Combo Hypo Alg and generate the corresponding function, without instantiation which is done in createSequences() """
698  self.combo = None
699  if self.isEmpty or self.comboHypoCfg is None:
700  return
701  comboNameFromStep = CFNaming.comboHypoName(self.name) # name expected from the step name
702  funcName = self.getComboHypoFncName() # name of the function generator
703  key = hash((comboNameFromStep, funcName))
704  if key not in _ComboHypoPool:
705  tmpCombo = ComboHypoNode(comboNameFromStep, self.comboHypoCfg)
706  CHname = tmpCombo.name[:-4] # remove 'Node'
707  # exceptions for BLS chains that re-use the same custom CH in differnt steps
708  # this breaks the run-one-CH-per-step, but the BLS CH are able to handle decisions internally
709  if comboNameFromStep != CHname:
710  log.debug("Created ComboHypo with name %s, expected from the step is instead %s. This is accepted only for allowed custom ComboHypos", CHname, comboNameFromStep)
711  _CustomComboHypoAllowed.add(CHname)
712  key = hash((CHname, funcName))
713  _ComboHypoPool[key] = tmpCombo
714  self.combo = _ComboHypoPool[key]
715  log.debug("Created combo %s with name %s, step comboName %s, key %s", funcName, self.combo.name, comboNameFromStep,key)
716 
717 

◆ setChainPartIndices()

def MenuComponents.ChainStep.setChainPartIndices (   self)

Definition at line 657 of file MenuComponents.py.

657  def setChainPartIndices(self):
658  leg_counter = 0
659  lists_of_chainPartNames = []
660  for step_dict in self.stepDicts:
661  if len(lists_of_chainPartNames) == 0:
662  lists_of_chainPartNames += [[cp['chainPartName'] for cp in step_dict['chainParts']]]
663  else:
664  new_list_of_chainPartNames = [cp['chainPartName'] for cp in step_dict['chainParts']]
665  if new_list_of_chainPartNames == lists_of_chainPartNames[-1]:
666  leg_counter -= len(new_list_of_chainPartNames)
667  for chainPart in step_dict['chainParts']:
668  chainPart['chainPartIndex'] = leg_counter
669  leg_counter += 1
670  return
671 

Member Data Documentation

◆ combo

MenuComponents.ChainStep.combo

Definition at line 698 of file MenuComponents.py.

◆ comboHypoCfg

MenuComponents.ChainStep.comboHypoCfg

Definition at line 611 of file MenuComponents.py.

◆ comboToolConfs

MenuComponents.ChainStep.comboToolConfs

Definition at line 612 of file MenuComponents.py.

◆ isEmpty

MenuComponents.ChainStep.isEmpty

Definition at line 615 of file MenuComponents.py.

◆ legIds

MenuComponents.ChainStep.legIds

Definition at line 646 of file MenuComponents.py.

◆ name

MenuComponents.ChainStep.name

Definition at line 608 of file MenuComponents.py.

◆ nLegs

MenuComponents.ChainStep.nLegs

Definition at line 613 of file MenuComponents.py.

◆ onlyJets

MenuComponents.ChainStep.onlyJets

Definition at line 633 of file MenuComponents.py.

◆ sequenceGens

MenuComponents.ChainStep.sequenceGens

Definition at line 610 of file MenuComponents.py.

◆ sequences

MenuComponents.ChainStep.sequences

Definition at line 609 of file MenuComponents.py.

◆ stepDicts

MenuComponents.ChainStep.stepDicts

Definition at line 614 of file MenuComponents.py.


The documentation for this class was generated from the following file:
test_athena_ntuple_filter.seq
seq
filter configuration ## -> we use the special sequence 'AthMasterSeq' which is run before any other a...
Definition: test_athena_ntuple_filter.py:18
python.TrigConfigSvcUtils.getChains
def getChains(connection, smk)
Definition: TrigConfigSvcUtils.py:592
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
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
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108