Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:13

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 
0004 ################################################################################
0005 # produce ttSemiLepEvent structure with all necessary ingredients
0006 ################################################################################
0007 
0008 ## std sequence to produce the ttSemiLepEventHypotheses
0009 from TopQuarkAnalysis.TopEventProducers.sequences.ttSemiLepEvtHypotheses_cff import *
0010 
0011 ## configure ttSemiLepEventBuilder
0012 from TopQuarkAnalysis.TopEventProducers.producers.TtSemiLepEvtBuilder_cfi import *
0013 
0014 ### make ttSemiLepEvent
0015 makeTtSemiLepEventTask = cms.Task(
0016     makeTtSemiLepHypothesesTask,
0017     ttSemiLepEvent
0018 )
0019 #makeTtSemiLepEvent = cms.Sequence(makeTtSemiLepEventTask)
0020 
0021 ################################################################################
0022 ## helper functions
0023 ## (examples of usage can be found in the ttSemiLepEvtBuilder_cfg.py)
0024 ################################################################################
0025 
0026 ## add hypotheses to the process
0027 def addTtSemiLepHypotheses(process,
0028                            names
0029                            ):
0030 
0031     ## edit list of input hypotheses for the TtSemiLepEventBuilder
0032     labels =  getattr(process.ttSemiLepEvent, "hypotheses")
0033     for obj in range(len(names)):
0034         ## create correct label from HypoClassKey string (stripping the leading "k")
0035         ## e.g. kKinFit -> ttSemiLepHypKinFit
0036         label = "ttSemiLepHyp" + names[obj][1:]
0037         ## add it to the list
0038         labels.append(label)
0039     process.ttSemiLepEvent.hypotheses = labels
0040 
0041     ### include hypotheses in the standard sequence
0042     #sequence = getattr(process, "makeTtSemiLepHypotheses")
0043     #for obj in range(len(names)):
0044         ### create correct label from HypoClassKey string (stripping the leading "k")
0045         ### e.g. kKinFit -> makeHypothesis_kinFit
0046         #if names[obj][1:4] == "MVA":
0047             #label = "makeHypothesis_" + names[obj][1:4].lower() + names[obj][4:]
0048         #else:
0049             #label = "makeHypothesis_" + names[obj][1:2].lower() + names[obj][2:]
0050         ### add it to the sequence
0051         #sequence += getattr(process, label)
0052 
0053 
0054 ## remove genMatch hypothesis from the process
0055 def removeTtSemiLepHypGenMatch(process):
0056     #process.makeTtSemiLepHypotheses.remove(process.makeHypothesis_genMatch)
0057     process.ttSemiLepEvent.hypotheses.remove("ttSemiLepHypGenMatch")
0058     process.ttSemiLepEvent.genEvent = ''
0059 
0060 
0061 ## set a specific attribute for all hypotheses to a given value
0062 ## -> this works for "jets", "leps", "mets", "maxNJets"
0063 def setForAllTtSemiLepHypotheses(process, attribute, value):
0064     modules = ["findTtSemiLepJetCombGeom",
0065                "findTtSemiLepJetCombMaxSumPtWMass",
0066                "findTtSemiLepJetCombMVA",
0067                "findTtSemiLepJetCombWMassDeltaTopMass",
0068                "findTtSemiLepJetCombWMassMaxSumPt",
0069                "hitFitTtSemiLepEventHypothesis",
0070                "kinFitTtSemiLepEventHypothesis",
0071                "ttSemiLepJetPartonMatch",
0072                "ttSemiLepHypGenMatch",
0073                "ttSemiLepHypGeom",
0074                "ttSemiLepHypHitFit",
0075                "ttSemiLepHypKinFit",
0076                "ttSemiLepHypMaxSumPtWMass",
0077                "ttSemiLepHypMVADisc",
0078                "ttSemiLepHypWMassDeltaTopMass",
0079                "ttSemiLepHypWMassMaxSumPt"
0080                ]
0081     for obj in range(len(modules)):
0082         object = getattr(process, modules[obj])
0083         if hasattr(object, attribute):
0084             setattr(object, attribute, value)
0085 
0086 ## use electrons instead of muons for the hypotheses
0087 def useElectronsForAllTtSemiLepHypotheses(process, elecLabel = "selectedPatElectrons"):
0088     ## use correct KinFitter module
0089     import TopQuarkAnalysis.TopKinFitter.TtSemiLepKinFitProducer_Electrons_cfi
0090     process.kinFitTtSemiLepEventHypothesis = TopQuarkAnalysis.TopKinFitter.TtSemiLepKinFitProducer_Electrons_cfi.kinFitTtSemiLepEvent.clone()
0091     import TopQuarkAnalysis.TopHitFit.TtSemiLepHitFitProducer_Electrons_cfi
0092     process.hitFitTtSemiLepEventHypothesis = TopQuarkAnalysis.TopHitFit.TtSemiLepHitFitProducer_Electrons_cfi.hitFitTtSemiLepEvent.clone()
0093     ## replace lepton InputTags in all modules
0094     setForAllTtSemiLepHypotheses(process, "leps", elecLabel)