CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ttSemiLepEvtBuilder_cff.py
Go to the documentation of this file.
2 
3 
4 ################################################################################
5 # produce ttSemiLepEvent structure with all necessary ingredients
6 ################################################################################
7 
8 ## std sequence to produce the ttSemiLepEventHypotheses
10 
11 ## configure ttSemiLepEventBuilder
13 
14 ## make ttSemiLepEvent
15 makeTtSemiLepEvent = cms.Sequence(makeTtSemiLepHypotheses *
16  ttSemiLepEvent
17  )
18 
19 
20 ################################################################################
21 ## helper functions
22 ## (examples of usage can be found in the ttSemiLepEvtBuilder_cfg.py)
23 ################################################################################
24 
25 ## add hypotheses to the process
26 def addTtSemiLepHypotheses(process,
27  names
28  ):
29 
30  ## edit list of input hypotheses for the TtSemiLepEventBuilder
31  labels = getattr(process.ttSemiLepEvent, "hypotheses")
32  for obj in range(len(names)):
33  ## create correct label from HypoClassKey string (stripping the leading "k")
34  ## e.g. kKinFit -> ttSemiLepHypKinFit
35  label = "ttSemiLepHyp" + names[obj][1:]
36  ## add it to the list
37  labels.append(label)
38  process.ttSemiLepEvent.hypotheses = labels
39 
40  ## include hypotheses in the standard sequence
41  sequence = getattr(process, "makeTtSemiLepHypotheses")
42  for obj in range(len(names)):
43  ## create correct label from HypoClassKey string (stripping the leading "k")
44  ## e.g. kKinFit -> makeHypothesis_kinFit
45  if names[obj][1:4] == "MVA":
46  label = "makeHypothesis_" + names[obj][1:4].lower() + names[obj][4:]
47  else:
48  label = "makeHypothesis_" + names[obj][1:2].lower() + names[obj][2:]
49  ## add it to the sequence
50  sequence += getattr(process, label)
51 
52 
53 ## remove genMatch hypothesis from the process
55  process.makeTtSemiLepHypotheses.remove(process.makeHypothesis_genMatch)
56  process.ttSemiLepEvent.hypotheses.remove("ttSemiLepHypGenMatch")
57 
58 
59 ## set a specific attribute for all hypotheses to a given value
60 ## -> this works for "jets", "leps", "mets", "maxNJets"
61 def setForAllTtSemiLepHypotheses(process, attribute, value):
62  modules = ["findTtSemiLepJetCombGeom",
63  "findTtSemiLepJetCombMaxSumPtWMass",
64  "findTtSemiLepJetCombMVA",
65  "findTtSemiLepJetCombWMassDeltaTopMass",
66  "findTtSemiLepJetCombWMassMaxSumPt",
67  "hitFitTtSemiLepEventHypothesis",
68  "kinFitTtSemiLepEventHypothesis",
69  "ttSemiLepJetPartonMatch",
70  "ttSemiLepHypGenMatch",
71  "ttSemiLepHypGeom",
72  "ttSemiLepHypHitFit",
73  "ttSemiLepHypKinFit",
74  "ttSemiLepHypMaxSumPtWMass",
75  "ttSemiLepHypMVADisc",
76  "ttSemiLepHypWMassDeltaTopMass",
77  "ttSemiLepHypWMassMaxSumPt"
78  ]
79  for obj in range(len(modules)):
80  object = getattr(process, modules[obj])
81  if hasattr(object, attribute):
82  setattr(object, attribute, value)
83 
84 ## use electrons instead of muons for the hypotheses
85 def useElectronsForAllTtSemiLepHypotheses(process, elecLabel = "selectedPatElectrons"):
86  ## use correct KinFitter module
87  import TopQuarkAnalysis.TopKinFitter.TtSemiLepKinFitProducer_Electrons_cfi
88  process.kinFitTtSemiLepEventHypothesis = TopQuarkAnalysis.TopKinFitter.TtSemiLepKinFitProducer_Electrons_cfi.kinFitTtSemiLepEvent.clone()
89  import TopQuarkAnalysis.TopHitFit.TtSemiLepHitFitProducer_Electrons_cfi
90  process.hitFitTtSemiLepEventHypothesis = TopQuarkAnalysis.TopHitFit.TtSemiLepHitFitProducer_Electrons_cfi.hitFitTtSemiLepEvent.clone()
91  ## replace lepton InputTags in all modules
92  setForAllTtSemiLepHypotheses(process, "leps", elecLabel)
def setForAllTtSemiLepHypotheses
set a specific attribute for all hypotheses to a given value -> this works for "jets", "leps", "mets", "maxNJets"
def addTtSemiLepHypotheses
helper functions (examples of usage can be found in the ttSemiLepEvtBuilder_cfg.py) ...
def useElectronsForAllTtSemiLepHypotheses
use electrons instead of muons for the hypotheses
produce ttSemiLepEvent structure with all necessary ingredients
def removeTtSemiLepHypGenMatch
remove genMatch hypothesis from the process
configure ttSemiLepEventBuilder