CMS 3D CMS Logo

electrons_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
6 from math import ceil,log
7 
8 from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma8XObjectUpdateModifier,egamma9X105XUpdateModifier,prependEgamma8XObjectUpdateModifier
9 ele9X105XUpdateModifier=egamma9X105XUpdateModifier.clone(
10  phoPhotonIso = "",
11  phoNeutralHadIso = "",
12  phoChargedHadIso = "",
13  phoChargedHadWorstVtxIso = "",
14  phoChargedHadWorstVtxConeVetoIso = "",
15  phoChargedHadPFPVIso = ""
16 )
17 #we have dataformat changes to 106X so to read older releases we use egamma updators
18 slimmedElectronsTo106X = cms.EDProducer("ModifiedElectronProducer",
19  src = cms.InputTag("slimmedElectrons"),
20  modifierConfig = cms.PSet( modifications = cms.VPSet(ele9X105XUpdateModifier) )
21 )
22 #might as well fix 80X while we're at it although the differences are not so relavent for nano
23 run2_miniAOD_80XLegacy.toModify( slimmedElectronsTo106X.modifierConfig.modifications, prependEgamma8XObjectUpdateModifier )
24 
25 # this below is used only in some eras
26 slimmedElectronsUpdated = cms.EDProducer("PATElectronUpdater",
27  src = cms.InputTag("slimmedElectronsTo106X"),
28  vertices = cms.InputTag("offlineSlimmedPrimaryVertices"),
29  computeMiniIso = cms.bool(False),
30  fixDxySign = cms.bool(True),
31  pfCandsForMiniIso = cms.InputTag("packedPFCandidates"),
32  miniIsoParamsB = PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi.patElectrons.miniIsoParamsB, # so they're in sync
33  miniIsoParamsE = PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi.patElectrons.miniIsoParamsE, # so they're in sync
34 )
35 run2_miniAOD_80XLegacy.toModify( slimmedElectronsUpdated, computeMiniIso = True )
36 # bypass the update to 106X in 106X to only pick up the IP sign fix
37 run2_egamma_2017.toModify(slimmedElectronsUpdated, src = cms.InputTag("slimmedElectrons"))
38 run2_egamma_2018.toModify(slimmedElectronsUpdated, src = cms.InputTag("slimmedElectrons"))
39 run2_nanoAOD_106Xv1.toModify(slimmedElectronsUpdated, src = cms.InputTag("slimmedElectrons"))
40 
41 for modifier in run2_miniAOD_80XLegacy,run2_nanoAOD_94X2016,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1:
42  modifier.toModify(slimmedElectronsUpdated, src = cms.InputTag("slimmedElectronsTo106X"))
43 
44 
45 electron_id_modules_WorkingPoints_nanoAOD = cms.PSet(
46  modules = cms.vstring(
47  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
48  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
49  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
50  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
51  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
52  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
53  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
54  ),
55  WorkingPoints = cms.vstring(
56  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto",
57  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose",
58  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium",
59  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight",
60  )
61 )
62 
63 for modifier in run2_miniAOD_80XLegacy,run2_nanoAOD_94X2016:
64  modifier.toModify(electron_id_modules_WorkingPoints_nanoAOD,
65  modules = cms.vstring(
66  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
67  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
68  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
69  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
70  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
71  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
72  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
73  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
74  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronHLTPreselecition_Summer16_V1_cff',
75  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_25ns_V1_cff',
76  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff',
77  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff',
78  ),
79  WorkingPoints = cms.vstring(
80  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto",
81  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose",
82  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium",
83  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight",
84  )
85 )
86 
87 
88 def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
89  docstring=''
90  for modname in modules:
91  ids= __import__(modname, globals(), locals(), ['idName','cutFlow'])
92  for name in dir(ids):
93  _id = getattr(ids,name)
94  if hasattr(_id,'idName') and hasattr(_id,'cutFlow'):
95  if (len(WorkingPoints)>0 and _id.idName==WorkingPoints[0].split(':')[-1]):
96  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))))
97  return docstring
98 
99 bitmapVIDForEle = cms.EDProducer("EleVIDNestedWPBitmapProducer",
100  src = cms.InputTag("slimmedElectrons"),
101  WorkingPoints = electron_id_modules_WorkingPoints_nanoAOD.WorkingPoints,
102 )
103 _bitmapVIDForEle_docstring = _get_bitmapVIDForEle_docstring(electron_id_modules_WorkingPoints_nanoAOD.modules,bitmapVIDForEle.WorkingPoints)
104 
105 bitmapVIDForEleSpring15 = bitmapVIDForEle.clone()
106 bitmapVIDForEleSpring15.WorkingPoints = cms.vstring(
107  "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto",
108  "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose",
109  "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium",
110 # "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight", # not fitting in sizeof(int)
111 )
112 _bitmapVIDForEleSpring15_docstring = _get_bitmapVIDForEle_docstring(electron_id_modules_WorkingPoints_nanoAOD.modules,bitmapVIDForEleSpring15.WorkingPoints)
113 
114 bitmapVIDForEleSum16 = bitmapVIDForEle.clone()
115 bitmapVIDForEleSum16.WorkingPoints = cms.vstring(
116  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto",
117  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose",
118  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium",
119  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight",
120 )
121 _bitmapVIDForEleSum16_docstring = _get_bitmapVIDForEle_docstring(electron_id_modules_WorkingPoints_nanoAOD.modules,bitmapVIDForEleSum16.WorkingPoints)
122 
123 bitmapVIDForEleHEEP = bitmapVIDForEle.clone()
124 bitmapVIDForEleHEEP.WorkingPoints = cms.vstring(
125  "egmGsfElectronIDs:heepElectronID-HEEPV70"
126 )
127 _bitmapVIDForEleHEEP_docstring = _get_bitmapVIDForEle_docstring(electron_id_modules_WorkingPoints_nanoAOD.modules,bitmapVIDForEleHEEP.WorkingPoints)
128 
129 
130 
131 
132 for modifier in run2_egamma_2017,run2_egamma_2018,run2_miniAOD_80XLegacy,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_94X2016,run2_nanoAOD_102Xv1,run2_nanoAOD_106Xv1:
133  modifier.toModify(bitmapVIDForEle, src = "slimmedElectronsUpdated")
134  modifier.toModify(bitmapVIDForEleSpring15, src = "slimmedElectronsUpdated")
135  modifier.toModify(bitmapVIDForEleSum16, src = "slimmedElectronsUpdated")
136  modifier.toModify(bitmapVIDForEleHEEP, src = "slimmedElectronsUpdated")
137 
138 
139 isoForEle = cms.EDProducer("EleIsoValueMapProducer",
140  src = cms.InputTag("slimmedElectrons"),
141  relative = cms.bool(False),
142  rho_MiniIso = cms.InputTag("fixedGridRhoFastjetAll"),
143  rho_PFIso = cms.InputTag("fixedGridRhoFastjetAll"),
144  EAFile_MiniIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
145  EAFile_PFIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
146 )
147 for modifier in run2_egamma_2017,run2_egamma_2018, run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_94X2016,run2_nanoAOD_102Xv1,run2_nanoAOD_106Xv1:
148  modifier.toModify(isoForEle, src = "slimmedElectronsUpdated")
149 
150 run2_miniAOD_80XLegacy.toModify(isoForEle, src = "slimmedElectronsUpdated",
151  EAFile_MiniIso = "RecoEgamma/ElectronIdentification/data/Spring15/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_25ns.txt",
152  EAFile_PFIso = "RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_80X.txt")
153 run2_nanoAOD_94X2016.toModify(isoForEle,
154  EAFile_MiniIso = "RecoEgamma/ElectronIdentification/data/Spring15/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_25ns.txt",
155  EAFile_PFIso = "RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_80X.txt")
156 
157 ptRatioRelForEle = cms.EDProducer("ElectronJetVarProducer",
158  srcJet = cms.InputTag("updatedJets"),
159  srcLep = cms.InputTag("slimmedElectrons"),
160  srcVtx = cms.InputTag("offlineSlimmedPrimaryVertices"),
161 )
162 for modifier in run2_egamma_2017,run2_egamma_2018, run2_miniAOD_80XLegacy,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_94X2016,run2_nanoAOD_102Xv1,run2_nanoAOD_106Xv1:
163  modifier.toModify(ptRatioRelForEle, srcLep = "slimmedElectronsUpdated")
164 
165 seedGainEle = cms.EDProducer("ElectronSeedGainProducer", src = cms.InputTag("slimmedElectrons"))
166 for modifier in run2_egamma_2017,run2_egamma_2018, run2_miniAOD_80XLegacy,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_94X2016,run2_nanoAOD_102Xv1,run2_nanoAOD_106Xv1:
167  modifier.toModify(seedGainEle, src = "slimmedElectronsUpdated")
168 
169 import RecoEgamma.EgammaTools.calibratedEgammas_cff
170 
171 calibratedPatElectronsUL17 = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatElectrons.clone(
172  produceCalibratedObjs = False,
173  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_24Feb2020_runEtaR9Gain_v2"),
174 )
175 run2_egamma_2017.toModify(calibratedPatElectronsUL17, src = "slimmedElectronsUpdated")
176 
177 calibratedPatElectronsUL18 = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatElectrons.clone(
178  produceCalibratedObjs = False,
179  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_29Sep2020_RunFineEtaR9Gain"),
180 )
181 run2_egamma_2018.toModify(calibratedPatElectronsUL18, src = "slimmedElectronsUpdated")
182 
183 calibratedPatElectrons80XLegacy = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatElectrons.clone(
184  produceCalibratedObjs = False,
185  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Legacy2016_07Aug2017_FineEtaR9_v3_ele_unc"),
186 )
187 run2_miniAOD_80XLegacy.toModify(calibratedPatElectrons80XLegacy, src = "slimmedElectronsUpdated")
188 
189 calibratedPatElectrons94X = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatElectrons.clone(
190  produceCalibratedObjs = False,
191  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_17Nov2017_v1_ele_unc"),
192 )
193 for modifier in run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_94X2016:
194  modifier.toModify(calibratedPatElectrons94X, src = "slimmedElectronsUpdated")
195 
196 calibratedPatElectrons102X = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatElectrons.clone(
197  produceCalibratedObjs = False,
198  correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_Step2Closure_CoarseEtaR9Gain_v2"),
199 )
200 run2_nanoAOD_102Xv1.toModify(calibratedPatElectrons102X, src = "slimmedElectronsUpdated")
201 
202 slimmedElectronsWithUserData = cms.EDProducer("PATElectronUserDataEmbedder",
203  src = cms.InputTag("slimmedElectrons"),
204  userFloats = cms.PSet(
205  mvaFall17V1Iso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV1Values"),
206  mvaFall17V1noIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV1Values"),
207  mvaFall17V2Iso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV2Values"),
208  mvaFall17V2noIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV2Values"),
209  miniIsoChg = cms.InputTag("isoForEle:miniIsoChg"),
210  miniIsoAll = cms.InputTag("isoForEle:miniIsoAll"),
211  PFIsoChg = cms.InputTag("isoForEle:PFIsoChg"),
212  PFIsoAll = cms.InputTag("isoForEle:PFIsoAll"),
213  PFIsoAll04 = cms.InputTag("isoForEle:PFIsoAll04"),
214  ptRatio = cms.InputTag("ptRatioRelForEle:ptRatio"),
215  ptRel = cms.InputTag("ptRatioRelForEle:ptRel"),
216  jetNDauChargedMVASel = cms.InputTag("ptRatioRelForEle:jetNDauChargedMVASel"),
217  ),
218  userIntFromBools = cms.PSet(
219 
220  mvaFall17V1Iso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp90"),
221  mvaFall17V1Iso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp80"),
222  mvaFall17V1Iso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wpLoose"),
223  mvaFall17V1noIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp90"),
224  mvaFall17V1noIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp80"),
225  mvaFall17V1noIso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wpLoose"),
226 
227  mvaFall17V2Iso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp90"),
228  mvaFall17V2Iso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp80"),
229  mvaFall17V2Iso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wpLoose"),
230  mvaFall17V2noIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp90"),
231  mvaFall17V2noIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp80"),
232  mvaFall17V2noIso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wpLoose"),
233 
234  cutbasedID_Fall17_V1_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-veto"),
235  cutbasedID_Fall17_V1_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-loose"),
236  cutbasedID_Fall17_V1_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-medium"),
237  cutbasedID_Fall17_V1_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-tight"),
238  cutbasedID_Fall17_V2_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto"),
239  cutbasedID_Fall17_V2_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose"),
240  cutbasedID_Fall17_V2_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium"),
241  cutbasedID_Fall17_V2_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight"),
242  cutbasedID_HEEP = cms.InputTag("egmGsfElectronIDs:heepElectronID-HEEPV70"),
243  ),
244  userInts = cms.PSet(
245  VIDNestedWPBitmap = cms.InputTag("bitmapVIDForEle"),
246  VIDNestedWPBitmapHEEP = cms.InputTag("bitmapVIDForEleHEEP"),
247  seedGain = cms.InputTag("seedGainEle"),
248  ),
249  userCands = cms.PSet(
250  jetForLepJetVar = cms.InputTag("ptRatioRelForEle:jetForLepJetVar") # warning: Ptr is null if no match is found
251  ),
252 )
253 for modifier in run2_egamma_2017,run2_egamma_2018, run2_miniAOD_80XLegacy,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_94X2016,run2_nanoAOD_102Xv1,run2_nanoAOD_106Xv1:
254  modifier.toModify(slimmedElectronsWithUserData, src = "slimmedElectronsUpdated")
255 
256 
257 run2_egamma_2017.toModify(slimmedElectronsWithUserData.userFloats,
258  ecalTrkEnergyErrPostCorrNew = cms.InputTag("calibratedPatElectronsUL17","ecalTrkEnergyErrPostCorr"),
259  ecalTrkEnergyPreCorrNew = cms.InputTag("calibratedPatElectronsUL17","ecalTrkEnergyPreCorr"),
260  ecalTrkEnergyPostCorrNew = cms.InputTag("calibratedPatElectronsUL17","ecalTrkEnergyPostCorr"),
261 )
262 
263 run2_egamma_2018.toModify(slimmedElectronsWithUserData.userFloats,
264  ecalTrkEnergyErrPostCorrNew = cms.InputTag("calibratedPatElectronsUL18","ecalTrkEnergyErrPostCorr"),
265  ecalTrkEnergyPreCorrNew = cms.InputTag("calibratedPatElectronsUL18","ecalTrkEnergyPreCorr"),
266  ecalTrkEnergyPostCorrNew = cms.InputTag("calibratedPatElectronsUL18","ecalTrkEnergyPostCorr"),
267 )
268 
269 run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userFloats,
270  mvaSpring16GP = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values"),
271  mvaSpring16HZZ = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16HZZV1Values"),
272 )
273 run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userFloats,
274  ecalTrkEnergyErrPostCorrNew = cms.InputTag("calibratedPatElectrons80XLegacy","ecalTrkEnergyErrPostCorr"),
275  ecalTrkEnergyPreCorrNew = cms.InputTag("calibratedPatElectrons80XLegacy","ecalTrkEnergyPreCorr"),
276  ecalTrkEnergyPostCorrNew = cms.InputTag("calibratedPatElectrons80XLegacy","ecalTrkEnergyPostCorr"),
277 )
278 run2_nanoAOD_94XMiniAODv1.toModify(slimmedElectronsWithUserData.userFloats,
279  ecalTrkEnergyErrPostCorrNew = cms.InputTag("calibratedPatElectrons94X","ecalTrkEnergyErrPostCorr"),
280  ecalTrkEnergyPreCorrNew = cms.InputTag("calibratedPatElectrons94X","ecalTrkEnergyPreCorr"),
281  ecalTrkEnergyPostCorrNew = cms.InputTag("calibratedPatElectrons94X","ecalTrkEnergyPostCorr"),
282 )
283 
284 
285 #the94X miniAOD V2 had a bug in the scale and smearing for electrons in the E/p comb
286 #therefore we redo it but but we need use a new name for the userFloat as we cant override existing userfloats
287 #for technical reasons
288 
289 run2_nanoAOD_94XMiniAODv2.toModify(slimmedElectronsWithUserData.userFloats,
290  ecalTrkEnergyErrPostCorrNew = cms.InputTag("calibratedPatElectrons94X","ecalTrkEnergyErrPostCorr"),
291  ecalTrkEnergyPreCorrNew = cms.InputTag("calibratedPatElectrons94X","ecalTrkEnergyPreCorr"),
292  ecalTrkEnergyPostCorrNew = cms.InputTag("calibratedPatElectrons94X","ecalTrkEnergyPostCorr"),
293 )
294 
295 run2_nanoAOD_102Xv1.toModify(slimmedElectronsWithUserData.userFloats,
296  ecalTrkEnergyErrPostCorrNew = cms.InputTag("calibratedPatElectrons102X","ecalTrkEnergyErrPostCorr"),
297  ecalTrkEnergyPreCorrNew = cms.InputTag("calibratedPatElectrons102X","ecalTrkEnergyPreCorr"),
298  ecalTrkEnergyPostCorrNew = cms.InputTag("calibratedPatElectrons102X","ecalTrkEnergyPostCorr"),
299 )
300 
301 run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userIntFromBools,
302  mvaSpring16GP_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp90"),
303  mvaSpring16GP_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp80"),
304  mvaSpring16HZZ_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-HZZ-V1-wpLoose"),
305  cutbasedID_Sum16_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto"),
306  cutbasedID_Sum16_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose"),
307  cutbasedID_Sum16_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium"),
308  cutbasedID_Sum16_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight"),
309  cutbasedID_HLT = cms.InputTag("egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1"),
310  cutbasedID_Spring15_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto"),
311  cutbasedID_Spring15_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose"),
312  cutbasedID_Spring15_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium"),
313  cutbasedID_Spring15_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight"),
314 )
315 
316 run2_nanoAOD_94X2016.toModify(slimmedElectronsWithUserData.userIntFromBools,
317  # MVAs and HEEP are already pre-computed. Cut-based too (except V2), but we re-add it for consistency with the nested bitmap
318  cutbasedID_Sum16_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto"),
319  cutbasedID_Sum16_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose"),
320  cutbasedID_Sum16_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium"),
321  cutbasedID_Sum16_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight"),
322  cutbasedID_HLT = cms.InputTag("egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1"),
323  cutbasedID_Spring15_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto"),
324  cutbasedID_Spring15_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose"),
325  cutbasedID_Spring15_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium"),
326  cutbasedID_Spring15_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight"),
327  cutbasedID_Fall17_V2_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto"),
328  cutbasedID_Fall17_V2_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose"),
329  cutbasedID_Fall17_V2_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium"),
330  cutbasedID_Fall17_V2_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight"),
331 
332 )
333 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
334  modifier.toModify(slimmedElectronsWithUserData.userInts,
335  VIDNestedWPBitmapSpring15 = cms.InputTag("bitmapVIDForEleSpring15"),
336  VIDNestedWPBitmapSum16 = cms.InputTag("bitmapVIDForEleSum16"),
337  )
338 
339 finalElectrons = cms.EDFilter("PATElectronRefSelector",
340  src = cms.InputTag("slimmedElectronsWithUserData"),
341  cut = cms.string("pt > 5 ")
342 )
343 
344 electronMVATTH= cms.EDProducer("EleBaseMVAValueMapProducer",
345  src = cms.InputTag("linkedObjects","electrons"),
346  weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/el_BDTG_2017.weights.xml"),
347  name = cms.string("electronMVATTH"),
348  isClassifier = cms.bool(True),
349  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"]),
350  variables = cms.PSet(
351  LepGood_pt = cms.string("pt"),
352  LepGood_eta = cms.string("eta"),
353  LepGood_jetNDauChargedMVASel = cms.string("?userCand('jetForLepJetVar').isNonnull()?userFloat('jetNDauChargedMVASel'):0"),
354  LepGood_miniRelIsoCharged = cms.string("userFloat('miniIsoChg')/pt"),
355  LepGood_miniRelIsoNeutral = cms.string("(userFloat('miniIsoAll')-userFloat('miniIsoChg'))/pt"),
356  LepGood_jetPtRelv2 = cms.string("?userCand('jetForLepJetVar').isNonnull()?userFloat('ptRel'):0"),
357  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"),
358  LepGood_jetPtRatio = cms.string("?userCand('jetForLepJetVar').isNonnull()?min(userFloat('ptRatio'),1.5):1.0/(1.0+userFloat('PFIsoAll04')/pt)"),
359  LepGood_dxy = cms.string("log(abs(dB('PV2D')))"),
360  LepGood_sip3d = cms.string("abs(dB('PV3D')/edB('PV3D'))"),
361  LepGood_dz = cms.string("log(abs(dB('PVDZ')))"),
362  LepGood_mvaFall17V2noIso = cms.string("userFloat('mvaFall17V2noIso')"),
363  )
364 )
365 run2_egamma_2016.toModify(electronMVATTH,
366  weightFile = "PhysicsTools/NanoAOD/data/el_BDTG_2016.weights.xml",
367 )
368 
369 electronTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
370  src = cms.InputTag("linkedObjects","electrons"),
371  cut = cms.string(""), #we should not filter on cross linked collections
372  name= cms.string("Electron"),
373  doc = cms.string("slimmedElectrons after basic selection (" + finalElectrons.cut.value()+")"),
374  singleton = cms.bool(False), # the number of entries is variable
375  extension = cms.bool(False), # this is the main table for the electrons
376  variables = cms.PSet(CandVars,
377  jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"),
378  photonIdx = Var("?overlaps('photons').size()>0?overlaps('photons')[0].key():-1", int, doc="index of the associated photon (-1 if none)"),
379  energyErr = Var("p4Error('P4_COMBINATION')",float,doc="energy error of the cluster-track combination",precision=6),
380  dz = Var("dB('PVDZ')",float,doc="dz (with sign) wrt first PV, in cm",precision=10),
381  dzErr = Var("abs(edB('PVDZ'))",float,doc="dz uncertainty, in cm",precision=6),
382  dxy = Var("dB('PV2D')",float,doc="dxy (with sign) wrt first PV, in cm",precision=10),
383  dxyErr = Var("edB('PV2D')",float,doc="dxy uncertainty, in cm",precision=6),
384  ip3d = Var("abs(dB('PV3D'))",float,doc="3D impact parameter wrt first PV, in cm",precision=10),
385  sip3d = Var("abs(dB('PV3D')/edB('PV3D'))",float,doc="3D impact parameter significance wrt first PV, in cm",precision=10),
386  deltaEtaSC = Var("superCluster().eta()-eta()",float,doc="delta eta (SC,ele) with sign",precision=10),
387  r9 = Var("full5x5_r9()",float,doc="R9 of the supercluster, calculated with full 5x5 region",precision=10),
388  sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10),
389  eInvMinusPInv = Var("(1-eSuperClusterOverP())/ecalEnergy()",float,doc="1/E_SC - 1/p_trk",precision=10),
390  scEtOverPt = Var("(superCluster().energy()/(pt*cosh(superCluster().eta())))-1",float,doc="(supercluster transverse energy)/pt-1",precision=8),
391 
392  mvaFall17V1Iso = Var("userFloat('mvaFall17V1Iso')",float,doc="MVA Iso ID V1 score"),
393  mvaFall17V1Iso_WP80 = Var("userInt('mvaFall17V1Iso_WP80')",bool,doc="MVA Iso ID V1 WP80"),
394  mvaFall17V1Iso_WP90 = Var("userInt('mvaFall17V1Iso_WP90')",bool,doc="MVA Iso ID V1 WP90"),
395  mvaFall17V1Iso_WPL = Var("userInt('mvaFall17V1Iso_WPL')",bool,doc="MVA Iso ID V1 loose WP"),
396  mvaFall17V1noIso = Var("userFloat('mvaFall17V1noIso')",float,doc="MVA noIso ID V1 score"),
397  mvaFall17V1noIso_WP80 = Var("userInt('mvaFall17V1noIso_WP80')",bool,doc="MVA noIso ID V1 WP80"),
398  mvaFall17V1noIso_WP90 = Var("userInt('mvaFall17V1noIso_WP90')",bool,doc="MVA noIso ID V1 WP90"),
399  mvaFall17V1noIso_WPL = Var("userInt('mvaFall17V1noIso_WPL')",bool,doc="MVA noIso ID V1 loose WP"),
400 
401  mvaFall17V2Iso = Var("userFloat('mvaFall17V2Iso')",float,doc="MVA Iso ID V2 score"),
402  mvaFall17V2Iso_WP80 = Var("userInt('mvaFall17V2Iso_WP80')",bool,doc="MVA Iso ID V2 WP80"),
403  mvaFall17V2Iso_WP90 = Var("userInt('mvaFall17V2Iso_WP90')",bool,doc="MVA Iso ID V2 WP90"),
404  mvaFall17V2Iso_WPL = Var("userInt('mvaFall17V2Iso_WPL')",bool,doc="MVA Iso ID V2 loose WP"),
405  mvaFall17V2noIso = Var("userFloat('mvaFall17V2noIso')",float,doc="MVA noIso ID V2 score"),
406  mvaFall17V2noIso_WP80 = Var("userInt('mvaFall17V2noIso_WP80')",bool,doc="MVA noIso ID V2 WP80"),
407  mvaFall17V2noIso_WP90 = Var("userInt('mvaFall17V2noIso_WP90')",bool,doc="MVA noIso ID V2 WP90"),
408  mvaFall17V2noIso_WPL = Var("userInt('mvaFall17V2noIso_WPL')",bool,doc="MVA noIso ID V2 loose WP"),
409 
410  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)"),
411  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)"),
412  vidNestedWPBitmap = Var("userInt('VIDNestedWPBitmap')",int,doc=_bitmapVIDForEle_docstring),
413  vidNestedWPBitmapHEEP = Var("userInt('VIDNestedWPBitmapHEEP')",int,doc=_bitmapVIDForEleHEEP_docstring),
414  cutBased_HEEP = Var("userInt('cutbasedID_HEEP')",bool,doc="cut-based HEEP ID"),
415  miniPFRelIso_chg = Var("userFloat('miniIsoChg')/pt",float,doc="mini PF relative isolation, charged component"),
416  miniPFRelIso_all = Var("userFloat('miniIsoAll')/pt",float,doc="mini PF relative isolation, total (with scaled rho*EA PU corrections)"),
417  pfRelIso03_chg = Var("userFloat('PFIsoChg')/pt",float,doc="PF relative isolation dR=0.3, charged component"),
418  pfRelIso03_all = Var("userFloat('PFIsoAll')/pt",float,doc="PF relative isolation dR=0.3, total (with rho*EA PU corrections)"),
419  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),
420  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),
421  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),
422  dr03TkSumPtHEEP = Var("?pt>35?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),
423  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),
424  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),
425  hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8),
426  tightCharge = Var("isGsfCtfScPixChargeConsistent() + isGsfScPixChargeConsistent()",int,doc="Tight charge criteria (0:none, 1:isGsfScPixChargeConsistent, 2:isGsfCtfScPixChargeConsistent)"),
427  convVeto = Var("passConversionVeto()",bool,doc="pass conversion veto"),
428  lostHits = Var("gsfTrack.hitPattern.numberOfLostHits('MISSING_INNER_HITS')","uint8",doc="number of missing inner hits"),
429  isPFcand = Var("pfCandidateRef().isNonnull()",bool,doc="electron is PF candidate"),
430  seedGain = Var("userInt('seedGain')","uint8",doc="Gain of the seed crystal"),
431  jetNDauCharged = Var("?userCand('jetForLepJetVar').isNonnull()?userFloat('jetNDauChargedMVASel'):0", "uint8", doc="number of charged daughters of the closest jet"),
432  ),
433  externalVariables = cms.PSet(
434  mvaTTH = ExtVar(cms.InputTag("electronMVATTH"),float, doc="TTH MVA lepton ID score",precision=14),
435  ),
436 )
437 
438 #the94X miniAOD V2 had a bug in the scale and smearing for electrons in the E/p comb
439 #therefore we redo it but but we need use a new name for the userFloat as we cant override existing userfloats
440 #for technical reasons
441 for modifier in run2_egamma_2017,run2_egamma_2018, run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_miniAOD_80XLegacy,run2_nanoAOD_102Xv1:
442  modifier.toModify(electronTable.variables,
443  pt = Var("pt*userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, precision=-1, doc="p_{T}"),
444  energyErr = Var("userFloat('ecalTrkEnergyErrPostCorrNew')", float, precision=6, doc="energy error of the cluster-track combination"),
445  eCorr = Var("userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, doc="ratio of the calibrated energy/miniaod energy"),
446  scEtOverPt = Var("(superCluster().energy()/(pt*userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')*cosh(superCluster().eta())))-1",float,doc="(supercluster transverse energy)/pt-1",precision=8),
447 )
448 
449 # scale and smearing only when available
450 for modifier in run2_nanoAOD_94X2016,:
451  modifier.toModify(electronTable.variables,
452  pt = Var("pt*userFloat('ecalTrkEnergyPostCorr')/userFloat('ecalTrkEnergyPreCorr')", float, precision=-1, doc="p_{T}"),
453  energyErr = Var("userFloat('ecalTrkEnergyErrPostCorr')", float, precision=6, doc="energy error of the cluster-track combination"),
454  eCorr = Var("userFloat('ecalTrkEnergyPostCorr')/userFloat('ecalTrkEnergyPreCorr')", float, doc="ratio of the calibrated energy/miniaod energy"),
455  scEtOverPt = Var("(superCluster().energy()/(pt*userFloat('ecalTrkEnergyPostCorr')/userFloat('ecalTrkEnergyPreCorr')*cosh(superCluster().eta())))-1",float,doc="(supercluster transverse energy)/pt-1",precision=8),
456  )
457 
458 run2_nanoAOD_94X2016.toModify(electronTable.variables,
459  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)"),
460  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)"),
461  #cutBased in 2016 corresponds to Spring16 not Fall17V2, so have to add in V2 ID explicitly
462  #it also doesnt exist in the miniAOD so have to redo it
463  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)"),
464  cutBased_HLTPreSel = Var("userInt('cutbasedID_HLT')",int,doc="cut-based HLT pre-selection ID"),
465  cutBased_HEEP = Var("electronID('heepElectronID-HEEPV70')",bool,doc="cut-based HEEP ID"),
466  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)"),
467  mvaSpring16GP = Var("userFloat('ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values')",float,doc="MVA Spring16 general-purpose ID score"),
468  mvaSpring16GP_WP80 = Var("electronID('mvaEleID-Spring16-GeneralPurpose-V1-wp80')",bool,doc="MVA Spring16 general-purpose ID WP80"),
469  mvaSpring16GP_WP90 = Var("electronID('mvaEleID-Spring16-GeneralPurpose-V1-wp90')",bool,doc="MVA Spring16 general-purpose ID WP90"),
470  mvaSpring16HZZ = Var("userFloat('ElectronMVAEstimatorRun2Spring16HZZV1Values')",float,doc="MVA Spring16 HZZ ID score"),
471  mvaSpring16HZZ_WPL = Var("electronID('mvaEleID-Spring16-HZZ-V1-wpLoose')",bool,doc="MVA Spring16 HZZ ID loose WP"),
472  mvaFall17V1Iso = Var("userFloat('ElectronMVAEstimatorRun2Fall17IsoV1Values')",float,doc="MVA Fall17 V1 Iso ID score"),
473  mvaFall17V1Iso_WP80 = Var("electronID('mvaEleID-Fall17-iso-V1-wp80')",bool,doc="MVA Fall17 V1 Iso ID WP80"),
474  mvaFall17V1Iso_WP90 = Var("electronID('mvaEleID-Fall17-iso-V1-wp90')",bool,doc="MVA Fall17 V1 Iso ID WP90"),
475  mvaFall17V1Iso_WPL = Var("electronID('mvaEleID-Fall17-iso-V1-wpLoose')",bool,doc="MVA Fall17 V1 Iso ID loose WP"),
476  mvaFall17V1noIso = Var("userFloat('ElectronMVAEstimatorRun2Fall17NoIsoV1Values')",float,doc="MVA Fall17 V1 noIso ID score"),
477  mvaFall17V1noIso_WP80 = Var("electronID('mvaEleID-Fall17-noIso-V1-wp80')",bool,doc="MVA Fall17 V1 noIso ID WP80"),
478  mvaFall17V1noIso_WP90 = Var("electronID('mvaEleID-Fall17-noIso-V1-wp90')",bool,doc="MVA Fall17 V1 noIso ID WP90"),
479  mvaFall17V1noIso_WPL = Var("electronID('mvaEleID-Fall17-noIso-V1-wpLoose')",bool,doc="MVA Fall17 V1 noIso ID loose WP"),
480  vidNestedWPBitmapSpring15 = Var("userInt('VIDNestedWPBitmapSpring15')",int,doc=_bitmapVIDForEleSpring15_docstring),
481  vidNestedWPBitmapSum16 = Var("userInt('VIDNestedWPBitmapSum16')",int,doc=_bitmapVIDForEleSum16_docstring),
482 )
483 run2_miniAOD_80XLegacy.toModify(electronTable.variables,
484  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)"),
485  cutBased_HLTPreSel = Var("userInt('cutbasedID_HLT')",int,doc="cut-based HLT pre-selection ID"),
486  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)"),
487  mvaSpring16GP = Var("userFloat('mvaSpring16GP')",float,doc="MVA general-purpose ID score"),
488  mvaSpring16GP_WP80 = Var("userInt('mvaSpring16GP_WP80')",bool,doc="MVA general-purpose ID WP80"),
489  mvaSpring16GP_WP90 = Var("userInt('mvaSpring16GP_WP90')",bool,doc="MVA general-purpose ID WP90"),
490  mvaSpring16HZZ = Var("userFloat('mvaSpring16HZZ')",float,doc="MVA HZZ ID score"),
491  mvaSpring16HZZ_WPL = Var("userInt('mvaSpring16HZZ_WPL')",bool,doc="MVA HZZ ID loose WP"),
492 
493  vidNestedWPBitmapSpring15 = Var("userInt('VIDNestedWPBitmapSpring15')",int,doc=_bitmapVIDForEleSpring15_docstring),
494  vidNestedWPBitmapSum16 = Var("userInt('VIDNestedWPBitmapSum16')",int,doc=_bitmapVIDForEleSum16_docstring),
495 
496 )
497 
498 electronsMCMatchForTable = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
499  src = electronTable.src, # final reco collection
500  matched = cms.InputTag("finalGenParticles"), # final mc-truth particle collection
501  mcPdgId = cms.vint32(11,22), # one or more PDG ID (11 = el, 22 = pho); absolute values (see below)
502  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
503  mcStatus = cms.vint32(1), # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering)
504  maxDeltaR = cms.double(0.3), # Minimum deltaR for the match
505  maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match
506  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
507  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
508 )
509 
510 electronMCTable = cms.EDProducer("CandMCMatchTableProducer",
511  src = electronTable.src,
512  mcMap = cms.InputTag("electronsMCMatchForTable"),
513  objName = electronTable.name,
514  objType = electronTable.name, #cms.string("Electron"),
515  branchName = cms.string("genPart"),
516  docString = cms.string("MC matching to status==1 electrons or photons"),
517 )
518 
519 electronSequence = cms.Sequence(bitmapVIDForEle + bitmapVIDForEleHEEP + isoForEle + ptRatioRelForEle + seedGainEle + slimmedElectronsWithUserData + finalElectrons)
520 electronTables = cms.Sequence (electronMVATTH + electronTable)
521 electronMC = cms.Sequence(electronsMCMatchForTable + electronMCTable)
522 from RecoEgamma.ElectronIdentification.heepIdVarValueMapProducer_cfi import heepIDVarValueMaps
523 _updateTo106X_sequence =cms.Sequence(heepIDVarValueMaps + slimmedElectronsTo106X)
524 heepIDVarValueMaps.dataFormat = 2
525 
526 _withTo106XAndUpdate_sequence = cms.Sequence(_updateTo106X_sequence + slimmedElectronsUpdated + electronSequence.copy())
527 
528 _withULAndUpdate_sequence = cms.Sequence(slimmedElectronsUpdated + electronSequence.copy())
529 
530 _withUL17AndUpdateScale_sequence = _withULAndUpdate_sequence.copy()
531 _withUL17AndUpdateScale_sequence.replace(slimmedElectronsWithUserData, calibratedPatElectronsUL17 + slimmedElectronsWithUserData)
532 run2_egamma_2017.toReplaceWith(electronSequence, _withUL17AndUpdateScale_sequence)
533 
534 _withUL18AndUpdateScale_sequence = _withULAndUpdate_sequence.copy()
535 _withUL18AndUpdateScale_sequence.replace(slimmedElectronsWithUserData, calibratedPatElectronsUL18 + slimmedElectronsWithUserData)
536 run2_egamma_2018.toReplaceWith(electronSequence, _withUL18AndUpdateScale_sequence)
537 
538 _withTo106XAndUpdateAnd80XLegacyScale_sequence = _withTo106XAndUpdate_sequence.copy()
539 _withTo106XAndUpdateAnd80XLegacyScale_sequence.replace(slimmedElectronsWithUserData, calibratedPatElectrons80XLegacy + bitmapVIDForEleSpring15 +bitmapVIDForEleSum16 + slimmedElectronsWithUserData)
540 run2_miniAOD_80XLegacy.toReplaceWith(electronSequence, _withTo106XAndUpdateAnd80XLegacyScale_sequence)
541 
542 _withTo106XAndUpdateAnd94XScale_sequence = _withTo106XAndUpdate_sequence.copy()
543 _withTo106XAndUpdateAnd94XScale_sequence.replace(slimmedElectronsWithUserData, calibratedPatElectrons94X + slimmedElectronsWithUserData)
544 run2_nanoAOD_94XMiniAODv1.toReplaceWith(electronSequence, _withTo106XAndUpdateAnd94XScale_sequence)
545 run2_nanoAOD_94XMiniAODv2.toReplaceWith(electronSequence, _withTo106XAndUpdateAnd94XScale_sequence)
546 
547 _withTo106XAndUpdateAnd_bitmapVIDForEleSpring15AndSum16_sequence = _withTo106XAndUpdate_sequence.copy()
548 _withTo106XAndUpdateAnd_bitmapVIDForEleSpring15AndSum16_sequence.replace(slimmedElectronsWithUserData, bitmapVIDForEleSpring15 + bitmapVIDForEleSum16 + slimmedElectronsWithUserData)
549 run2_nanoAOD_94X2016.toReplaceWith(electronSequence, _withTo106XAndUpdateAnd_bitmapVIDForEleSpring15AndSum16_sequence)
550 
551 _withTo106XAndUpdateAnd102XScale_sequence = _withTo106XAndUpdate_sequence.copy()
552 _withTo106XAndUpdateAnd102XScale_sequence.replace(slimmedElectronsWithUserData, calibratedPatElectrons102X + slimmedElectronsWithUserData)
553 run2_nanoAOD_102Xv1.toReplaceWith(electronSequence, _withTo106XAndUpdateAnd102XScale_sequence)
554 
555 _withUpdate_sequence = electronSequence.copy()
556 _withUpdate_sequence.replace(bitmapVIDForEle, slimmedElectronsUpdated + bitmapVIDForEle)
557 run2_nanoAOD_106Xv1.toReplaceWith(electronSequence, _withUpdate_sequence)
electrons_cff._get_bitmapVIDForEle_docstring
def _get_bitmapVIDForEle_docstring(modules, WorkingPoints)
Definition: electrons_cff.py:88
electronProducer_cfi
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
common_cff
common_cff.Var
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
common_cff.ExtVar
def ExtVar(tag, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:31
nano_eras_cff
electrons_cff.int
int
Definition: electrons_cff.py:377
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23