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=None, comboToolConfs=None, isEmpty=False, createsGhostLegs=False)
 
def createSequences (self)
 
def setChainPartIndices (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
 
 stepDicts
 
 nLegs
 
 isEmpty
 
 onlyJets
 
 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;
there is one leg per ChainDict;
a step can have one leg (single) or more legs (combined);
not-empty steps have one sequence per leg;
empty steps have zero sequences, while chainDict len is not zero; 
legID is taken from the ChainDict;

Definition at line 590 of file MenuComponents.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 600 of file MenuComponents.py.

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

Member Function Documentation

◆ __repr__()

def MenuComponents.ChainStep.__repr__ (   self)

Definition at line 721 of file MenuComponents.py.

721  def __repr__(self):
722  if len(self.sequenceGens) == 0:
723  return "\n--- ChainStep %s ---\n is Empty, ChainDict = %s "%(self.name, ' '.join(map(str, [dic['chainName'] for dic in self.stepDicts])) )
724 
725  repr_string= "\n--- ChainStep %s ---\n , nLegs = %s ChainDict = %s \n + MenuSequenceGens = %s "%\
726  (self.name, self.nLegs,
727  ' '.join(map(str, [dic['chainName'] for dic in self.stepDicts])),
728  ' '.join(map(str, [seq.func.__name__ for seq in self.sequenceGens]) ))
729 
730  if self.combo is not None:
731  repr_string += "\n + ComboHypo = %s" % self.combo.Alg.name
732  if len(self.comboToolConfs)>0:
733  repr_string +=", ComboHypoTools = %s" %(' '.join(map(str, [tool.__name__ for tool in self.comboToolConfs])))
734  repr_string += "\n"
735  return repr_string
736 
737 

◆ addComboHypoTools()

def MenuComponents.ChainStep.addComboHypoTools (   self,
  tool 
)

Definition at line 676 of file MenuComponents.py.

676  def addComboHypoTools(self, tool):
677  #this function does not add tools, it just adds one tool. do not pass it a list!
678  self.comboToolConfs.append(tool)
679 

◆ createComboHypoTools()

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

Definition at line 707 of file MenuComponents.py.

707  def createComboHypoTools(self, flags, chainName):
708  chainDict = HLTMenuConfig.getChainDictFromChainName(chainName)
709  self.combo.createComboHypoTools(flags, chainDict, self.comboToolConfs)
710 

◆ createSequences()

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

Definition at line 651 of file MenuComponents.py.

651  def createSequences(self):
652  """ creation of this step sequences with instantiation of the CAs"""
653  log.debug("createSequences: creating %d sequences for step %s", len(self.sequenceGens), self.name)
654  for seq in self.sequenceGens:
655  log.debug("createSequences: creating sequence %s", seq.func.__name__)
656  self.sequences.append(seq()) # create the sequences
657 
658 

◆ getChainLegs()

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

Definition at line 711 of file MenuComponents.py.

711  def getChainLegs(self):
712  """ This is extrapolating the chain legs from the step dictionaries"""
713  legs = [part['chainName'] for part in self.stepDicts]
714  return legs
715 

◆ getChainNames()

def MenuComponents.ChainStep.getChainNames (   self)

Definition at line 716 of file MenuComponents.py.

716  def getChainNames(self):
717  if self.combo is not None:
718  return list(self.combo.getChains())
719  return self.getChainLegs()
720 

◆ getComboHypoFncName()

def MenuComponents.ChainStep.getComboHypoFncName (   self)

Definition at line 680 of file MenuComponents.py.

680  def getComboHypoFncName(self):
681  return self.comboHypoCfg.func.__name__
682 
683 
684 

◆ 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 685 of file MenuComponents.py.

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

◆ setChainPartIndices()

def MenuComponents.ChainStep.setChainPartIndices (   self)

Definition at line 660 of file MenuComponents.py.

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

Member Data Documentation

◆ combo

MenuComponents.ChainStep.combo

Definition at line 687 of file MenuComponents.py.

◆ comboHypoCfg

MenuComponents.ChainStep.comboHypoCfg

Definition at line 614 of file MenuComponents.py.

◆ comboToolConfs

MenuComponents.ChainStep.comboToolConfs

Definition at line 615 of file MenuComponents.py.

◆ isEmpty

MenuComponents.ChainStep.isEmpty

Definition at line 618 of file MenuComponents.py.

◆ name

MenuComponents.ChainStep.name

Definition at line 608 of file MenuComponents.py.

◆ nLegs

MenuComponents.ChainStep.nLegs

Definition at line 617 of file MenuComponents.py.

◆ onlyJets

MenuComponents.ChainStep.onlyJets

Definition at line 636 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 616 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.processes.powheg.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.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
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108