6 from PhysicsTools.PatAlgos.tools.trigTools
import _addEventContent
7 from PhysicsTools.PatUtils.tools.jmeUncertaintyTools
import JetMEtUncertaintyTools
16 """ Shift energy of electrons, photons, muons, tau-jets and other jets
17 reconstructed in the event up/down,
18 in order to estimate effect of energy scale uncertainties on No-PU MET
20 _label =
'runNoPileUpMEtUncertainties'
21 _defaultParameters = dicttypes.SortedKeysDict()
23 JetMEtUncertaintyTools.__init__(self)
25 "Flag to enable/disable usage of charged hadron subtraction when reconstructing jets", Type=bool)
26 self.addParameter(self.
_defaultParameters,
'pfCandCollection', cms.InputTag(
'particleFlow'),
27 "Input PFCandidate collection", Type=cms.InputTag)
29 "Flag to enable/disable usage of 'unclustered energy' calibration", Type=bool)
31 "Parameter of No-PU MET algorithm ", Type=float)
36 shiftedParticleCollections, pfCandCollection, doApplyUnclEnergyCalibration,
37 sfNoPUjetOffsetEnCorr,
39 doApplyChargedHadronSubtraction,
41 jecUncertaintyFile, jecUncertaintyTag,
45 uncorrectedJetCollection =
None
46 smearedUncorrectedJetCollection =
None
47 correctedJetCollection =
None
48 smearedCorrectedJetCollection =
None
49 smearedPFCandidateCollection =
None
50 smearedPFCandToVertexAssociation =
None
55 pfNoPUMEtSequence =
None
56 patPFMetNoPileUp =
None
57 jetCorrLabelUpToL3 =
None
58 jetCorrLabelUpToL3Residual =
None
61 if doApplyChargedHadronSubtraction:
62 if not hasattr(process,
"pfNoPUchsMEt"):
63 process.load(
"RecoMET.METPUSubtraction.pfNoPUchsMEt_cff")
64 uncorrectedJetCollection =
'ak4PFchsJets'
65 smearedUncorrectedJetCollection =
"smearedUncorrectedJetsForPFNoPUchsMEt"
66 correctedJetCollection =
'calibratedAK4PFchsJetsForPFNoPUchsMEt'
67 smearedCorrectedJetCollection =
"smearedCorrectedJetsForPFNoPUchsMEt"
68 smearedPFCandidateCollection =
"smearedPFCandidatesForPFNoPUchsMEt"
69 smearedPFCandToVertexAssociation =
"smearedPFCandidateToVertexAssociationForPFNoPUchsMEt"
70 puJetId =
"puJetIdForPFNoPUchsMEt"
72 pfNoPUMEtData =
"pfNoPUchsMEtData"
73 pfNoPUMEt =
"pfNoPUchsMEt"
74 pfNoPUMEtSequence =
"pfNoPUchsMEtSequence"
75 patPFMetNoPileUp =
"patPFNoPUchsMEt"
76 jetCorrLabelUpToL3 =
"ak4PFchsL1FastL2L3Corrector"
77 jetCorrLabelUpToL3Residual =
"ak4PFchsL1FastL2L3ResidualCorrector"
80 if not hasattr(process,
"pfNoPUMEt"):
81 process.load(
"RecoMET.METPUSubtraction.pfNoPUMET_cff")
82 uncorrectedJetCollection =
'ak4PFJets'
83 smearedUncorrectedJetCollection =
"smearedUncorrectedJetsForPFNoPUMEt"
84 correctedJetCollection =
'calibratedAK4PFJetsForPFNoPUMEt'
85 smearedCorrectedJetCollection =
"smearedCorrectedJetsForPFNoPUMEt"
86 smearedPFCandidateCollection =
"smearedPFCandidatesForPFNoPUMEt"
87 smearedPFCandToVertexAssociation =
"smearedPFCandidateToVertexAssociationForPFNoPUMEt"
88 puJetId =
"puJetIdForPFNoPUMEt"
89 puJetIdTag =
"full53xId"
90 pfNoPUMEtData =
"pfNoPUMEtData"
91 pfNoPUMEt =
"pfNoPUMEt"
92 pfNoPUMEtSequence =
"pfNoPUMEtSequence"
93 patPFMetNoPileUp =
"patPFNoPUMEt"
94 jetCorrLabelUpToL3 =
"ak4PFL1FastL2L3Corrector"
95 jetCorrLabelUpToL3Residual =
"ak4PFL1FastL2L3ResidualCorrector"
98 process.load(
"RecoMET.METPUSubtraction.pfNoPUMET_cff")
100 configtools.cloneProcessingSnippet(process, getattr(process, pfNoPUMEtSequence), postfix)
104 pfNoPUMEtModule = getattr(process, pfNoPUMEt + postfix)
105 pfNoPUMEtModule.sfNoPUjetOffsetEnCorr = cms.double(sfNoPUjetOffsetEnCorr)
107 uncalibratedPFCandCollection = pfCandCollection.moduleLabel
109 process.load(
"RecoJets.Configuration.GenJetParticles_cff")
110 metUncertaintySequence += process.genParticlesForJetsNoNu
111 process.load(
"RecoJets.Configuration.RecoGenJets_cff")
112 metUncertaintySequence += process.ak4GenJetsNoNu
113 setattr(process, smearedUncorrectedJetCollection + postfix, cms.EDProducer(
"SmearedPFJetProducer",
114 src = cms.InputTag(uncorrectedJetCollection),
115 jetCorrLabel = cms.InputTag(jetCorrLabelUpToL3.value()),
116 dRmaxGenJetMatch = cms.string(
'min(0.5, 0.1 + 0.3*exp(-0.05*(genJetPt - 10.)))'),
117 sigmaMaxGenJetMatch = cms.double(3.),
118 inputFileName = cms.FileInPath(
'PhysicsTools/PatUtils/data/pfJetResolutionMCtoDataCorrLUT.root'),
119 lutName = cms.string(
'pfJetResolutionMCtoDataCorrLUT'),
120 jetResolutions = jetResolutions.METSignificance_params,
121 skipRawJetPtThreshold = cms.double(10.),
122 skipCorrJetPtThreshold = cms.double(1.e-2),
123 srcGenJets = cms.InputTag(
'ak4GenJetsNoNu'),
126 metUncertaintySequence += getattr(process, smearedUncorrectedJetCollection + postfix)
127 getattr(process, correctedJetCollection + postfix).src = cms.InputTag(smearedUncorrectedJetCollection + postfix)
128 setattr(process, smearedPFCandidateCollection + postfix, cms.EDProducer(
"SmearedPFCandidateProducerForPFNoPUMEt",
129 srcPFCandidates = pfCandCollection,
130 srcJets = cms.InputTag(uncorrectedJetCollection),
131 jetCorrLabel = cms.InputTag(jetCorrLabelUpToL3.value()),
132 dRmaxGenJetMatch = cms.string(
'min(0.5, 0.1 + 0.3*exp(-0.05*(genJetPt - 10.)))'),
133 sigmaMaxGenJetMatch = cms.double(3.),
134 inputFileName = cms.FileInPath(
'PhysicsTools/PatUtils/data/pfJetResolutionMCtoDataCorrLUT.root'),
135 lutName = cms.string(
'pfJetResolutionMCtoDataCorrLUT'),
136 jetResolutions = jetResolutions.METSignificance_params,
137 skipRawJetPtThreshold = cms.double(10.),
138 skipCorrJetPtThreshold = cms.double(1.e-2),
139 srcGenJets = cms.InputTag(
'ak4GenJetsNoNu'),
142 metUncertaintySequence += getattr(process, smearedPFCandidateCollection + postfix)
143 uncalibratedPFCandCollection = smearedPFCandidateCollection + postfix
144 setattr(process, smearedPFCandToVertexAssociation + postfix, getattr(process,
"pfCandidateToVertexAssociationForPFNoPUMEt" + postfix).
clone(
145 PFCandidateCollection = cms.InputTag(smearedPFCandidateCollection + postfix)
147 metUncertaintySequence += getattr(process, smearedPFCandToVertexAssociation + postfix)
148 modulePFNoPUMEtData = getattr(process, pfNoPUMEtData + postfix)
149 setattr(modulePFNoPUMEtData,
"srcPFCandidates", cms.InputTag(smearedPFCandidateCollection + postfix))
150 setattr(modulePFNoPUMEtData,
"srcPFCandToVertexAssociations", cms.InputTag(smearedPFCandToVertexAssociation + postfix))
152 calibratedPFCandCollection = uncalibratedPFCandCollection
153 calibratedPFCandToVertexAssociation =
"pfCandidateToVertexAssociationForPFNoPUMEt" + postfix
154 calibratedPFCandPFNoPUMEtData = pfNoPUMEtData + postfix
155 if doApplyUnclEnergyCalibration:
156 calibratedPFCandCollection =
"calibratedPFCandidatesForPFNoPUMEt" + postfix
157 setattr(process, calibratedPFCandCollection, cms.EDProducer(
"PFCandResidualCorrProducer",
158 src = cms.InputTag(uncalibratedPFCandCollection),
159 residualCorrLabel = cms.string(
""),
160 residualCorrEtaMax = cms.double(9.9),
161 extraCorrFactor = cms.double(1.),
162 isMC = cms.bool(
True),
163 srcGenPileUpSummary = cms.InputTag(
'addPileupInfo'),
164 residualCorrVsNumPileUp = cms.PSet(
166 offset = cms.FileInPath(
'JetMETCorrections/Type1MET/data/unclEnResidualCorr_Data_runs190456to208686_pfCands_offset.txt'),
167 slope = cms.FileInPath(
'JetMETCorrections/Type1MET/data/unclEnResidualCorr_Data_runs190456to208686_pfCands_slope.txt')
170 offset = cms.FileInPath(
'JetMETCorrections/Type1MET/data/unclEnResidualCorr_ZplusJets_madgraph_pfCands_offset.txt'),
171 slope = cms.FileInPath(
'JetMETCorrections/Type1MET/data/unclEnResidualCorr_ZplusJets_madgraph_pfCands_slope.txt')
174 verbosity = cms.int32(0)
176 metUncertaintySequence += getattr(process, calibratedPFCandCollection)
177 calibratedPFCandToVertexAssociation =
"calibratedPFCandidateToVertexAssociationForPFNoPUMEt" + postfix
178 setattr(process, calibratedPFCandToVertexAssociation, getattr(process,
"pfCandidateToVertexAssociationForPFNoPUMEt" + postfix).
clone(
179 PFCandidateCollection = cms.InputTag(calibratedPFCandCollection)
181 metUncertaintySequence += getattr(process, calibratedPFCandToVertexAssociation)
182 calibratedPFCandPFNoPUMEtData =
"calibratedPFCandPFNoPUMEtData" + postfix
183 setattr(process, calibratedPFCandPFNoPUMEtData, getattr(process,
"pfNoPUMEtData" + postfix).
clone(
184 srcPFCandidates = cms.InputTag(calibratedPFCandCollection),
185 srcPFCandToVertexAssociations = cms.InputTag(calibratedPFCandToVertexAssociation),
187 getattr(process, pfNoPUMEtSequence + postfix).
replace(
188 getattr(process,
"pfNoPUMEtData" + postfix),
189 getattr(process,
"pfNoPUMEtData" + postfix) + getattr(process, calibratedPFCandPFNoPUMEtData))
190 getattr(process,
"pfNoPUMEt" + postfix).srcMVAMEtData = cms.InputTag(calibratedPFCandPFNoPUMEtData)
191 getattr(process,
"pfMETcorrType0ForPFNoPUMEt" + postfix).srcPFCandidateToVertexAssociations = cms.InputTag(calibratedPFCandToVertexAssociation)
193 metUncertaintySequence += getattr(process, pfNoPUMEtSequence + postfix)
198 self._addPATMEtProducer(process, metUncertaintySequence,
'pfNoPUMEt' + postfix, patPFMetNoPileUp, collectionsToKeep, postfix)
202 variations = [
'Up',
'Down']
203 varDir= {
'Up':1.,
'Down':-1. }
208 for leptonCollection
in [ [
'Electron',
'En',
'electronCollection', 0.3 ],
209 [
'Photon',
'En',
'photonCollection', 0.3 ],
210 [
'Muon',
'En',
'muonCollection', 0.3 ],
211 [
'Tau',
'En',
'tauCollection', 0.3 ] ]:
212 if ( leptonCollection[2]
in shiftedParticleCollections )
and isValidInputTag(shiftedParticleCollections[leptonCollection[2]]):
213 pfCandCollectionLeptonShift = \
214 self._addPFCandidatesForPFMEtInput(
215 process, metUncertaintySequence,
216 shiftedParticleCollections[
'%s' % leptonCollection[2]], leptonCollection[0], leptonCollection[1],
217 shiftedParticleCollections[
'%s%sUp' % (leptonCollection[2], leptonCollection[1])], shiftedParticleCollections[
'%s%sDown' % (leptonCollection[2], leptonCollection[1])],
219 cms.InputTag(calibratedPFCandCollection),
"ForPFNoPU%sMEt%s" % (chsLabel, postfix))
222 for var
in variations:
224 modulePFCandidateToVertexAssociationShift = process.pfCandidateToVertexAssociation.clone(
225 PFCandidateCollection = cms.InputTag(pfCandCollectionLeptonShift[var])
227 modulePFCandidateToVertexAssociationShiftName =
"pfCandidateToVertexAssociation%s%s%sForPileUpPF%sMEt%s" % (leptonCollection[0], leptonCollection[1], var, chsLabel, postfix)
228 setattr(process, modulePFCandidateToVertexAssociationShiftName, modulePFCandidateToVertexAssociationShift)
229 metUncertaintySequence += modulePFCandidateToVertexAssociationShift
230 uncorrectedJetsShiftName =
"pfJets%s%s%sForPFNoPU%sMEt%s" % (leptonCollection[0], leptonCollection[1], var, chsLabel, postfix)
231 uncorrectedJetsShift = cms.EDProducer(
"ShiftedPFJetProducerByMatchedObject",
232 srcJets = cms.InputTag(uncorrectedJetCollection),
233 srcUnshiftedObjects = cms.InputTag(shiftedParticleCollections[ leptonCollection[2] ]),
234 srcShiftedObjects = cms.InputTag(shiftedParticleCollections[
'%s%sUp' % (leptonCollection[2], leptonCollection[1])]),
235 dRmatch_Jet = cms.double(leptonCollection[3])
237 setattr(process, uncorrectedJetsShiftName, uncorrectedJetsShift)
238 metUncertaintySequence += uncorrectedJetsShift
239 correctedJetsShift =
"correctedJets%s%s%sForPFNoPU%sMEt%s" % (leptonCollection[0], leptonCollection[1], var, chsLabel, postfix)
240 setattr(process, correctedJetsShift, getattr(process, correctedJetCollection + postfix).
clone(
241 src = cms.InputTag(uncorrectedJetsShiftName)
243 metUncertaintySequence += getattr(process, correctedJetsShift)
245 puJetIdShift =
"puJetId%s%s%sForPFNoPU%sMEt%s" % (leptonCollection[0], leptonCollection[1], var, chsLabel, postfix)
246 setattr(process, puJetIdShift, getattr(process, puJetId).
clone(
247 jets = cms.InputTag(correctedJetsShift)
249 metUncertaintySequence += getattr(process, puJetIdShift)
250 moduleMEtDataLeptonShift = getattr(process, calibratedPFCandPFNoPUMEtData).
clone(
251 srcPFCandidates = cms.InputTag(pfCandCollectionLeptonShift[var]),
252 srcPFCandToVertexAssociations = cms.InputTag(modulePFCandidateToVertexAssociationShiftName),
253 srcJets = cms.InputTag(correctedJetsShift),
254 srcJetIds = cms.InputTag(puJetIdShift, puJetIdTag)
256 moduleMEtDataLeptonShiftName =
"%s%s%s%s%s" % (pfNoPUMEtData, leptonCollection[0], leptonCollection[1], var, postfix)
257 setattr(process, moduleMEtDataLeptonShiftName, moduleMEtDataLeptonShift)
258 metUncertaintySequence += moduleMEtDataLeptonShift
259 moduleMEtLeptonShift = getattr(process, pfNoPUMEt + postfix).
clone(
260 srcMVAMEtDataLeptonMatch = cms.InputTag(moduleMEtDataLeptonShiftName),
261 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(
262 shiftedParticleCollections, leptonCollection[2],
'%s%s%s' % (leptonCollection[2], leptonCollection[1], var), postfix = postfix))
264 moduleMEtLeptonShiftName =
"%s%s%s%s%s" % (pfNoPUMEt, leptonCollection[0], leptonCollection[1], var, postfix)
265 setattr(process, moduleMEtLeptonShiftName, moduleMEtLeptonShift)
266 metUncertaintySequence += moduleMEtLeptonShift
267 self._addPATMEtProducer(process, metUncertaintySequence,
268 moduleMEtLeptonShiftName,
'%s%s%s%s' % (patPFMetNoPileUp, leptonCollection[0], leptonCollection[1], var),
269 collectionsToKeep, postfix)
274 for var
in variations:
275 uncorrectedJetsEnShift =
None
276 correctedJetsEnShift =
None
277 if doApplyChargedHadronSubtraction:
278 uncorrectedJetsEnShift =
"uncorrectedJetsEn%sForPFNoPUchsMEt%s" % (var, postfix)
279 correctedJetsEnShift =
"correctedJetsEn%sForPFNoPUchsMEt%s" % (var, postfix)
281 uncorrectedJetsEnShift =
"uncorrectedJetsEn%sForPFNoPUMEt%s" % (var, postfix)
282 correctedJetsEnShift =
"correctedJetsEn%sForPFNoPUMEt%s" % (var, postfix)
284 setattr(process, uncorrectedJetsEnShift, cms.EDProducer(
"ShiftedPFJetProducer",
285 src = cms.InputTag(uncorrectedJetCollection),
286 jetCorrInputFileName = cms.FileInPath(jecUncertaintyFile),
287 jetCorrUncertaintyTag = cms.string(jecUncertaintyTag),
288 addResidualJES = cms.bool(
True),
289 jetCorrLabelUpToL3 = cms.InputTag(jetCorrLabelUpToL3.value()),
290 jetCorrLabelUpToL3Res = cms.InputTag(jetCorrLabelUpToL3Residual.value()),
291 shiftBy = cms.double( varDir[var] *varyByNsigmas),
294 metUncertaintySequence += getattr(process, uncorrectedJetsEnShift)
295 setattr(process, correctedJetsEnShift, getattr(process, uncorrectedJetsEnShift).
clone(
296 src = cms.InputTag(correctedJetCollection + postfix),
297 addResidualJES = cms.bool(
False)
299 metUncertaintySequence += getattr(process, correctedJetsEnShift)
300 puJetIdJetEnShift =
"%sJetEn%s%s" % (puJetId, var, postfix)
301 setattr(process, puJetIdJetEnShift, getattr(process, puJetId + postfix).
clone(
302 jets = cms.InputTag(correctedJetsEnShift)
304 metUncertaintySequence += getattr(process, puJetIdJetEnShift)
305 pfNoPUMEtDataJetEnShift =
"%sJetEn%s%s" % (pfNoPUMEtData, var, postfix)
306 setattr(process, pfNoPUMEtDataJetEnShift, getattr(process, calibratedPFCandPFNoPUMEtData).
clone(
307 srcJets = cms.InputTag(correctedJetsEnShift),
308 srcJetIds = cms.InputTag(puJetIdJetEnShift, puJetIdTag)
310 metUncertaintySequence += getattr(process, pfNoPUMEtDataJetEnShift)
311 pfNoPUMEtJetEnShift =
"%sJetEn%s%s" % (pfNoPUMEt, var, postfix)
312 setattr(process, pfNoPUMEtJetEnShift, getattr(process, pfNoPUMEt + postfix).
clone(
313 srcMVAMEtData = cms.InputTag(pfNoPUMEtDataJetEnShift),
314 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix = postfix))
316 metUncertaintySequence += getattr(process, pfNoPUMEtJetEnShift)
317 self._addPATMEtProducer(process, metUncertaintySequence,
318 pfNoPUMEtJetEnShift,
"%sJetEn%s" % (patPFMetNoPileUp, var), collectionsToKeep, postfix)
321 if hasattr(process, smearedUncorrectedJetCollection + postfix):
323 for var
in variations:
325 smearedUncorrectedJetsResShift =
None
326 calibratedJetsResShift =
None
327 smearedPFCandidatesJetResShift =
None
328 smearedPFCandToVertexAssociationJetResShift =
None
329 if doApplyChargedHadronSubtraction:
330 smearedUncorrectedJetsResShift =
"smearedUncorrectedJetsRes%sForPFNoPUchsMEt%s" % (var, postfix)
331 smearedPFCandidatesJetResShift =
"smearedPFCandidatesJetRes%sForPFNoPUchsMEt%s" % (var, postfix)
332 smearedPFCandToVertexAssociationJetResShift =
"smearedPFCandidateToVertexAssociationJetRes%sForPFNoPUchsMEt%s" % (var, postfix)
334 smearedUncorrectedJetsResShift =
"smearedUncorrectedJetsRes%sForPFNoPUMEt%s" % (var, postfix)
335 smearedPFCandidatesJetResShift =
"smearedPFCandidatesJetRes%sForPFNoPUMEt%s" % (var, postfix)
336 smearedPFCandToVertexAssociationJetResShift =
"smearedPFCandidateToVertexAssociationJetRes%sForPFNoPUMEt%s" % (var, postfix)
337 setattr(process, smearedUncorrectedJetsResShift, getattr(process, smearedUncorrectedJetCollection + postfix).
clone(
338 shiftBy = cms.double(varDir[var]*varyByNsigmas)
340 metUncertaintySequence += getattr(process, smearedUncorrectedJetsResShift)
341 correctedJetsResShift = correctedJetCollection.replace(
"Jets",
"JetsRes"+var)
342 setattr(process, correctedJetsResShift + postfix, getattr(process, correctedJetCollection + postfix).
clone(
343 src = cms.InputTag(smearedUncorrectedJetsResShift)
345 metUncertaintySequence += getattr(process, correctedJetsResShift + postfix)
346 puJetIdJetResShift =
"%sJetRes%s%s" % (puJetId, var, postfix)
347 setattr(process, puJetIdJetResShift, getattr(process, puJetId + postfix).
clone(
348 jets = cms.InputTag(correctedJetsResShift + postfix)
350 metUncertaintySequence += getattr(process, puJetIdJetResShift)
351 setattr(process, smearedPFCandidatesJetResShift, getattr(process, smearedPFCandidateCollection + postfix).
clone(
352 shiftBy = cms.double(varDir[var]*varyByNsigmas)
354 metUncertaintySequence += getattr(process, smearedPFCandidatesJetResShift)
355 setattr(process, smearedPFCandToVertexAssociationJetResShift, getattr(process,
"pfCandidateToVertexAssociationForPFNoPUMEt" + postfix).
clone(
356 PFCandidateCollection = cms.InputTag(smearedPFCandidatesJetResShift)
358 metUncertaintySequence += getattr(process, smearedPFCandToVertexAssociationJetResShift)
359 pfNoPUMEtDataJetResShift =
"%sJetRes%s%s" % (pfNoPUMEtData, var, postfix)
360 setattr(process, pfNoPUMEtDataJetResShift, getattr(process, calibratedPFCandPFNoPUMEtData).
clone(
361 srcJets = cms.InputTag(correctedJetsResShift +postfix),
362 srcJetIds = cms.InputTag(puJetIdJetResShift, puJetIdTag),
363 srcPFCandidates = cms.InputTag(smearedPFCandidatesJetResShift),
364 srcPFCandToVertexAssociations = cms.InputTag(smearedPFCandToVertexAssociationJetResShift)
366 metUncertaintySequence += getattr(process, pfNoPUMEtDataJetResShift)
367 pfNoPUMEtJetResShift =
"%sJetRes%s%s" % (pfNoPUMEt, var, postfix)
368 setattr(process, pfNoPUMEtJetResShift, getattr(process, pfNoPUMEt + postfix).
clone(
369 srcMVAMEtData = cms.InputTag(pfNoPUMEtDataJetResShift),
370 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix = postfix))
372 metUncertaintySequence += getattr(process, pfNoPUMEtJetResShift)
373 self._addPATMEtProducer(process, metUncertaintySequence,
374 pfNoPUMEtJetResShift,
"%sJetRes%s" % (patPFMetNoPileUp, var), collectionsToKeep, postfix)
378 pfCandsUnclusteredEnShift =
None
379 pfCandidateToVertexAssociationUnclusteredEnShift =
None
380 pfMETcorrType0UnclusteredEnShift =
None
381 if doApplyChargedHadronSubtraction:
382 pfCandsUnclusteredEnShift =
"pfCandsUnclusteredEn%sForPFNoPUchsMEt%s" % (var, postfix)
383 pfCandidateToVertexAssociationUnclusteredEnShift =
"pfCandidateToVertexAssociationUnclusteredEn%sForPFNoPUchsMEt%s" % (var, postfix)
384 pfMETcorrType0UnclusteredEnShift =
"pfMETcorrType0UnclusteredEn%sForPFNoPUchsMEt%s" % (var, postfix)
386 pfCandsUnclusteredEnShift =
"pfCandsUnclusteredEn%sForPFNoPUMEt%s" % (var, postfix)
387 pfCandidateToVertexAssociationUnclusteredEnShift =
"pfCandidateToVertexAssociationUnclusteredEn%sForPFNoPUMEt%s" % (var, postfix)
388 pfMETcorrType0UnclusteredEnShift =
"pfMETcorrType0UnclusteredEn%sForPFNoPUMEt%s" % (var, postfix)
389 setattr(process, pfCandsUnclusteredEnShift, cms.EDProducer(
"ShiftedPFCandidateProducerForPFNoPUMEt",
390 srcPFCandidates = cms.InputTag(calibratedPFCandCollection),
391 srcJets = cms.InputTag(correctedJetCollection + postfix),
392 jetCorrInputFileName = cms.FileInPath(jecUncertaintyFile),
393 jetCorrUncertaintyTag = cms.string(jecUncertaintyTag),
394 minJetPt = cms.double(10.0),
395 shiftBy = cms.double(varDir[var]*varyByNsigmas),
396 unclEnUncertainty = cms.double(0.10)
398 metUncertaintySequence += getattr(process, pfCandsUnclusteredEnShift)
399 setattr(process, pfCandidateToVertexAssociationUnclusteredEnShift, process.pfCandidateToVertexAssociation.clone(
400 PFCandidateCollection = cms.InputTag(pfCandsUnclusteredEnShift)
402 metUncertaintySequence += getattr(process, pfCandidateToVertexAssociationUnclusteredEnShift)
403 setattr(process, pfMETcorrType0UnclusteredEnShift, getattr(process,
"pfMETcorrType0" + postfix).
clone(
404 srcPFCandidateToVertexAssociations = cms.InputTag(pfCandidateToVertexAssociationUnclusteredEnShift)
406 metUncertaintySequence += getattr(process, pfMETcorrType0UnclusteredEnShift)
407 pfNoPUMEtDataUnclusteredEnShift =
"%sUnclusteredEn%s%s" % (pfNoPUMEtData, var, postfix)
408 setattr(process, pfNoPUMEtDataUnclusteredEnShift, getattr(process, calibratedPFCandPFNoPUMEtData).
clone(
409 srcPFCandidates = cms.InputTag(pfCandsUnclusteredEnShift),
410 srcPFCandToVertexAssociations = cms.InputTag(pfCandidateToVertexAssociationUnclusteredEnShift)
412 metUncertaintySequence += getattr(process, pfNoPUMEtDataUnclusteredEnShift)
413 pfNoPUMEtUnclusteredEnShift =
"%sUnclusteredEn%s%s" % (pfNoPUMEt, var, postfix)
414 setattr(process, pfNoPUMEtUnclusteredEnShift, getattr(process, pfNoPUMEt + postfix).
clone(
415 srcMVAMEtData = cms.InputTag(pfNoPUMEtDataUnclusteredEnShift),
416 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix = postfix)),
417 srcType0Correction = cms.InputTag(pfMETcorrType0UnclusteredEnShift)
419 metUncertaintySequence += getattr(process, pfNoPUMEtUnclusteredEnShift)
420 self._addPATMEtProducer(process, metUncertaintySequence,
421 pfNoPUMEtUnclusteredEnShift,
'%sUnclusteredEn%s' % (patPFMetNoPileUp, var), collectionsToKeep, postfix)
424 electronCollection =
None,
425 photonCollection =
None,
426 muonCollection =
None,
427 tauCollection =
None,
428 jetCollection =
None,
429 dRjetCleaning =
None,
431 doApplyChargedHadronSubtraction =
None,
433 jetSmearFileName =
None,
434 jetSmearHistogram =
None,
435 pfCandCollection =
None,
436 doApplyUnclEnergyCalibration =
None,
437 sfNoPUjetOffsetEnCorr =
None,
438 jetCorrPayloadName =
None,
439 jetCorrLabelUpToL3 =
None,
440 jetCorrLabelUpToL3Res =
None,
441 jecUncertaintyFile =
None,
442 jecUncertaintyTag =
None,
443 varyByNsigmas =
None,
444 addToPatDefaultSequence =
None,
447 JetMEtUncertaintyTools.__call__(
449 electronCollection = electronCollection,
450 photonCollection = photonCollection,
451 muonCollection = muonCollection,
452 tauCollection = tauCollection,
453 jetCollection = jetCollection,
454 jetCorrLabel = jetCorrLabel,
455 doSmearJets = doSmearJets,
456 jetSmearFileName = jetSmearFileName,
457 jetSmearHistogram = jetSmearHistogram,
458 jetCorrPayloadName = jetCorrPayloadName,
459 jetCorrLabelUpToL3 = jetCorrLabelUpToL3,
460 jetCorrLabelUpToL3Res = jetCorrLabelUpToL3Res,
461 jecUncertaintyFile = jecUncertaintyFile,
462 jecUncertaintyTag = jecUncertaintyTag,
463 varyByNsigmas = varyByNsigmas,
464 addToPatDefaultSequence = addToPatDefaultSequence,
465 outputModule = outputModule,
467 if doApplyChargedHadronSubtraction
is None:
468 doApplyChargedHadronSubtraction = self.
_defaultParameters[
'doApplyChargedHadronSubtraction'].value
469 pfCandCollection = self._initializeInputTag(pfCandCollection,
'pfCandCollection')
470 if doApplyUnclEnergyCalibration
is None:
471 doApplyUnclEnergyCalibration = self.
_defaultParameters[
'doApplyUnclEnergyCalibration'].value
472 if sfNoPUjetOffsetEnCorr
is None:
475 self.setParameter(
'doApplyChargedHadronSubtraction', doApplyChargedHadronSubtraction)
476 self.setParameter(
'pfCandCollection', pfCandCollection)
477 self.setParameter(
'doApplyUnclEnergyCalibration', doApplyUnclEnergyCalibration)
478 self.setParameter(
'sfNoPUjetOffsetEnCorr', sfNoPUjetOffsetEnCorr)
483 electronCollection = self._parameters[
'electronCollection'].value
484 photonCollection = self._parameters[
'photonCollection'].value
485 muonCollection = self._parameters[
'muonCollection'].value
486 tauCollection = self._parameters[
'tauCollection'].value
487 jetCollection = self._parameters[
'jetCollection'].value
488 jetCorrLabel = self._parameters[
'jetCorrLabel'].value
489 doApplyChargedHadronSubtraction = self._parameters[
'doApplyChargedHadronSubtraction'].value
491 if doApplyChargedHadronSubtraction:
495 doSmearJets = self._parameters[
'doSmearJets'].value
496 jetSmearFileName = self._parameters[
'jetSmearFileName'].value
497 jetSmearHistogram = self._parameters[
'jetSmearHistogram'].value
498 pfCandCollection = self._parameters[
'pfCandCollection'].value
499 doApplyUnclEnergyCalibration = self._parameters[
'doApplyUnclEnergyCalibration'].value
500 sfNoPUjetOffsetEnCorr = self._parameters[
'sfNoPUjetOffsetEnCorr'].value
501 jetCorrPayloadName = self._parameters[
'jetCorrPayloadName'].value
502 jetCorrLabelUpToL3 = self._parameters[
'jetCorrLabelUpToL3'].value
503 jetCorrLabelUpToL3Res = self._parameters[
'jetCorrLabelUpToL3Res'].value
504 jecUncertaintyFile = self._parameters[
'jecUncertaintyFile'].value
505 jecUncertaintyTag = self._parameters[
'jecUncertaintyTag'].value
506 varyByNsigmas = self._parameters[
'varyByNsigmas'].value
507 addToPatDefaultSequence = self._parameters[
'addToPatDefaultSequence'].value
508 outputModule = self._parameters[
'outputModule'].value
509 postfix = self._parameters[
'postfix'].value
511 if not hasattr(process,
"pf%sNoPUMEtUncertaintySequence%s" % (chsLabel, postfix)):
512 metUncertaintySequence = cms.Sequence()
513 setattr(process,
"pf%sNoPUMEtUncertaintySequence%s" % (chsLabel, postfix), metUncertaintySequence)
514 metUncertaintySequence = getattr(process,
"pf%sNoPUMEtUncertaintySequence%s" % (chsLabel, postfix))
516 collectionsToKeep = []
518 lastJetCollection = jetCollection.value()
524 lastJetCollection = \
525 addSmearedJets(process, lastJetCollection, [
"smeared", jetCollection.value(),
"ForPFNoPU%sMEt" % chsLabel ],
526 jetSmearFileName, jetSmearHistogram, jetResolutions, varyByNsigmas,
None,
527 sequence = metUncertaintySequence, postfix = postfix)
529 collectionsToKeep.append(lastJetCollection)
536 shiftedParticleSequence, shiftedParticleCollections, addCollectionsToKeep = \
537 self._addShiftedParticleCollections(process,
538 electronCollection.value(),
539 photonCollection.value(),
540 muonCollection.value(),
541 tauCollection.value(),
542 jetCollection.value(), lastJetCollection, lastJetCollection,
544 jetCorrLabelUpToL3, jetCorrLabelUpToL3Res,
545 jecUncertaintyFile, jecUncertaintyTag,
546 jetSmearFileName, jetSmearHistogram,
548 "ForPFNoPU%sMEt%s" % (chsLabel, postfix))
549 setattr(process,
"shiftedParticlesForPFNoPU%sMEtUncertainties%s" % (chsLabel, postfix), shiftedParticleSequence)
550 metUncertaintySequence += getattr(process,
"shiftedParticlesForPFNoPU%sMEtUncertainties%s" % (chsLabel, postfix))
551 collectionsToKeep.extend(addCollectionsToKeep)
558 shiftedParticleCollections, pfCandCollection, doApplyUnclEnergyCalibration,
559 sfNoPUjetOffsetEnCorr,
561 doApplyChargedHadronSubtraction,
563 jecUncertaintyFile, jecUncertaintyTag,
568 if addToPatDefaultSequence:
569 if not hasattr(process,
"patDefaultSequence"):
570 raise ValueError(
"PAT default sequence is not defined !!")
571 process.patDefaultSequence += metUncertaintySequence
575 if outputModule
is not None and hasattr(process, outputModule):
577 getattr(process, outputModule).outputCommands,
578 [
'keep *_%s_*_%s' % (collectionToKeep, process.name_())
for collectionToKeep
in collectionsToKeep ])
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)