592 def __init__(self, name, SequenceGens = None, chainDicts = None, comboHypoCfg = None, comboToolConfs = None, isEmpty = False, createsGhostLegs = False):
593
594
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
609 self.nLegs = len(self.stepDicts)
610 self.isEmpty = isEmpty
611
612
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