CMS 3D CMS Logo

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