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
18 egmPhotonIDSequence = cms.Sequence(cms.Task(egmPhotonIsolationMiniAODTask,photonIDValueMapProducer,photonMVAValueMapProducer,egmPhotonIDs,photonRegressionValueMapProducer))
19 egmPhotonIDs.physicsObjectIDs = cms.VPSet()
20 egmPhotonIDs.physicsObjectSrc = cms.InputTag(
'slimmedPhotons')
22 _photon_id_vid_modules_WorkingPoints = cms.PSet(
23 modules = cms.vstring(
24 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff',
25 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1_cff',
27 WorkingPoints = cms.vstring(
30 "egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V1-medium",
34 run2_miniAOD_80XLegacy.toModify(_photon_id_vid_modules_WorkingPoints,
35 modules = cms.vstring(
36 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
37 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff',
39 WorkingPoints = cms.vstring(
40 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-loose",
41 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-medium",
42 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-tight",
45 run2_nanoAOD_94X2016.toModify(_photon_id_vid_modules_WorkingPoints,
46 modules = cms.vstring(
47 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
49 WorkingPoints = cms.vstring(
50 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-loose",
51 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-medium",
52 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-tight",
57 _bitmapVIDForPho_docstring =
'' 58 for modname
in _photon_id_vid_modules_WorkingPoints.modules:
59 ids= __import__(modname, globals(), locals(), [
'idName',
'cutFlow'])
61 _id = getattr(ids,name)
62 if hasattr(_id,
'idName')
and hasattr(_id,
'cutFlow'):
64 if (len(_photon_id_vid_modules_WorkingPoints.WorkingPoints)>0
and _id.idName==_photon_id_vid_modules_WorkingPoints.WorkingPoints[0].
split(
':')[-1]):
65 _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_vid_modules_WorkingPoints.WorkingPoints)+1,2))))
67 bitmapVIDForPho = cms.EDProducer(
"PhoVIDNestedWPBitmapProducer",
68 src = cms.InputTag(
"slimmedPhotons"),
69 WorkingPoints = _photon_id_vid_modules_WorkingPoints.WorkingPoints,
72 isoForPho = cms.EDProducer(
"PhoIsoValueMapProducer",
73 src = cms.InputTag(
"slimmedPhotons"),
74 relative = cms.bool(
False),
75 rho_PFIso = cms.InputTag(
"fixedGridRhoFastjetAll"),
76 mapIsoChg = cms.InputTag(
"photonIDValueMapProducer:phoChargedIsolation"),
77 mapIsoNeu = cms.InputTag(
"photonIDValueMapProducer:phoNeutralHadronIsolation"),
78 mapIsoPho = cms.InputTag(
"photonIDValueMapProducer:phoPhotonIsolation"),
79 EAFile_PFIso_Chg = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfChargedHadrons_90percentBased_TrueVtx.txt"),
80 EAFile_PFIso_Neu = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfNeutralHadrons_90percentBased_TrueVtx.txt"),
81 EAFile_PFIso_Pho = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Fall17/effAreaPhotons_cone03_pfPhotons_90percentBased_TrueVtx.txt"),
83 run2_miniAOD_80XLegacy.toModify(isoForPho,
84 EAFile_PFIso_Chg = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Spring16/effAreaPhotons_cone03_pfChargedHadrons_90percentBased.txt"),
85 EAFile_PFIso_Neu = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Spring16/effAreaPhotons_cone03_pfNeutralHadrons_90percentBased.txt"),
86 EAFile_PFIso_Pho = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Spring16/effAreaPhotons_cone03_pfPhotons_90percentBased.txt"),
89 import EgammaAnalysis.ElectronTools.calibratedPhotonsRun2_cfi
90 calibratedPatPhotons80X = EgammaAnalysis.ElectronTools.calibratedPhotonsRun2_cfi.calibratedPatPhotons.clone(
91 correctionFile = cms.string(
"PhysicsTools/NanoAOD/data/80X_ichepV2_2016_pho"),
92 semiDeterministic = cms.bool(
True),
94 energyCorrForPhoton80X = cms.EDProducer(
"PhotonEnergyVarProducer",
95 srcRaw = cms.InputTag(
"slimmedPhotons"),
96 srcCorr = cms.InputTag(
"calibratedPatPhotons80X"),
98 import RecoEgamma.EgammaTools.calibratedEgammas_cff
99 calibratedPatPhotons94Xv1 = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatPhotons.clone(
100 produceCalibratedObjs =
False 104 slimmedPhotonsWithUserData = cms.EDProducer(
"PATPhotonUserDataEmbedder",
105 src = cms.InputTag(
"slimmedPhotons"),
106 userFloats = cms.PSet(
107 mvaID = cms.InputTag(
"photonMVAValueMapProducer:PhotonMVAEstimatorRunIIFall17v1Values"),
108 PFIsoChg = cms.InputTag(
"isoForPho:PFIsoChg"),
109 PFIsoAll = cms.InputTag(
"isoForPho:PFIsoAll"),
111 userIntFromBools = cms.PSet(
112 cutbasedID_loose = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V1-loose"),
113 cutbasedID_medium = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V1-medium"),
114 cutbasedID_tight = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Fall17-94X-V1-tight"),
115 mvaID_WP90 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-RunIIFall17-v1-wp90"),
116 mvaID_WP80 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-RunIIFall17-v1-wp80"),
119 VIDNestedWPBitmap = cms.InputTag(
"bitmapVIDForPho"),
122 run2_miniAOD_80XLegacy.toModify(slimmedPhotonsWithUserData.userFloats,
123 mvaID = cms.InputTag(
"photonMVAValueMapProducer:PhotonMVAEstimatorRun2Spring16NonTrigV1Values"),
124 eCorr = cms.InputTag(
"energyCorrForPhoton80X",
"eCorr")
126 run2_miniAOD_80XLegacy.toModify(slimmedPhotonsWithUserData.userIntFromBools,
127 cutbasedID_loose = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-loose"),
128 cutbasedID_medium = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-medium"),
129 cutbasedID_tight = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-tight"),
130 mvaID_WP90 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-Spring16-nonTrig-V1-wp90"),
131 mvaID_WP80 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-Spring16-nonTrig-V1-wp80"),
133 run2_nanoAOD_94X2016.toModify(slimmedPhotonsWithUserData.userFloats,
136 run2_nanoAOD_94X2016.toModify(slimmedPhotonsWithUserData.userIntFromBools,
137 cutbasedID_loose = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-loose"),
138 cutbasedID_medium = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-medium"),
139 cutbasedID_tight = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-tight"),
144 run2_nanoAOD_94XMiniAODv1.toModify(slimmedPhotonsWithUserData.userFloats,
145 ecalEnergyErrPostCorr = cms.InputTag(
"calibratedPatPhotons94Xv1",
"ecalEnergyErrPostCorr"),
146 ecalEnergyPreCorr = cms.InputTag(
"calibratedPatPhotons94Xv1",
"ecalEnergyPreCorr"),
147 ecalEnergyPostCorr = cms.InputTag(
"calibratedPatPhotons94Xv1",
"ecalEnergyPostCorr"),
150 finalPhotons = cms.EDFilter(
"PATPhotonRefSelector",
151 src = cms.InputTag(
"slimmedPhotonsWithUserData"),
152 cut = cms.string(
"pt > 5 ")
155 photonTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
156 src = cms.InputTag(
"linkedObjects",
"photons"),
157 cut = cms.string(
""),
158 name= cms.string(
"Photon"),
159 doc = cms.string(
"slimmedPhotons after basic selection (" + finalPhotons.cut.value()+
")"),
160 singleton = cms.bool(
False),
161 extension = cms.bool(
False),
162 variables = cms.PSet(CandVars,
163 jetIdx =
Var(
"?hasUserCand('jet')?userCand('jet').key():-1", int, doc=
"index of the associated jet (-1 if none)"),
164 electronIdx =
Var(
"?hasUserCand('electron')?userCand('electron').key():-1", int, doc=
"index of the associated electron (-1 if none)"),
165 energyErr =
Var(
"getCorrectedEnergyError('regression2')",float,doc=
"energy error of the cluster from regression",precision=6),
166 r9 =
Var(
"full5x5_r9()",float,doc=
"R9 of the supercluster, calculated with full 5x5 region",precision=10),
167 sieie =
Var(
"full5x5_sigmaIetaIeta()",float,doc=
"sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10),
168 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)"),
169 vidNestedWPBitmap =
Var(
"userInt('VIDNestedWPBitmap')",int,doc=_bitmapVIDForPho_docstring),
170 electronVeto =
Var(
"passElectronVeto()",bool,doc=
"pass electron veto"),
171 pixelSeed =
Var(
"hasPixelSeed()",bool,doc=
"has pixel seed"),
172 mvaID =
Var(
"userFloat('mvaID')",float,doc=
"MVA ID score",precision=10),
173 mvaID_WP90 =
Var(
"userInt('mvaID_WP90')",bool,doc=
"MVA ID WP90"),
174 mvaID_WP80 =
Var(
"userInt('mvaID_WP80')",bool,doc=
"MVA ID WP80"),
175 pfRelIso03_chg =
Var(
"userFloat('PFIsoChg')/pt",float,doc=
"PF relative isolation dR=0.3, charged component (with rho*EA PU corrections)"),
176 pfRelIso03_all =
Var(
"userFloat('PFIsoAll')/pt",float,doc=
"PF relative isolation dR=0.3, total (with rho*EA PU corrections)"),
177 hoe =
Var(
"hadronicOverEm()",float,doc=
"H over E",precision=8),
178 isScEtaEB =
Var(
"abs(superCluster().eta()) < 1.4442",bool,doc=
"is supercluster eta within barrel acceptance"),
179 isScEtaEE =
Var(
"abs(superCluster().eta()) > 1.566 && abs(superCluster().eta()) < 2.5",bool,doc=
"is supercluster eta within endcap acceptance"),
182 for modifier
in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016:
183 modifier.toModify(photonTable.variables,
184 pt =
Var(
"pt*userFloat('ecalEnergyPostCorr')/userFloat('ecalEnergyPreCorr')", float, precision=-1, doc=
"p_{T}"),
185 energyErr =
Var(
"userFloat('ecalEnergyErrPostCorr')",float,doc=
"energy error of the cluster from regression",precision=6),
186 eCorr =
Var(
"userFloat('ecalEnergyPostCorr')/userFloat('ecalEnergyPreCorr')",float,doc=
"ratio of the calibrated energy/miniaod energy"),
188 run2_nanoAOD_94X2016.toModify(photonTable.variables,
189 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)"),
190 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)"),
191 mvaID =
Var(
"userFloat('PhotonMVAEstimatorRun2Spring16NonTrigV1Values')",float,doc=
"MVA Spring16NonTrigV1 ID score",precision=10),
192 mvaID17 =
Var(
"userFloat('PhotonMVAEstimatorRunIIFall17v1p1Values')",float,doc=
"MVA Fall17v1p1 ID score",precision=10),
193 mvaID_WP90 =
Var(
"photonID('mvaPhoID-Spring16-nonTrig-V1-wp80')",bool,doc=
"MVA Spring16NonTrigV1 ID WP90"),
194 mvaID_WP80 =
Var(
"photonID('mvaPhoID-Spring16-nonTrig-V1-wp90')",bool,doc=
"MVA Spring16NonTrigV1 ID WP80"),
195 mvaID17_WP90 =
Var(
"photonID('mvaPhoID-RunIIFall17-v1p1-wp80')",bool,doc=
"MVA Fall17v1p1 ID WP90"),
196 mvaID17_WP80 =
Var(
"photonID('mvaPhoID-RunIIFall17-v1p1-wp90')",bool,doc=
"MVA Fall17v1p1 ID WP80"),
198 run2_miniAOD_80XLegacy.toModify(photonTable.variables,
199 cutBasedBitmap =
None,
200 cutBased =
Var(
"userInt('cutbasedID_loose')+userInt('cutbasedID_medium')+userInt('cutbasedID_tight')",int,doc=
"cut-based ID (0:fail, 1::loose, 2:medium, 3:tight)"),
201 pt =
Var(
"pt*userFloat('eCorr')", float, precision=-1, doc=
"p_{T} (no energy correction & smearing)"),
202 energyErr =
Var(
"getCorrectedEnergyError('regression2')*userFloat('eCorr')",float,doc=
"energy error of the cluster from regression",precision=6),
203 eCorr =
Var(
"userFloat('eCorr')",float,doc=
"ratio of the calibrated energy/miniaod energy"),
207 photonsMCMatchForTable = cms.EDProducer(
"MCMatcher",
208 src = photonTable.src,
209 matched = cms.InputTag(
"finalGenParticles"),
210 mcPdgId = cms.vint32(11,22),
211 checkCharge = cms.bool(
False),
212 mcStatus = cms.vint32(1),
213 maxDeltaR = cms.double(0.3),
214 maxDPtRel = cms.double(0.5),
215 resolveAmbiguities = cms.bool(
True),
216 resolveByMatchQuality = cms.bool(
True),
219 photonMCTable = cms.EDProducer(
"CandMCMatchTableProducer",
220 src = photonTable.src,
221 mcMap = cms.InputTag(
"photonsMCMatchForTable"),
222 objName = photonTable.name,
223 objType = photonTable.name,
224 branchName = cms.string(
"genPart"),
225 docString = cms.string(
"MC matching to status==1 photons or electrons"),
228 photonSequence = cms.Sequence(egmPhotonIDSequence + bitmapVIDForPho + isoForPho + slimmedPhotonsWithUserData + finalPhotons)
229 photonTables = cms.Sequence ( photonTable)
230 photonMC = cms.Sequence(photonsMCMatchForTable + photonMCTable)
232 _with80XScale_sequence = photonSequence.copy()
233 _with80XScale_sequence.replace(slimmedPhotonsWithUserData, calibratedPatPhotons80X + energyCorrForPhoton80X + slimmedPhotonsWithUserData)
234 run2_miniAOD_80XLegacy.toReplaceWith(photonSequence, _with80XScale_sequence)
236 _with94Xv1Scale_sequence = photonSequence.copy()
237 _with94Xv1Scale_sequence.replace(slimmedPhotonsWithUserData, calibratedPatPhotons94Xv1 + slimmedPhotonsWithUserData)
238 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)