1 |
dgele |
1.1 |
import FWCore.ParameterSet.Config as cms
|
2 |
|
|
|
3 |
|
|
from PhysicsTools.PatAlgos.tools.coreTools import *
|
4 |
|
|
from PhysicsTools.PatAlgos.tools.jetTools import *
|
5 |
|
|
from PhysicsTools.PatAlgos.tools.tauTools import *
|
6 |
|
|
|
7 |
|
|
def adaptPFMuons(process,module):
|
8 |
|
|
module.useParticleFlow = True
|
9 |
|
|
print "Temporarily switching off isolation & isoDeposits for PF Muons"
|
10 |
|
|
module.isolation = cms.PSet()
|
11 |
|
|
module.isoDeposits = cms.PSet()
|
12 |
|
|
pass
|
13 |
|
|
def adaptPFElectrons(process,module):
|
14 |
|
|
module.useParticleFlow = True
|
15 |
|
|
print "Temporarily switching off isolation & isoDeposits for PF Electrons"
|
16 |
|
|
module.isolation = cms.PSet()
|
17 |
|
|
module.isoDeposits = cms.PSet()
|
18 |
|
|
print "Temporarily switching off electron ID for PF Electrons"
|
19 |
|
|
module.isolation = cms.PSet()
|
20 |
|
|
module.addElectronID = False
|
21 |
|
|
if module.embedTrack.value():
|
22 |
|
|
module.embedTrack = False
|
23 |
|
|
print "Temporarily switching off electron track embedding"
|
24 |
|
|
if module.embedGsfTrack.value():
|
25 |
|
|
module.embedGsfTrack = False
|
26 |
|
|
print "Temporarily switching off electron gsf track embedding"
|
27 |
|
|
if module.embedSuperCluster.value():
|
28 |
|
|
module.embedSuperCluster = False
|
29 |
|
|
print "Temporarily switching off electron supercluster embedding"
|
30 |
|
|
def adaptPFPhotons(process,module):
|
31 |
|
|
raise RuntimeError, "Photons are not supported yet"
|
32 |
|
|
def adaptPFJets(process,module):
|
33 |
|
|
module.embedCaloTowers = False
|
34 |
|
|
|
35 |
|
|
def addPFCandidates(process,src,patLabel='PFParticles',cut=""):
|
36 |
|
|
from PhysicsTools.PatAlgos.producersLayer1.pfParticleProducer_cfi import allLayer1PFParticles
|
37 |
|
|
# make modules
|
38 |
|
|
producer = allLayer1PFParticles.clone(pfCandidateSource = src)
|
39 |
|
|
filter = cms.EDFilter("PATPFParticleSelector",
|
40 |
|
|
src = cms.InputTag('allLayer1' + patLabel),
|
41 |
|
|
cut = cms.string(cut))
|
42 |
|
|
counter = cms.EDFilter("PATCandViewCountFilter",
|
43 |
|
|
minNumber = cms.uint32(0),
|
44 |
|
|
maxNumber = cms.uint32(999999),
|
45 |
|
|
src = cms.InputTag('selectedLayer1' + patLabel))
|
46 |
|
|
# add modules to process
|
47 |
|
|
setattr(process, 'allLayer1' + patLabel, producer)
|
48 |
|
|
setattr(process, 'selectedLayer1' + patLabel, filter)
|
49 |
|
|
setattr(process, 'countLayer1' + patLabel, counter)
|
50 |
|
|
# insert into sequence
|
51 |
|
|
process.allLayer1Objects.replace(process.allLayer1Summary, producer + process.allLayer1Summary)
|
52 |
|
|
process.selectedLayer1Objects.replace(process.selectedLayer1Summary, filter + process.selectedLayer1Summary)
|
53 |
|
|
process.countLayer1Objects += counter
|
54 |
|
|
# summary tables
|
55 |
|
|
process.aodSummary.candidates.append(src)
|
56 |
|
|
process.allLayer1Summary.candidates.append(cms.InputTag('allLayer1' + patLabel))
|
57 |
|
|
process.selectedLayer1Summary.candidates.append(cms.InputTag('selectedLayer1' + patLabel))
|
58 |
|
|
|
59 |
|
|
def switchToPFMET(process,input=cms.InputTag('pfMET')):
|
60 |
|
|
oldMETSource = process.layer1METs.metSource
|
61 |
|
|
switchMCAndTriggerMatch(process,oldMETSource,input)
|
62 |
|
|
process.layer1METs.metSource = input
|
63 |
|
|
process.layer1METs.addMuonCorrections = False
|
64 |
|
|
#process.patJetMETCorrections.remove(process.patMETCorrections)
|
65 |
|
|
process.patAODExtraReco.remove(process.patMETCorrections)
|
66 |
|
|
|
67 |
|
|
def usePF2PAT(process,runPF2PAT=True):
|
68 |
|
|
"""Switch PAT to use PF2PAT instead of AOD sources. if 'runPF2PAT' is true, we'll also add PF2PAT in front of the PAT sequence"""
|
69 |
|
|
# -------- CORE ---------------
|
70 |
|
|
if runPF2PAT:
|
71 |
|
|
process.load("PhysicsTools.PFCandProducer.PF2PAT_cff")
|
72 |
|
|
process.patAODCoreReco += process.PF2PAT
|
73 |
|
|
# note: I can't just replace it, because other people could have added stuff here (e.g. btagging)
|
74 |
|
|
removeCleaning(process)
|
75 |
|
|
process.aodSummary.candidates = cms.VInputTag();
|
76 |
|
|
|
77 |
|
|
# -------- OBJECTS ------------
|
78 |
|
|
# Muons
|
79 |
|
|
process.allLayer1Muons.pfMuonSource = cms.InputTag("pfMuons")
|
80 |
|
|
adaptPFMuons(process,process.allLayer1Muons)
|
81 |
|
|
switchMCAndTriggerMatch(process,process.allLayer1Muons.muonSource,process.allLayer1Muons.pfMuonSource)
|
82 |
|
|
process.aodSummary.candidates.append(process.allLayer1Muons.pfMuonSource)
|
83 |
|
|
|
84 |
|
|
# Electrons
|
85 |
|
|
# process.allLayer1Electrons.pfElectronSource = cms.InputTag("pfElectrons")
|
86 |
|
|
# adaptPFElectrons(process,process.allLayer1Electrons)
|
87 |
|
|
# switchMCAndTriggerMatch(process,process.allLayer1Electrons.electronSource,process.allLayer1Electrons.pfElectronSource)
|
88 |
|
|
# process.aodSummary.candidates.append(process.allLayer1Electrons.pfElectronSource)
|
89 |
|
|
# process.patAODCoreReco.remove(process.electronsNoDuplicates)
|
90 |
|
|
# process.patAODExtraReco.remove(process.patElectronId)
|
91 |
|
|
# process.patAODExtraReco.remove(process.patElectronIsolation)
|
92 |
|
|
print "Temporarily switching off electrons completely"
|
93 |
|
|
removeSpecificPATObject(process,'Electrons')
|
94 |
|
|
process.patAODCoreReco.remove(process.electronsNoDuplicates)
|
95 |
|
|
process.patAODExtraReco.remove(process.patElectronId)
|
96 |
|
|
process.patAODExtraReco.remove(process.patElectronIsolation)
|
97 |
|
|
#process.countLayer1Leptons.countElectrons = False
|
98 |
|
|
|
99 |
|
|
# Photons
|
100 |
|
|
print "Temporarily switching off photons completely"
|
101 |
|
|
removeSpecificPATObject(process,'Photons')
|
102 |
|
|
process.patAODExtraReco.remove(process.patPhotonIsolation)
|
103 |
|
|
|
104 |
|
|
# Jets
|
105 |
|
|
switchJetCollection(process, cms.InputTag('pfTopProjection','PFJets'),
|
106 |
|
|
doJTA=True,
|
107 |
|
|
doBTagging=True,
|
108 |
|
|
jetCorrLabel=None, # You may want to apply jet energy corrections
|
109 |
|
|
doType1MET=False) # You don't want CaloMET with PFJets, do you?
|
110 |
|
|
adaptPFJets(process, process.allLayer1Jets)
|
111 |
|
|
process.aodSummary.candidates.append(process.allLayer1Jets.jetSource)
|
112 |
|
|
|
113 |
|
|
# Taus
|
114 |
|
|
#oldTaus = process.allLayer1Taus.tauSource
|
115 |
|
|
oldTaus = cms.InputTag("pfRecoTauProducer")
|
116 |
|
|
process.allLayer1Taus.tauSource = cms.InputTag("allLayer0Taus")
|
117 |
|
|
switchMCAndTriggerMatch(process, oldTaus, process.allLayer1Taus.tauSource)
|
118 |
|
|
redoPFTauDiscriminators(process, oldTaus, process.allLayer1Taus.tauSource)
|
119 |
|
|
process.aodSummary.candidates.append(process.allLayer1Taus.tauSource)
|
120 |
|
|
print "Set corret names of tau-IDs"
|
121 |
|
|
process.allLayer1Taus.tauIDSources = cms.PSet(
|
122 |
|
|
leadingTrackFinding = cms.InputTag("pfRecoTauDiscriminationByLeadingTrackFinding"),
|
123 |
|
|
leadingTrackPtCut = cms.InputTag("pfRecoTauDiscriminationByLeadingTrackPtCut"),
|
124 |
|
|
trackIsolation = cms.InputTag("pfRecoTauDiscriminationByTrackIsolation"),
|
125 |
|
|
ecalIsolation = cms.InputTag("pfRecoTauDiscriminationByECALIsolation"),
|
126 |
|
|
byIsolation = cms.InputTag("pfRecoTauDiscriminationByIsolation"),
|
127 |
|
|
byIsolationPi = cms.InputTag("pfRecoTauDiscriminationByIsolationUsingLeadingPion"),
|
128 |
|
|
leadingPiPtCut = cms.InputTag("pfRecoTauDiscriminationByLeadingPionPtCut"),
|
129 |
|
|
trackIsolationPi = cms.InputTag("pfRecoTauDiscriminationByTrackIsolationUsingLeadingPion"),
|
130 |
|
|
ecalIsolationPi = cms.InputTag("pfRecoTauDiscriminationByECALIsolationUsingLeadingPion"),
|
131 |
|
|
againstElectron = cms.InputTag("pfRecoTauDiscriminationAgainstElectron"),
|
132 |
|
|
againstMuon = cms.InputTag("pfRecoTauDiscriminationAgainstMuon")
|
133 |
|
|
)
|
134 |
|
|
process.allLayer1Taus.decayModeSrc = cms.InputTag("pfTauDecayMode")
|
135 |
|
|
print "Change src in calculation of pf-isodep for taus"
|
136 |
|
|
#pfNoPileUpColl = cms.InputTag("pfNoPileUp","PFCandidates")
|
137 |
|
|
process.tauIsoDepositPFCandidates.src = process.allLayer1Taus.tauSource
|
138 |
|
|
process.tauIsoDepositPFCandidates.ExtractorPSet.tauSource = process.allLayer1Taus.tauSource
|
139 |
|
|
#process.tauIsoDepositPFCandidates.ExtractorPSet.candidateSource = pfNoPileUpColl
|
140 |
|
|
process.tauIsoDepositPFChargedHadrons.src = process.allLayer1Taus.tauSource
|
141 |
|
|
process.tauIsoDepositPFChargedHadrons.ExtractorPSet.tauSource = process.allLayer1Taus.tauSource
|
142 |
|
|
#process.pfAllChargedHadrons.src = pfNoPileUpColl
|
143 |
|
|
process.tauIsoDepositPFNeutralHadrons.src = process.allLayer1Taus.tauSource
|
144 |
|
|
process.tauIsoDepositPFNeutralHadrons.ExtractorPSet.tauSource = process.allLayer1Taus.tauSource
|
145 |
|
|
#process.pfAllNeutralHadrons.src = pfNoPileUpColl
|
146 |
|
|
process.tauIsoDepositPFGammas.src = process.allLayer1Taus.tauSource
|
147 |
|
|
process.tauIsoDepositPFGammas.ExtractorPSet.tauSource = process.allLayer1Taus.tauSource
|
148 |
|
|
#process.pfAllPhotons.src = pfNoPileUpColl
|
149 |
|
|
|
150 |
|
|
# MET
|
151 |
|
|
switchToPFMET(process, cms.InputTag('pfMET'))
|
152 |
|
|
|
153 |
|
|
# Unmasked PFCandidates
|
154 |
|
|
addPFCandidates(process,cms.InputTag('pfTopProjection','PFCandidates'),patLabel='PFParticles',cut="")
|