CMS 3D CMS Logo

puppiForMET_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
4 from CommonTools.PileupAlgos.PhotonPuppi_cff import setupPuppiPhoton,setupPuppiPhotonMiniAOD
5 
6 from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask
7 
8 def makePuppies( process ):
9 
10  task = getPatAlgosToolsTask(process)
11 
12  process.load('CommonTools.PileupAlgos.Puppi_cff')
13  task.add(process.puppi)
14  process.pfNoLepPUPPI = cms.EDFilter("PdgIdCandViewSelector",
15  src = cms.InputTag("particleFlow"),
16  pdgId = cms.vint32( 1,2,22,111,130,310,2112,211,-211,321,-321,999211,2212,-2212 )
17  )
18  task.add(process.pfNoLepPUPPI)
19  process.pfLeptonsPUPPET = cms.EDFilter("PdgIdCandViewSelector",
20  src = cms.InputTag("particleFlow"),
21  pdgId = cms.vint32(-11,11,-13,13),
22  )
23  task.add(process.pfLeptonsPUPPET)
24 
25  addToProcessAndTask('puppiNoLep', process.puppi.clone(), process, task)
26  process.puppiNoLep.candName = cms.InputTag('pfNoLepPUPPI')
27  process.puppiMerged = cms.EDProducer("CandViewMerger",src = cms.VInputTag( 'puppiNoLep','pfLeptonsPUPPET'))
28  task.add(process.puppiMerged)
29  process.load('CommonTools.PileupAlgos.PhotonPuppi_cff')
30  task.add(process.puppiPhoton)
31  addToProcessAndTask('puppiForMET', process.puppiPhoton.clone(), process, task)
32  #Line below replaces reference linking wiht delta R matching because the puppi references after merging are not consistent with those of the original PF collection
33  process.puppiForMET.useRefs = False
34  #Line below points puppi MET to puppi no lepton which increases the response
35  process.puppiForMET.puppiCandName = 'puppiMerged'
36 
37 
38 def makePuppiesFromMiniAOD( process, createScheduledSequence=False ):
39  task = getPatAlgosToolsTask(process)
40  process.load('CommonTools.PileupAlgos.Puppi_cff')
41  task.add(process.puppi)
42  process.puppi.candName = cms.InputTag('packedPFCandidates')
43  process.puppi.clonePackedCands = cms.bool(True)
44  process.puppi.vertexName = cms.InputTag('offlineSlimmedPrimaryVertices')
45  process.puppi.useExistingWeights = cms.bool(True)
46  process.pfNoLepPUPPI = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string("abs(pdgId) != 13 && abs(pdgId) != 11 && abs(pdgId) != 15"))
47  task.add(process.pfNoLepPUPPI)
48  process.pfLeptonsPUPPET = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string("abs(pdgId) == 13 || abs(pdgId) == 11 || abs(pdgId) == 15"))
49  task.add(process.pfLeptonsPUPPET)
50  addToProcessAndTask('puppiNoLep', process.puppi.clone(), process, task)
51  process.puppiNoLep.candName = cms.InputTag('pfNoLepPUPPI')
52  process.puppiNoLep.useWeightsNoLep = cms.bool(True)
53  process.puppiNoLep.useExistingWeights = cms.bool(True)
54  process.puppiMerged = cms.EDProducer("CandViewMerger",src = cms.VInputTag( 'puppiNoLep','pfLeptonsPUPPET'))
55  task.add(process.puppiMerged)
56  process.load('CommonTools.PileupAlgos.PhotonPuppi_cff')
57  task.add(process.puppiPhoton)
58  addToProcessAndTask('puppiForMET', process.puppiPhoton.clone(), process, task)
59  process.puppiForMET.candName = cms.InputTag('packedPFCandidates')
60  process.puppiForMET.photonName = cms.InputTag('slimmedPhotons')
61  process.puppiForMET.runOnMiniAOD = cms.bool(True)
63  task.add(process.egmPhotonIDTask)
64  #Line below replaces reference linking wiht delta R matching because the puppi references after merging are not consistent with those of the original packed candidate collection
65  process.puppiForMET.useRefs = False
66  #Line below points puppi MET to puppi no lepton which increases the response
67  process.puppiForMET.puppiCandName = 'puppiMerged'
68 
69  #making a sequence for people running the MET tool in scheduled mode
70  if createScheduledSequence:
71  puppiMETSequence = cms.Sequence(process.puppi*process.pfLeptonsPUPPET*process.pfNoLepPUPPI*process.puppiNoLep*process.puppiMerged*process.puppiForMET)
72  setattr(process, "puppiMETSequence", puppiMETSequence)
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:27
def makePuppies(process)
def setupPuppiPhotonMiniAOD(process)
def getPatAlgosToolsTask(process)
Definition: helpers.py:12
def makePuppiesFromMiniAOD(process, createScheduledSequence=False)