CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/TopQuarkAnalysis/TopEventProducers/python/sequences/ttSemiLepEvtBuilder_cff.py

Go to the documentation of this file.
00001 import FWCore.ParameterSet.Config as cms
00002 
00003 
00004 ################################################################################
00005 # produce ttSemiLepEvent structure with all necessary ingredients
00006 ################################################################################
00007 
00008 ## std sequence to produce the ttSemiLepEventHypotheses
00009 from TopQuarkAnalysis.TopEventProducers.sequences.ttSemiLepEvtHypotheses_cff import *
00010 
00011 ## configure ttSemiLepEventBuilder
00012 from TopQuarkAnalysis.TopEventProducers.producers.TtSemiLepEvtBuilder_cfi import *
00013 
00014 ## make ttSemiLepEvent
00015 makeTtSemiLepEvent = cms.Sequence(makeTtSemiLepHypotheses *
00016                                   ttSemiLepEvent
00017                                   )
00018 
00019 
00020 ################################################################################
00021 ## helper functions
00022 ## (examples of usage can be found in the ttSemiLepEvtBuilder_cfg.py)
00023 ################################################################################
00024 
00025 ## add hypotheses to the process
00026 def addTtSemiLepHypotheses(process,
00027                            names
00028                            ):
00029 
00030     ## edit list of input hypotheses for the TtSemiLepEventBuilder
00031     labels =  getattr(process.ttSemiLepEvent, "hypotheses")
00032     for obj in range(len(names)):
00033         ## create correct label from HypoClassKey string (stripping the leading "k")
00034         ## e.g. kKinFit -> ttSemiLepHypKinFit
00035         label = "ttSemiLepHyp" + names[obj][1:]
00036         ## add it to the list
00037         labels.append(label)
00038     process.ttSemiLepEvent.hypotheses = labels
00039 
00040     ## include hypotheses in the standard sequence
00041     sequence = getattr(process, "makeTtSemiLepHypotheses")
00042     for obj in range(len(names)):
00043         ## create correct label from HypoClassKey string (stripping the leading "k")
00044         ## e.g. kKinFit -> makeHypothesis_kinFit
00045         if names[obj][1:4] == "MVA":
00046             label = "makeHypothesis_" + names[obj][1:4].lower() + names[obj][4:]
00047         else:
00048             label = "makeHypothesis_" + names[obj][1:2].lower() + names[obj][2:]
00049         ## add it to the sequence
00050         sequence += getattr(process, label)
00051 
00052 
00053 ## remove genMatch hypothesis from the process
00054 def removeTtSemiLepHypGenMatch(process):
00055     process.makeTtSemiLepHypotheses.remove(process.makeHypothesis_genMatch)
00056     process.ttSemiLepEvent.hypotheses.remove("ttSemiLepHypGenMatch")
00057 
00058 
00059 ## set a specific attribute for all hypotheses to a given value
00060 ## -> this works for "jets", "leps", "mets", "maxNJets"
00061 def setForAllTtSemiLepHypotheses(process, attribute, value):
00062     modules = ["findTtSemiLepJetCombGeom",
00063                "findTtSemiLepJetCombMaxSumPtWMass",
00064                "findTtSemiLepJetCombMVA",
00065                "findTtSemiLepJetCombWMassDeltaTopMass",
00066                "findTtSemiLepJetCombWMassMaxSumPt",
00067                "hitFitTtSemiLepEventHypothesis",
00068                "kinFitTtSemiLepEventHypothesis",
00069                "ttSemiLepJetPartonMatch",
00070                "ttSemiLepHypGenMatch",
00071                "ttSemiLepHypGeom",
00072                "ttSemiLepHypHitFit",
00073                "ttSemiLepHypKinFit",
00074                "ttSemiLepHypMaxSumPtWMass",
00075                "ttSemiLepHypMVADisc",               
00076                "ttSemiLepHypWMassDeltaTopMass",
00077                "ttSemiLepHypWMassMaxSumPt"
00078                ]
00079     for obj in range(len(modules)):
00080         object = getattr(process, modules[obj])
00081         if hasattr(object, attribute):
00082             setattr(object, attribute, value)
00083 
00084 ## use electrons instead of muons for the hypotheses
00085 def useElectronsForAllTtSemiLepHypotheses(process, elecLabel = "selectedPatElectrons"):
00086     ## use correct KinFitter module
00087     import TopQuarkAnalysis.TopKinFitter.TtSemiLepKinFitProducer_Electrons_cfi
00088     process.kinFitTtSemiLepEventHypothesis = TopQuarkAnalysis.TopKinFitter.TtSemiLepKinFitProducer_Electrons_cfi.kinFitTtSemiLepEvent.clone()
00089     import TopQuarkAnalysis.TopHitFit.TtSemiLepHitFitProducer_Electrons_cfi
00090     process.hitFitTtSemiLepEventHypothesis = TopQuarkAnalysis.TopHitFit.TtSemiLepHitFitProducer_Electrons_cfi.hitFitTtSemiLepEvent.clone()
00091     ## replace lepton InputTags in all modules
00092     setForAllTtSemiLepHypotheses(process, "leps", elecLabel)