CMS 3D CMS Logo

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