6 from PhysicsTools.PatAlgos.tools.trigTools
import _addEventContent
14 """ Shift energy of electrons, photons, muons, tau-jets and other jets
15 reconstructed in the event up/down,
16 in order to estimate effect of energy scale uncertainties on MET
18 _label=
'runMEtUncertainties'
19 _defaultParameters=dicttypes.SortedKeysDict()
21 ConfigToolBase.__init__(self)
22 self.addParameter(self.
_defaultParameters,
'electronCollection', cms.InputTag(
'selectedPatElectrons'),
23 "Input electron collection", Type=cms.InputTag, acceptNoneValue=
True)
25 "Input photon collection", Type=cms.InputTag, acceptNoneValue=
True)
26 self.addParameter(self.
_defaultParameters,
'muonCollection', cms.InputTag(
'selectedPatMuons'),
27 "Input muon collection", Type=cms.InputTag, acceptNoneValue=
True)
28 self.addParameter(self.
_defaultParameters,
'tauCollection', cms.InputTag(
'selectedPatTaus'),
29 "Input tau collection", Type=cms.InputTag, acceptNoneValue=
True)
30 self.addParameter(self.
_defaultParameters,
'jetCollection', cms.InputTag(
'selectedPatJets'),
31 "Input jet collection", Type=cms.InputTag)
33 "Eta-phi distance for extra jet cleaning", Type=float)
35 "NOTE: use 'L3Absolute' for MC/'L2L3Residual' for Data", Type=str)
37 "Flag to enable/disable jet smearing to better match MC to Data", Type=bool)
39 "Flag to enable/disable sequence for Type 1 corrected PFMEt", Type=bool)
41 "Flag to enable/disable sequence for Type 1 + 2 corrected PFMEt", Type=bool)
43 "Flag to enable/disable sequence for MVA-based PFMEt", Type=bool)
45 "Flag to enable/disable sequence for no-PU PFMEt", Type=bool)
47 "Flag to enable/disable usage of Type-0 MET corrections", Type=bool)
49 "MET sys. shift correction parameters", Type=cms.PSet)
51 "Flag to enable/disable usage of MET sys. shift corrections", Type=bool)
52 self.addParameter(self.
_defaultParameters,
'jetSmearFileName',
'PhysicsTools/PatUtils/data/pfJetResolutionMCtoDataCorrLUT.root',
53 "Name of ROOT file containing histogram with jet smearing factors", Type=str)
54 self.addParameter(self.
_defaultParameters,
'jetSmearHistogram',
'pfJetResolutionMCtoDataCorrLUT',
55 "Name of histogram with jet smearing factors", Type=str)
56 self.addParameter(self.
_defaultParameters,
'pfCandCollection', cms.InputTag(
'particleFlow'),
57 "Input PFCandidate collection", Type=cms.InputTag)
59 "Use AK5PF for PFJets, AK5Calo for CaloJets", Type=str)
61 "Number of standard deviations by which energies are varied", Type=float)
63 "Flag to enable/disable that metUncertaintySequence is inserted into patDefaultSequence", Type=bool)
65 "Module label of PoolOutputModule (empty label indicates no PoolOutputModule is to be configured)", Type=str)
67 "Technical parameter to identify the resulting sequence and its modules (allows multiple calls in a job)", Type=str)
76 if not len(moduleName_parts) > 0:
77 raise ValueError(
"Empty list !!")
82 for part
in moduleName_parts:
83 if part
is None or part ==
"":
86 part = part.replace(
"selected",
"")
87 part = part.replace(
"clean",
"")
90 moduleName += part[0].lower() + part[1:]
93 if lastPart[-1].islower()
or lastPart[-1].isdigit():
94 moduleName += part[0].capitalize() + part[1:]
96 moduleName += part[0].lower() + part[1:]
100 setattr(process, moduleName, module)
106 def _addSmearedJets(self, process, jetCollection, smearedJetCollectionName_parts,
107 jetSmearFileName, jetSmearHistogram, varyByNsigmas,
108 shiftBy =
None, postfix =
""):
110 smearedJets = cms.EDProducer(
"SmearedPATJetProducer",
111 src = cms.InputTag(jetCollection),
112 dRmaxGenJetMatch = cms.string(
'TMath::Min(0.5, 0.1 + 0.3*TMath::Exp(-0.05*(genJetPt - 10.)))'),
113 sigmaMaxGenJetMatch = cms.double(5.),
114 inputFileName = cms.FileInPath(jetSmearFileName),
115 lutName = cms.string(jetSmearHistogram),
116 jetResolutions = jetResolutions.METSignificance_params,
128 skipJetSelection = cms.string(
129 'jecSetsAvailable & abs(energy - correctedP4("Uncorrected").energy) > (5.*min(energy, correctedP4("Uncorrected").energy))'
131 skipRawJetPtThreshold = cms.double(10.),
132 skipCorrJetPtThreshold = cms.double(1.e-2)
134 if shiftBy
is not None:
135 setattr(smearedJets,
"shiftBy", cms.double(shiftBy*varyByNsigmas))
136 smearedJetCollection = \
138 smearedJetCollectionName_parts,
139 getattr(process,
"metUncertaintySequence"+postfix), postfix)
141 return smearedJetCollection
144 particleCollection, particleType, shiftType, particleCollectionShiftUp, particleCollectionShiftDown,
145 metProducer, sequence, postfix):
149 moduleMETcorrShiftUp = cms.EDProducer(
"ShiftedParticleMETcorrInputProducer",
150 srcOriginal = cms.InputTag(particleCollection),
151 srcShifted = cms.InputTag(particleCollectionShiftUp)
153 moduleMETcorrShiftUpName =
"patPFMETcorr%s%sUp" % (particleType, shiftType)
154 moduleMETcorrShiftUpName += postfix
155 setattr(process, moduleMETcorrShiftUpName, moduleMETcorrShiftUp)
156 sequence += moduleMETcorrShiftUp
157 moduleMETcorrShiftDown = moduleMETcorrShiftUp.clone(
158 srcShifted = cms.InputTag(particleCollectionShiftDown)
160 moduleMETcorrShiftDownName =
"patPFMETcorr%s%sDown" % (particleType, shiftType)
161 moduleMETcorrShiftDownName += postfix
162 setattr(process, moduleMETcorrShiftDownName, moduleMETcorrShiftDown)
163 sequence += moduleMETcorrShiftDown
166 moduleMETshiftUp = metProducer.clone(
167 src = cms.InputTag(metProducer.label()),
168 srcType1Corrections = cms.VInputTag(
169 cms.InputTag(moduleMETcorrShiftUpName)
172 metProducerLabel = metProducer.label()
174 if metProducerLabel[-len(postfix):] == postfix:
175 metProducerLabel = metProducerLabel[0:-len(postfix)]
177 raise StandardError(
"Tried to remove postfix %s from label %s, but it wasn't there" % (postfix, metProducerLabel))
178 moduleMETshiftUpName =
"%s%s%sUp" % (metProducerLabel, particleType, shiftType)
179 moduleMETshiftUpName += postfix
180 setattr(process, moduleMETshiftUpName, moduleMETshiftUp)
181 sequence += moduleMETshiftUp
182 moduleMETshiftDown = moduleMETshiftUp.clone(
183 srcType1Corrections = cms.VInputTag(
184 cms.InputTag(moduleMETcorrShiftDownName)
187 moduleMETshiftDownName =
"%s%s%sDown" % (metProducerLabel, particleType, shiftType)
188 moduleMETshiftDownName += postfix
189 setattr(process, moduleMETshiftDownName, moduleMETshiftDown)
190 sequence += moduleMETshiftDown
192 metCollectionsUp_Down = [
193 moduleMETshiftUpName,
194 moduleMETshiftDownName
197 return metCollectionsUp_Down
203 elif type(input) == str:
204 retVal = cms.InputTag(input)
212 if isinstance(input, cms.InputTag):
213 input_str = input.value()
214 if input
is None or input_str ==
'""':
224 jetCollection, cleanedJetCollection, lastJetCollection,
225 jetCollectionResUp, jetCollectionResDown,
229 shiftedParticlesForMEtUncertainties = cms.Sequence()
230 setattr(process,
"shiftedParticlesForMEtUncertainties"+postfix, shiftedParticlesForMEtUncertainties)
232 shiftedParticleCollections = {}
233 shiftedParticleCollections[
'electronCollection'] = electronCollection
234 shiftedParticleCollections[
'photonCollection'] = photonCollection
235 shiftedParticleCollections[
'muonCollection'] = muonCollection
236 shiftedParticleCollections[
'tauCollection'] = tauCollection
237 shiftedParticleCollections[
'jetCollection'] = jetCollection
238 shiftedParticleCollections[
'cleanedJetCollection'] = cleanedJetCollection
239 shiftedParticleCollections[
'lastJetCollection'] = lastJetCollection
240 shiftedParticleCollections[
'jetCollectionResUp'] = jetCollectionResUp
241 shiftedParticleCollections[
'jetCollectionResDown'] = jetCollectionResDown
242 collectionsToKeep = []
251 jetsEnUpForRawMEt = cms.EDProducer(
"ShiftedPATJetProducer",
252 src = cms.InputTag(lastJetCollection),
255 jetCorrInputFileName = cms.FileInPath(
'PhysicsTools/PatUtils/data/Summer12_V2_DATA_AK5PF_UncertaintySources.txt'),
256 jetCorrUncertaintyTag = cms.string(
"SubTotalDataMC"),
257 addResidualJES = cms.bool(
True),
258 jetCorrLabelUpToL3 = cms.string(
"ak5PFL1FastL2L3"),
259 jetCorrLabelUpToL3Res = cms.string(
"ak5PFL1FastL2L3Residual"),
260 shiftBy = cms.double(+1.*varyByNsigmas)
262 jetCollectionEnUpForRawMEt = \
264 [
"shifted", jetCollection.value(),
"EnUpForRawMEt" ],
265 shiftedParticlesForMEtUncertainties, postfix)
266 shiftedParticleCollections[
'jetCollectionEnUpForRawMEt'] = jetCollectionEnUpForRawMEt
267 collectionsToKeep.append(jetCollectionEnUpForRawMEt)
268 jetsEnDownForRawMEt = jetsEnUpForRawMEt.clone(
269 shiftBy = cms.double(-1.*varyByNsigmas)
271 jetCollectionEnDownForRawMEt = \
273 [
"shifted", jetCollection.value(),
"EnDownForRawMEt" ],
274 shiftedParticlesForMEtUncertainties, postfix)
275 shiftedParticleCollections[
'jetCollectionEnDownForRawMEt'] = jetCollectionEnDownForRawMEt
276 collectionsToKeep.append(jetCollectionEnDownForRawMEt)
278 jetsEnUpForCorrMEt = jetsEnUpForRawMEt.clone(
279 addResidualJES = cms.bool(
False)
281 jetCollectionEnUpForCorrMEt = \
283 [
"shifted", jetCollection.value(),
"EnUpForCorrMEt" ],
284 shiftedParticlesForMEtUncertainties, postfix)
285 shiftedParticleCollections[
'jetCollectionEnUpForCorrMEt'] = jetCollectionEnUpForCorrMEt
286 collectionsToKeep.append(jetCollectionEnUpForCorrMEt)
287 jetsEnDownForCorrMEt = jetsEnUpForCorrMEt.clone(
288 shiftBy = cms.double(-1.*varyByNsigmas)
290 jetCollectionEnDownForCorrMEt = \
292 [
"shifted", jetCollection.value(),
"EnDownForCorrMEt" ],
293 shiftedParticlesForMEtUncertainties, postfix)
294 shiftedParticleCollections[
'jetCollectionEnDownForCorrMEt'] = jetCollectionEnDownForCorrMEt
295 collectionsToKeep.append(jetCollectionEnDownForCorrMEt)
301 electronCollectionEnUp =
None
302 electronCollectionEnDown =
None
304 electronsEnUp = cms.EDProducer(
"ShiftedPATElectronProducer",
305 src = electronCollection,
308 binSelection = cms.string(
'isEB'),
309 binUncertainty = cms.double(0.006)
312 binSelection = cms.string(
'!isEB'),
313 binUncertainty = cms.double(0.015)
316 shiftBy = cms.double(+1.*varyByNsigmas)
318 electronCollectionEnUp = \
320 [
"shifted", electronCollection.value(),
"EnUp" ],
321 shiftedParticlesForMEtUncertainties, postfix)
322 shiftedParticleCollections[
'electronCollectionEnUp'] = electronCollectionEnUp
323 collectionsToKeep.append(electronCollectionEnUp)
324 electronsEnDown = electronsEnUp.clone(
325 shiftBy = cms.double(-1.*varyByNsigmas)
327 electronCollectionEnDown = \
329 [
"shifted", electronCollection.value(),
"EnDown" ],
330 shiftedParticlesForMEtUncertainties, postfix)
331 shiftedParticleCollections[
'electronCollectionEnDown'] = electronCollectionEnDown
332 collectionsToKeep.append(electronCollectionEnDown)
338 photonCollectionEnUp =
None
339 photonCollectionEnDown =
None
341 photonsEnUp = cms.EDProducer(
"ShiftedPATPhotonProducer",
342 src = photonCollection,
345 binSelection = cms.string(
'isEB = true'),
346 binUncertainty = cms.double(0.01)
349 binSelection = cms.string(
'isEB = false'),
350 binUncertainty = cms.double(0.025)
353 shiftBy = cms.double(+1.*varyByNsigmas)
355 photonCollectionEnUp = \
357 [
"shifted", photonCollection.value(),
"EnUp" ],
358 shiftedParticlesForMEtUncertainties, postfix)
359 shiftedParticleCollections[
'photonCollectionEnUp'] = photonCollectionEnUp
360 collectionsToKeep.append(photonCollectionEnUp)
361 photonsEnDown = photonsEnUp.clone(
362 shiftBy = cms.double(-1.*varyByNsigmas)
364 photonCollectionEnDown = \
366 [
"shifted", photonCollection.value(),
"EnDown" ],
367 shiftedParticlesForMEtUncertainties, postfix)
368 shiftedParticleCollections[
'photonCollectionEnDown'] = photonCollectionEnDown
369 collectionsToKeep.append(photonCollectionEnDown)
375 muonCollectionEnUp =
None
376 muonCollectionEnDown =
None
378 muonsEnUp = cms.EDProducer(
"ShiftedPATMuonProducer",
379 src = muonCollection,
380 uncertainty = cms.double(0.002),
381 shiftBy = cms.double(+1.*varyByNsigmas)
383 muonCollectionEnUp = \
385 [
"shifted", muonCollection.value(),
"EnUp" ],
386 shiftedParticlesForMEtUncertainties, postfix)
387 shiftedParticleCollections[
'muonCollectionEnUp'] = muonCollectionEnUp
388 collectionsToKeep.append(muonCollectionEnUp)
389 muonsEnDown = muonsEnUp.clone(
390 shiftBy = cms.double(-1.*varyByNsigmas)
392 muonCollectionEnDown = \
394 [
"shifted", muonCollection.value(),
"EnDown" ],
395 shiftedParticlesForMEtUncertainties, postfix)
396 shiftedParticleCollections[
'muonCollectionEnDown'] = muonCollectionEnDown
397 collectionsToKeep.append(muonCollectionEnDown)
403 tauCollectionEnUp =
None
404 tauCollectionEnDown =
None
406 tausEnUp = cms.EDProducer(
"ShiftedPATTauProducer",
408 uncertainty = cms.double(0.03),
409 shiftBy = cms.double(+1.*varyByNsigmas)
411 tauCollectionEnUp = \
413 [
"shifted", tauCollection.value(),
"EnUp" ],
414 shiftedParticlesForMEtUncertainties, postfix)
415 shiftedParticleCollections[
'tauCollectionEnUp'] = tauCollectionEnUp
416 collectionsToKeep.append(tauCollectionEnUp)
417 tausEnDown = tausEnUp.clone(
418 shiftBy = cms.double(-1.*varyByNsigmas)
420 tauCollectionEnDown = \
422 [
"shifted", tauCollection.value(),
"EnDown" ],
423 shiftedParticlesForMEtUncertainties, postfix)
424 shiftedParticleCollections[
'tauCollectionEnDown'] = tauCollectionEnDown
425 collectionsToKeep.append(tauCollectionEnDown)
427 return ( shiftedParticleCollections, collectionsToKeep )
430 shiftedParticleCollections, pfCandCollection,
434 makeType1p2corrPFMEt,
436 sysShiftCorrParameter,
442 if not (makeType1corrPFMEt
or makeType1p2corrPFMEt):
445 if not hasattr(process,
'producePatPFMETCorrections'):
446 process.load(
"PhysicsTools.PatUtils.patPFMETCorrections_cff")
452 configtools.cloneProcessingSnippet(process, process.producePatPFMETCorrections,
"OriginalReserved")
454 if postfix ==
"OriginalReserved":
455 raise ValueError(
"Postfix label '%s' is reserved for internal usage !!" % postfix)
457 if hasattr(process,
"producePatPFMETCorrectionsOriginalReserved"):
458 configtools.cloneProcessingSnippet(process, process.producePatPFMETCorrectionsOriginalReserved, postfix, removePostfix=
"OriginalReserved")
460 configtools.cloneProcessingSnippet(process, process.producePatPFMETCorrections, postfix)
463 getattr(process,
"pfCandsNotInJet"+postfix).bottomCollection = pfCandCollection
464 getattr(process,
"selectedPatJetsForMETtype1p2Corr"+postfix).src = shiftedParticleCollections[
'lastJetCollection']
465 getattr(process,
"selectedPatJetsForMETtype2Corr"+postfix).src = shiftedParticleCollections[
'lastJetCollection']
468 if doApplySysShiftCorr:
469 if not hasattr(process,
'pfMEtSysShiftCorrSequence'):
470 process.load(
"JetMETCorrections.Type1MET.pfMETsysShiftCorrections_cfi")
472 configtools.cloneProcessingSnippet(process, process.pfMEtSysShiftCorrSequence, postfix)
474 getattr(process,
"pfMEtSysShiftCorr"+postfix).parameter = sysShiftCorrParameter
475 metUncertaintySequence += getattr(process,
"pfMEtSysShiftCorrSequence"+postfix)
477 metUncertaintySequence += getattr(process,
"producePatPFMETCorrections"+postfix)
479 patType1correctionsCentralValue = [ cms.InputTag(
'patPFJetMETtype1p2Corr'+postfix,
'type1') ]
481 patType1correctionsCentralValue.extend([ cms.InputTag(
'patPFMETtype0Corr'+postfix) ])
482 if doApplySysShiftCorr:
483 patType1correctionsCentralValue.extend([ cms.InputTag(
'pfMEtSysShiftCorr'+postfix) ])
484 getattr(process,
"patType1CorrectedPFMet"+postfix).srcType1Corrections = cms.VInputTag(patType1correctionsCentralValue)
485 getattr(process,
"patType1p2CorrectedPFMet"+postfix).srcType1Corrections = cms.VInputTag(patType1correctionsCentralValue)
487 collectionsToKeep.extend([
489 'patType1CorrectedPFMet'+postfix,
490 'patType1p2CorrectedPFMet'+postfix])
492 setattr(process,
"selectedPatJetsForMETtype1p2CorrEnUp"+postfix,
493 getattr(process, shiftedParticleCollections[
'jetCollectionEnUpForCorrMEt']).
clone(
494 src = cms.InputTag(
'selectedPatJetsForMETtype1p2Corr'+postfix)
496 metUncertaintySequence += getattr(process,
"selectedPatJetsForMETtype1p2CorrEnUp"+postfix)
497 setattr(process,
"selectedPatJetsForMETtype1p2CorrEnDown"+postfix,
498 getattr(process, shiftedParticleCollections[
'jetCollectionEnDownForCorrMEt']).
clone(
499 src = cms.InputTag(
'selectedPatJetsForMETtype1p2Corr'+postfix)
501 metUncertaintySequence += getattr(process,
"selectedPatJetsForMETtype1p2CorrEnDown"+postfix)
502 if makeType1p2corrPFMEt:
503 setattr(process,
"selectedPatJetsForMETtype2CorrEnUp"+postfix,
504 getattr(process, shiftedParticleCollections[
'jetCollectionEnUpForCorrMEt']).
clone(
505 src = cms.InputTag(
'selectedPatJetsForMETtype2Corr'+postfix)
507 metUncertaintySequence += getattr(process,
"selectedPatJetsForMETtype2CorrEnUp"+postfix)
508 setattr(process,
"selectedPatJetsForMETtype2CorrEnDown"+postfix,
509 getattr(process, shiftedParticleCollections[
'jetCollectionEnDownForCorrMEt']).
clone(
510 src = cms.InputTag(
'selectedPatJetsForMETtype2Corr'+postfix)
512 metUncertaintySequence += getattr(process,
"selectedPatJetsForMETtype2CorrEnDown"+postfix)
515 setattr(process,
"selectedPatJetsForMETtype1p2CorrResUp"+postfix,
516 getattr(process, shiftedParticleCollections[
'jetCollectionResUp']).
clone(
517 src = cms.InputTag(
'selectedPatJetsForMETtype1p2Corr'+postfix)
519 metUncertaintySequence += getattr(process,
"selectedPatJetsForMETtype1p2CorrResUp"+postfix)
520 setattr(process,
"selectedPatJetsForMETtype1p2CorrResDown"+postfix,
521 getattr(process, shiftedParticleCollections[
'jetCollectionResDown']).
clone(
522 src = cms.InputTag(
'selectedPatJetsForMETtype1p2Corr'+postfix)
524 metUncertaintySequence += getattr(process,
"selectedPatJetsForMETtype1p2CorrResDown"+postfix)
525 if makeType1p2corrPFMEt:
526 setattr(process,
"selectedPatJetsForMETtype2CorrResUp"+postfix,
527 getattr(process, shiftedParticleCollections[
'jetCollectionResUp']).
clone(
528 src = cms.InputTag(
'selectedPatJetsForMETtype2Corr'+postfix)
530 metUncertaintySequence += getattr(process,
"selectedPatJetsForMETtype2CorrResUp"+postfix)
531 setattr(process,
"selectedPatJetsForMETtype2CorrResDown"+postfix,
532 getattr(process, shiftedParticleCollections[
'jetCollectionResDown']).
clone(
533 src = cms.InputTag(
'selectedPatJetsForMETtype2Corr'+postfix)
535 metUncertaintySequence += getattr(process,
"selectedPatJetsForMETtype2CorrResDown"+postfix)
539 smearedPatPFMetSequence = cms.Sequence()
540 setattr(process,
"smearedPatPFMetSequence"+postfix, smearedPatPFMetSequence)
541 setattr(process,
"patPFMetForMEtUncertainty"+postfix, getattr(process,
"patPFMet"+postfix).
clone())
542 smearedPatPFMetSequence += getattr(process,
"patPFMetForMEtUncertainty"+postfix)
543 setattr(process,
"patPFMETcorrJetSmearing"+postfix, cms.EDProducer(
"ShiftedParticleMETcorrInputProducer",
544 srcOriginal = cms.InputTag(shiftedParticleCollections[
'cleanedJetCollection']),
545 srcShifted = cms.InputTag(shiftedParticleCollections[
'lastJetCollection'])
547 smearedPatPFMetSequence += getattr(process,
"patPFMETcorrJetSmearing"+postfix)
548 getattr(process,
"producePatPFMETCorrections"+postfix).
replace(getattr(process,
"patPFMet"+postfix), smearedPatPFMetSequence)
549 setattr(process,
"patPFMet"+postfix, getattr(process,
"patType1CorrectedPFMet"+postfix).
clone(
550 src = cms.InputTag(
'patPFMetForMEtUncertainty'+postfix),
551 srcType1Corrections = cms.VInputTag(
552 cms.InputTag(
'patPFMETcorrJetSmearing'+postfix)
555 smearedPatPFMetSequence += getattr(process,
"patPFMet"+postfix)
556 metUncertaintySequence += smearedPatPFMetSequence
559 metCollectionsUp_DownForRawMEt = \
561 process, shiftedParticleCollections[
'lastJetCollection'],
"Jet",
"En",
562 shiftedParticleCollections[
'jetCollectionEnUpForRawMEt'], shiftedParticleCollections[
'jetCollectionEnDownForRawMEt'],
563 getattr(process,
"patPFMet"+postfix), metUncertaintySequence, postfix)
564 collectionsToKeep.extend(metCollectionsUp_DownForRawMEt)
566 metCollectionsUp_DownForCorrMEt = \
568 process, shiftedParticleCollections[
'lastJetCollection'],
"Jet",
"En",
569 shiftedParticleCollections[
'jetCollectionEnUpForCorrMEt'], shiftedParticleCollections[
'jetCollectionEnDownForCorrMEt'],
570 getattr(process,
"patType1CorrectedPFMet"+postfix), metUncertaintySequence, postfix)
571 collectionsToKeep.extend(metCollectionsUp_DownForCorrMEt)
574 if makeType1p2corrPFMEt:
575 setattr(process,
"patPFJetMETtype1p2CorrEnUp"+postfix, getattr(process,
"patPFJetMETtype1p2Corr"+postfix).
clone(
576 src = cms.InputTag(getattr(process,
"selectedPatJetsForMETtype1p2CorrEnUp"+postfix).
label()),
577 jetCorrLabel = cms.string(jetCorrLabel)
579 metUncertaintySequence += getattr(process,
"patPFJetMETtype1p2CorrEnUp"+postfix)
580 setattr(process,
"patPFJetMETtype1p2CorrEnDown"+postfix, getattr(process,
"patPFJetMETtype1p2CorrEnUp"+postfix).
clone(
581 src = cms.InputTag(getattr(process,
"selectedPatJetsForMETtype1p2CorrEnDown"+postfix).
label())
583 metUncertaintySequence += getattr(process,
"patPFJetMETtype1p2CorrEnDown"+postfix)
584 setattr(process,
"patPFJetMETtype2CorrEnUp"+postfix, getattr(process,
"patPFJetMETtype2Corr"+postfix).
clone(
585 src = cms.InputTag(
'selectedPatJetsForMETtype2CorrEnUp'+postfix)
587 metUncertaintySequence += getattr(process,
"patPFJetMETtype2CorrEnUp"+postfix)
588 setattr(process,
"patPFJetMETtype2CorrEnDown"+postfix, getattr(process,
"patPFJetMETtype2Corr"+postfix).
clone(
589 src = cms.InputTag(
'selectedPatJetsForMETtype2CorrEnDown'+postfix)
591 metUncertaintySequence += getattr(process,
"patPFJetMETtype2CorrEnDown"+postfix)
593 patType1correctionsJetEnUp = [ cms.InputTag(
'patPFJetMETtype1p2CorrEnUp'+postfix,
'type1') ]
595 patType1correctionsJetEnUp.extend([ cms.InputTag(
'patPFMETtype0Corr'+postfix) ])
596 if doApplySysShiftCorr:
597 patType1correctionsJetEnUp.extend([ cms.InputTag(
'pfMEtSysShiftCorr'+postfix) ])
598 setattr(process,
"patType1p2CorrectedPFMetJetEnUp"+postfix, getattr(process,
"patType1p2CorrectedPFMet"+postfix).
clone(
599 srcType1Corrections = cms.VInputTag(patType1correctionsJetEnUp),
600 srcUnclEnergySums = cms.VInputTag(
601 cms.InputTag(
'patPFJetMETtype1p2CorrEnUp'+postfix,
'type2' ),
602 cms.InputTag(
'patPFJetMETtype2CorrEnUp'+postfix,
'type2' ),
603 cms.InputTag(
'patPFJetMETtype1p2CorrEnUp'+postfix,
'offset'),
604 cms.InputTag(
'pfCandMETcorr'+postfix)
607 metUncertaintySequence += getattr(process,
"patType1p2CorrectedPFMetJetEnUp"+postfix)
608 collectionsToKeep.append(
'patType1p2CorrectedPFMetJetEnUp'+postfix)
609 patType1correctionsJetEnDown = [ cms.InputTag(
'patPFJetMETtype1p2CorrEnDown'+postfix,
'type1') ]
611 patType1correctionsJetEnDown.extend([ cms.InputTag(
'patPFMETtype0Corr'+postfix) ])
612 if doApplySysShiftCorr:
613 patType1correctionsJetEnDown.extend([ cms.InputTag(
'pfMEtSysShiftCorr'+postfix) ])
614 setattr(process,
"patType1p2CorrectedPFMetJetEnDown"+postfix, getattr(process,
"patType1p2CorrectedPFMetJetEnUp"+postfix).
clone(
615 srcType1Corrections = cms.VInputTag(patType1correctionsJetEnDown),
616 srcUnclEnergySums = cms.VInputTag(
617 cms.InputTag(
'patPFJetMETtype1p2CorrEnDown'+postfix,
'type2' ),
618 cms.InputTag(
'patPFJetMETtype2CorrEnDown'+postfix,
'type2' ),
619 cms.InputTag(
'patPFJetMETtype1p2CorrEnDown'+postfix,
'offset'),
620 cms.InputTag(
'pfCandMETcorr'+postfix)
623 metUncertaintySequence += getattr(process,
"patType1p2CorrectedPFMetJetEnDown"+postfix)
624 collectionsToKeep.append(
'patType1p2CorrectedPFMetJetEnDown'+postfix)
628 for metProducer
in [ getattr(process,
"patPFMet"+postfix),
629 getattr(process,
"patType1CorrectedPFMet"+postfix) ]:
631 metCollectionsUp_Down = \
633 process, shiftedParticleCollections[
'lastJetCollection'],
"Jet",
"Res",
634 shiftedParticleCollections[
'jetCollectionResUp'], shiftedParticleCollections[
'jetCollectionResDown'],
635 metProducer, metUncertaintySequence, postfix)
636 collectionsToKeep.extend(metCollectionsUp_Down)
639 if makeType1p2corrPFMEt:
640 setattr(process,
"patPFJetMETtype1p2CorrResUp"+postfix, getattr(process,
"patPFJetMETtype1p2Corr"+postfix).
clone(
641 src = cms.InputTag(getattr(process,
"selectedPatJetsForMETtype1p2CorrResUp"+postfix).
label()),
642 jetCorrLabel = cms.string(jetCorrLabel)
644 metUncertaintySequence += getattr(process,
"patPFJetMETtype1p2CorrResUp"+postfix)
645 setattr(process,
"patPFJetMETtype1p2CorrResDown"+postfix, getattr(process,
"patPFJetMETtype1p2CorrResUp"+postfix).
clone(
646 src = cms.InputTag(getattr(process,
"selectedPatJetsForMETtype1p2CorrResDown"+postfix).
label())
648 metUncertaintySequence += getattr(process,
"patPFJetMETtype1p2CorrResDown"+postfix)
649 setattr(process,
"patPFJetMETtype2CorrResUp"+postfix, getattr(process,
"patPFJetMETtype2Corr"+postfix).
clone(
650 src = cms.InputTag(
'selectedPatJetsForMETtype2CorrResUp'+postfix)
652 metUncertaintySequence += getattr(process,
"patPFJetMETtype2CorrResUp"+postfix)
653 setattr(process,
"patPFJetMETtype2CorrResDown"+postfix, getattr(process,
"patPFJetMETtype2Corr"+postfix).
clone(
654 src = cms.InputTag(
'selectedPatJetsForMETtype2CorrResDown'+postfix)
656 metUncertaintySequence += getattr(process,
"patPFJetMETtype2CorrResDown"+postfix)
658 patType1correctionsJetResUp = [ cms.InputTag(
'patPFJetMETtype1p2CorrResUp'+postfix,
'type1') ]
660 patType1correctionsJetResUp.extend([ cms.InputTag(
'patPFMETtype0Corr'+postfix) ])
661 if doApplySysShiftCorr:
662 patType1correctionsJetResUp.extend([ cms.InputTag(
'pfMEtSysShiftCorr'+postfix) ])
663 setattr(process,
"patType1p2CorrectedPFMetJetResUp"+postfix, getattr(process,
"patType1p2CorrectedPFMet"+postfix).
clone(
664 srcType1Corrections = cms.VInputTag(patType1correctionsJetResUp),
665 srcUnclEnergySums = cms.VInputTag(
666 cms.InputTag(
'patPFJetMETtype1p2CorrResUp'+postfix,
'type2' ),
667 cms.InputTag(
'patPFJetMETtype2CorrResUp'+postfix,
'type2' ),
668 cms.InputTag(
'patPFJetMETtype1p2CorrResUp'+postfix,
'offset'),
669 cms.InputTag(
'pfCandMETcorr'+postfix)
672 metUncertaintySequence += getattr(process,
"patType1p2CorrectedPFMetJetResUp"+postfix)
673 collectionsToKeep.append(
'patType1p2CorrectedPFMetJetResUp'+postfix)
674 patType1correctionsJetResDown = [ cms.InputTag(
'patPFJetMETtype1p2CorrResDown'+postfix,
'type1') ]
676 patType1correctionsJetResDown.extend([ cms.InputTag(
'patPFMETtype0Corr'+postfix) ])
677 if doApplySysShiftCorr:
678 patType1correctionsJetResDown.extend([ cms.InputTag(
'pfMEtSysShiftCorr'+postfix) ])
679 setattr(process,
"patType1p2CorrectedPFMetJetResDown"+postfix, getattr(process,
"patType1p2CorrectedPFMetJetResUp"+postfix).
clone(
680 srcType1Corrections = cms.VInputTag(patType1correctionsJetResDown),
681 srcUnclEnergySums = cms.VInputTag(
682 cms.InputTag(
'patPFJetMETtype1p2CorrResDown'+postfix,
'type2' ),
683 cms.InputTag(
'patPFJetMETtype2CorrResDown'+postfix,
'type2' ),
684 cms.InputTag(
'patPFJetMETtype1p2CorrResDown'+postfix,
'offset'),
685 cms.InputTag(
'pfCandMETcorr'+postfix)
688 metUncertaintySequence += getattr(process,
"patType1p2CorrectedPFMetJetResDown"+postfix)
689 collectionsToKeep.append(
'patType1p2CorrectedPFMetJetResDown'+postfix)
696 unclEnMETcorrections = [
697 [
'pfCandMETcorr'+postfix, [
'' ] ],
698 [
'patPFJetMETtype1p2Corr'+postfix, [
'type2',
'offset' ] ],
699 [
'patPFJetMETtype2Corr'+postfix, [
'type2' ] ],
701 unclEnMETcorrectionsUp = []
702 unclEnMETcorrectionsDown = []
703 for srcUnclEnMETcorr
in unclEnMETcorrections:
704 moduleUnclEnMETcorrUp = cms.EDProducer(
"ShiftedMETcorrInputProducer",
706 [ cms.InputTag(srcUnclEnMETcorr[0], instanceLabel)
for instanceLabel
in srcUnclEnMETcorr[1] ]
708 uncertainty = cms.double(0.10),
709 shiftBy = cms.double(+1.*varyByNsigmas)
711 baseName = srcUnclEnMETcorr[0]
713 if baseName[-len(postfix):] == postfix:
714 baseName = baseName[0:-len(postfix)]
716 raise StandardError(
"Tried to remove postfix %s from label %s, but it wasn't there" % (postfix, baseName))
717 moduleUnclEnMETcorrUpName =
"%sUnclusteredEnUp" % baseName
718 moduleUnclEnMETcorrUpName += postfix
719 setattr(process, moduleUnclEnMETcorrUpName, moduleUnclEnMETcorrUp)
720 metUncertaintySequence += moduleUnclEnMETcorrUp
721 unclEnMETcorrectionsUp.extend([ cms.InputTag(moduleUnclEnMETcorrUpName, instanceLabel)
722 for instanceLabel
in srcUnclEnMETcorr[1] ] )
723 moduleUnclEnMETcorrDown = moduleUnclEnMETcorrUp.clone(
724 shiftBy = cms.double(-1.*varyByNsigmas)
726 moduleUnclEnMETcorrDownName =
"%sUnclusteredEnDown" % baseName
727 moduleUnclEnMETcorrDownName += postfix
728 setattr(process, moduleUnclEnMETcorrDownName, moduleUnclEnMETcorrDown)
729 metUncertaintySequence += moduleUnclEnMETcorrDown
730 unclEnMETcorrectionsDown.extend([ cms.InputTag(moduleUnclEnMETcorrDownName, instanceLabel)
731 for instanceLabel
in srcUnclEnMETcorr[1] ] )
734 setattr(process,
"patPFMetUnclusteredEnUp"+postfix, getattr(process,
"patType1CorrectedPFMet"+postfix).
clone(
735 src = cms.InputTag(
'patPFMet'+postfix),
736 srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsUp)
738 metUncertaintySequence += getattr(process,
"patPFMetUnclusteredEnUp"+postfix)
739 collectionsToKeep.append(
'patPFMetUnclusteredEnUp'+postfix)
740 setattr(process,
"patPFMetUnclusteredEnDown"+postfix, getattr(process,
"patPFMetUnclusteredEnUp"+postfix).
clone(
741 srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsDown)
743 metUncertaintySequence += getattr(process,
"patPFMetUnclusteredEnDown"+postfix)
744 collectionsToKeep.append(
'patPFMetUnclusteredEnDown'+postfix)
747 setattr(process,
"patType1CorrectedPFMetUnclusteredEnUp"+postfix, getattr(process,
"patType1CorrectedPFMet"+postfix).
clone(
748 src = cms.InputTag(
'patType1CorrectedPFMet'+postfix),
749 srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsUp)
751 metUncertaintySequence += getattr(process,
"patType1CorrectedPFMetUnclusteredEnUp"+postfix)
752 collectionsToKeep.append(
'patType1CorrectedPFMetUnclusteredEnUp'+postfix)
753 setattr(process,
"patType1CorrectedPFMetUnclusteredEnDown"+postfix, getattr(process,
"patType1CorrectedPFMetUnclusteredEnUp"+postfix).
clone(
754 srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsDown)
756 metUncertaintySequence += getattr(process,
"patType1CorrectedPFMetUnclusteredEnDown"+postfix)
757 collectionsToKeep.append(
'patType1CorrectedPFMetUnclusteredEnDown'+postfix)
760 if makeType1p2corrPFMEt:
761 setattr(process,
"patType1p2CorrectedPFMetUnclusteredEnUp"+postfix, getattr(process,
"patType1p2CorrectedPFMet"+postfix).
clone(
762 srcUnclEnergySums = cms.VInputTag(
763 cms.InputTag(
'patPFJetMETtype1p2Corr'+postfix,
'type2' ),
764 cms.InputTag(
'patPFJetMETtype1p2CorrUnclusteredEnUp'+postfix,
'type2' ),
765 cms.InputTag(
'patPFJetMETtype2Corr'+postfix,
'type2' ),
766 cms.InputTag(
'patPFJetMETtype2CorrUnclusteredEnUp'+postfix,
'type2' ),
767 cms.InputTag(
'patPFJetMETtype1p2Corr'+postfix,
'offset'),
768 cms.InputTag(
'patPFJetMETtype1p2CorrUnclusteredEnUp'+postfix,
'offset'),
769 cms.InputTag(
'pfCandMETcorr'+postfix),
770 cms.InputTag(
'pfCandMETcorrUnclusteredEnUp'+postfix)
773 metUncertaintySequence += getattr(process,
"patType1p2CorrectedPFMetUnclusteredEnUp"+postfix)
774 collectionsToKeep.append(
'patType1p2CorrectedPFMetUnclusteredEnUp'+postfix)
775 setattr(process,
"patType1p2CorrectedPFMetUnclusteredEnDown"+postfix, getattr(process,
"patType1p2CorrectedPFMetUnclusteredEnUp"+postfix).
clone(
776 srcUnclEnergySums = cms.VInputTag(
777 cms.InputTag(
'patPFJetMETtype1p2Corr'+postfix,
'type2' ),
778 cms.InputTag(
'patPFJetMETtype1p2CorrUnclusteredEnDown'+postfix,
'type2' ),
779 cms.InputTag(
'patPFJetMETtype2Corr'+postfix,
'type2' ),
780 cms.InputTag(
'patPFJetMETtype2CorrUnclusteredEnDown'+postfix,
'type2' ),
781 cms.InputTag(
'patPFJetMETtype1p2Corr'+postfix,
'offset'),
782 cms.InputTag(
'patPFJetMETtype1p2CorrUnclusteredEnDown'+postfix,
'offset'),
783 cms.InputTag(
'pfCandMETcorr'+postfix),
784 cms.InputTag(
'pfCandMETcorrUnclusteredEnDown'+postfix)
787 metUncertaintySequence += getattr(process,
"patType1p2CorrectedPFMetUnclusteredEnDown"+postfix)
788 collectionsToKeep.append(
'patType1p2CorrectedPFMetUnclusteredEnDown'+postfix)
794 metProducers = [ getattr(process,
"patPFMet"+postfix),
795 getattr(process,
"patType1CorrectedPFMet"+postfix) ]
796 if makeType1p2corrPFMEt:
797 metProducers.append( getattr(process,
"patType1p2CorrectedPFMet"+postfix) )
798 for metProducer
in metProducers:
801 metCollectionsUp_Down = \
803 process, shiftedParticleCollections[
'electronCollection'].
value(),
"Electron",
"En",
804 shiftedParticleCollections[
'electronCollectionEnUp'], shiftedParticleCollections[
'electronCollectionEnDown'],
805 metProducer, metUncertaintySequence, postfix)
806 collectionsToKeep.extend(metCollectionsUp_Down)
809 metCollectionsUp_Down = \
811 process, shiftedParticleCollections[
'photonCollection'].
value(),
"Photon",
"En",
812 shiftedParticleCollections[
'photonCollectionEnUp'], shiftedParticleCollections[
'photonCollectionEnDown'],
813 metProducer, metUncertaintySequence, postfix)
814 collectionsToKeep.extend(metCollectionsUp_Down)
817 metCollectionsUp_Down = \
819 process, shiftedParticleCollections[
'muonCollection'].
value(),
"Muon",
"En",
820 shiftedParticleCollections[
'muonCollectionEnUp'], shiftedParticleCollections[
'muonCollectionEnDown'],
821 metProducer, metUncertaintySequence, postfix)
822 collectionsToKeep.extend(metCollectionsUp_Down)
825 metCollectionsUp_Down = \
827 process, shiftedParticleCollections[
'tauCollection'].
value(),
"Tau",
"En",
828 shiftedParticleCollections[
'tauCollectionEnUp'], shiftedParticleCollections[
'tauCollectionEnDown'],
829 metProducer, metUncertaintySequence, postfix)
830 collectionsToKeep.extend(metCollectionsUp_Down)
833 particleCollection, particleType, shiftType, particleCollectionShiftUp, particleCollectionShiftDown,
835 pfCandCollection, postfix):
837 srcUnshiftedObjects = particleCollection
838 if isinstance(srcUnshiftedObjects, cms.InputTag):
839 srcUnshiftedObjects = srcUnshiftedObjects.value()
840 moduleShiftUp = cms.EDProducer(
"ShiftedPFCandidateProducerForPFMEtMVA",
841 srcPFCandidates = pfCandCollection,
842 srcUnshiftedObjects = cms.InputTag(srcUnshiftedObjects),
843 srcShiftedObjects = cms.InputTag(particleCollectionShiftUp),
844 dRmatch_PFCandidate = cms.double(dRmatch)
846 moduleNameShiftUp =
"pfCandidates%s%sUpForMEtUncertainties" % (particleType, shiftType)
847 moduleNameShiftUp += postfix
848 setattr(process, moduleNameShiftUp, moduleShiftUp)
849 metUncertaintySequence += moduleShiftUp
851 moduleShiftDown = moduleShiftUp.clone(
852 srcShiftedObjects = cms.InputTag(particleCollectionShiftDown)
854 moduleNameShiftDown =
"pfCandidates%s%sDownForMEtUncertainties" % (particleType, shiftType)
855 moduleNameShiftDown += postfix
856 setattr(process, moduleNameShiftDown, moduleShiftDown)
857 metUncertaintySequence += moduleShiftDown
859 return ( moduleNameShiftUp, moduleNameShiftDown )
861 def _getLeptonsForPFMEtInput(self, shiftedParticleCollections, substituteKeyUnshifted = None, substituteKeyShifted = None, postfix=""):
863 for collectionName
in [
'electronCollection',
868 if substituteKeyUnshifted
is not None and substituteKeyUnshifted
in shiftedParticleCollections.keys()
and \
869 substituteKeyShifted
is not None and substituteKeyShifted
in shiftedParticleCollections.keys()
and \
870 shiftedParticleCollections[collectionName] == shiftedParticleCollections[substituteKeyUnshifted]:
871 retVal.append(cms.InputTag(shiftedParticleCollections[substituteKeyShifted]))
873 retVal.append(shiftedParticleCollections[collectionName])
877 pfMEtCollection, patMEtCollection,
878 collectionsToKeep, postfix):
880 module = patMETs.clone(
881 metSource = cms.InputTag(pfMEtCollection),
882 addMuonCorrections = cms.bool(
False),
883 genMETSource = cms.InputTag(
'genMetTrue')
885 patMEtCollectionName = patMEtCollection+postfix
886 setattr(process, patMEtCollectionName, module)
887 metUncertaintySequence += module
888 collectionsToKeep.append(patMEtCollectionName)
891 shiftedParticleCollections, pfCandCollection,
898 if not makePFMEtByMVA:
901 if not hasattr(process,
"pfMEtMVA"):
902 process.load(
"JetMETCorrections.METPUSubtraction.mvaPFMET_cff")
904 lastUncorrectedJetCollectionForPFMEtByMVA =
'ak5PFJets'
905 lastCorrectedJetCollectionForPFMEtByMVA =
'calibratedAK5PFJetsForPFMEtMVA'
907 configtools.cloneProcessingSnippet(process, process.pfMEtMVAsequence, postfix)
908 lastCorrectedJetCollectionForPFMEtByMVA += postfix
911 process.load(
"RecoJets.Configuration.GenJetParticles_cff")
912 metUncertaintySequence += process.genParticlesForJetsNoNu
913 process.load(
"RecoJets.Configuration.RecoGenJets_cff")
914 metUncertaintySequence += process.ak5GenJetsNoNu
915 setattr(process,
"smearedUncorrectedJetsForPFMEtByMVA"+postfix, cms.EDProducer(
"SmearedPFJetProducer",
916 src = cms.InputTag(
'ak5PFJets'),
917 jetCorrLabel = cms.string(
"ak5PFL1FastL2L3"),
918 dRmaxGenJetMatch = cms.string(
'TMath::Min(0.5, 0.1 + 0.3*TMath::Exp(-0.05*(genJetPt - 10.)))'),
919 sigmaMaxGenJetMatch = cms.double(5.),
920 inputFileName = cms.FileInPath(
'PhysicsTools/PatUtils/data/pfJetResolutionMCtoDataCorrLUT.root'),
921 lutName = cms.string(
'pfJetResolutionMCtoDataCorrLUT'),
922 jetResolutions = jetResolutions.METSignificance_params,
923 skipRawJetPtThreshold = cms.double(10.),
924 skipCorrJetPtThreshold = cms.double(1.e-2),
925 srcGenJets = cms.InputTag(
'ak5GenJetsNoNu')
927 metUncertaintySequence += getattr(process,
"smearedUncorrectedJetsForPFMEtByMVA"+postfix)
928 getattr(process,
"calibratedAK5PFJetsForPFMEtMVA"+postfix).src = cms.InputTag(
'smearedUncorrectedJetsForPFMEtByMVA'+postfix)
929 getattr(process,
"pfMEtMVA"+postfix).srcUncorrJets = cms.InputTag(
'smearedUncorrectedJetsForPFMEtByMVA'+postfix)
930 metUncertaintySequence += getattr(process,
"calibratedAK5PFJetsForPFMEtMVA"+postfix)
931 setattr(process,
"smearedCorrectedJetsForPFMEtByMVA"+postfix, getattr(process,
"smearedUncorrectedJetsForPFMEtByMVA"+postfix).
clone(
932 src = cms.InputTag(
'calibratedAK5PFJetsForPFMEtMVA'+postfix),
933 jetCorrLabel = cms.string(
"")
935 metUncertaintySequence += getattr(process,
"smearedCorrectedJetsForPFMEtByMVA"+postfix)
936 getattr(process,
"pfMEtMVA"+postfix).srcCorrJets = cms.InputTag(
'smearedCorrectedJetsForPFMEtByMVA'+postfix)
937 metUncertaintySequence += getattr(process,
"pfMEtMVA"+postfix)
939 metUncertaintySequence += getattr(process,
"pfMEtMVAsequence"+postfix)
941 'pfMEtMVA'+postfix,
'patPFMetMVA', collectionsToKeep, postfix)
943 for leptonCollection
in [ [
'Electron',
'En',
'electronCollection', 0.3 ],
944 [
'Photon',
'En',
'photonCollection', 0.3 ],
945 [
'Muon',
'En',
'muonCollection', 0.3 ],
946 [
'Tau',
'En',
'tauCollection', 0.3 ] ]:
948 pfCandCollectionLeptonShiftUp, pfCandCollectionLeptonShiftDown = \
950 process, metUncertaintySequence,
951 shiftedParticleCollections[
'%s' % leptonCollection[2]], leptonCollection[0], leptonCollection[1],
952 shiftedParticleCollections[
'%s%sUp' % (leptonCollection[2], leptonCollection[1])],
953 shiftedParticleCollections[
'%s%sDown' % (leptonCollection[2], leptonCollection[1])],
955 pfCandCollection, postfix)
956 modulePFMEtLeptonShiftUp = getattr(process,
"pfMEtMVA"+postfix).
clone(
957 srcPFCandidates = cms.InputTag(pfCandCollectionLeptonShiftUp),
959 shiftedParticleCollections, leptonCollection[2],
'%s%sUp' % (leptonCollection[2], leptonCollection[1]), postfix=postfix))
961 modulePFMEtLeptonShiftUpName =
"pfMEtMVA%s%sUp" % (leptonCollection[0], leptonCollection[1])
962 modulePFMEtLeptonShiftUpName += postfix
963 setattr(process, modulePFMEtLeptonShiftUpName, modulePFMEtLeptonShiftUp)
964 metUncertaintySequence += modulePFMEtLeptonShiftUp
966 modulePFMEtLeptonShiftUpName,
'patPFMetMVA%s%sUp' % (leptonCollection[0], leptonCollection[1]), collectionsToKeep, postfix)
967 modulePFMEtLeptonShiftDown = getattr(process,
"pfMEtMVA"+postfix).
clone(
968 srcPFCandidates = cms.InputTag(pfCandCollectionLeptonShiftDown),
970 shiftedParticleCollections, leptonCollection[2],
'%s%sDown' % (leptonCollection[2], leptonCollection[1]), postfix=postfix))
972 modulePFMEtLeptonShiftDownName =
"pfMEtMVA%s%sDown" % (leptonCollection[0], leptonCollection[1])
973 modulePFMEtLeptonShiftDownName += postfix
974 setattr(process, modulePFMEtLeptonShiftDownName, modulePFMEtLeptonShiftDown)
975 metUncertaintySequence += modulePFMEtLeptonShiftDown
977 modulePFMEtLeptonShiftDownName,
'patPFMetMVA%s%sDown' % (leptonCollection[0], leptonCollection[1]), collectionsToKeep, postfix)
980 setattr(process,
"uncorrectedJetsEnUpForPFMEtByMVA"+postfix, cms.EDProducer(
"ShiftedPFJetProducer",
981 src = cms.InputTag(lastUncorrectedJetCollectionForPFMEtByMVA),
982 jetCorrInputFileName = cms.FileInPath(
'PhysicsTools/PatUtils/data/Summer12_V2_DATA_AK5PF_UncertaintySources.txt'),
983 jetCorrUncertaintyTag = cms.string(
"SubTotalDataMC"),
984 addResidualJES = cms.bool(
True),
985 jetCorrLabelUpToL3 = cms.string(
"ak5PFL1FastL2L3"),
986 jetCorrLabelUpToL3Res = cms.string(
"ak5PFL1FastL2L3Residual"),
987 shiftBy = cms.double(+1.*varyByNsigmas)
989 metUncertaintySequence += getattr(process,
"uncorrectedJetsEnUpForPFMEtByMVA"+postfix)
990 setattr(process,
"uncorrectedJetsEnDownForPFMEtByMVA"+postfix, getattr(process,
"uncorrectedJetsEnUpForPFMEtByMVA"+postfix).
clone(
991 shiftBy = cms.double(-1.*varyByNsigmas)
993 metUncertaintySequence += getattr(process,
"uncorrectedJetsEnDownForPFMEtByMVA"+postfix)
994 setattr(process,
"correctedJetsEnUpForPFMEtByMVA"+postfix, getattr(process,
"uncorrectedJetsEnUpForPFMEtByMVA"+postfix).
clone(
995 src = cms.InputTag(lastCorrectedJetCollectionForPFMEtByMVA),
996 addResidualJES = cms.bool(
False),
997 shiftBy = cms.double(+1.*varyByNsigmas)
999 metUncertaintySequence += getattr(process,
"correctedJetsEnUpForPFMEtByMVA"+postfix)
1000 setattr(process,
"correctedJetsEnDownForPFMEtByMVA"+postfix, getattr(process,
"correctedJetsEnUpForPFMEtByMVA"+postfix).
clone(
1001 shiftBy = cms.double(-1.*varyByNsigmas)
1003 metUncertaintySequence += getattr(process,
"correctedJetsEnDownForPFMEtByMVA"+postfix)
1004 pfCandCollectionJetEnUp, pfCandCollectionJetEnDown = \
1006 process, metUncertaintySequence,
1007 shiftedParticleCollections[
'lastJetCollection'],
"Jet",
"En",
1008 shiftedParticleCollections[
'jetCollectionEnUpForCorrMEt'], shiftedParticleCollections[
'jetCollectionEnDownForCorrMEt'],
1010 pfCandCollection, postfix)
1011 setattr(process,
"pfMEtMVAJetEnUp"+postfix, getattr(process,
"pfMEtMVA").
clone(
1012 srcCorrJets = cms.InputTag(
'correctedJetsEnUpForPFMEtByMVA'+postfix),
1013 srcUncorrJets = cms.InputTag(
'uncorrectedJetsEnUpForPFMEtByMVA'+postfix),
1014 srcPFCandidates = cms.InputTag(pfCandCollectionJetEnUp),
1017 metUncertaintySequence += getattr(process,
"pfMEtMVAJetEnUp"+postfix)
1019 'pfMEtMVAJetEnUp'+postfix,
'patPFMetMVAJetEnUp', collectionsToKeep, postfix)
1020 setattr(process,
"pfMEtMVAJetEnDown"+postfix, getattr(process,
"pfMEtMVA"+postfix).
clone(
1021 srcCorrJets = cms.InputTag(
'correctedJetsEnDownForPFMEtByMVA'+postfix),
1022 srcUncorrJets = cms.InputTag(
'uncorrectedJetsEnDownForPFMEtByMVA'+postfix),
1023 srcPFCandidates = cms.InputTag(pfCandCollectionJetEnDown),
1026 metUncertaintySequence += getattr(process,
"pfMEtMVAJetEnDown"+postfix)
1028 'pfMEtMVAJetEnDown'+postfix,
'patPFMetMVAJetEnDown', collectionsToKeep, postfix)
1030 if hasattr(process,
"smearedUncorrectedJetsForPFMEtByMVA"+postfix):
1031 setattr(process,
"uncorrectedJetsResUpForPFMEtByMVA"+postfix, getattr(process,
"smearedUncorrectedJetsForPFMEtByMVA"+postfix).
clone(
1032 shiftBy = cms.double(-1.*varyByNsigmas)
1034 metUncertaintySequence += getattr(process,
"uncorrectedJetsResUpForPFMEtByMVA"+postfix)
1035 setattr(process,
"uncorrectedJetsResDownForPFMEtByMVA"+postfix, getattr(process,
"smearedUncorrectedJetsForPFMEtByMVA"+postfix).
clone(
1036 shiftBy = cms.double(+1.*varyByNsigmas)
1038 metUncertaintySequence += getattr(process,
"uncorrectedJetsResDownForPFMEtByMVA"+postfix)
1039 setattr(process,
"correctedJetsResUpForPFMEtByMVA"+postfix, getattr(process,
"smearedCorrectedJetsForPFMEtByMVA"+postfix).
clone(
1040 shiftBy = cms.double(-1.*varyByNsigmas)
1042 metUncertaintySequence += getattr(process,
"correctedJetsResUpForPFMEtByMVA"+postfix)
1043 setattr(process,
"correctedJetsResDownForPFMEtByMVA"+postfix, getattr(process,
"smearedCorrectedJetsForPFMEtByMVA"+postfix).
clone(
1044 shiftBy = cms.double(+1.*varyByNsigmas)
1046 metUncertaintySequence += getattr(process,
"correctedJetsResDownForPFMEtByMVA"+postfix)
1047 pfCandCollectionJetResUp, pfCandCollectionJetResDown = \
1049 process, metUncertaintySequence,
1050 shiftedParticleCollections[
'jetCollection'],
"Jet",
"Res",
1051 shiftedParticleCollections[
'jetCollectionResUp'], shiftedParticleCollections[
'jetCollectionResDown'],
1053 pfCandCollection, postfix)
1054 setattr(process,
"pfMEtMVAJetResUp"+postfix, getattr(process,
"pfMEtMVA"+postfix).
clone(
1055 srcCorrJets = cms.InputTag(
'correctedJetsResUpForPFMEtByMVA'+postfix),
1056 srcUncorrJets = cms.InputTag(
'uncorrectedJetsResUpForPFMEtByMVA'+postfix),
1057 srcPFCandidates = cms.InputTag(pfCandCollectionJetResUp),
1060 metUncertaintySequence += getattr(process,
"pfMEtMVAJetResUp"+postfix)
1062 'pfMEtMVAJetResUp'+postfix,
'patPFMetMVAJetResUp', collectionsToKeep, postfix)
1063 setattr(process,
"pfMEtMVAJetResDown"+postfix, getattr(process,
"pfMEtMVA"+postfix).
clone(
1064 srcCorrJets = cms.InputTag(
'correctedJetsResDownForPFMEtByMVA'+postfix),
1065 srcUncorrJets = cms.InputTag(
'uncorrectedJetsResDownForPFMEtByMVA'+postfix),
1066 srcPFCandidates = cms.InputTag(pfCandCollectionJetResDown),
1069 metUncertaintySequence += getattr(process,
"pfMEtMVAJetResDown"+postfix)
1071 'pfMEtMVAJetResDown'+postfix,
'patPFMetMVAJetResDown', collectionsToKeep, postfix)
1073 setattr(process,
"pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA"+postfix, cms.EDProducer(
"ShiftedPFCandidateProducer",
1074 src = cms.InputTag(
'pfCandsNotInJet'),
1075 shiftBy = cms.double(+1.*varyByNsigmas),
1076 uncertainty = cms.double(0.10)
1078 metUncertaintySequence += getattr(process,
"pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA"+postfix)
1079 setattr(process,
"pfCandsNotInJetUnclusteredEnDownForPFMEtByMVA"+postfix, getattr(process,
"pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA"+postfix).
clone(
1080 shiftBy = cms.double(-1.*varyByNsigmas)
1082 metUncertaintySequence += getattr(process,
"pfCandsNotInJetUnclusteredEnDownForPFMEtByMVA"+postfix)
1083 pfCandCollectionUnclusteredEnUp, pfCandCollectionUnclusteredEnDown = \
1085 process, metUncertaintySequence,
1086 pfCandCollection,
"Unclustered",
"En",
1087 'pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA'+postfix,
'pfCandsNotInJetUnclusteredEnDownForPFMEtByMVA'+postfix,
1089 pfCandCollection, postfix)
1090 setattr(process,
"pfMEtMVAUnclusteredEnUp"+postfix, getattr(process,
"pfMEtMVA"+postfix).
clone(
1091 srcPFCandidates = cms.InputTag(pfCandCollectionUnclusteredEnUp),
1094 metUncertaintySequence += getattr(process,
"pfMEtMVAUnclusteredEnUp"+postfix)
1096 'pfMEtMVAUnclusteredEnUp'+postfix,
'patPFMetMVAUnclusteredEnUp', collectionsToKeep, postfix)
1097 setattr(process,
"pfMEtMVAUnclusteredEnDown"+postfix, getattr(process,
"pfMEtMVA"+postfix).
clone(
1098 srcPFCandidates = cms.InputTag(pfCandCollectionUnclusteredEnDown),
1101 metUncertaintySequence += getattr(process,
"pfMEtMVAUnclusteredEnDown"+postfix)
1103 'pfMEtMVAUnclusteredEnDown'+postfix,
'patPFMetMVAUnclusteredEnDown', collectionsToKeep, postfix)
1107 shiftedParticleCollections, pfCandCollection,
1114 if not makeNoPileUpPFMEt:
1117 if not hasattr(process,
"noPileUpPFMEt"):
1118 process.load(
"JetMETCorrections.METPUSubtraction.noPileUpPFMET_cff")
1120 lastUncorrectedJetCollectionForNoPileUpPFMEt =
'ak5PFJets'
1121 lastCorrectedJetCollectionForNoPileUpPFMEt =
'calibratedAK5PFJetsForNoPileUpPFMEt'
1123 configtools.cloneProcessingSnippet(process, process.noPileUpPFMEtSequence, postfix)
1124 lastCorrectedJetCollectionForNoPileUpPFMEt+= postfix
1128 process.load(
"RecoJets.Configuration.GenJetParticles_cff")
1129 metUncertaintySequence += process.genParticlesForJetsNoNu
1130 process.load(
"RecoJets.Configuration.RecoGenJets_cff")
1131 metUncertaintySequence += process.ak5GenJetsNoNu
1132 setattr(process,
"smearedUncorrectedJetsForNoPileUpPFMEt"+postfix, cms.EDProducer(
"SmearedPFJetProducer",
1133 src = cms.InputTag(
'ak5PFJets'),
1134 jetCorrLabel = cms.string(
"ak5PFL1FastL2L3"),
1135 dRmaxGenJetMatch = cms.string(
'TMath::Min(0.5, 0.1 + 0.3*TMath::Exp(-0.05*(genJetPt - 10.)))'),
1136 sigmaMaxGenJetMatch = cms.double(5.),
1137 inputFileName = cms.FileInPath(
'PhysicsTools/PatUtils/data/pfJetResolutionMCtoDataCorrLUT.root'),
1138 lutName = cms.string(
'pfJetResolutionMCtoDataCorrLUT'),
1139 jetResolutions = jetResolutions.METSignificance_params,
1140 skipRawJetPtThreshold = cms.double(10.),
1141 skipCorrJetPtThreshold = cms.double(1.e-2),
1142 srcGenJets = cms.InputTag(
'ak5GenJetsNoNu'),
1145 metUncertaintySequence += getattr(process,
"smearedUncorrectedJetsForNoPileUpPFMEt"+postfix)
1146 getattr(process,
"calibratedAK5PFJetsForNoPileUpPFMEt"+postfix).src = cms.InputTag(
'smearedUncorrectedJetsForNoPileUpPFMEt'+postfix)
1147 metUncertaintySequence += getattr(process,
"noPileUpPFMEtSequence"+postfix)
1149 'noPileUpPFMEt'+postfix,
'patPFMetNoPileUp', collectionsToKeep, postfix)
1151 for leptonCollection
in [ [
'Electron',
'En',
'electronCollection', 0.3 ],
1152 [
'Photon',
'En',
'photonCollection', 0.3 ],
1153 [
'Muon',
'En',
'muonCollection', 0.3 ],
1154 [
'Tau',
'En',
'tauCollection', 0.3 ] ]:
1156 pfCandCollectionLeptonShiftUp, pfCandCollectionLeptonShiftDown = \
1158 process, metUncertaintySequence,
1159 shiftedParticleCollections[
'%s' % leptonCollection[2]], leptonCollection[0], leptonCollection[1],
1160 shiftedParticleCollections[
'%s%sUp' % (leptonCollection[2], leptonCollection[1])], shiftedParticleCollections[
'%s%sDown' % (leptonCollection[2], leptonCollection[1])],
1161 leptonCollection[3],
1162 pfCandCollection, postfix)
1163 modulePFCandidateToVertexAssociationShiftUp = process.pfCandidateToVertexAssociation.clone(
1164 PFCandidateCollection = cms.InputTag(pfCandCollectionLeptonShiftUp)
1166 modulePFCandidateToVertexAssociationShiftUpName =
"pfCandidateToVertexAssociation%s%sUp" % (leptonCollection[0], leptonCollection[1])
1167 modulePFCandidateToVertexAssociationShiftUpName += postfix
1168 setattr(process, modulePFCandidateToVertexAssociationShiftUpName, modulePFCandidateToVertexAssociationShiftUp)
1169 metUncertaintySequence += modulePFCandidateToVertexAssociationShiftUp
1170 modulePFMEtDataLeptonShiftUp = getattr(process,
"noPileUpPFMEtData"+postfix).
clone(
1171 srcPFCandidates = cms.InputTag(pfCandCollectionLeptonShiftUp),
1172 srcPFCandToVertexAssociations = cms.InputTag(modulePFCandidateToVertexAssociationShiftUpName)
1174 modulePFMEtDataLeptonShiftUpName =
"noPileUpPFMEtData%s%sUp" % (leptonCollection[0], leptonCollection[1])
1175 modulePFMEtDataLeptonShiftUpName += postfix
1176 setattr(process, modulePFMEtDataLeptonShiftUpName, modulePFMEtDataLeptonShiftUp)
1177 metUncertaintySequence += modulePFMEtDataLeptonShiftUp
1178 modulePFMEtLeptonShiftUp = getattr(process,
"noPileUpPFMEt"+postfix).
clone(
1179 srcMVAMEtData = cms.InputTag(modulePFMEtDataLeptonShiftUpName),
1181 shiftedParticleCollections, leptonCollection[2],
'%s%sUp' % (leptonCollection[2], leptonCollection[1]), postfix=postfix))
1183 modulePFMEtLeptonShiftUpName =
"noPileUpPFMEt%s%sUp" % (leptonCollection[0], leptonCollection[1])
1184 modulePFMEtLeptonShiftUpName += postfix
1185 setattr(process, modulePFMEtLeptonShiftUpName, modulePFMEtLeptonShiftUp)
1186 metUncertaintySequence += modulePFMEtLeptonShiftUp
1188 modulePFMEtLeptonShiftUpName,
'patPFMetNoPileUp%s%sUp' % (leptonCollection[0], leptonCollection[1]), collectionsToKeep, postfix)
1189 modulePFCandidateToVertexAssociationShiftDown = modulePFCandidateToVertexAssociationShiftUp.clone(
1190 PFCandidateCollection = cms.InputTag(pfCandCollectionLeptonShiftDown)
1192 modulePFCandidateToVertexAssociationShiftDownName =
"pfCandidateToVertexAssociation%s%sDown" % (leptonCollection[0], leptonCollection[1])
1193 modulePFCandidateToVertexAssociationShiftDownName += postfix
1194 setattr(process, modulePFCandidateToVertexAssociationShiftDownName, modulePFCandidateToVertexAssociationShiftDown)
1195 metUncertaintySequence += modulePFCandidateToVertexAssociationShiftDown
1196 modulePFMEtDataLeptonShiftDown = getattr(process,
"noPileUpPFMEtData"+postfix).
clone(
1197 srcPFCandidates = cms.InputTag(pfCandCollectionLeptonShiftDown),
1198 srcPFCandToVertexAssociations = cms.InputTag(modulePFCandidateToVertexAssociationShiftDownName)
1200 modulePFMEtDataLeptonShiftDownName =
"noPileUpPFMEtData%s%sDown" % (leptonCollection[0], leptonCollection[1])
1201 modulePFMEtDataLeptonShiftDownName += postfix
1202 setattr(process, modulePFMEtDataLeptonShiftDownName, modulePFMEtDataLeptonShiftDown)
1203 metUncertaintySequence += modulePFMEtDataLeptonShiftDown
1204 modulePFMEtLeptonShiftDown = getattr(process,
"noPileUpPFMEt"+postfix).
clone(
1205 srcMVAMEtData = cms.InputTag(modulePFMEtDataLeptonShiftDownName),
1207 shiftedParticleCollections, leptonCollection[2],
'%s%sDown' % (leptonCollection[2], leptonCollection[1]), postfix=postfix))
1209 modulePFMEtLeptonShiftDownName =
"noPileUpPFMEt%s%sDown" % (leptonCollection[0], leptonCollection[1])
1210 modulePFMEtLeptonShiftDownName += postfix
1211 setattr(process, modulePFMEtLeptonShiftDownName, modulePFMEtLeptonShiftDown)
1212 metUncertaintySequence += modulePFMEtLeptonShiftDown
1214 modulePFMEtLeptonShiftDownName,
'patPFMetNoPileUp%s%sDown' % (leptonCollection[0], leptonCollection[1]), collectionsToKeep, postfix)
1217 setattr(process,
"uncorrectedJetsEnUpForNoPileUpPFMEt"+postfix, cms.EDProducer(
"ShiftedPFJetProducer",
1218 src = cms.InputTag(lastUncorrectedJetCollectionForNoPileUpPFMEt),
1219 jetCorrInputFileName = cms.FileInPath(
'PhysicsTools/PatUtils/data/Summer12_V2_DATA_AK5PF_UncertaintySources.txt'),
1220 jetCorrUncertaintyTag = cms.string(
"SubTotalDataMC"),
1221 addResidualJES = cms.bool(
False),
1222 jetCorrLabelUpToL3 = cms.string(
"ak5PFL1FastL2L3"),
1223 jetCorrLabelUpToL3Res = cms.string(
"ak5PFL1FastL2L3Residual"),
1224 shiftBy = cms.double(+1.*varyByNsigmas),
1227 metUncertaintySequence += getattr(process,
"uncorrectedJetsEnUpForNoPileUpPFMEt"+postfix)
1228 setattr(process,
"correctedJetsEnUpForNoPileUpPFMEt"+postfix, getattr(process,
"uncorrectedJetsEnUpForNoPileUpPFMEt"+postfix).
clone(
1229 src = cms.InputTag(lastCorrectedJetCollectionForNoPileUpPFMEt),
1230 addResidualJES = cms.bool(
False),
1231 shiftBy = cms.double(+1.*varyByNsigmas)
1233 metUncertaintySequence += getattr(process,
"correctedJetsEnUpForNoPileUpPFMEt"+postfix)
1234 setattr(process,
"puJetIdForNoPileUpPFMEtJetEnUp"+postfix, getattr(process,
"puJetIdForNoPileUpPFMEt"+postfix).
clone(
1235 jets = cms.InputTag(
'correctedJetsEnUpForNoPileUpPFMEt'+postfix)
1237 metUncertaintySequence += getattr(process,
"puJetIdForNoPileUpPFMEtJetEnUp"+postfix)
1238 setattr(process,
"noPileUpPFMEtDataJetEnUp"+postfix, getattr(process,
"noPileUpPFMEtData"+postfix).
clone(
1239 srcJets = cms.InputTag(
'correctedJetsEnUpForNoPileUpPFMEt'+postfix),
1240 srcJetIds = cms.InputTag(
'puJetIdForNoPileUpPFMEtJetEnUp'+postfix,
'fullId')
1242 metUncertaintySequence += getattr(process,
"noPileUpPFMEtDataJetEnUp"+postfix)
1243 setattr(process,
"noPileUpPFMEtJetEnUp"+postfix, getattr(process,
"noPileUpPFMEt"+postfix).
clone(
1244 srcMVAMEtData = cms.InputTag(
'noPileUpPFMEtDataJetEnUp'+postfix),
1247 metUncertaintySequence += getattr(process,
"noPileUpPFMEtJetEnUp"+postfix)
1249 'noPileUpPFMEtJetEnUp'+postfix,
'patPFMetNoPileUpJetEnUp', collectionsToKeep, postfix)
1250 setattr(process,
"uncorrectedJetsEnDownForNoPileUpPFMEt"+postfix, getattr(process,
"uncorrectedJetsEnUpForNoPileUpPFMEt"+postfix).
clone(
1251 shiftBy = cms.double(-1.*varyByNsigmas)
1253 metUncertaintySequence += getattr(process,
"uncorrectedJetsEnDownForNoPileUpPFMEt"+postfix)
1254 setattr(process,
"correctedJetsEnDownForNoPileUpPFMEt"+postfix, getattr(process,
"correctedJetsEnUpForNoPileUpPFMEt"+postfix).
clone(
1255 shiftBy = cms.double(-1.*varyByNsigmas)
1257 metUncertaintySequence += getattr(process,
"correctedJetsEnDownForNoPileUpPFMEt"+postfix)
1258 setattr(process,
"puJetIdForNoPileUpPFMEtJetEnDown"+postfix, getattr(process,
"puJetIdForNoPileUpPFMEt"+postfix).
clone(
1259 jets = cms.InputTag(
'correctedJetsEnDownForNoPileUpPFMEt'+postfix)
1261 metUncertaintySequence += getattr(process,
"puJetIdForNoPileUpPFMEtJetEnDown"+postfix)
1262 setattr(process,
"noPileUpPFMEtDataJetEnDown"+postfix, getattr(process,
"noPileUpPFMEtData"+postfix).
clone(
1263 srcJets = cms.InputTag(
'correctedJetsEnDownForNoPileUpPFMEt'+postfix),
1264 srcJetIds = cms.InputTag(
'puJetIdForNoPileUpPFMEtJetEnDown'+postfix,
'fullId')
1266 metUncertaintySequence += getattr(process,
"noPileUpPFMEtDataJetEnDown"+postfix)
1267 setattr(process,
"noPileUpPFMEtJetEnDown"+postfix, getattr(process,
"noPileUpPFMEt"+postfix).
clone(
1268 srcMVAMEtData = cms.InputTag(
'noPileUpPFMEtDataJetEnDown'+postfix),
1271 metUncertaintySequence += getattr(process,
"noPileUpPFMEtJetEnDown"+postfix)
1273 'noPileUpPFMEtJetEnDown'+postfix,
'patPFMetNoPileUpJetEnDown', collectionsToKeep, postfix)
1275 if hasattr(process,
"smearedUncorrectedJetsForNoPileUpPFMEt"+postfix):
1276 setattr(process,
"smearedCorrectedJetsForNoPileUpPFMEt"+postfix, getattr(process,
"smearedUncorrectedJetsForNoPileUpPFMEt"+postfix).
clone(
1277 src = cms.InputTag(
'calibratedAK5PFJetsForNoPileUpPFMEt'+postfix),
1278 jetCorrLabel = cms.string(
"")
1280 setattr(process,
"correctedJetsResUpForNoPileUpPFMEt"+postfix, getattr(process,
"smearedCorrectedJetsForNoPileUpPFMEt"+postfix).
clone(
1281 shiftBy = cms.double(-1.*varyByNsigmas)
1283 metUncertaintySequence += getattr(process,
"correctedJetsResUpForNoPileUpPFMEt"+postfix)
1284 setattr(process,
"correctedJetsResDownForNoPileUpPFMEt"+postfix, getattr(process,
"smearedCorrectedJetsForNoPileUpPFMEt"+postfix).
clone(
1285 shiftBy = cms.double(+1.*varyByNsigmas)
1287 metUncertaintySequence += getattr(process,
"correctedJetsResDownForNoPileUpPFMEt"+postfix)
1288 setattr(process,
"puJetIdForNoPileUpPFMEtJetResUp"+postfix, getattr(process,
"puJetIdForNoPileUpPFMEt"+postfix).
clone(
1289 jets = cms.InputTag(
'correctedJetsResUpForNoPileUpPFMEt'+postfix)
1291 metUncertaintySequence += getattr(process,
"puJetIdForNoPileUpPFMEtJetResUp"+postfix)
1292 setattr(process,
"noPileUpPFMEtDataJetResUp"+postfix, getattr(process,
"noPileUpPFMEtData"+postfix).
clone(
1293 srcJets = cms.InputTag(
'correctedJetsResUpForNoPileUpPFMEt'+postfix),
1294 srcJetIds = cms.InputTag(
'puJetIdForNoPileUpPFMEtJetResUp'+postfix,
'fullId')
1296 metUncertaintySequence += getattr(process,
"noPileUpPFMEtDataJetResUp"+postfix)
1297 setattr(process,
"noPileUpPFMEtJetResUp"+postfix, getattr(process,
"noPileUpPFMEt"+postfix).
clone(
1298 srcMVAMEtData = cms.InputTag(
'noPileUpPFMEtDataJetResUp'+postfix),
1301 metUncertaintySequence += getattr(process,
"noPileUpPFMEtJetResUp"+postfix)
1303 'noPileUpPFMEtJetResUp'+postfix,
'patPFMetNoPileUpJetResUp', collectionsToKeep, postfix)
1304 setattr(process,
"puJetIdForNoPileUpPFMEtJetResDown"+postfix, getattr(process,
"puJetIdForNoPileUpPFMEt"+postfix).
clone(
1305 jets = cms.InputTag(
'correctedJetsResDownForNoPileUpPFMEt'+postfix)
1307 metUncertaintySequence += getattr(process,
"puJetIdForNoPileUpPFMEtJetResDown"+postfix)
1308 setattr(process,
"noPileUpPFMEtDataJetResDown"+postfix, getattr(process,
"noPileUpPFMEtData"+postfix).
clone(
1309 srcJets = cms.InputTag(
'correctedJetsResDownForNoPileUpPFMEt'+postfix),
1310 srcJetIds = cms.InputTag(
'puJetIdForNoPileUpPFMEtJetResDown'+postfix,
'fullId')
1312 metUncertaintySequence += getattr(process,
"noPileUpPFMEtDataJetResDown"+postfix)
1313 setattr(process,
"noPileUpPFMEtJetResDown"+postfix, getattr(process,
"noPileUpPFMEt"+postfix).
clone(
1314 srcMVAMEtData = cms.InputTag(
'noPileUpPFMEtDataJetResDown'+postfix),
1317 metUncertaintySequence += getattr(process,
"noPileUpPFMEtJetResDown"+postfix)
1319 'noPileUpPFMEtJetResDown'+postfix,
'patPFMetNoPileUpJetResDown', collectionsToKeep, postfix)
1321 setattr(process,
"pfCandsUnclusteredEnUpForNoPileUpPFMEt"+postfix, cms.EDProducer(
"ShiftedPFCandidateProducerForNoPileUpPFMEt",
1322 srcPFCandidates = cms.InputTag(
'particleFlow'),
1323 srcJets = cms.InputTag(
'calibratedAK5PFJetsForNoPileUpPFMEt'+postfix),
1324 jetCorrInputFileName = cms.FileInPath(
'PhysicsTools/PatUtils/data/Summer12_V2_DATA_AK5PF_UncertaintySources.txt'),
1325 jetCorrUncertaintyTag = cms.string(
"SubTotalDataMC"),
1326 minJetPt = cms.double(10.0),
1327 shiftBy = cms.double(+1.*varyByNsigmas),
1328 unclEnUncertainty = cms.double(0.10)
1330 metUncertaintySequence += getattr(process,
"pfCandsUnclusteredEnUpForNoPileUpPFMEt"+postfix)
1331 setattr(process,
"pfCandidateToVertexAssociationUnclusteredEnUpForNoPileUpPFMEt"+postfix, process.pfCandidateToVertexAssociation.clone(
1332 PFCandidateCollection = cms.InputTag(
'pfCandsUnclusteredEnUpForNoPileUpPFMEt'+postfix)
1334 metUncertaintySequence += getattr(process,
"pfCandidateToVertexAssociationUnclusteredEnUpForNoPileUpPFMEt"+postfix)
1335 setattr(process,
"noPileUpPFMEtDataUnclusteredEnUp"+postfix, getattr(process,
"noPileUpPFMEtData"+postfix).
clone(
1336 srcPFCandidates = cms.InputTag(
'pfCandsUnclusteredEnUpForNoPileUpPFMEt'+postfix),
1337 srcPFCandToVertexAssociations = cms.InputTag(
'pfCandidateToVertexAssociationUnclusteredEnUpForNoPileUpPFMEt'+postfix),
1339 metUncertaintySequence += getattr(process,
"noPileUpPFMEtDataUnclusteredEnUp"+postfix)
1340 setattr(process,
"noPileUpPFMEtUnclusteredEnUp"+postfix, getattr(process,
"noPileUpPFMEt"+postfix).
clone(
1341 srcMVAMEtData = cms.InputTag(
'noPileUpPFMEtDataUnclusteredEnUp'+postfix),
1344 metUncertaintySequence += getattr(process,
"noPileUpPFMEtUnclusteredEnUp"+postfix)
1346 'noPileUpPFMEtUnclusteredEnUp'+postfix,
'patPFMetNoPileUpUnclusteredEnUp', collectionsToKeep, postfix)
1347 setattr(process,
"pfCandsUnclusteredEnDownForNoPileUpPFMEt"+postfix, getattr(process,
"pfCandsUnclusteredEnUpForNoPileUpPFMEt"+postfix).
clone(
1348 shiftBy = cms.double(-1.*varyByNsigmas),
1350 metUncertaintySequence += getattr(process,
"pfCandsUnclusteredEnDownForNoPileUpPFMEt"+postfix)
1351 setattr(process,
"pfCandidateToVertexAssociationUnclusteredEnDownForNoPileUpPFMEt"+postfix, process.pfCandidateToVertexAssociation.clone(
1352 PFCandidateCollection = cms.InputTag(
'pfCandsUnclusteredEnDownForNoPileUpPFMEt'+postfix)
1354 metUncertaintySequence += getattr(process,
"pfCandidateToVertexAssociationUnclusteredEnDownForNoPileUpPFMEt"+postfix)
1355 setattr(process,
"noPileUpPFMEtDataUnclusteredEnDown"+postfix, getattr(process,
"noPileUpPFMEtData"+postfix).
clone(
1356 srcPFCandidates = cms.InputTag(
'pfCandsUnclusteredEnDownForNoPileUpPFMEt'+postfix),
1357 srcPFCandToVertexAssociations = cms.InputTag(
'pfCandidateToVertexAssociationUnclusteredEnDownForNoPileUpPFMEt'+postfix),
1359 metUncertaintySequence += getattr(process,
"noPileUpPFMEtDataUnclusteredEnDown"+postfix)
1360 setattr(process,
"noPileUpPFMEtUnclusteredEnDown"+postfix, getattr(process,
"noPileUpPFMEt"+postfix).
clone(
1361 srcMVAMEtData = cms.InputTag(
'noPileUpPFMEtDataUnclusteredEnDown'+postfix),
1364 metUncertaintySequence += getattr(process,
"noPileUpPFMEtUnclusteredEnDown"+postfix)
1366 'noPileUpPFMEtUnclusteredEnDown'+postfix,
'patPFMetNoPileUpUnclusteredEnDown', collectionsToKeep, postfix)
1369 electronCollection =
None,
1370 photonCollection =
None,
1371 muonCollection =
None,
1372 tauCollection =
None,
1373 jetCollection =
None,
1374 dRjetCleaning =
None,
1375 jetCorrLabel =
None,
1377 makeType1corrPFMEt =
None,
1378 makeType1p2corrPFMEt =
None,
1379 makePFMEtByMVA =
None,
1380 makeNoPileUpPFMEt =
None,
1381 doApplyType0corr =
None,
1382 sysShiftCorrParameter =
None,
1383 doApplySysShiftCorr =
None,
1384 jetSmearFileName =
None,
1385 jetSmearHistogram =
None,
1386 pfCandCollection =
None,
1387 jetCorrPayloadName =
None,
1388 varyByNsigmas =
None,
1389 addToPatDefaultSequence =
None,
1390 outputModule =
None,
1397 if jetCorrLabel
is None:
1399 if dRjetCleaning
is None:
1401 if doSmearJets
is None:
1403 if makeType1corrPFMEt
is None:
1405 if makeType1p2corrPFMEt
is None:
1407 if makePFMEtByMVA
is None:
1409 if makeNoPileUpPFMEt
is None:
1411 if doApplyType0corr
is None:
1413 if sysShiftCorrParameter
is None:
1415 if doApplySysShiftCorr
is None:
1417 if sysShiftCorrParameter
is None:
1418 if doApplySysShiftCorr:
1419 raise ValueError(
"MET sys. shift correction parameters must be specified explicitely !!")
1420 sysShiftCorrParameter = cms.PSet()
1421 if jetSmearFileName
is None:
1423 if jetSmearHistogram
is None:
1426 if jetCorrPayloadName
is None:
1428 if varyByNsigmas
is None:
1430 if addToPatDefaultSequence
is None:
1432 if outputModule
is None:
1437 self.setParameter(
'electronCollection', electronCollection)
1438 self.setParameter(
'photonCollection', photonCollection)
1439 self.setParameter(
'muonCollection', muonCollection)
1440 self.setParameter(
'tauCollection', tauCollection)
1441 self.setParameter(
'jetCollection', jetCollection)
1442 self.setParameter(
'jetCorrLabel', jetCorrLabel)
1443 self.setParameter(
'dRjetCleaning', dRjetCleaning)
1444 self.setParameter(
'doSmearJets', doSmearJets)
1445 self.setParameter(
'makeType1corrPFMEt', makeType1corrPFMEt)
1446 self.setParameter(
'makeType1p2corrPFMEt', makeType1p2corrPFMEt)
1447 self.setParameter(
'makePFMEtByMVA', makePFMEtByMVA)
1448 self.setParameter(
'makeNoPileUpPFMEt', makeNoPileUpPFMEt)
1449 self.setParameter(
'doApplyType0corr', doApplyType0corr)
1450 self.setParameter(
'doApplySysShiftCorr', doApplySysShiftCorr)
1451 self.setParameter(
'sysShiftCorrParameter', sysShiftCorrParameter)
1452 self.setParameter(
'jetSmearFileName', jetSmearFileName)
1453 self.setParameter(
'jetSmearHistogram', jetSmearHistogram)
1454 self.setParameter(
'pfCandCollection', pfCandCollection)
1455 self.setParameter(
'jetCorrPayloadName', jetCorrPayloadName)
1456 self.setParameter(
'varyByNsigmas', varyByNsigmas)
1457 self.setParameter(
'addToPatDefaultSequence', addToPatDefaultSequence)
1458 self.setParameter(
'outputModule', outputModule)
1459 self.setParameter(
'postfix', postfix)
1464 electronCollection = self._parameters[
'electronCollection'].value
1465 photonCollection = self._parameters[
'photonCollection'].value
1466 muonCollection = self._parameters[
'muonCollection'].value
1467 tauCollection = self._parameters[
'tauCollection'].value
1468 jetCollection = self._parameters[
'jetCollection'].value
1469 jetCorrLabel = self._parameters[
'jetCorrLabel'].value
1470 dRjetCleaning = self._parameters[
'dRjetCleaning'].value
1471 doSmearJets = self._parameters[
'doSmearJets'].value
1472 makeType1corrPFMEt = self._parameters[
'makeType1corrPFMEt'].value
1473 makeType1p2corrPFMEt = self._parameters[
'makeType1p2corrPFMEt'].value
1474 makePFMEtByMVA = self._parameters[
'makePFMEtByMVA'].value
1475 makeNoPileUpPFMEt = self._parameters[
'makeNoPileUpPFMEt'].value
1476 doApplyType0corr = self._parameters[
'doApplyType0corr'].value
1477 sysShiftCorrParameter = self._parameters[
'sysShiftCorrParameter'].value
1478 doApplySysShiftCorr = self._parameters[
'doApplySysShiftCorr'].value
1479 jetSmearFileName = self._parameters[
'jetSmearFileName'].value
1480 jetSmearHistogram = self._parameters[
'jetSmearHistogram'].value
1481 pfCandCollection = self._parameters[
'pfCandCollection'].value
1482 jetCorrPayloadName = self._parameters[
'jetCorrPayloadName'].value
1483 varyByNsigmas = self._parameters[
'varyByNsigmas'].value
1484 addToPatDefaultSequence = self._parameters[
'addToPatDefaultSequence'].value
1485 outputModule = self._parameters[
'outputModule'].value
1486 postfix = self._parameters[
'postfix'].value
1488 metUncertaintySequence = cms.Sequence()
1489 setattr(process,
"metUncertaintySequence"+postfix, metUncertaintySequence)
1491 collectionsToKeep = []
1495 jetsNotOverlappingWithLeptonsForMEtUncertainty = cms.EDProducer(
"PATJetCleaner",
1496 src = jetCollection,
1497 preselection = cms.string(
''),
1498 checkOverlaps = cms.PSet(),
1499 finalCut = cms.string(
'')
1501 numOverlapCollections = 0
1503 [
'electrons', electronCollection ],
1504 [
'photons', photonCollection ],
1505 [
'muons', muonCollection ],
1506 [
'taus', tauCollection ] ]:
1508 setattr(jetsNotOverlappingWithLeptonsForMEtUncertainty.checkOverlaps, collection[0], cms.PSet(
1509 src = collection[1],
1510 algorithm = cms.string(
"byDeltaR"),
1511 preselection = cms.string(
""),
1512 deltaR = cms.double(0.5),
1513 checkRecoComponents = cms.bool(
False),
1514 pairCut = cms.string(
""),
1515 requireNoOverlaps = cms.bool(
True),
1517 numOverlapCollections = numOverlapCollections + 1
1518 lastJetCollection = jetCollection.value()
1519 if numOverlapCollections >= 1:
1520 lastJetCollection = \
1522 [ jetCollection.value(),
"NotOverlappingWithLeptonsForMEtUncertainty" ],
1523 metUncertaintySequence, postfix)
1524 cleanedJetCollection = lastJetCollection
1528 jetCollectionResUp =
None
1529 jetCollectionResDown =
None
1531 lastJetCollection = \
1532 self.
_addSmearedJets(process, cleanedJetCollection, [
"smeared", jetCollection.value() ],
1533 jetSmearFileName, jetSmearHistogram, varyByNsigmas, postfix=postfix)
1535 jetCollectionResUp = \
1536 self.
_addSmearedJets(process, cleanedJetCollection, [
"smeared", jetCollection.value(),
"ResUp" ],
1537 jetSmearFileName, jetSmearHistogram, varyByNsigmas,
1538 -1., postfix=postfix)
1539 collectionsToKeep.append(jetCollectionResUp)
1540 jetCollectionResDown = \
1541 self.
_addSmearedJets(process, cleanedJetCollection, [
"smeared", jetCollection.value(),
"ResDown" ],
1542 jetSmearFileName, jetSmearHistogram, varyByNsigmas,
1543 +1., postfix=postfix)
1544 collectionsToKeep.append(jetCollectionResDown)
1546 collectionsToKeep.append(lastJetCollection)
1553 shiftedParticleCollections, addCollectionsToKeep = \
1559 jetCollection, cleanedJetCollection, lastJetCollection,
1560 jetCollectionResUp, jetCollectionResDown,
1563 metUncertaintySequence += getattr(process,
"shiftedParticlesForMEtUncertainties"+postfix)
1564 collectionsToKeep.extend(addCollectionsToKeep)
1571 shiftedParticleCollections, pfCandCollection,
1575 makeType1p2corrPFMEt,
1577 sysShiftCorrParameter,
1578 doApplySysShiftCorr,
1588 shiftedParticleCollections, pfCandCollection,
1600 shiftedParticleCollections, pfCandCollection,
1608 if addToPatDefaultSequence
and process.options.allowUnscheduled ==
False:
1609 if not hasattr(process,
"patDefaultSequence"):
1610 raise ValueError(
"PAT default sequence is not defined !!")
1611 process.patDefaultSequence += metUncertaintySequence
1615 if outputModule
is not None and hasattr(process, outputModule):
1617 getattr(process, outputModule).outputCommands,
1618 [
'keep *_%s_*_%s' % (collectionToKeep, process.name_())
for collectionToKeep
in collectionsToKeep ])