|
def | __init__ (self, name, SequenceGens=None, chainDicts=None, comboHypoCfg=ComboHypoCfg, comboToolConfs=None, isEmpty=False, createsGhostLegs=False) |
|
def | createSequences (self) |
|
def | relabelLegIdsForJets (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) |
|
Class to describe one step of a chain; if multiplicity is greater than 1, the step is combo/combined. Set one multiplicity value per sequence
Definition at line 624 of file MenuComponents.py.
◆ __init__()
def MenuComponents.ChainStep.__init__ |
( |
|
self, |
|
|
|
name, |
|
|
|
SequenceGens = None , |
|
|
|
chainDicts = None , |
|
|
|
comboHypoCfg = ComboHypoCfg , |
|
|
|
comboToolConfs = None , |
|
|
|
isEmpty = False , |
|
|
|
createsGhostLegs = False |
|
) |
| |
Definition at line 627 of file MenuComponents.py.
627 def __init__(self, name, SequenceGens = None, chainDicts = None, comboHypoCfg = ComboHypoCfg , comboToolConfs = None, isEmpty = False, createsGhostLegs = False):
630 if SequenceGens
is None: SequenceGens = []
631 if comboToolConfs
is None: comboToolConfs = []
633 assert chainDicts
is not None,
"Error building a ChainStep without a chainDicts"
637 self.sequenceGens = SequenceGens
638 self.comboHypoCfg = comboHypoCfg
639 self.comboToolConfs =
list(comboToolConfs)
640 self.stepDicts = chainDicts
642 self.isEmpty = isEmpty
644 self.multiplicity = []
646 self.multiplicity = [1
for seq
in self.sequenceGens]
647 log.debug(
"Building step %s for chain %s: len=%d multiplicty=%s", name, chainDicts[0][
'chainName'], len(chainDicts),
' '.
join(map(str,[mult
for mult
in self.multiplicity])))
649 if len(chainDicts) != len(self.multiplicity)
and 'Jet' not in chainDicts[0][
'signatures']:
650 log.error(
"[ChainStep] SequenceGens: %s",self.sequenceGens)
651 log.error(
"[ChainStep] chainDicts: %s",chainDicts)
652 log.error(
"[ChainStep] multiplicity: %s",self.multiplicity)
653 raise RuntimeError(
"[ChainStep] Tried to configure a ChainStep %s with %i multiplicity and %i dictionaries. These lists must have the same size" % (name, len(self.multiplicity), len(chainDicts)) )
656 for iseq, seq
in enumerate(self.sequenceGens):
657 if not isinstance(seq, functools.partial):
658 log.error(
"[ChainStep] %s SequenceGens verification failed, sequence %d is not partial function, likely ChainBase.getStep function was not used", self.name, iseq)
659 log.error(
"[ChainStep] It rather seems to be of type %s trying to print it",
type(seq))
660 raise RuntimeError(
"Sequence is not packaged in a tuple, see error message above" )
662 self.onlyJets =
False
664 if len(chainDicts) > 0
and 'signature' in chainDicts[0]:
665 leg_signatures = [step[
'signature']
for step
in chainDicts
if step[
'signature'] !=
'Bjet']
666 if (len(self.multiplicity) > 0
and leg_signatures.count(
'Jet') == 1)
and (len(
set(leg_signatures)) > 1
and chainDicts[0][
'signatures'].
count(
'Jet') > 1)
and (len(leg_signatures) != 2
or leg_signatures.count(
'MET') == 0):
667 index_jetLeg = leg_signatures.index(
'Jet')
668 self.multiplicity[index_jetLeg:index_jetLeg] = [1] * (len(chainDicts[0][
'chainMultiplicities']) - len(self.multiplicity))
669 sig_set =
set([step[
'signature']
for step
in chainDicts])
670 if len(sig_set) == 1
and (
'Jet' in sig_set
or 'Bjet' in sig_set):
672 if len(sig_set) == 2
and (
'Jet' in sig_set
and 'Bjet' in sig_set):
679 self.setChainPartIndices()
680 self.legIds = self.getLegIds()
◆ __repr__()
def MenuComponents.ChainStep.__repr__ |
( |
|
self | ) |
|
Definition at line 808 of file MenuComponents.py.
809 if len(self.sequenceGens) == 0:
810 return "\n--- ChainStep %s ---\n is Empty, ChainDict = %s "%(self.name,
' '.
join(map(str, [dic[
'chainName']
for dic
in self.stepDicts])) )
812 repr_string=
"\n--- ChainStep %s ---\n , multiplicity = %s ChainDict = %s \n + MenuSequenceGens = %s "%\
813 (self.name,
' '.
join(map(str,[mult
for mult
in self.multiplicity])),
814 ' '.
join(map(str, [dic[
'chainName']
for dic
in self.stepDicts])),
815 ' '.
join(map(str, [seq.func.__name__
for seq
in self.sequenceGens]) ))
817 if self.combo
is not None:
818 repr_string +=
"\n + ComboHypo = %s" % self.combo.Alg.name
819 if len(self.comboToolConfs)>0:
820 repr_string +=
", ComboHypoTools = %s" %(
' '.
join(map(str, [tool.__name__
for tool
in self.comboToolConfs])))
◆ addComboHypoTools()
def MenuComponents.ChainStep.addComboHypoTools |
( |
|
self, |
|
|
|
tool |
|
) |
| |
◆ createComboHypoTools()
def MenuComponents.ChainStep.createComboHypoTools |
( |
|
self, |
|
|
|
flags, |
|
|
|
chainName |
|
) |
| |
Definition at line 794 of file MenuComponents.py.
794 def createComboHypoTools(self, flags, chainName):
795 chainDict = HLTMenuConfig.getChainDictFromChainName(chainName)
796 self.combo.createComboHypoTools(flags, chainDict, self.comboToolConfs)
◆ createSequences()
def MenuComponents.ChainStep.createSequences |
( |
|
self | ) |
|
creation of this step sequences with instantiation of the CAs
Definition at line 683 of file MenuComponents.py.
683 def createSequences(self):
684 """ creation of this step sequences with instantiation of the CAs"""
685 log.debug(
"creating sequences for step %s", self.name)
686 for seq
in self.sequenceGens:
◆ getChainLegs()
def MenuComponents.ChainStep.getChainLegs |
( |
|
self | ) |
|
This is extrapolating the chain legs from the step dictionaries
Definition at line 798 of file MenuComponents.py.
798 def getChainLegs(self):
799 """ This is extrapolating the chain legs from the step dictionaries"""
800 legs = [part[
'chainName']
for part
in self.stepDicts]
◆ getChainNames()
def MenuComponents.ChainStep.getChainNames |
( |
|
self | ) |
|
Definition at line 803 of file MenuComponents.py.
803 def getChainNames(self):
804 if self.combo
is not None:
806 return self.getChainLegs()
◆ getComboHypoFncName()
def MenuComponents.ChainStep.getComboHypoFncName |
( |
|
self | ) |
|
Definition at line 767 of file MenuComponents.py.
767 def getComboHypoFncName(self):
768 return self.comboHypoCfg.func.__name__
if isinstance(self.comboHypoCfg, functools.partial)
else self.comboHypoCfg
◆ getLegIds()
def MenuComponents.ChainStep.getLegIds |
( |
|
self | ) |
|
get the gelId from the step dictionary for multi-leg chains
Definition at line 747 of file MenuComponents.py.
748 """ get the gelId from the step dictionary for multi-leg chains"""
749 if len(self.multiplicity) <= 1:
752 for istep,step_dict
in enumerate(self.stepDicts):
753 if step_dict[
'chainName'][0:3] !=
'leg':
757 log.error(
"[getLegIds] chain %s has multiplicities %s but no legs? ",step_dict[
'chainName'], self.multiplicity)
758 raise Exception(
"[getLegIds] cannot extract leg IDs, exiting.")
760 leg_ids += [
int(step_dict[
'chainName'][3:6])]
◆ 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 770 of file MenuComponents.py.
771 """ Configure the Combo Hypo Alg and generate the corresponding function, without instantiation which is done in createSequences() """
773 if self.isEmpty
or self.comboHypoCfg
is None:
775 comboNameFromStep = CFNaming.comboHypoName(self.name)
776 funcName = self.getComboHypoFncName()
777 key =
hash((comboNameFromStep, funcName))
778 if key
not in _ComboHypoPool:
779 tmpCombo = ComboHypoNode(comboNameFromStep, self.comboHypoCfg)
782 if comboNameFromStep+
"Node" != tmpCombo.name:
783 log.info(
"WARNING Created ComboHypo with name %s, expected from the step is instead %s. This is accepted only for allowed custom ComboHypos", tmpCombo.name, comboNameFromStep)
784 key =
hash((tmpCombo.name, funcName))
785 _ComboHypoPool[key] = tmpCombo
786 self.combo = _ComboHypoPool[key]
787 log.debug(
"Created combo %s with name %s, step comboName %s, key %s", funcName, self.combo.name, comboNameFromStep,key)
◆ relabelLegIdsForJets()
def MenuComponents.ChainStep.relabelLegIdsForJets |
( |
|
self | ) |
|
Definition at line 689 of file MenuComponents.py.
689 def relabelLegIdsForJets(self):
693 for step_dict
in self.stepDicts:
694 if 'Jet' in step_dict[
'signatures']
or 'Bjet' in step_dict[
'signatures']:
696 leg_counter += [len(step_dict[
'chainParts'])]
697 elif len(step_dict[
'chainParts']) > 1:
698 log.error(
"[relabelLegIdsForJets] this should only happen for jet chains, but the signatures are %s",step_dict[
'signatures'])
699 raise Exception(
"[relabelLegIdsForJets] leg labelling is probably wrong...")
703 self.onlyJets =
False
704 if len(leg_counter) == len(self.multiplicity):
707 log.debug(
"[relabelLegIdsForJets] leg_counter: %s , onlyjets: %s, multiplicity: %s...",leg_counter, self.onlyJets, self.multiplicity)
709 if not has_jets
or len(leg_counter) == len(self.multiplicity):
712 if len(leg_counter) == 1
or (len(
set(leg_counter)) == 1
and leg_counter[0] == 1):
715 elif len(
set(leg_counter[:-1])) == 1
and leg_counter[0] == 1:
720 for i,nLegParts
in enumerate(leg_counter):
721 oldLegName = self.stepDicts[i][
'chainName']
722 if re.search(
'^leg[0-9]{3}_',oldLegName):
723 oldLegName = oldLegName[7:]
725 log.error(
"[relabelLegIdsForJets] you told me to relabel the legs for %s",self.stepDicts)
726 raise Exception(
"[relabelLegIdsForJets] you told me to relabel the legs but this leg doesn't have a legXXX_ name!")
727 self.stepDicts[i][
'chainName'] =
legName(oldLegName,nLegs)
◆ setChainPartIndices()
def MenuComponents.ChainStep.setChainPartIndices |
( |
|
self | ) |
|
Definition at line 732 of file MenuComponents.py.
732 def setChainPartIndices(self):
734 lists_of_chainPartNames = []
735 for step_dict
in self.stepDicts:
736 if len(lists_of_chainPartNames) == 0:
737 lists_of_chainPartNames += [[cp[
'chainPartName']
for cp
in step_dict[
'chainParts']]]
739 new_list_of_chainPartNames = [cp[
'chainPartName']
for cp
in step_dict[
'chainParts']]
740 if new_list_of_chainPartNames == lists_of_chainPartNames[-1]:
741 leg_counter -= len(new_list_of_chainPartNames)
742 for chainPart
in step_dict[
'chainParts']:
743 chainPart[
'chainPartIndex'] = leg_counter
◆ combo
MenuComponents.ChainStep.combo |
◆ comboHypoCfg
MenuComponents.ChainStep.comboHypoCfg |
◆ comboToolConfs
MenuComponents.ChainStep.comboToolConfs |
◆ isEmpty
MenuComponents.ChainStep.isEmpty |
◆ legIds
MenuComponents.ChainStep.legIds |
◆ multiplicity
MenuComponents.ChainStep.multiplicity |
◆ name
MenuComponents.ChainStep.name |
◆ onlyJets
MenuComponents.ChainStep.onlyJets |
◆ sequenceGens
MenuComponents.ChainStep.sequenceGens |
◆ sequences
MenuComponents.ChainStep.sequences |
◆ stepDicts
MenuComponents.ChainStep.stepDicts |
The documentation for this class was generated from the following file:
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.