|
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 634 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 637 of file MenuComponents.py.
637 def __init__(self, name, SequenceGens = None, chainDicts = None, comboHypoCfg = ComboHypoCfg , comboToolConfs = None, isEmpty = False, createsGhostLegs = False):
640 if SequenceGens
is None: SequenceGens = []
641 if comboToolConfs
is None: comboToolConfs = []
643 assert chainDicts
is not None,
"Error building a ChainStep without a chainDicts"
647 self.sequenceGens = SequenceGens
648 self.comboHypoCfg = comboHypoCfg
649 self.comboToolConfs =
list(comboToolConfs)
650 self.stepDicts = chainDicts
652 self.isEmpty = isEmpty
654 self.multiplicity = []
656 self.multiplicity = [1
for seq
in self.sequenceGens]
657 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])))
659 if len(chainDicts) != len(self.multiplicity)
and 'Jet' not in chainDicts[0][
'signatures']:
660 log.error(
"[ChainStep] SequenceGens: %s",self.sequenceGens)
661 log.error(
"[ChainStep] chainDicts: %s",chainDicts)
662 log.error(
"[ChainStep] multiplicity: %s",self.multiplicity)
663 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)) )
666 for iseq, seq
in enumerate(self.sequenceGens):
667 if not isinstance(seq, functools.partial):
668 log.error(
"[ChainStep] %s SequenceGens verification failed, sequence %d is not partial function, likely ChainBase.getStep function was not used", self.name, iseq)
669 log.error(
"[ChainStep] It rather seems to be of type %s trying to print it",
type(seq))
670 raise RuntimeError(
"Sequence is not packaged in a tuple, see error message above" )
672 self.onlyJets =
False
674 if len(chainDicts) > 0
and 'signature' in chainDicts[0]:
675 leg_signatures = [step[
'signature']
for step
in chainDicts
if step[
'signature'] !=
'Bjet']
676 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):
677 index_jetLeg = leg_signatures.index(
'Jet')
678 self.multiplicity[index_jetLeg:index_jetLeg] = [1] * (len(chainDicts[0][
'chainMultiplicities']) - len(self.multiplicity))
679 sig_set =
set([step[
'signature']
for step
in chainDicts])
680 if len(sig_set) == 1
and (
'Jet' in sig_set
or 'Bjet' in sig_set):
682 if len(sig_set) == 2
and (
'Jet' in sig_set
and 'Bjet' in sig_set):
689 self.setChainPartIndices()
690 self.legIds = self.getLegIds()
◆ __repr__()
def MenuComponents.ChainStep.__repr__ |
( |
|
self | ) |
|
Definition at line 817 of file MenuComponents.py.
818 if len(self.sequenceGens) == 0:
819 return "\n--- ChainStep %s ---\n is Empty, ChainDict = %s "%(self.name,
' '.
join(map(str, [dic[
'chainName']
for dic
in self.stepDicts])) )
821 repr_string=
"\n--- ChainStep %s ---\n , multiplicity = %s ChainDict = %s \n + MenuSequenceGens = %s "%\
822 (self.name,
' '.
join(map(str,[mult
for mult
in self.multiplicity])),
823 ' '.
join(map(str, [dic[
'chainName']
for dic
in self.stepDicts])),
824 ' '.
join(map(str, [seq.func.__name__
for seq
in self.sequenceGens]) ))
826 if self.combo
is not None:
827 repr_string +=
"\n + ComboHypo = %s" % self.combo.Alg.name
828 if len(self.comboToolConfs)>0:
829 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 803 of file MenuComponents.py.
803 def createComboHypoTools(self, flags, chainName):
804 chainDict = HLTMenuConfig.getChainDictFromChainName(chainName)
805 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 693 of file MenuComponents.py.
693 def createSequences(self):
694 """ creation of this step sequences with instantiation of the CAs"""
695 log.debug(
"creating sequences for step %s", self.name)
696 for seq
in self.sequenceGens:
◆ getChainLegs()
def MenuComponents.ChainStep.getChainLegs |
( |
|
self | ) |
|
This is extrapolating the chain legs from the step dictionaries
Definition at line 807 of file MenuComponents.py.
807 def getChainLegs(self):
808 """ This is extrapolating the chain legs from the step dictionaries"""
809 legs = [part[
'chainName']
for part
in self.stepDicts]
◆ getChainNames()
def MenuComponents.ChainStep.getChainNames |
( |
|
self | ) |
|
Definition at line 812 of file MenuComponents.py.
812 def getChainNames(self):
813 if self.combo
is not None:
815 return self.getChainLegs()
◆ getComboHypoFncName()
def MenuComponents.ChainStep.getComboHypoFncName |
( |
|
self | ) |
|
Definition at line 777 of file MenuComponents.py.
777 def getComboHypoFncName(self):
778 return self.comboHypoCfg.__name__
if isinstance(self.comboHypoCfg, types.FunctionType)
else self.comboHypoCfg
◆ getLegIds()
def MenuComponents.ChainStep.getLegIds |
( |
|
self | ) |
|
get the gelId from the step dictionary for multi-leg chains
Definition at line 757 of file MenuComponents.py.
758 """ get the gelId from the step dictionary for multi-leg chains"""
759 if len(self.multiplicity) <= 1:
762 for istep,step_dict
in enumerate(self.stepDicts):
763 if step_dict[
'chainName'][0:3] !=
'leg':
767 log.error(
"[getLegIds] chain %s has multiplicities %s but no legs? ",step_dict[
'chainName'], self.multiplicity)
768 raise Exception(
"[getLegIds] cannot extract leg IDs, exiting.")
770 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 781 of file MenuComponents.py.
782 """ Configure the Combo Hypo Alg and generate the corresponding function, without instantiation which is done in createSequences() """
784 if self.isEmpty
or self.comboHypoCfg
is None:
786 comboNameFromStep = CFNaming.comboHypoName(self.name)
787 funcName = self.getComboHypoFncName()
788 key =
hash((comboNameFromStep, funcName))
789 if key
not in _ComboHypoPool:
790 tmpCombo = ComboHypoNode(comboNameFromStep, self.comboHypoCfg)
791 CHname = tmpCombo.name[:-4]
794 if comboNameFromStep != CHname:
795 log.debug(
"Created ComboHypo with name %s, expected from the step is instead %s. This is accepted only for allowed custom ComboHypos", CHname, comboNameFromStep)
796 _CustomComboHypoAllowed.add(CHname)
797 key =
hash((CHname, funcName))
798 _ComboHypoPool[key] = tmpCombo
799 self.combo = _ComboHypoPool[key]
800 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 699 of file MenuComponents.py.
699 def relabelLegIdsForJets(self):
703 for step_dict
in self.stepDicts:
704 if 'Jet' in step_dict[
'signatures']
or 'Bjet' in step_dict[
'signatures']:
706 leg_counter += [len(step_dict[
'chainParts'])]
707 elif len(step_dict[
'chainParts']) > 1:
708 log.error(
"[relabelLegIdsForJets] this should only happen for jet chains, but the signatures are %s",step_dict[
'signatures'])
709 raise Exception(
"[relabelLegIdsForJets] leg labelling is probably wrong...")
713 self.onlyJets =
False
714 if len(leg_counter) == len(self.multiplicity):
717 log.debug(
"[relabelLegIdsForJets] leg_counter: %s , onlyjets: %s, multiplicity: %s...",leg_counter, self.onlyJets, self.multiplicity)
719 if not has_jets
or len(leg_counter) == len(self.multiplicity):
722 if len(leg_counter) == 1
or (len(
set(leg_counter)) == 1
and leg_counter[0] == 1):
725 elif len(
set(leg_counter[:-1])) == 1
and leg_counter[0] == 1:
730 for i,nLegParts
in enumerate(leg_counter):
731 oldLegName = self.stepDicts[i][
'chainName']
732 if re.search(
'^leg[0-9]{3}_',oldLegName):
733 oldLegName = oldLegName[7:]
735 log.error(
"[relabelLegIdsForJets] you told me to relabel the legs for %s",self.stepDicts)
736 raise Exception(
"[relabelLegIdsForJets] you told me to relabel the legs but this leg doesn't have a legXXX_ name!")
737 self.stepDicts[i][
'chainName'] =
legName(oldLegName,nLegs)
◆ setChainPartIndices()
def MenuComponents.ChainStep.setChainPartIndices |
( |
|
self | ) |
|
Definition at line 742 of file MenuComponents.py.
742 def setChainPartIndices(self):
744 lists_of_chainPartNames = []
745 for step_dict
in self.stepDicts:
746 if len(lists_of_chainPartNames) == 0:
747 lists_of_chainPartNames += [[cp[
'chainPartName']
for cp
in step_dict[
'chainParts']]]
749 new_list_of_chainPartNames = [cp[
'chainPartName']
for cp
in step_dict[
'chainParts']]
750 if new_list_of_chainPartNames == lists_of_chainPartNames[-1]:
751 leg_counter -= len(new_list_of_chainPartNames)
752 for chainPart
in step_dict[
'chainParts']:
753 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.