600 def __init__(self, name, SequenceGens = None, chainDicts = None, comboHypoCfg = None, comboToolConfs = None, isEmpty = False, createsGhostLegs = False):
601
602
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
617 self.nLegs = len(self.stepDicts)
618 self.isEmpty = isEmpty
619
620
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