5 if isinstance(input, cms.InputTag):
6 input_str = input.value()
7 if input
is None or input_str ==
'""':
15 if not len(moduleName_parts) > 0:
16 raise ValueError(
"Empty list !!")
21 for part
in moduleName_parts:
22 if part
is None or part ==
"":
25 part = part.replace(
"selected",
"")
26 part = part.replace(
"clean",
"")
29 moduleName += part[0].lower() + part[1:]
32 if lastPart[-1].islower()
or lastPart[-1].isdigit():
33 moduleName += part[0].capitalize() + part[1:]
35 moduleName += part[0].lower() + part[1:]
39 setattr(process, moduleName, module)
48 varyByNsigmas,sequence, postfix =
""):
50 shiftedParticleCollections = {}
51 collectionsToKeep = []
53 shiftedCollectionName = identifier+
"Collection"
54 shiftedParticleCollections[ shiftedCollectionName ] = objectCollection
58 objectCollectionUp =
None
59 objectCollectionDown =
None
68 varyByNsigmas, sequence,postfix)
72 objectModuleUp = getattr(process, objectCollectionUp)
73 shiftedParticleCollections[ shiftedCollectionName+
'EnUp'] = objectCollectionUp
74 collectionsToKeep.append(objectCollectionUp)
79 objectModuleDown = objectModuleUp.clone(
80 shiftBy = cms.double(-1.*varyByNsigmas)
83 [
"shifted", objectCollection,
"EnDown" ],
85 shiftedParticleCollections[ shiftedCollectionName+
'EnDown'] = objectCollectionDown
86 collectionsToKeep.append(objectCollectionDown)
89 return (shiftedParticleCollections, collectionsToKeep)
94 varyByNsigmas,sequence,postfix=
""):
96 shiftedCollectionUp =
None
98 if identifier ==
"electron":
99 shiftedModuleUp = cms.EDProducer(
"ShiftedPATElectronProducer",
100 src = cms.InputTag(objectCollection),
103 binSelection = cms.string(
'isEB'),
104 binUncertainty = cms.double(0.006)
107 binSelection = cms.string(
'!isEB'),
108 binUncertainty = cms.double(0.015)
111 shiftBy = cms.double(+1.*varyByNsigmas)
114 if identifier ==
"photon":
115 shiftedModuleUp = cms.EDProducer(
"ShiftedPATPhotonProducer",
116 src = cms.InputTag(objectCollection),
119 binSelection = cms.string(
'isEB'),
120 binUncertainty = cms.double(0.01)
123 binSelection = cms.string(
'!isEB'),
124 binUncertainty = cms.double(0.025)
127 shiftBy = cms.double(+1.*varyByNsigmas)
130 if identifier ==
"muon":
131 shiftedModuleUp = cms.EDProducer(
"ShiftedPATMuonProducer",
132 src = cms.InputTag(objectCollection),
135 binSelection = cms.string(
'pt < 100'),
136 binUncertainty = cms.double(0.002)
139 binSelection = cms.string(
'pt >= 100'),
140 binUncertainty = cms.double(0.05)
143 shiftBy = cms.double(+1.*varyByNsigmas)
146 if identifier ==
"tau":
147 shiftedModuleUp = cms.EDProducer(
"ShiftedPATTauProducer",
148 src = cms.InputTag(objectCollection),
149 uncertainty = cms.double(0.03),
150 shiftBy = cms.double(+1.*varyByNsigmas)
154 [
"shifted", objectCollection,
"EnUp" ],
157 return shiftedCollectionUp
163 jetCorrLabelUpToL3, jetCorrLabelUpToL3Res,
164 jecUncertaintyFile, jecUncertaintyTag,
165 varyByNsigmas, sequence,
168 shiftedParticleCollections = {}
169 collectionsToKeep = []
171 shiftedParticleCollections[
'jetCollection'] = jetCollection
172 shiftedParticleCollections[
'lastJetCollection'] = lastJetCollection
178 variations = {
"Up":1.,
"Down":-1. }
180 for var
in variations.keys():
184 jetsEnShiftForRawMEt = cms.EDProducer(
"ShiftedPATJetProducer",
185 src = cms.InputTag(lastJetCollection),
188 jetCorrInputFileName = cms.FileInPath(jecUncertaintyFile),
189 jetCorrUncertaintyTag = cms.string(jecUncertaintyTag),
190 addResidualJES = cms.bool(
True),
191 jetCorrLabelUpToL3 = cms.InputTag(jetCorrLabelUpToL3.value()),
192 jetCorrLabelUpToL3Res = cms.InputTag(jetCorrLabelUpToL3Res.value()),
193 shiftBy = cms.double(variations[var]*varyByNsigmas)
196 jetCollectionEnShiftForRawMEt = \
198 [
"shifted", jetCollection,
"En%sForRawMEt"%var ],
200 shiftedParticleCollections[
'jetCollectionEn%sForRawMEt'%var ] = jetCollectionEnShiftForRawMEt
201 collectionsToKeep.append(jetCollectionEnShiftForRawMEt)
207 jetsEnShift = jetsEnShiftForRawMEt.clone(
208 addResidualJES = cms.bool(
False)
213 [
"shifted", jetCollection,
"En"+ var ],
215 shiftedParticleCollections[
'jetCollectionEn' + var ] = jetCollectionEnShift
216 collectionsToKeep.append(jetCollectionEnShift)
219 return (shiftedParticleCollections, collectionsToKeep)
223 def addSmearedJets(process, jetCollection, smearedJetCollectionName_parts,
224 jetSmearFileName, jetSmearHistogram, jetResolutions,
225 varyByNsigmas, shiftBy =
None, sequence =
None, postfix =
""):
227 smearedJets = cms.EDProducer(
"SmearedPATJetProducer",
228 src = cms.InputTag(jetCollection),
229 dRmaxGenJetMatch = cms.string(
'min(0.5, 0.1 + 0.3*exp(-0.05*(genJetPt - 10.)))'),
230 sigmaMaxGenJetMatch = cms.double(3.),
231 inputFileName = cms.FileInPath(jetSmearFileName),
232 lutName = cms.string(jetSmearHistogram),
233 jetResolutions = jetResolutions.METSignificance_params,
245 skipJetSelection = cms.string(
246 'jecSetsAvailable & abs(energy - correctedP4("Uncorrected").energy) > (5.*min(energy, correctedP4("Uncorrected").energy))'
248 skipRawJetPtThreshold = cms.double(10.),
249 skipCorrJetPtThreshold = cms.double(1.e-2),
250 verbosity = cms.int32(0)
252 if shiftBy
is not None:
253 setattr(smearedJets,
"shiftBy", cms.double(shiftBy*varyByNsigmas))
255 smearedJetCollectionName_parts,
258 return smearedJetCollection