1 import FWCore.ParameterSet.Config
as cms
6 from PhysicsTools.PatAlgos.tools.trigTools
import _addEventContent
7 from PhysicsTools.PatUtils.tools.jmeUncertaintyTools
import JetMEtUncertaintyTools
15 """ Produce collection of pat::Jets with jet energy and resolution shifted up/down, 16 in order to estimate effect of systematic uncertainties 18 _label=
'runJetUncertainties' 19 _defaultParameters = dicttypes.SortedKeysDict()
21 JetMEtUncertaintyTools.__init__(self)
23 "Eta-phi distance for extra jet cleaning", Type=float)
28 electronCollection =
None,
29 photonCollection =
None,
30 muonCollection =
None,
36 jetSmearFileName =
None,
37 jetSmearHistogram =
None,
38 jetCorrPayloadName =
None,
39 jetCorrLabelUpToL3 =
None,
40 jetCorrLabelUpToL3Res =
None,
41 jecUncertaintyFile =
None,
42 jecUncertaintyTag =
None,
44 addToPatDefaultSequence =
None,
47 JetMEtUncertaintyTools.__call__(
49 electronCollection = electronCollection,
50 photonCollection = photonCollection,
51 muonCollection = muonCollection,
52 tauCollection = tauCollection,
53 jetCollection = jetCollection,
54 jetCorrLabel = jetCorrLabel,
55 doSmearJets = doSmearJets,
56 jetSmearFileName = jetSmearFileName,
57 jetSmearHistogram = jetSmearHistogram,
58 jetCorrPayloadName = jetCorrPayloadName,
59 jetCorrLabelUpToL3 = jetCorrLabelUpToL3,
60 jetCorrLabelUpToL3Res = jetCorrLabelUpToL3Res,
61 jecUncertaintyFile = jecUncertaintyFile,
62 jecUncertaintyTag = jecUncertaintyTag,
63 varyByNsigmas = varyByNsigmas,
64 addToPatDefaultSequence = addToPatDefaultSequence,
65 outputModule = outputModule,
67 if dRjetCleaning
is None:
70 self.setParameter(
'dRjetCleaning', dRjetCleaning)
75 electronCollection = self.
_parameters[
'electronCollection'].value
76 photonCollection = self.
_parameters[
'photonCollection'].value
77 muonCollection = self.
_parameters[
'muonCollection'].value
78 tauCollection = self.
_parameters[
'tauCollection'].value
79 jetCollection = self.
_parameters[
'jetCollection'].value
80 jetCorrLabel = self.
_parameters[
'jetCorrLabel'].value
81 dRjetCleaning = self.
_parameters[
'dRjetCleaning'].value
83 jetSmearFileName = self.
_parameters[
'jetSmearFileName'].value
84 jetSmearHistogram = self.
_parameters[
'jetSmearHistogram'].value
85 jetCorrPayloadName = self.
_parameters[
'jetCorrPayloadName'].value
86 jetCorrLabelUpToL3 = self.
_parameters[
'jetCorrLabelUpToL3'].value
87 jetCorrLabelUpToL3Res = self.
_parameters[
'jetCorrLabelUpToL3Res'].value
88 jecUncertaintyFile = self.
_parameters[
'jecUncertaintyFile'].value
89 jecUncertaintyTag = self.
_parameters[
'jecUncertaintyTag'].value
90 varyByNsigmas = self.
_parameters[
'varyByNsigmas'].value
91 addToPatDefaultSequence = self.
_parameters[
'addToPatDefaultSequence'].value
92 outputModule = self.
_parameters[
'outputModule'].value
95 if not hasattr(process,
"jetUncertaintySequence" + postfix):
96 jetUncertaintySequence = cms.Sequence()
97 setattr(process,
"jetUncertaintySequence" + postfix, jetUncertaintySequence)
98 jetUncertaintySequence = getattr(process,
"jetUncertaintySequence" + postfix)
100 collectionsToKeep = []
104 lastJetCollection, cleanedJetCollection = \
105 self._addCleanedJets(process, jetCollection,
106 electronCollection, photonCollection, muonCollection, tauCollection,
107 jetUncertaintySequence, postfix)
111 jetCollectionResUp =
None 112 jetCollectionResDown =
None 114 lastJetCollection = \
115 self._addSmearedJets(process, cleanedJetCollection, [
"smeared", jetCollection.value() ],
116 jetSmearFileName, jetSmearHistogram, varyByNsigmas,
117 uncertaintySequence = jetUncertaintySequence, postfix = postfix)
118 jetCollectionResUp = \
119 self._addSmearedJets(process, cleanedJetCollection, [
"smeared", jetCollection.value(),
"ResUp" ],
120 jetSmearFileName, jetSmearHistogram, varyByNsigmas, -1.,
121 uncertaintySequence = jetUncertaintySequence, postfix = postfix)
122 collectionsToKeep.append(jetCollectionResUp)
123 jetCollectionResDown = \
124 self._addSmearedJets(process, cleanedJetCollection, [
"smeared", jetCollection.value(),
"ResDown" ],
125 jetSmearFileName, jetSmearHistogram, varyByNsigmas, +1.,
126 uncertaintySequence = jetUncertaintySequence, postfix = postfix)
127 collectionsToKeep.append(jetCollectionResDown)
129 collectionsToKeep.append(lastJetCollection)
136 shiftedParticleSequence, shiftedParticleCollections, addCollectionsToKeep = \
137 self._addShiftedParticleCollections(process,
142 jetCollection, cleanedJetCollection, lastJetCollection,
143 jetCollectionResUp, jetCollectionResDown,
144 jetCorrLabelUpToL3, jetCorrLabelUpToL3Res,
145 jecUncertaintyFile, jecUncertaintyTag,
148 setattr(process,
"shiftedParticlesForJetUncertainties" + postfix, shiftedParticleSequence)
149 jetUncertaintySequence += getattr(process,
"shiftedParticlesForJetUncertainties" + postfix)
150 collectionsToKeep.extend(addCollectionsToKeep)
153 if addToPatDefaultSequence:
154 if not hasattr(process,
"patDefaultSequence"):
155 raise ValueError(
"PAT default sequence is not defined !!")
156 process.patDefaultSequence += jetUncertaintySequence
160 if outputModule
is not None and hasattr(process, outputModule):
162 getattr(process, outputModule).outputCommands,
163 [
'keep *_%s_*_%s' % (collectionToKeep, process.name_())
for collectionToKeep
in collectionsToKeep ])
def __call__(self, process, electronCollection=None, photonCollection=None, muonCollection=None, tauCollection=None, jetCollection=None, dRjetCleaning=None, jetCorrLabel=None, doSmearJets=None, jetSmearFileName=None, jetSmearHistogram=None, jetCorrPayloadName=None, jetCorrLabelUpToL3=None, jetCorrLabelUpToL3Res=None, jecUncertaintyFile=None, jecUncertaintyTag=None, varyByNsigmas=None, addToPatDefaultSequence=None, outputModule=None, postfix=None)
def toolCode(self, process)