Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:15

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 process = cms.Process("TagProbe")
0004 
0005 ######### EXAMPLE CFG 
0006 ###  A simple test of runnning T&P on Zmumu to determine muon isolation and identification efficiencies
0007 ###  More a showcase of the tool than an actual physics example
0008 
0009 process.load('FWCore.MessageService.MessageLogger_cfi')
0010 process.options   = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) )
0011 process.MessageLogger.cerr.FwkReport.reportEvery = 100
0012 
0013 process.source = cms.Source("PoolSource", 
0014     fileNames = cms.untracked.vstring(
0015         '/store/relval/CMSSW_7_2_1/RelValZMM_13/GEN-SIM-RECO/PU50ns_PHYS14_25_V1_Phys14-v1/00000/287B9489-B85E-E411-95DF-02163E00EB3F.root'
0016     )
0017 )
0018 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(500) )    
0019 
0020 ## Tags. In a real analysis we should require that the tag muon fires the trigger, 
0021 ##       that's easy with PAT muons but not RECO/AOD ones, so we won't do it here
0022 ##       (the J/Psi example shows it)
0023 process.tagMuons = cms.EDFilter("MuonRefSelector",
0024     src = cms.InputTag("muons"),
0025     cut = cms.string("isGlobalMuon && pt > 20 && abs(eta) < 2"), 
0026 )
0027 ## Probes. Now we just use Tracker Muons as probes
0028 process.probeMuons = cms.EDFilter("MuonRefSelector",
0029     src = cms.InputTag("muons"),
0030     cut = cms.string("isTrackerMuon && pt > 10"), 
0031 )
0032 
0033 ## Here we show how to define passing probes with a selector
0034 ## although for this case a string cut in the TagProbeFitTreeProducer would be enough
0035 process.probesPassingCal = cms.EDFilter("MuonRefSelector",
0036     src = cms.InputTag("muons"),
0037     cut = cms.string(process.probeMuons.cut.value() + " && caloCompatibility > 0.6"),
0038 )
0039 
0040 ## Here we show how to use a module to compute an external variable
0041 process.drToNearestJet = cms.EDProducer("DeltaRNearestJetComputer",
0042     probes = cms.InputTag("muons"),
0043        # ^^--- NOTA BENE: if probes are defined by ref, as in this case, 
0044        #       this must be the full collection, not the subset by refs.
0045     objects = cms.InputTag("ak5CaloJets"),
0046     objectSelection = cms.InputTag("et > 20 && abs(eta) < 3 && n60 > 3 && (.05 < emEnergyFraction < .95)"),
0047 )
0048 
0049 ## Combine Tags and Probes into Z candidates, applying a mass cut
0050 process.tpPairs = cms.EDProducer("CandViewShallowCloneCombiner",
0051     decay = cms.string("tagMuons@+ probeMuons@-"), # charge coniugate states are implied
0052     cut   = cms.string("40 < mass < 200"),
0053 )
0054 
0055 ## Match muons to MC
0056 process.muMcMatch = cms.EDFilter("MCTruthDeltaRMatcherNew",
0057     pdgId = cms.vint32(13),
0058     src = cms.InputTag("muons"),
0059     distMin = cms.double(0.3),
0060     matched = cms.InputTag("genParticles")
0061 )
0062 
0063 ## Make the tree
0064 process.muonEffs = cms.EDAnalyzer("TagProbeFitTreeProducer",
0065     # pairs
0066     tagProbePairs = cms.InputTag("tpPairs"),
0067     arbitration   = cms.string("OneProbe"),
0068     # variables to use
0069     variables = cms.PSet(
0070         ## methods of reco::Candidate
0071         eta = cms.string("eta"),
0072         pt  = cms.string("pt"),
0073         ## a method of the reco::Muon object (thanks to the 3.4.X StringParser)
0074         nsegm = cms.string("numberOfMatches"), 
0075         ## this one is an external variable
0076         drj = cms.InputTag("drToNearestJet"),
0077     ),
0078     # choice of what defines a 'passing' probe
0079     flags = cms.PSet(
0080         ## one defined by an external collection of passing probes
0081         passingCal = cms.InputTag("probesPassingCal"), 
0082         ## two defined by simple string cuts
0083         passingGlb = cms.string("isGlobalMuon"),
0084         passingIso = cms.string("(isolationR03.hadEt+isolationR03.emEt+isolationR03.sumPt) < 0.1 * pt"),
0085     ),
0086     # mc-truth info
0087     isMC = cms.bool(True),
0088     motherPdgId = cms.vint32(22,23),
0089     makeMCUnbiasTree = cms.bool(True),
0090     checkMotherInUnbiasEff = cms.bool(True),
0091     tagMatches = cms.InputTag("muMcMatch"),
0092     probeMatches  = cms.InputTag("muMcMatch"),
0093     allProbes     = cms.InputTag("probeMuons"),
0094 )
0095 ##    ____       _   _     
0096 ##   |  _ \ __ _| |_| |__  
0097 ##   | |_) / _` | __| '_ \ 
0098 ##   |  __/ (_| | |_| | | |
0099 ##   |_|   \__,_|\__|_| |_|
0100 ##                         
0101 process.tagAndProbe = cms.Path( 
0102     (process.tagMuons + process.probeMuons) *   # 'A*B' means 'B needs output of A'; 
0103     (process.probesPassingCal +                 # 'A+B' means 'if you want you can re-arrange the order'
0104      process.drToNearestJet   +
0105      process.tpPairs +
0106      process.muMcMatch) *
0107     process.muonEffs
0108 )
0109 
0110 process.TFileService = cms.Service("TFileService", fileName = cms.string("testTagProbeFitTreeProducer_ZMuMu.root"))
0111 
0112 
0113 
0114