1 import FWCore.ParameterSet.Config
as cms
2 from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff
import run2_miniAOD_80XLegacy
4 from math
import ceil,log
6 from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff
import run2_miniAOD_80XLegacy
7 from Configuration.Eras.Modifier_run2_nanoAOD_92X_cff
import run2_nanoAOD_92X
8 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv1_cff
import run2_nanoAOD_94XMiniAODv1
9 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff
import run2_nanoAOD_94XMiniAODv2
10 from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff
import run2_nanoAOD_94X2016
12 photon_id_modules_WorkingPoints_nanoAOD = cms.PSet(
13 modules = cms.vstring(
14 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff',
15 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V2_cff',
16 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff',
17 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff',
19 WorkingPoints = cms.vstring(
20 "egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-loose",
21 "egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-medium",
22 "egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-tight",
25 run2_miniAOD_80XLegacy.toModify(photon_id_modules_WorkingPoints_nanoAOD,
26 modules = cms.vstring(
27 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
28 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff',
30 WorkingPoints = cms.vstring(
31 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-loose",
32 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-medium",
33 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-tight",
36 run2_nanoAOD_94X2016.toModify(photon_id_modules_WorkingPoints_nanoAOD,
37 modules = cms.vstring(
38 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
40 WorkingPoints = cms.vstring(
41 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-loose",
42 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-medium",
43 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-tight",
48 _bitmapVIDForPho_docstring =
'' 49 for modname
in photon_id_modules_WorkingPoints_nanoAOD.modules:
50 ids= __import__(modname, globals(), locals(), [
'idName',
'cutFlow'])
52 _id = getattr(ids,name)
53 if hasattr(_id,
'idName')
and hasattr(_id,
'cutFlow'):
54 if (len(photon_id_modules_WorkingPoints_nanoAOD.WorkingPoints)>0
and _id.idName==photon_id_modules_WorkingPoints_nanoAOD.WorkingPoints[0].
split(
':')[-1]):
55 _bitmapVIDForPho_docstring =
'VID compressed bitmap (%s), %d bits per cut'%(
','.
join([cut.cutName.value()
for cut
in _id.cutFlow]),
int(ceil(
log(len(photon_id_modules_WorkingPoints_nanoAOD.WorkingPoints)+1,2))))
57 bitmapVIDForPho = cms.EDProducer(
"PhoVIDNestedWPBitmapProducer",
58 src = cms.InputTag(
"slimmedPhotons"),
59 WorkingPoints = photon_id_modules_WorkingPoints_nanoAOD.WorkingPoints,
62 isoForPho = cms.EDProducer(
"PhoIsoValueMapProducer",
63 src = cms.InputTag(
"slimmedPhotons"),
64 relative = cms.bool(
False),
65 rho_PFIso = cms.InputTag(
"fixedGridRhoFastjetAll"),
66 mapIsoChg = cms.InputTag(
"photonIDValueMapProducer:phoChargedIsolation"),
67 mapIsoNeu = cms.InputTag(
"photonIDValueMapProducer:phoNeutralHadronIsolation"),
68 mapIsoPho = cms.InputTag(
"photonIDValueMapProducer:phoPhotonIsolation"),
69 EAFile_PFIso_Chg = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfChargedHadrons_90percentBased_V2.txt"),
70 EAFile_PFIso_Neu = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfNeutralHadrons_90percentBased_V2.txt"),
71 EAFile_PFIso_Pho = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfPhotons_90percentBased_V2.txt"),
73 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
74 modifier.toModify(isoForPho,
75 EAFile_PFIso_Chg = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Spring16/effAreaPhotons_cone03_pfChargedHadrons_90percentBased.txt"),
76 EAFile_PFIso_Neu = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Spring16/effAreaPhotons_cone03_pfNeutralHadrons_90percentBased.txt"),
77 EAFile_PFIso_Pho = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Spring16/effAreaPhotons_cone03_pfPhotons_90percentBased.txt"),
80 import EgammaAnalysis.ElectronTools.calibratedPhotonsRun2_cfi
81 calibratedPatPhotons80X = EgammaAnalysis.ElectronTools.calibratedPhotonsRun2_cfi.calibratedPatPhotons.clone(
82 correctionFile = cms.string(
"PhysicsTools/NanoAOD/data/80X_ichepV2_2016_pho"),
83 semiDeterministic = cms.bool(
True),
85 energyCorrForPhoton80X = cms.EDProducer(
"PhotonEnergyVarProducer",
86 srcRaw = cms.InputTag(
"slimmedPhotons"),
87 srcCorr = cms.InputTag(
"calibratedPatPhotons80X"),
89 import RecoEgamma.EgammaTools.calibratedEgammas_cff
90 calibratedPatPhotons94Xv1 = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatPhotons.clone(
91 produceCalibratedObjs =
False 95 slimmedPhotonsWithUserData = cms.EDProducer(
"PATPhotonUserDataEmbedder",
96 src = cms.InputTag(
"slimmedPhotons"),
97 userFloats = cms.PSet(
98 mvaID = cms.InputTag(
"photonMVAValueMapProducer:PhotonMVAEstimatorRunIIFall17v2Values"),
99 mvaIDV1 = cms.InputTag(
"photonMVAValueMapProducer:PhotonMVAEstimatorRunIIFall17v1p1Values"),
100 PFIsoChg = cms.InputTag(
"isoForPho:PFIsoChg"),
101 PFIsoAll = cms.InputTag(
"isoForPho:PFIsoAll"),
103 userIntFromBools = cms.PSet(
104 cutbasedID_loose = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-loose"),
105 cutbasedID_medium = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-medium"),
106 cutbasedID_tight = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V2-tight"),
107 mvaID_WP90 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-RunIIFall17-v2-wp90"),
108 mvaID_WP80 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-RunIIFall17-v2-wp80"),
109 cutbasedIDV1_loose = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V1-loose"),
110 cutbasedIDV1_medium = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V1-medium"),
111 cutbasedIDV1_tight = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V1-tight"),
112 mvaIDV1_WP90 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-RunIIFall17-v1p1-wp90"),
113 mvaIDV1_WP80 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-RunIIFall17-v1p1-wp80"),
116 VIDNestedWPBitmap = cms.InputTag(
"bitmapVIDForPho"),
119 run2_miniAOD_80XLegacy.toModify(slimmedPhotonsWithUserData.userFloats,
120 mvaID = cms.InputTag(
"photonMVAValueMapProducer:PhotonMVAEstimatorRun2Spring16NonTrigV1Values"),
122 eCorr = cms.InputTag(
"energyCorrForPhoton80X",
"eCorr")
124 run2_miniAOD_80XLegacy.toModify(slimmedPhotonsWithUserData.userIntFromBools,
125 cutbasedID_loose = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-loose"),
126 cutbasedID_medium = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-medium"),
127 cutbasedID_tight = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-tight"),
128 mvaID_WP90 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-Spring16-nonTrig-V1-wp90"),
129 mvaID_WP80 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-Spring16-nonTrig-V1-wp80"),
130 cutbasedIDV1_loose =
None,
131 cutbasedIDV1_medium =
None,
132 cutbasedIDV1_tight =
None,
136 run2_nanoAOD_94X2016.toModify(slimmedPhotonsWithUserData.userFloats,
140 run2_nanoAOD_94X2016.toModify(slimmedPhotonsWithUserData.userIntFromBools,
141 cutbasedID_loose = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-loose"),
142 cutbasedID_medium = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-medium"),
143 cutbasedID_tight = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-tight"),
146 cutbasedIDV1_loose =
None,
147 cutbasedIDV1_medium =
None,
148 cutbasedIDV1_tight =
None,
153 run2_nanoAOD_94XMiniAODv1.toModify(slimmedPhotonsWithUserData.userFloats,
154 ecalEnergyErrPostCorr = cms.InputTag(
"calibratedPatPhotons94Xv1",
"ecalEnergyErrPostCorr"),
155 ecalEnergyPreCorr = cms.InputTag(
"calibratedPatPhotons94Xv1",
"ecalEnergyPreCorr"),
156 ecalEnergyPostCorr = cms.InputTag(
"calibratedPatPhotons94Xv1",
"ecalEnergyPostCorr"),
159 finalPhotons = cms.EDFilter(
"PATPhotonRefSelector",
160 src = cms.InputTag(
"slimmedPhotonsWithUserData"),
161 cut = cms.string(
"pt > 5 ")
164 photonTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
165 src = cms.InputTag(
"linkedObjects",
"photons"),
166 cut = cms.string(
""),
167 name= cms.string(
"Photon"),
168 doc = cms.string(
"slimmedPhotons after basic selection (" + finalPhotons.cut.value()+
")"),
169 singleton = cms.bool(
False),
170 extension = cms.bool(
False),
171 variables = cms.PSet(CandVars,
172 jetIdx =
Var(
"?hasUserCand('jet')?userCand('jet').key():-1", int, doc=
"index of the associated jet (-1 if none)"),
173 electronIdx =
Var(
"?hasUserCand('electron')?userCand('electron').key():-1", int, doc=
"index of the associated electron (-1 if none)"),
174 energyErr =
Var(
"getCorrectedEnergyError('regression2')",float,doc=
"energy error of the cluster from regression",precision=6),
175 r9 =
Var(
"full5x5_r9()",float,doc=
"R9 of the supercluster, calculated with full 5x5 region",precision=10),
176 sieie =
Var(
"full5x5_sigmaIetaIeta()",float,doc=
"sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10),
177 cutBasedBitmap =
Var(
"userInt('cutbasedID_loose')+2*userInt('cutbasedID_medium')+4*userInt('cutbasedID_tight')",int,doc=
"cut-based ID bitmap, 2^(0:loose, 1:medium, 2:tight)"),
178 cutBasedV1Bitmap =
Var(
"userInt('cutbasedIDV1_loose')+2*userInt('cutbasedIDV1_medium')+4*userInt('cutbasedIDV1_tight')",int,doc=
"cut-based ID bitmap, Fall17 V1, 2^(0:loose, 1:medium, 2:tight)"),
179 vidNestedWPBitmap =
Var(
"userInt('VIDNestedWPBitmap')",int,doc=_bitmapVIDForPho_docstring),
180 electronVeto =
Var(
"passElectronVeto()",bool,doc=
"pass electron veto"),
181 pixelSeed =
Var(
"hasPixelSeed()",bool,doc=
"has pixel seed"),
182 mvaID =
Var(
"userFloat('mvaID')",float,doc=
"MVA ID score",precision=10),
183 mvaIDV1 =
Var(
"userFloat('mvaIDV1')",float,doc=
"MVA ID score, Fall17 V1p1",precision=10),
184 mvaID_WP90 =
Var(
"userInt('mvaID_WP90')",bool,doc=
"MVA ID WP90"),
185 mvaID_WP80 =
Var(
"userInt('mvaID_WP80')",bool,doc=
"MVA ID WP80"),
186 pfRelIso03_chg =
Var(
"userFloat('PFIsoChg')/pt",float,doc=
"PF relative isolation dR=0.3, charged component (with rho*EA PU corrections)"),
187 pfRelIso03_all =
Var(
"userFloat('PFIsoAll')/pt",float,doc=
"PF relative isolation dR=0.3, total (with rho*EA PU corrections)"),
188 hoe =
Var(
"hadronicOverEm()",float,doc=
"H over E",precision=8),
189 isScEtaEB =
Var(
"abs(superCluster().eta()) < 1.4442",bool,doc=
"is supercluster eta within barrel acceptance"),
190 isScEtaEE =
Var(
"abs(superCluster().eta()) > 1.566 && abs(superCluster().eta()) < 2.5",bool,doc=
"is supercluster eta within endcap acceptance"),
193 for modifier
in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016:
194 modifier.toModify(photonTable.variables,
195 pt =
Var(
"pt*userFloat('ecalEnergyPostCorr')/userFloat('ecalEnergyPreCorr')", float, precision=-1, doc=
"p_{T}"),
196 energyErr =
Var(
"userFloat('ecalEnergyErrPostCorr')",float,doc=
"energy error of the cluster from regression",precision=6),
197 eCorr =
Var(
"userFloat('ecalEnergyPostCorr')/userFloat('ecalEnergyPreCorr')",float,doc=
"ratio of the calibrated energy/miniaod energy"),
199 run2_nanoAOD_94X2016.toModify(photonTable.variables,
200 cutBasedBitmap =
None,
201 cutBasedV1Bitmap =
None,
202 cutBased =
Var(
"userInt('cutbasedID_loose')+userInt('cutbasedID_medium')+userInt('cutbasedID_tight')",int,doc=
"cut-based Spring16-V2p2 ID (0:fail, 1::loose, 2:medium, 3:tight)"),
203 cutBased17Bitmap =
Var(
"photonID('cutBasedPhotonID-Fall17-94X-V1-loose')+2*photonID('cutBasedPhotonID-Fall17-94X-V1-medium')+4*photonID('cutBasedPhotonID-Fall17-94X-V1-tight')",int,doc=
"cut-based Fall17-94X-V1 ID bitmap, 2^(0:loose, 1:medium, 2:tight)"),
204 mvaID =
Var(
"userFloat('PhotonMVAEstimatorRun2Spring16NonTrigV1Values')",float,doc=
"MVA Spring16NonTrigV1 ID score",precision=10),
206 mvaID17 =
Var(
"userFloat('PhotonMVAEstimatorRunIIFall17v1p1Values')",float,doc=
"MVA Fall17v1p1 ID score",precision=10),
207 mvaID_WP90 =
Var(
"photonID('mvaPhoID-Spring16-nonTrig-V1-wp80')",bool,doc=
"MVA Spring16NonTrigV1 ID WP90"),
208 mvaID_WP80 =
Var(
"photonID('mvaPhoID-Spring16-nonTrig-V1-wp90')",bool,doc=
"MVA Spring16NonTrigV1 ID WP80"),
209 mvaID17_WP90 =
Var(
"photonID('mvaPhoID-RunIIFall17-v1p1-wp90')",bool,doc=
"MVA Fall17v1p1 ID WP90"),
210 mvaID17_WP80 =
Var(
"photonID('mvaPhoID-RunIIFall17-v1p1-wp80')",bool,doc=
"MVA Fall17v1p1 ID WP80"),
212 run2_miniAOD_80XLegacy.toModify(photonTable.variables,
213 cutBasedBitmap =
None,
214 cutBasedV1Bitmap =
None,
216 cutBased =
Var(
"userInt('cutbasedID_loose')+userInt('cutbasedID_medium')+userInt('cutbasedID_tight')",int,doc=
"cut-based ID (0:fail, 1::loose, 2:medium, 3:tight)"),
217 pt =
Var(
"pt*userFloat('eCorr')", float, precision=-1, doc=
"p_{T} (no energy correction & smearing)"),
218 energyErr =
Var(
"getCorrectedEnergyError('regression2')*userFloat('eCorr')",float,doc=
"energy error of the cluster from regression",precision=6),
219 eCorr =
Var(
"userFloat('eCorr')",float,doc=
"ratio of the calibrated energy/miniaod energy"),
223 photonsMCMatchForTable = cms.EDProducer(
"MCMatcher",
224 src = photonTable.src,
225 matched = cms.InputTag(
"finalGenParticles"),
226 mcPdgId = cms.vint32(11,22),
227 checkCharge = cms.bool(
False),
228 mcStatus = cms.vint32(1),
229 maxDeltaR = cms.double(0.3),
230 maxDPtRel = cms.double(0.5),
231 resolveAmbiguities = cms.bool(
True),
232 resolveByMatchQuality = cms.bool(
True),
235 photonMCTable = cms.EDProducer(
"CandMCMatchTableProducer",
236 src = photonTable.src,
237 mcMap = cms.InputTag(
"photonsMCMatchForTable"),
238 objName = photonTable.name,
239 objType = photonTable.name,
240 branchName = cms.string(
"genPart"),
241 docString = cms.string(
"MC matching to status==1 photons or electrons"),
244 photonSequence = cms.Sequence(bitmapVIDForPho + isoForPho + slimmedPhotonsWithUserData + finalPhotons)
245 photonTables = cms.Sequence ( photonTable)
246 photonMC = cms.Sequence(photonsMCMatchForTable + photonMCTable)
248 _with80XScale_sequence = photonSequence.copy()
249 _with80XScale_sequence.replace(slimmedPhotonsWithUserData, calibratedPatPhotons80X + energyCorrForPhoton80X + slimmedPhotonsWithUserData)
250 run2_miniAOD_80XLegacy.toReplaceWith(photonSequence, _with80XScale_sequence)
252 _with94Xv1Scale_sequence = photonSequence.copy()
253 _with94Xv1Scale_sequence.replace(slimmedPhotonsWithUserData, calibratedPatPhotons94Xv1 + slimmedPhotonsWithUserData)
254 run2_nanoAOD_94XMiniAODv1.toReplaceWith(photonSequence, _with94Xv1Scale_sequence)
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
static std::string join(char **cmd)