CMS 3D CMS Logo

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