1 import FWCore.ParameterSet.Config
as cms
2 from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff
import run2_miniAOD_80XLegacy
3 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv1_cff
import run2_nanoAOD_94XMiniAODv1
4 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff
import run2_nanoAOD_94XMiniAODv2
5 from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff
import run2_nanoAOD_94X2016
9 from math
import ceil,log
12 slimmedElectronsUpdated = cms.EDProducer(
"PATElectronUpdater",
13 src = cms.InputTag(
"slimmedElectrons"),
14 vertices = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
15 computeMiniIso = cms.bool(
False),
16 pfCandsForMiniIso = cms.InputTag(
"packedPFCandidates"),
17 miniIsoParamsB = PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi.patElectrons.miniIsoParamsB,
18 miniIsoParamsE = PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi.patElectrons.miniIsoParamsE,
20 run2_miniAOD_80XLegacy.toModify( slimmedElectronsUpdated, computeMiniIso =
True )
22 electron_id_modules_WorkingPoints_nanoAOD = cms.PSet(
23 modules = cms.vstring(
24 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
25 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
26 'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
27 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
28 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
29 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
30 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
32 WorkingPoints = cms.vstring(
33 "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto",
34 "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose",
35 "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium",
36 "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight",
40 for modifier
in run2_miniAOD_80XLegacy,run2_nanoAOD_94X2016:
41 modifier.toModify(electron_id_modules_WorkingPoints_nanoAOD,
42 modules = cms.vstring(
43 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
44 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
45 'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
46 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
47 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
48 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
49 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
50 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
51 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronHLTPreselecition_Summer16_V1_cff',
52 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_25ns_V1_cff',
53 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff',
54 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff',
56 WorkingPoints = cms.vstring(
57 "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto",
58 "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose",
59 "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium",
60 "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight",
67 for modname
in modules:
68 ids= __import__(modname, globals(), locals(), [
'idName',
'cutFlow'])
70 _id = getattr(ids,name)
71 if hasattr(_id,
'idName')
and hasattr(_id,
'cutFlow'):
72 if (len(WorkingPoints)>0
and _id.idName==WorkingPoints[0].
split(
':')[-1]):
73 docstring =
'VID compressed bitmap (%s), %d bits per cut'%(
','.
join([cut.cutName.value()
for cut
in _id.cutFlow]),
int(ceil(
log(len(WorkingPoints)+1,2))))
76 bitmapVIDForEle = cms.EDProducer(
"EleVIDNestedWPBitmapProducer",
77 src = cms.InputTag(
"slimmedElectrons"),
78 WorkingPoints = electron_id_modules_WorkingPoints_nanoAOD.WorkingPoints,
82 bitmapVIDForEleSpring15 = bitmapVIDForEle.clone()
83 bitmapVIDForEleSpring15.WorkingPoints = cms.vstring(
84 "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto",
85 "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose",
86 "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium",
91 bitmapVIDForEleSum16 = bitmapVIDForEle.clone()
92 bitmapVIDForEleSum16.WorkingPoints = cms.vstring(
93 "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto",
94 "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose",
95 "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium",
96 "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight",
100 bitmapVIDForEleHEEP = bitmapVIDForEle.clone()
101 bitmapVIDForEleHEEP.WorkingPoints = cms.vstring(
102 "egmGsfElectronIDs:heepElectronID-HEEPV70" 107 for modifier
in run2_miniAOD_80XLegacy, :
108 modifier.toModify(bitmapVIDForEle, src =
"slimmedElectronsUpdated")
109 modifier.toModify(bitmapVIDForEleSpring15, src =
"slimmedElectronsUpdated")
110 modifier.toModify(bitmapVIDForEleSum16, src =
"slimmedElectronsUpdated")
111 modifier.toModify(bitmapVIDForEleHEEP, src =
"slimmedElectronsUpdated")
113 isoForEle = cms.EDProducer(
"EleIsoValueMapProducer",
114 src = cms.InputTag(
"slimmedElectrons"),
115 relative = cms.bool(
False),
116 rho_MiniIso = cms.InputTag(
"fixedGridRhoFastjetAll"),
117 rho_PFIso = cms.InputTag(
"fixedGridRhoFastjetAll"),
118 EAFile_MiniIso = cms.FileInPath(
"RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
119 EAFile_PFIso = cms.FileInPath(
"RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
121 run2_miniAOD_80XLegacy.toModify(isoForEle, src =
"slimmedElectronsUpdated",
122 EAFile_MiniIso =
"RecoEgamma/ElectronIdentification/data/Spring15/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_25ns.txt",
123 EAFile_PFIso =
"RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_80X.txt")
124 run2_nanoAOD_94X2016.toModify(isoForEle,
125 EAFile_MiniIso =
"RecoEgamma/ElectronIdentification/data/Spring15/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_25ns.txt",
126 EAFile_PFIso =
"RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_80X.txt")
128 ptRatioRelForEle = cms.EDProducer(
"ElectronJetVarProducer",
129 srcJet = cms.InputTag(
"updatedJets"),
130 srcLep = cms.InputTag(
"slimmedElectrons"),
131 srcVtx = cms.InputTag(
"offlineSlimmedPrimaryVertices"),
133 run2_miniAOD_80XLegacy.toModify(ptRatioRelForEle, srcLep =
"slimmedElectronsUpdated")
135 seedGainEle = cms.EDProducer(
"ElectronSeedGainProducer", src = cms.InputTag(
"slimmedElectrons"))
136 run2_miniAOD_80XLegacy.toModify(seedGainEle, src =
"slimmedElectronsUpdated")
138 import EgammaAnalysis.ElectronTools.calibratedElectronsRun2_cfi
140 import RecoEgamma.EgammaTools.calibratedEgammas_cff
142 calibratedPatElectrons80XLegacy = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatElectrons.clone(
143 produceCalibratedObjs =
False,
144 correctionFile = cms.string(
"EgammaAnalysis/ElectronTools/data/ScalesSmearings/Legacy2016_07Aug2017_FineEtaR9_v3_ele_unc"),
146 run2_miniAOD_80XLegacy.toModify(calibratedPatElectrons80XLegacy, src =
"slimmedElectronsUpdated")
148 calibratedPatElectrons94X = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatElectrons.clone(
149 produceCalibratedObjs =
False,
150 correctionFile = cms.string(
"EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_17Nov2017_v1_ele_unc"),
153 calibratedPatElectrons102X = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatElectrons.clone(
154 produceCalibratedObjs =
False,
155 correctionFile = cms.string(
"EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_Step2Closure_CoarseEtaR9Gain_v2"),
158 slimmedElectronsWithUserData = cms.EDProducer(
"PATElectronUserDataEmbedder",
159 src = cms.InputTag(
"slimmedElectrons"),
160 userFloats = cms.PSet(
161 mvaFall17V1Iso = cms.InputTag(
"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV1Values"),
162 mvaFall17V1noIso = cms.InputTag(
"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV1Values"),
163 mvaFall17V2Iso = cms.InputTag(
"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV2Values"),
164 mvaFall17V2noIso = cms.InputTag(
"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV2Values"),
165 miniIsoChg = cms.InputTag(
"isoForEle:miniIsoChg"),
166 miniIsoAll = cms.InputTag(
"isoForEle:miniIsoAll"),
167 PFIsoChg = cms.InputTag(
"isoForEle:PFIsoChg"),
168 PFIsoAll = cms.InputTag(
"isoForEle:PFIsoAll"),
169 PFIsoAll04 = cms.InputTag(
"isoForEle:PFIsoAll04"),
170 ptRatio = cms.InputTag(
"ptRatioRelForEle:ptRatio"),
171 ptRel = cms.InputTag(
"ptRatioRelForEle:ptRel"),
172 jetNDauChargedMVASel = cms.InputTag(
"ptRatioRelForEle:jetNDauChargedMVASel"),
173 dr03TkSumPtHEEP = cms.InputTag(
"heepIDVarValueMaps",
"eleTrkPtIso")
175 userIntFromBools = cms.PSet(
177 mvaFall17V1Iso_WP90 = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp90"),
178 mvaFall17V1Iso_WP80 = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp80"),
179 mvaFall17V1Iso_WPL = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wpLoose"),
180 mvaFall17V1noIso_WP90 = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp90"),
181 mvaFall17V1noIso_WP80 = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp80"),
182 mvaFall17V1noIso_WPL = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wpLoose"),
184 mvaFall17V2Iso_WP90 = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp90"),
185 mvaFall17V2Iso_WP80 = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp80"),
186 mvaFall17V2Iso_WPL = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wpLoose"),
187 mvaFall17V2noIso_WP90 = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp90"),
188 mvaFall17V2noIso_WP80 = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp80"),
189 mvaFall17V2noIso_WPL = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wpLoose"),
191 cutbasedID_Fall17_V1_veto = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-veto"),
192 cutbasedID_Fall17_V1_loose = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-loose"),
193 cutbasedID_Fall17_V1_medium = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-medium"),
194 cutbasedID_Fall17_V1_tight = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-tight"),
195 cutbasedID_Fall17_V2_veto = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto"),
196 cutbasedID_Fall17_V2_loose = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose"),
197 cutbasedID_Fall17_V2_medium = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium"),
198 cutbasedID_Fall17_V2_tight = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight"),
199 cutbasedID_HEEP = cms.InputTag(
"egmGsfElectronIDs:heepElectronID-HEEPV70"),
202 VIDNestedWPBitmap = cms.InputTag(
"bitmapVIDForEle"),
203 VIDNestedWPBitmapHEEP = cms.InputTag(
"bitmapVIDForEleHEEP"),
204 seedGain = cms.InputTag(
"seedGainEle"),
206 userCands = cms.PSet(
207 jetForLepJetVar = cms.InputTag(
"ptRatioRelForEle:jetForLepJetVar")
210 run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData, src =
"slimmedElectronsUpdated")
211 run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userFloats,
212 mvaSpring16GP = cms.InputTag(
"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values"),
213 mvaSpring16HZZ = cms.InputTag(
"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16HZZV1Values"),
215 run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userFloats,
216 ecalTrkEnergyErrPostCorrNew = cms.InputTag(
"calibratedPatElectrons80XLegacy",
"ecalTrkEnergyErrPostCorr"),
217 ecalTrkEnergyPreCorrNew = cms.InputTag(
"calibratedPatElectrons80XLegacy",
"ecalTrkEnergyPreCorr"),
218 ecalTrkEnergyPostCorrNew = cms.InputTag(
"calibratedPatElectrons80XLegacy",
"ecalTrkEnergyPostCorr"),
220 run2_nanoAOD_94XMiniAODv1.toModify(slimmedElectronsWithUserData.userFloats,
221 ecalTrkEnergyErrPostCorrNew = cms.InputTag(
"calibratedPatElectrons94X",
"ecalTrkEnergyErrPostCorr"),
222 ecalTrkEnergyPreCorrNew = cms.InputTag(
"calibratedPatElectrons94X",
"ecalTrkEnergyPreCorr"),
223 ecalTrkEnergyPostCorrNew = cms.InputTag(
"calibratedPatElectrons94X",
"ecalTrkEnergyPostCorr"),
229 run2_nanoAOD_94XMiniAODv2.toModify(slimmedElectronsWithUserData.userFloats,
230 ecalTrkEnergyErrPostCorrNew = cms.InputTag(
"calibratedPatElectrons94X",
"ecalTrkEnergyErrPostCorr"),
231 ecalTrkEnergyPreCorrNew = cms.InputTag(
"calibratedPatElectrons94X",
"ecalTrkEnergyPreCorr"),
232 ecalTrkEnergyPostCorrNew = cms.InputTag(
"calibratedPatElectrons94X",
"ecalTrkEnergyPostCorr"),
235 (~(run2_miniAOD_80XLegacy | run2_nanoAOD_94X2016 | run2_nanoAOD_94XMiniAODv1 | run2_nanoAOD_94XMiniAODv2)).toModify(slimmedElectronsWithUserData.userFloats,
236 ecalTrkEnergyErrPostCorrNew = cms.InputTag(
"calibratedPatElectrons102X",
"ecalTrkEnergyErrPostCorr"),
237 ecalTrkEnergyPreCorrNew = cms.InputTag(
"calibratedPatElectrons102X",
"ecalTrkEnergyPreCorr"),
238 ecalTrkEnergyPostCorrNew = cms.InputTag(
"calibratedPatElectrons102X",
"ecalTrkEnergyPostCorr"),
242 run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userIntFromBools,
243 mvaSpring16GP_WP90 = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp90"),
244 mvaSpring16GP_WP80 = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp80"),
245 mvaSpring16HZZ_WPL = cms.InputTag(
"egmGsfElectronIDs:mvaEleID-Spring16-HZZ-V1-wpLoose"),
246 cutbasedID_Sum16_veto = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto"),
247 cutbasedID_Sum16_loose = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose"),
248 cutbasedID_Sum16_medium = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium"),
249 cutbasedID_Sum16_tight = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight"),
250 cutbasedID_HLT = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1"),
251 cutbasedID_Spring15_veto = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto"),
252 cutbasedID_Spring15_loose = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose"),
253 cutbasedID_Spring15_medium = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium"),
254 cutbasedID_Spring15_tight = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight"),
257 run2_nanoAOD_94X2016.toModify(slimmedElectronsWithUserData.userIntFromBools,
259 cutbasedID_Sum16_veto = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto"),
260 cutbasedID_Sum16_loose = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose"),
261 cutbasedID_Sum16_medium = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium"),
262 cutbasedID_Sum16_tight = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight"),
263 cutbasedID_HLT = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1"),
264 cutbasedID_Spring15_veto = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto"),
265 cutbasedID_Spring15_loose = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose"),
266 cutbasedID_Spring15_medium = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium"),
267 cutbasedID_Spring15_tight = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight"),
268 cutbasedID_Fall17_V2_veto = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto"),
269 cutbasedID_Fall17_V2_loose = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose"),
270 cutbasedID_Fall17_V2_medium = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium"),
271 cutbasedID_Fall17_V2_tight = cms.InputTag(
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight"),
274 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
275 modifier.toModify(slimmedElectronsWithUserData.userInts,
276 VIDNestedWPBitmapSpring15 = cms.InputTag(
"bitmapVIDForEleSpring15"),
277 VIDNestedWPBitmapSum16 = cms.InputTag(
"bitmapVIDForEleSum16"),
280 finalElectrons = cms.EDFilter(
"PATElectronRefSelector",
281 src = cms.InputTag(
"slimmedElectronsWithUserData"),
282 cut = cms.string(
"pt > 5 ")
285 electronMVATTH= cms.EDProducer(
"EleBaseMVAValueMapProducer",
286 src = cms.InputTag(
"linkedObjects",
"electrons"),
287 weightFile = cms.FileInPath(
"PhysicsTools/NanoAOD/data/el_BDTG_2017.weights.xml"),
288 name = cms.string(
"electronMVATTH"),
289 isClassifier = cms.bool(
True),
290 variablesOrder = cms.vstring([
"LepGood_pt",
"LepGood_eta",
"LepGood_jetNDauChargedMVASel",
"LepGood_miniRelIsoCharged",
"LepGood_miniRelIsoNeutral",
"LepGood_jetPtRelv2",
"LepGood_jetDF",
"LepGood_jetPtRatio",
"LepGood_dxy",
"LepGood_sip3d",
"LepGood_dz",
"LepGood_mvaFall17V2noIso"]),
291 variables = cms.PSet(
292 LepGood_pt = cms.string(
"pt"),
293 LepGood_eta = cms.string(
"eta"),
294 LepGood_jetNDauChargedMVASel = cms.string(
"?userCand('jetForLepJetVar').isNonnull()?userFloat('jetNDauChargedMVASel'):0"),
295 LepGood_miniRelIsoCharged = cms.string(
"userFloat('miniIsoChg')/pt"),
296 LepGood_miniRelIsoNeutral = cms.string(
"(userFloat('miniIsoAll')-userFloat('miniIsoChg'))/pt"),
297 LepGood_jetPtRelv2 = cms.string(
"?userCand('jetForLepJetVar').isNonnull()?userFloat('ptRel'):0"),
298 LepGood_jetDF = cms.string(
"?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probbb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:problepb'),0.0):0.0"),
299 LepGood_jetPtRatio = cms.string(
"?userCand('jetForLepJetVar').isNonnull()?min(userFloat('ptRatio'),1.5):1.0/(1.0+userFloat('PFIsoAll04')/pt)"),
300 LepGood_dxy = cms.string(
"log(abs(dB('PV2D')))"),
301 LepGood_sip3d = cms.string(
"abs(dB('PV3D')/edB('PV3D'))"),
302 LepGood_dz = cms.string(
"log(abs(dB('PVDZ')))"),
303 LepGood_mvaFall17V2noIso = cms.string(
"userFloat('mvaFall17V2noIso')"),
306 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
307 modifier.toModify(electronMVATTH,
308 weightFile =
"PhysicsTools/NanoAOD/data/el_BDTG_2016.weights.xml",
311 electronTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
312 src = cms.InputTag(
"linkedObjects",
"electrons"),
313 cut = cms.string(
""),
314 name= cms.string(
"Electron"),
315 doc = cms.string(
"slimmedElectrons after basic selection (" + finalElectrons.cut.value()+
")"),
316 singleton = cms.bool(
False),
317 extension = cms.bool(
False),
318 variables = cms.PSet(CandVars,
319 jetIdx =
Var(
"?hasUserCand('jet')?userCand('jet').key():-1", int, doc=
"index of the associated jet (-1 if none)"),
320 photonIdx =
Var(
"?overlaps('photons').size()>0?overlaps('photons')[0].key():-1", int, doc=
"index of the associated photon (-1 if none)"),
321 energyErr =
Var(
"p4Error('P4_COMBINATION')",float,doc=
"energy error of the cluster-track combination",precision=6),
322 dz =
Var(
"dB('PVDZ')",float,doc=
"dz (with sign) wrt first PV, in cm",precision=10),
323 dzErr =
Var(
"abs(edB('PVDZ'))",float,doc=
"dz uncertainty, in cm",precision=6),
324 dxy =
Var(
"dB('PV2D')",float,doc=
"dxy (with sign) wrt first PV, in cm",precision=10),
325 dxyErr =
Var(
"edB('PV2D')",float,doc=
"dxy uncertainty, in cm",precision=6),
326 ip3d =
Var(
"abs(dB('PV3D'))",float,doc=
"3D impact parameter wrt first PV, in cm",precision=10),
327 sip3d =
Var(
"abs(dB('PV3D')/edB('PV3D'))",float,doc=
"3D impact parameter significance wrt first PV, in cm",precision=10),
328 deltaEtaSC =
Var(
"superCluster().eta()-eta()",float,doc=
"delta eta (SC,ele) with sign",precision=10),
329 r9 =
Var(
"full5x5_r9()",float,doc=
"R9 of the supercluster, calculated with full 5x5 region",precision=10),
330 sieie =
Var(
"full5x5_sigmaIetaIeta()",float,doc=
"sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10),
331 eInvMinusPInv =
Var(
"(1-eSuperClusterOverP())/ecalEnergy()",float,doc=
"1/E_SC - 1/p_trk",precision=10),
333 mvaFall17V1Iso =
Var(
"userFloat('mvaFall17V1Iso')",float,doc=
"MVA Iso ID V1 score"),
334 mvaFall17V1Iso_WP80 =
Var(
"userInt('mvaFall17V1Iso_WP80')",bool,doc=
"MVA Iso ID V1 WP80"),
335 mvaFall17V1Iso_WP90 =
Var(
"userInt('mvaFall17V1Iso_WP90')",bool,doc=
"MVA Iso ID V1 WP90"),
336 mvaFall17V1Iso_WPL =
Var(
"userInt('mvaFall17V1Iso_WPL')",bool,doc=
"MVA Iso ID V1 loose WP"),
337 mvaFall17V1noIso =
Var(
"userFloat('mvaFall17V1noIso')",float,doc=
"MVA noIso ID V1 score"),
338 mvaFall17V1noIso_WP80 =
Var(
"userInt('mvaFall17V1noIso_WP80')",bool,doc=
"MVA noIso ID V1 WP80"),
339 mvaFall17V1noIso_WP90 =
Var(
"userInt('mvaFall17V1noIso_WP90')",bool,doc=
"MVA noIso ID V1 WP90"),
340 mvaFall17V1noIso_WPL =
Var(
"userInt('mvaFall17V1noIso_WPL')",bool,doc=
"MVA noIso ID V1 loose WP"),
342 mvaFall17V2Iso =
Var(
"userFloat('mvaFall17V2Iso')",float,doc=
"MVA Iso ID V2 score"),
343 mvaFall17V2Iso_WP80 =
Var(
"userInt('mvaFall17V2Iso_WP80')",bool,doc=
"MVA Iso ID V2 WP80"),
344 mvaFall17V2Iso_WP90 =
Var(
"userInt('mvaFall17V2Iso_WP90')",bool,doc=
"MVA Iso ID V2 WP90"),
345 mvaFall17V2Iso_WPL =
Var(
"userInt('mvaFall17V2Iso_WPL')",bool,doc=
"MVA Iso ID V2 loose WP"),
346 mvaFall17V2noIso =
Var(
"userFloat('mvaFall17V2noIso')",float,doc=
"MVA noIso ID V2 score"),
347 mvaFall17V2noIso_WP80 =
Var(
"userInt('mvaFall17V2noIso_WP80')",bool,doc=
"MVA noIso ID V2 WP80"),
348 mvaFall17V2noIso_WP90 =
Var(
"userInt('mvaFall17V2noIso_WP90')",bool,doc=
"MVA noIso ID V2 WP90"),
349 mvaFall17V2noIso_WPL =
Var(
"userInt('mvaFall17V2noIso_WPL')",bool,doc=
"MVA noIso ID V2 loose WP"),
351 cutBased =
Var(
"userInt('cutbasedID_Fall17_V2_veto')+userInt('cutbasedID_Fall17_V2_loose')+userInt('cutbasedID_Fall17_V2_medium')+userInt('cutbasedID_Fall17_V2_tight')",int,doc=
"cut-based ID Fall17 V2 (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
352 cutBased_Fall17_V1 =
Var(
"userInt('cutbasedID_Fall17_V1_veto')+userInt('cutbasedID_Fall17_V1_loose')+userInt('cutbasedID_Fall17_V1_medium')+userInt('cutbasedID_Fall17_V1_tight')",int,doc=
"cut-based ID Fall17 V1 (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
353 vidNestedWPBitmap =
Var(
"userInt('VIDNestedWPBitmap')",int,doc=_bitmapVIDForEle_docstring),
354 vidNestedWPBitmapHEEP =
Var(
"userInt('VIDNestedWPBitmapHEEP')",int,doc=_bitmapVIDForEleHEEP_docstring),
355 cutBased_HEEP =
Var(
"userInt('cutbasedID_HEEP')",bool,doc=
"cut-based HEEP ID"),
356 miniPFRelIso_chg =
Var(
"userFloat('miniIsoChg')/pt",float,doc=
"mini PF relative isolation, charged component"),
357 miniPFRelIso_all =
Var(
"userFloat('miniIsoAll')/pt",float,doc=
"mini PF relative isolation, total (with scaled rho*EA PU corrections)"),
358 pfRelIso03_chg =
Var(
"userFloat('PFIsoChg')/pt",float,doc=
"PF relative isolation dR=0.3, charged component"),
359 pfRelIso03_all =
Var(
"userFloat('PFIsoAll')/pt",float,doc=
"PF relative isolation dR=0.3, total (with rho*EA PU corrections)"),
360 jetRelIso =
Var(
"?userCand('jetForLepJetVar').isNonnull()?(1./userFloat('ptRatio'))-1.:userFloat('PFIsoAll04')/pt",float,doc=
"Relative isolation in matched jet (1/ptRatio-1, pfRelIso04_all if no matched jet)",precision=8),
361 jetPtRelv2 =
Var(
"?userCand('jetForLepJetVar').isNonnull()?userFloat('ptRel'):0",float,doc=
"Relative momentum of the lepton with respect to the closest jet after subtracting the lepton",precision=8),
362 dr03TkSumPt =
Var(
"?pt>35?dr03TkSumPt():0",float,doc=
"Non-PF track isolation within a delta R cone of 0.3 with electron pt > 35 GeV",precision=8),
363 dr03TkSumPtHEEP =
Var(
"?pt>35?userFloat('dr03TkSumPtHEEP'):0",float,doc=
"Non-PF track isolation within a delta R cone of 0.3 with electron pt > 35 GeV used in HEEP ID",precision=8),
364 dr03EcalRecHitSumEt =
Var(
"?pt>35?dr03EcalRecHitSumEt():0",float,doc=
"Non-PF Ecal isolation within a delta R cone of 0.3 with electron pt > 35 GeV",precision=8),
365 dr03HcalDepth1TowerSumEt =
Var(
"?pt>35?dr03HcalDepth1TowerSumEt():0",float,doc=
"Non-PF Hcal isolation within a delta R cone of 0.3 with electron pt > 35 GeV",precision=8),
366 hoe =
Var(
"hadronicOverEm()",float,doc=
"H over E",precision=8),
367 tightCharge =
Var(
"isGsfCtfScPixChargeConsistent() + isGsfScPixChargeConsistent()",int,doc=
"Tight charge criteria (0:none, 1:isGsfScPixChargeConsistent, 2:isGsfCtfScPixChargeConsistent)"),
368 convVeto =
Var(
"passConversionVeto()",bool,doc=
"pass conversion veto"),
369 lostHits =
Var(
"gsfTrack.hitPattern.numberOfLostHits('MISSING_INNER_HITS')",
"uint8",doc=
"number of missing inner hits"),
370 isPFcand =
Var(
"pfCandidateRef().isNonnull()",bool,doc=
"electron is PF candidate"),
371 seedGain =
Var(
"userInt('seedGain')",
"uint8",doc=
"Gain of the seed crystal"),
373 externalVariables = cms.PSet(
374 mvaTTH =
ExtVar(cms.InputTag(
"electronMVATTH"),float, doc=
"TTH MVA lepton ID score",precision=14),
378 for modifier
in run2_nanoAOD_94X2016,:
379 modifier.toModify(electronTable.variables,
380 pt =
Var(
"pt*userFloat('ecalTrkEnergyPostCorr')/userFloat('ecalTrkEnergyPreCorr')", float, precision=-1, doc=
"p_{T}"),
381 energyErr =
Var(
"userFloat('ecalTrkEnergyErrPostCorr')", float, precision=6, doc=
"energy error of the cluster-track combination"),
382 eCorr =
Var(
"userFloat('ecalTrkEnergyPostCorr')/userFloat('ecalTrkEnergyPreCorr')", float, doc=
"ratio of the calibrated energy/miniaod energy"),
388 (~run2_nanoAOD_94X2016).toModify(electronTable.variables,
389 pt =
Var(
"pt*userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, precision=-1, doc=
"p_{T}"),
390 energyErr =
Var(
"userFloat('ecalTrkEnergyErrPostCorrNew')", float, precision=6, doc=
"energy error of the cluster-track combination"),
391 eCorr =
Var(
"userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, doc=
"ratio of the calibrated energy/miniaod energy"),
394 run2_nanoAOD_94X2016.toModify(electronTable.variables,
395 cutBased_Sum16 =
Var(
"userInt('cutbasedID_Sum16_veto')+userInt('cutbasedID_Sum16_loose')+userInt('cutbasedID_Sum16_medium')+userInt('cutbasedID_Sum16_tight')",int,doc=
"cut-based Summer16 ID (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
396 cutBased_Fall17_V1 =
Var(
"electronID('cutBasedElectronID-Fall17-94X-V1-veto')+electronID('cutBasedElectronID-Fall17-94X-V1-loose')+electronID('cutBasedElectronID-Fall17-94X-V1-medium')+electronID('cutBasedElectronID-Fall17-94X-V1-tight')",int,doc=
"cut-based Fall17 ID (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
399 cutBased =
Var(
"userInt('cutbasedID_Fall17_V2_veto')+userInt('cutbasedID_Fall17_V2_loose')+userInt('cutbasedID_Fall17_V2_medium')+userInt('cutbasedID_Fall17_V2_tight')",int,doc=
"cut-based ID Fall17 V2 (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
400 cutBased_HLTPreSel =
Var(
"userInt('cutbasedID_HLT')",int,doc=
"cut-based HLT pre-selection ID"),
401 cutBased_HEEP =
Var(
"electronID('heepElectronID-HEEPV70')",bool,doc=
"cut-based HEEP ID"),
402 cutBased_Spring15 =
Var(
"userInt('cutbasedID_Spring15_veto')+userInt('cutbasedID_Spring15_loose')+userInt('cutbasedID_Spring15_medium')+userInt('cutbasedID_Spring15_tight')",int,doc=
"cut-based Spring15 ID (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
403 mvaSpring16GP =
Var(
"userFloat('ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values')",float,doc=
"MVA Spring16 general-purpose ID score"),
404 mvaSpring16GP_WP80 =
Var(
"electronID('mvaEleID-Spring16-GeneralPurpose-V1-wp80')",bool,doc=
"MVA Spring16 general-purpose ID WP80"),
405 mvaSpring16GP_WP90 =
Var(
"electronID('mvaEleID-Spring16-GeneralPurpose-V1-wp90')",bool,doc=
"MVA Spring16 general-purpose ID WP90"),
406 mvaSpring16HZZ =
Var(
"userFloat('ElectronMVAEstimatorRun2Spring16HZZV1Values')",float,doc=
"MVA Spring16 HZZ ID score"),
407 mvaSpring16HZZ_WPL =
Var(
"electronID('mvaEleID-Spring16-HZZ-V1-wpLoose')",bool,doc=
"MVA Spring16 HZZ ID loose WP"),
408 mvaFall17V1Iso =
Var(
"userFloat('ElectronMVAEstimatorRun2Fall17IsoV1Values')",float,doc=
"MVA Fall17 V1 Iso ID score"),
409 mvaFall17V1Iso_WP80 =
Var(
"electronID('mvaEleID-Fall17-iso-V1-wp80')",bool,doc=
"MVA Fall17 V1 Iso ID WP80"),
410 mvaFall17V1Iso_WP90 =
Var(
"electronID('mvaEleID-Fall17-iso-V1-wp90')",bool,doc=
"MVA Fall17 V1 Iso ID WP90"),
411 mvaFall17V1Iso_WPL =
Var(
"electronID('mvaEleID-Fall17-iso-V1-wpLoose')",bool,doc=
"MVA Fall17 V1 Iso ID loose WP"),
412 mvaFall17V1noIso =
Var(
"userFloat('ElectronMVAEstimatorRun2Fall17NoIsoV1Values')",float,doc=
"MVA Fall17 V1 noIso ID score"),
413 mvaFall17V1noIso_WP80 =
Var(
"electronID('mvaEleID-Fall17-noIso-V1-wp80')",bool,doc=
"MVA Fall17 V1 noIso ID WP80"),
414 mvaFall17V1noIso_WP90 =
Var(
"electronID('mvaEleID-Fall17-noIso-V1-wp90')",bool,doc=
"MVA Fall17 V1 noIso ID WP90"),
415 mvaFall17V1noIso_WPL =
Var(
"electronID('mvaEleID-Fall17-noIso-V1-wpLoose')",bool,doc=
"MVA Fall17 V1 noIso ID loose WP"),
416 vidNestedWPBitmapSpring15 =
Var(
"userInt('VIDNestedWPBitmapSpring15')",int,doc=_bitmapVIDForEleSpring15_docstring),
417 vidNestedWPBitmapSum16 =
Var(
"userInt('VIDNestedWPBitmapSum16')",int,doc=_bitmapVIDForEleSum16_docstring),
419 run2_miniAOD_80XLegacy.toModify(electronTable.variables,
420 cutBased_Sum16 =
Var(
"userInt('cutbasedID_Sum16_veto')+userInt('cutbasedID_Sum16_loose')+userInt('cutbasedID_Sum16_medium')+userInt('cutbasedID_Sum16_tight')",int,doc=
"cut-based Summer16 ID (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
421 cutBased_HLTPreSel =
Var(
"userInt('cutbasedID_HLT')",int,doc=
"cut-based HLT pre-selection ID"),
422 cutBased_Spring15 =
Var(
"userInt('cutbasedID_Spring15_veto')+userInt('cutbasedID_Spring15_loose')+userInt('cutbasedID_Spring15_medium')+userInt('cutbasedID_Spring15_tight')",int,doc=
"cut-based Spring15 ID (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
423 mvaSpring16GP =
Var(
"userFloat('mvaSpring16GP')",float,doc=
"MVA general-purpose ID score"),
424 mvaSpring16GP_WP80 =
Var(
"userInt('mvaSpring16GP_WP80')",bool,doc=
"MVA general-purpose ID WP80"),
425 mvaSpring16GP_WP90 =
Var(
"userInt('mvaSpring16GP_WP90')",bool,doc=
"MVA general-purpose ID WP90"),
426 mvaSpring16HZZ =
Var(
"userFloat('mvaSpring16HZZ')",float,doc=
"MVA HZZ ID score"),
427 mvaSpring16HZZ_WPL =
Var(
"userInt('mvaSpring16HZZ_WPL')",bool,doc=
"MVA HZZ ID loose WP"),
429 vidNestedWPBitmapSpring15 =
Var(
"userInt('VIDNestedWPBitmapSpring15')",int,doc=_bitmapVIDForEleSpring15_docstring),
430 vidNestedWPBitmapSum16 =
Var(
"userInt('VIDNestedWPBitmapSum16')",int,doc=_bitmapVIDForEleSum16_docstring),
434 electronsMCMatchForTable = cms.EDProducer(
"MCMatcher",
435 src = electronTable.src,
436 matched = cms.InputTag(
"finalGenParticles"),
437 mcPdgId = cms.vint32(11,22),
438 checkCharge = cms.bool(
False),
439 mcStatus = cms.vint32(1),
440 maxDeltaR = cms.double(0.3),
441 maxDPtRel = cms.double(0.5),
442 resolveAmbiguities = cms.bool(
True),
443 resolveByMatchQuality = cms.bool(
True),
446 electronMCTable = cms.EDProducer(
"CandMCMatchTableProducer",
447 src = electronTable.src,
448 mcMap = cms.InputTag(
"electronsMCMatchForTable"),
449 objName = electronTable.name,
450 objType = electronTable.name,
451 branchName = cms.string(
"genPart"),
452 docString = cms.string(
"MC matching to status==1 electrons or photons"),
455 electronSequence = cms.Sequence(bitmapVIDForEle + bitmapVIDForEleHEEP + isoForEle + ptRatioRelForEle + seedGainEle + slimmedElectronsWithUserData + finalElectrons)
456 electronTables = cms.Sequence (electronMVATTH + electronTable)
457 electronMC = cms.Sequence(electronsMCMatchForTable + electronMCTable)
459 _withUpdate_sequence = cms.Sequence(slimmedElectronsUpdated + electronSequence.copy())
461 _withUpdateAnd80XLegacyScale_sequence = _withUpdate_sequence.copy()
462 _withUpdateAnd80XLegacyScale_sequence.replace(slimmedElectronsWithUserData, calibratedPatElectrons80XLegacy + bitmapVIDForEleSpring15 +bitmapVIDForEleSum16 + slimmedElectronsWithUserData)
463 run2_miniAOD_80XLegacy.toReplaceWith(electronSequence, _withUpdateAnd80XLegacyScale_sequence)
465 _with94XScale_sequence = electronSequence.copy()
466 _with94XScale_sequence.replace(slimmedElectronsWithUserData, calibratedPatElectrons94X + slimmedElectronsWithUserData)
467 run2_nanoAOD_94XMiniAODv1.toReplaceWith(electronSequence, _with94XScale_sequence)
468 run2_nanoAOD_94XMiniAODv2.toReplaceWith(electronSequence, _with94XScale_sequence)
470 _with_bitmapVIDForEleSpring15AndSum16_sequence = electronSequence.copy()
471 _with_bitmapVIDForEleSpring15AndSum16_sequence.replace(slimmedElectronsWithUserData, bitmapVIDForEleSpring15 + bitmapVIDForEleSum16 + slimmedElectronsWithUserData)
472 run2_nanoAOD_94X2016.toReplaceWith(electronSequence, _with_bitmapVIDForEleSpring15AndSum16_sequence)
474 _with102XScale_sequence = electronSequence.copy()
475 _with102XScale_sequence.replace(slimmedElectronsWithUserData, calibratedPatElectrons102X + slimmedElectronsWithUserData)
476 (~(run2_miniAOD_80XLegacy | run2_nanoAOD_94X2016 | run2_nanoAOD_94XMiniAODv1 | run2_nanoAOD_94XMiniAODv2)).toReplaceWith(electronSequence, _with102XScale_sequence)
def ExtVar(tag, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
def _get_bitmapVIDForEle_docstring(modules, WorkingPoints)
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
static std::string join(char **cmd)