CMS 3D CMS Logo

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