Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 process = cms.Process("Test")
0004 
0005 #------------------------------------------------------------------------------------------------------
0006 # To configure the Matching, we have to configure the PAT-Workflow starting from the patDefaultSequence:
0007 #------------------------------------------------------------------------------------------------------
0008 
0009 from PhysicsTools.PatAlgos.patTemplate_cfg import *
0010 
0011 ## prepare several clones of match associations for status 1, 3 and in flight muons (status -1)
0012 ## add inFlightMuons
0013 process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
0014 process.inFlightMuons = cms.EDProducer("PATGenCandsFromSimTracksProducer",
0015         src           = cms.InputTag("g4SimHits"),   ## use "fastSimProducer" for FastSim
0016         setStatus     = cms.int32(-1),
0017         particleTypes = cms.vstring("mu+"),          ## picks also mu-, of course
0018         filter        = cms.vstring("pt > 0.5"),     ## just for testing
0019         makeMotherLink = cms.bool(True),
0020         writeAncestors = cms.bool(True),             ## save also the intermediate GEANT ancestors of the muons
0021         genParticles   = cms.InputTag("genParticles"),
0022 )
0023 
0024 process.muMatch3 = process.muonMatch.clone(mcStatus = [3]) # hard scattering
0025 process.muMatch1 = process.muonMatch.clone(mcStatus = [1]) # stable
0026 process.muMatchF = process.muonMatch.clone(mcStatus = [-1], matched = cms.InputTag("inFlightMuons"))
0027 
0028 process.muMatch1.checkCharge = False
0029 process.muMatch3.checkCharge = False
0030 
0031 #process.muMatch3.resolveByMatchQuality = True
0032 #process.muMatch1.resolveByMatchQuality = True
0033 
0034 process.muMatch3.maxDeltaR = 0.05
0035 process.muMatch3.maxDPtRel = 0.1
0036 
0037 process.muMatch1.maxDeltaR = 0.05
0038 process.muMatch1.maxDPtRel = 0.1
0039 
0040 process.muMatchF.maxDeltaR = 0.3
0041 process.muMatchF.maxDPtRel = 0.2
0042 
0043 
0044 process.muonMatchByPt = cms.EDProducer("MCMatcherByPt", # cut on deltaR, deltaPt/Pt; pick best by deltaPt
0045     src     = cms.InputTag("muons"), # RECO objects to match
0046     matched = cms.InputTag("genParticles"),   # mc-truth particle collection
0047     mcPdgId     = cms.vint32(13), # one or more PDG ID (13 = muon); absolute values (see below)
0048     checkCharge = cms.bool(True), # True = require RECO and MC objects to have the same charge
0049     mcStatus = cms.vint32(1),     # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering)
0050     maxDeltaR = cms.double(0.5),  # Minimum deltaR for the match
0051     maxDPtRel = cms.double(0.5),  # Minimum deltaPt/Pt for the match
0052     resolveAmbiguities = cms.bool(True),     # Forbid two RECO objects to match to the same GEN object
0053     resolveByMatchQuality = cms.bool(False), # False = just match input in order; True = pick lowest deltaR pair first
0054 )
0055 
0056 
0057 ## add the new matches to the default sequence
0058 process.patDefaultSequence.replace(process.muonMatch,
0059                                    process.muMatch1 +
0060                                    process.muMatch3 +
0061                                    process.muMatchF
0062                                   #+ process.muonMatchByPt
0063 )
0064 
0065 process.patMuons.genParticleMatch = cms.VInputTag(
0066     cms.InputTag("muMatch3"),
0067     cms.InputTag("muMatch1"),
0068     cms.InputTag("muMatchF")
0069     #, cms.InputTag("muonMatchByPt")
0070 )
0071 
0072 
0073 #-----------------------------------------
0074 # As usual add those two usefull things:
0075 #----------------------------------------
0076 
0077 process.TFileService = cms.Service("TFileService",
0078   fileName = cms.string('analyzePatMCMatchingExtended.root')
0079 )
0080 
0081 process.MessageLogger = cms.Service("MessageLogger")
0082 
0083 
0084 #----------------------------------------------------------------------
0085 # Finally let's analyze the matching and run all that in correct order:
0086 #----------------------------------------------------------------------
0087 
0088 process.analyzePatMCMatching = cms.EDAnalyzer("PatMCMatchingExtended",
0089   muonSrc     = cms.untracked.InputTag("cleanPatMuons")
0090 )
0091 
0092 process.out.outputCommands = cms.untracked.vstring('keep *')
0093 process.outpath.remove(process.out)
0094 
0095 
0096 process.p = cms.Path(process.inFlightMuons + process.patDefaultSequence + process.analyzePatMCMatching)
0097 
0098 
0099 #----------------------------------------------------------------------
0100 # Change the input file to compare
0101 #----------------------------------------------------------------------
0102 process.maxEvents.input = -1
0103 
0104 ## Source
0105 from PhysicsTools.PatAlgos.tools.cmsswVersionTools import pickRelValInputFiles
0106 process.source = cms.Source("PoolSource",
0107     fileNames = cms.untracked.vstring(
0108      pickRelValInputFiles( cmsswVersion  = 'CMSSW_4_2_8'
0109                         #, relVal        =  'RelValZMM'
0110                         , relVal        =  'RelValJpsiMM'
0111                         , globalTag     = 'START42_V12'
0112                         , numberOfFiles = 1
0113                         )
0114     )
0115 )
0116 
0117 del(process.out)
0118 del(process.outpath)