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