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

Public Member Functions

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

Public Attributes

 name = name
list sequences = []
 sequenceGens = SequenceGens
 comboHypoCfg = comboHypoCfg
 comboToolConfs = list(comboToolConfs)
 stepDicts = chainDicts
 nLegs = len(self.stepDicts)
 isEmpty = isEmpty
bool onlyJets = False
 combo = None

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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 592 of file MenuComponents.py.

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

Member Function Documentation

◆ __repr__()

MenuComponents.ChainStep.__repr__ ( self)

Definition at line 713 of file MenuComponents.py.

713 def __repr__(self):
714 if len(self.sequenceGens) == 0:
715 return "\n--- ChainStep %s ---\n is Empty, ChainDict = %s "%(self.name, ' '.join(map(str, [dic['chainName'] for dic in self.stepDicts])) )
716
717 repr_string= "\n--- ChainStep %s ---\n , nLegs = %s ChainDict = %s \n + MenuSequenceGens = %s "%\
718 (self.name, self.nLegs,
719 ' '.join(map(str, [dic['chainName'] for dic in self.stepDicts])),
720 ' '.join(map(str, [seq.func.__name__ for seq in self.sequenceGens]) ))
721
722 if self.combo is not None:
723 repr_string += "\n + ComboHypo = %s" % self.combo.Alg.name
724 if len(self.comboToolConfs)>0:
725 repr_string +=", ComboHypoTools = %s" %(' '.join(map(str, [tool.__name__ for tool in self.comboToolConfs])))
726 repr_string += "\n"
727 return repr_string
728
729
STL class.

◆ addComboHypoTools()

MenuComponents.ChainStep.addComboHypoTools ( self,
tool )

Definition at line 668 of file MenuComponents.py.

668 def addComboHypoTools(self, tool):
669 #this function does not add tools, it just adds one tool. do not pass it a list!
670 self.comboToolConfs.append(tool)
671

◆ createComboHypoTools()

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

Definition at line 699 of file MenuComponents.py.

699 def createComboHypoTools(self, flags, chainName):
700 chainDict = HLTMenuConfig.getChainDictFromChainName(chainName)
701 self.combo.createComboHypoTools(flags, chainDict, self.comboToolConfs)
702

◆ createSequences()

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

Definition at line 643 of file MenuComponents.py.

643 def createSequences(self):
644 """ creation of this step sequences with instantiation of the CAs"""
645 log.debug("createSequences: creating %d sequences for step %s", len(self.sequenceGens), self.name)
646 for seq in self.sequenceGens:
647 log.debug("createSequences: creating sequence %s", seq.func.__name__)
648 self.sequences.append(seq()) # create the sequences
649
650

◆ getChainLegs()

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

Definition at line 703 of file MenuComponents.py.

703 def getChainLegs(self):
704 """ This is extrapolating the chain legs from the step dictionaries"""
705 legs = [part['chainName'] for part in self.stepDicts]
706 return legs
707

◆ getChainNames()

MenuComponents.ChainStep.getChainNames ( self)

Definition at line 708 of file MenuComponents.py.

708 def getChainNames(self):
709 if self.combo is not None:
710 return list(self.combo.getChains())
711 return self.getChainLegs()
712

◆ getComboHypoFncName()

MenuComponents.ChainStep.getComboHypoFncName ( self)

Definition at line 672 of file MenuComponents.py.

672 def getComboHypoFncName(self):
673 return self.comboHypoCfg.func.__name__
674
675
676

◆ makeCombo()

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

Definition at line 677 of file MenuComponents.py.

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

◆ setChainPartIndices()

MenuComponents.ChainStep.setChainPartIndices ( self)

Definition at line 652 of file MenuComponents.py.

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

Member Data Documentation

◆ combo

MenuComponents.ChainStep.combo = None

Definition at line 679 of file MenuComponents.py.

◆ comboHypoCfg

MenuComponents.ChainStep.comboHypoCfg = comboHypoCfg

Definition at line 606 of file MenuComponents.py.

◆ comboToolConfs

MenuComponents.ChainStep.comboToolConfs = list(comboToolConfs)

Definition at line 607 of file MenuComponents.py.

◆ isEmpty

MenuComponents.ChainStep.isEmpty = isEmpty

Definition at line 610 of file MenuComponents.py.

◆ name

MenuComponents.ChainStep.name = name

Definition at line 600 of file MenuComponents.py.

◆ nLegs

MenuComponents.ChainStep.nLegs = len(self.stepDicts)

Definition at line 609 of file MenuComponents.py.

◆ onlyJets

bool MenuComponents.ChainStep.onlyJets = False

Definition at line 628 of file MenuComponents.py.

◆ sequenceGens

MenuComponents.ChainStep.sequenceGens = SequenceGens

Definition at line 602 of file MenuComponents.py.

◆ sequences

list MenuComponents.ChainStep.sequences = []

Definition at line 601 of file MenuComponents.py.

◆ stepDicts

MenuComponents.ChainStep.stepDicts = chainDicts

Definition at line 608 of file MenuComponents.py.


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