test
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.
1 import FWCore.ParameterSet.Config as cms
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  process.ttSemiLepEvent.genEvent = ''
58 
59 
60 ## set a specific attribute for all hypotheses to a given value
61 ## -> this works for "jets", "leps", "mets", "maxNJets"
62 def setForAllTtSemiLepHypotheses(process, attribute, value):
63  modules = ["findTtSemiLepJetCombGeom",
64  "findTtSemiLepJetCombMaxSumPtWMass",
65  "findTtSemiLepJetCombMVA",
66  "findTtSemiLepJetCombWMassDeltaTopMass",
67  "findTtSemiLepJetCombWMassMaxSumPt",
68  "hitFitTtSemiLepEventHypothesis",
69  "kinFitTtSemiLepEventHypothesis",
70  "ttSemiLepJetPartonMatch",
71  "ttSemiLepHypGenMatch",
72  "ttSemiLepHypGeom",
73  "ttSemiLepHypHitFit",
74  "ttSemiLepHypKinFit",
75  "ttSemiLepHypMaxSumPtWMass",
76  "ttSemiLepHypMVADisc",
77  "ttSemiLepHypWMassDeltaTopMass",
78  "ttSemiLepHypWMassMaxSumPt"
79  ]
80  for obj in range(len(modules)):
81  object = getattr(process, modules[obj])
82  if hasattr(object, attribute):
83  setattr(object, attribute, value)
84 
85 ## use electrons instead of muons for the hypotheses
86 def useElectronsForAllTtSemiLepHypotheses(process, elecLabel = "selectedPatElectrons"):
87  ## use correct KinFitter module
88  import TopQuarkAnalysis.TopKinFitter.TtSemiLepKinFitProducer_Electrons_cfi
89  process.kinFitTtSemiLepEventHypothesis = TopQuarkAnalysis.TopKinFitter.TtSemiLepKinFitProducer_Electrons_cfi.kinFitTtSemiLepEvent.clone()
90  import TopQuarkAnalysis.TopHitFit.TtSemiLepHitFitProducer_Electrons_cfi
91  process.hitFitTtSemiLepEventHypothesis = TopQuarkAnalysis.TopHitFit.TtSemiLepHitFitProducer_Electrons_cfi.hitFitTtSemiLepEvent.clone()
92  ## replace lepton InputTags in all modules
93  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
make ttSemiLepEvent makeTtSemiLepEvent = cms.Sequence(makeTtSemiLepHypotheses * ttSemiLepEvent ) ...
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