CMS 3D CMS Logo

electrons_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
5 from math import ceil,log
6 #NOTE: All definitions of modules should point to the latest flavour of the electronTable in NanoAOD.
7 #Common modifications for past eras are done at the end whereas modifications specific to a single era is done after the original definition.
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 
37 for modifier in run2_miniAOD_80XLegacy,run2_nanoAOD_94X2016,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1:
38  modifier.toModify(slimmedElectronsUpdated, src = "slimmedElectronsTo106X" )
39 
40 electron_id_modules_WorkingPoints_nanoAOD = cms.PSet(
41  modules = cms.vstring(
42  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
43  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
44  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
45  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
46  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
47  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
48  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
49  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer16UL_ID_ISO_cff',
50  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer17UL_ID_ISO_cff',
51  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer18UL_ID_ISO_cff',
52  ),
53  WorkingPoints = cms.vstring(
54  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto",
55  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose",
56  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium",
57  "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight",
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 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  srcForID = cms.InputTag("reducedEgamma","reducedGedGsfElectrons"),
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  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 )
110 _bitmapVIDForEleSpring15_docstring = _get_bitmapVIDForEle_docstring(electron_id_modules_WorkingPoints_nanoAOD.modules,bitmapVIDForEleSpring15.WorkingPoints)
111 
112 bitmapVIDForEleSum16 = bitmapVIDForEle.clone(
113  WorkingPoints = cms.vstring(
114  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto",
115  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose",
116  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium",
117  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight",
118  )
119 )
120 _bitmapVIDForEleSum16_docstring = _get_bitmapVIDForEle_docstring(electron_id_modules_WorkingPoints_nanoAOD.modules,bitmapVIDForEleSum16.WorkingPoints)
121 
122 bitmapVIDForEleHEEP = bitmapVIDForEle.clone(
123  WorkingPoints = cms.vstring("egmGsfElectronIDs:heepElectronID-HEEPV70"
124  )
125 )
126 _bitmapVIDForEleHEEP_docstring = _get_bitmapVIDForEle_docstring(electron_id_modules_WorkingPoints_nanoAOD.modules,bitmapVIDForEleHEEP.WorkingPoints)
127 
130 isoForEle = cms.EDProducer("EleIsoValueMapProducer",
131  src = cms.InputTag("slimmedElectrons"),
132  relative = cms.bool(False),
133  rho_MiniIso = cms.InputTag("fixedGridRhoFastjetAll"),
134  rho_PFIso = cms.InputTag("fixedGridRhoFastjetAll"),
135  EAFile_MiniIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
136  EAFile_PFIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
137 )
138 run2_miniAOD_80XLegacy.toModify(isoForEle,
139  EAFile_MiniIso = "RecoEgamma/ElectronIdentification/data/Spring15/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_25ns.txt",
140  EAFile_PFIso = "RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_80X.txt")
141 run2_nanoAOD_94X2016.toModify(isoForEle,
142  EAFile_MiniIso = "RecoEgamma/ElectronIdentification/data/Spring15/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_25ns.txt",
143  EAFile_PFIso = "RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_80X.txt")
144 
147 ptRatioRelForEle = cms.EDProducer("ElectronJetVarProducer",
148  srcJet = cms.InputTag("updatedJetsPuppi"),
149  srcLep = cms.InputTag("slimmedElectrons"),
150  srcVtx = cms.InputTag("offlineSlimmedPrimaryVertices"),
151 )
152 
154 seedGainEle = cms.EDProducer("ElectronSeedGainProducer", src = cms.InputTag("slimmedElectrons"))
155 
158 import RecoEgamma.EgammaTools.calibratedEgammas_cff
159 
160 calibratedPatElectronsNano = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatElectrons.clone(
161  produceCalibratedObjs = False,
162  src = "slimmedElectrons"
163 )
164 
165 (run2_egamma_2016 & tracker_apv_vfp30_2016).toModify(calibratedPatElectronsNano,
166  correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_preVFP_RunFineEtaR9Gain"
167 )
168 
169 (run2_egamma_2016 & ~tracker_apv_vfp30_2016).toModify(calibratedPatElectronsNano,
170  correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_postVFP_RunFineEtaR9Gain"
171 )
172 
173 run2_egamma_2017.toModify(calibratedPatElectronsNano,
174  correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_24Feb2020_runEtaR9Gain_v2"
175 )
176 
177 run2_egamma_2018.toModify(calibratedPatElectronsNano,
178  correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_29Sep2020_RunFineEtaR9Gain"
179 )
180 
181 run2_miniAOD_80XLegacy.toModify(calibratedPatElectronsNano,
182  correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Legacy2016_07Aug2017_FineEtaR9_v3_ele_unc"
183  )
184 
185 for modifier in run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2:
186  modifier.toModify(calibratedPatElectronsNano,
187  correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_17Nov2017_v1_ele_unc"
188  )
189 
190 run2_nanoAOD_102Xv1.toModify(calibratedPatElectronsNano,
191  correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_Step2Closure_CoarseEtaR9Gain_v2"
192 )
193 
196 slimmedElectronsWithUserData = cms.EDProducer("PATElectronUserDataEmbedder",
197  src = cms.InputTag("slimmedElectrons"),
198  parentSrcs = cms.VInputTag("reducedEgamma:reducedGedGsfElectrons"),
199  userFloats = cms.PSet(
200  mvaFall17V1Iso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV1Values"),
201  mvaFall17V1noIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV1Values"),
202  mvaIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV2Values"),
203  mvaNoIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV2Values"),
204  mvaHZZIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Summer18ULIdIsoValues"),
205  miniIsoChg = cms.InputTag("isoForEle:miniIsoChg"),
206  miniIsoAll = cms.InputTag("isoForEle:miniIsoAll"),
207  PFIsoChg = cms.InputTag("isoForEle:PFIsoChg"),
208  PFIsoAll = cms.InputTag("isoForEle:PFIsoAll"),
209  PFIsoAll04 = cms.InputTag("isoForEle:PFIsoAll04"),
210  ptRatio = cms.InputTag("ptRatioRelForEle:ptRatio"),
211  ptRel = cms.InputTag("ptRatioRelForEle:ptRel"),
212  jetNDauChargedMVASel = cms.InputTag("ptRatioRelForEle:jetNDauChargedMVASel"),
213  ecalTrkEnergyErrPostCorrNew = cms.InputTag("calibratedPatElectronsNano","ecalTrkEnergyErrPostCorr"),
214  ecalTrkEnergyPreCorrNew = cms.InputTag("calibratedPatElectronsNano","ecalTrkEnergyPreCorr"),
215  ecalTrkEnergyPostCorrNew = cms.InputTag("calibratedPatElectronsNano","ecalTrkEnergyPostCorr"),
216  energyScaleUpNew = cms.InputTag("calibratedPatElectronsNano","energyScaleUp"),
217  energyScaleDownNew = cms.InputTag("calibratedPatElectronsNano","energyScaleDown"),
218  energySigmaUpNew = cms.InputTag("calibratedPatElectronsNano","energySigmaUp"),
219  energySigmaDownNew = cms.InputTag("calibratedPatElectronsNano","energySigmaDown"),
220 
221  ),
222  userIntFromBools = cms.PSet(
223 
224  mvaFall17V1Iso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp90"),
225  mvaFall17V1Iso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp80"),
226  mvaFall17V1Iso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wpLoose"),
227  mvaFall17V1noIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp90"),
228  mvaFall17V1noIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp80"),
229  mvaFall17V1noIso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wpLoose"),
230 
231  mvaIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp90"),
232  mvaIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp80"),
233  mvaIso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wpLoose"),
234  mvaNoIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp90"),
235  mvaNoIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp80"),
236  mvaNoIso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wpLoose"),
237 
238  cutbasedID_Fall17_V1_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-veto"),
239  cutbasedID_Fall17_V1_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-loose"),
240  cutbasedID_Fall17_V1_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-medium"),
241  cutbasedID_Fall17_V1_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-tight"),
242  cutbasedID_Fall17_V2_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto"),
243  cutbasedID_Fall17_V2_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose"),
244  cutbasedID_Fall17_V2_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium"),
245  cutbasedID_Fall17_V2_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight"),
246  cutbasedID_HEEP = cms.InputTag("egmGsfElectronIDs:heepElectronID-HEEPV70"),
247  ),
248  userInts = cms.PSet(
249  VIDNestedWPBitmap = cms.InputTag("bitmapVIDForEle"),
250  VIDNestedWPBitmapHEEP = cms.InputTag("bitmapVIDForEleHEEP"),
251  seedGain = cms.InputTag("seedGainEle"),
252  ),
253  userCands = cms.PSet(
254  jetForLepJetVar = cms.InputTag("ptRatioRelForEle:jetForLepJetVar") # warning: Ptr is null if no match is found
255  ),
256 )
257 
258 
259 run2_nanoAOD_94X2016.toModify(slimmedElectronsWithUserData.userFloats,
260  ecalTrkEnergyErrPostCorrNew = None,
261  ecalTrkEnergyPreCorrNew = None,
262  ecalTrkEnergyPostCorrNew = None,
263  energyScaleUpNew = None,
264  energyScaleDownNew = None,
265  energySigmaUpNew = None,
266  energySigmaDownNew = None
267 
268 
269 )
270 
271 run2_nanoAOD_94X2016.toModify(slimmedElectronsWithUserData.userIntFromBools,
272  # MVAs and HEEP are already pre-computed. Cut-based too (except V2), but we re-add it for consistency with the nested bitmap
273  cutbasedID_Sum16_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto"),
274  cutbasedID_Sum16_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose"),
275  cutbasedID_Sum16_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium"),
276  cutbasedID_Sum16_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight"),
277  cutbasedID_HLT = cms.InputTag("egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1"),
278  cutbasedID_Spring15_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto"),
279  cutbasedID_Spring15_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose"),
280  cutbasedID_Spring15_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium"),
281  cutbasedID_Spring15_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight"),
282  cutbasedID_Fall17_V2_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto"),
283  cutbasedID_Fall17_V2_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose"),
284  cutbasedID_Fall17_V2_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium"),
285  cutbasedID_Fall17_V2_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight"),
286 
287 )
288 
289 run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userFloats,
290  mvaSpring16GP = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values"),
291  mvaSpring16HZZ = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16HZZV1Values"),
292 )
293 
294 run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userIntFromBools,
295  mvaSpring16GP_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp90"),
296  mvaSpring16GP_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp80"),
297  mvaSpring16HZZ_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-HZZ-V1-wpLoose"),
298  cutbasedID_Sum16_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto"),
299  cutbasedID_Sum16_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose"),
300  cutbasedID_Sum16_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium"),
301  cutbasedID_Sum16_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight"),
302  cutbasedID_HLT = cms.InputTag("egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1"),
303  cutbasedID_Spring15_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto"),
304  cutbasedID_Spring15_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose"),
305  cutbasedID_Spring15_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium"),
306  cutbasedID_Spring15_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight"),
307 )
308 
309 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
310  modifier.toModify(slimmedElectronsWithUserData.userInts,
311  VIDNestedWPBitmapSpring15 = cms.InputTag("bitmapVIDForEleSpring15"),
312  VIDNestedWPBitmapSum16 = cms.InputTag("bitmapVIDForEleSum16"),
313  )
314 (~run2_nanoAOD_preUL & run2_egamma_2016).toModify(slimmedElectronsWithUserData.userFloats,
315  mvaHZZIso = "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Summer16ULIdIsoValues",
316 )
317 (~run2_nanoAOD_preUL & run2_egamma_2017).toModify(slimmedElectronsWithUserData.userFloats,
318  mvaHZZIso = "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Summer17ULIdIsoValues" ,
319 )
320 (~run2_nanoAOD_preUL & run2_egamma_2018).toModify(slimmedElectronsWithUserData.userFloats,
321  mvaHZZIso = "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Summer18ULIdIsoValues",
322 )
323 
325 finalElectrons = cms.EDFilter("PATElectronRefSelector",
326  src = cms.InputTag("slimmedElectronsWithUserData"),
327  cut = cms.string("pt > 5 ")
328 )
329 
331 electronMVATTH= cms.EDProducer("EleBaseMVAValueMapProducer",
332  src = cms.InputTag("linkedObjects","electrons"),
333  weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/el_BDTG_2017.weights.xml"),
334  name = cms.string("electronMVATTH"),
335  isClassifier = cms.bool(True),
336  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"]),
337  variables = cms.PSet(
338  LepGood_pt = cms.string("pt"),
339  LepGood_eta = cms.string("eta"),
340  LepGood_jetNDauChargedMVASel = cms.string("?userCand('jetForLepJetVar').isNonnull()?userFloat('jetNDauChargedMVASel'):0"),
341  LepGood_miniRelIsoCharged = cms.string("userFloat('miniIsoChg')/pt"),
342  LepGood_miniRelIsoNeutral = cms.string("(userFloat('miniIsoAll')-userFloat('miniIsoChg'))/pt"),
343  LepGood_jetPtRelv2 = cms.string("?userCand('jetForLepJetVar').isNonnull()?userFloat('ptRel'):0"),
344  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"),
345  LepGood_jetPtRatio = cms.string("?userCand('jetForLepJetVar').isNonnull()?min(userFloat('ptRatio'),1.5):1.0/(1.0+userFloat('PFIsoAll04')/pt)"),
346  LepGood_dxy = cms.string("log(abs(dB('PV2D')))"),
347  LepGood_sip3d = cms.string("abs(dB('PV3D')/edB('PV3D'))"),
348  LepGood_dz = cms.string("log(abs(dB('PVDZ')))"),
349  LepGood_mvaFall17V2noIso = cms.string("userFloat('mvaNoIso')"),
350  )
351 )
352 run2_egamma_2016.toModify(electronMVATTH,
353  weightFile = "PhysicsTools/NanoAOD/data/el_BDTG_2016.weights.xml",
354 )
355 
357 electronTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
358  src = cms.InputTag("linkedObjects","electrons"),
359  cut = cms.string(""), #we should not filter on cross linked collections
360  name= cms.string("Electron"),
361  doc = cms.string("slimmedElectrons after basic selection (" + finalElectrons.cut.value()+")"),
362  singleton = cms.bool(False), # the number of entries is variable
363  extension = cms.bool(False), # this is the main table for the electrons
364  variables = cms.PSet(CandVars,
365  jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"),
366  photonIdx = Var("?overlaps('photons').size()>0?overlaps('photons')[0].key():-1", int, doc="index of the associated photon (-1 if none)"),
367  energyErr = Var("p4Error('P4_COMBINATION')",float,doc="energy error of the cluster-track combination",precision=6),
368  dz = Var("dB('PVDZ')",float,doc="dz (with sign) wrt first PV, in cm",precision=10),
369  dzErr = Var("abs(edB('PVDZ'))",float,doc="dz uncertainty, in cm",precision=6),
370  dxy = Var("dB('PV2D')",float,doc="dxy (with sign) wrt first PV, in cm",precision=10),
371  dxyErr = Var("edB('PV2D')",float,doc="dxy uncertainty, in cm",precision=6),
372  ip3d = Var("abs(dB('PV3D'))",float,doc="3D impact parameter wrt first PV, in cm",precision=10),
373  sip3d = Var("abs(dB('PV3D')/edB('PV3D'))",float,doc="3D impact parameter significance wrt first PV, in cm",precision=10),
374  deltaEtaSC = Var("superCluster().eta()-eta()",float,doc="delta eta (SC,ele) with sign",precision=10),
375  r9 = Var("full5x5_r9()",float,doc="R9 of the supercluster, calculated with full 5x5 region",precision=10),
376  sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10),
377  eInvMinusPInv = Var("(1-eSuperClusterOverP())/ecalEnergy()",float,doc="1/E_SC - 1/p_trk",precision=10),
378  scEtOverPt = Var("(superCluster().energy()/(pt*cosh(superCluster().eta())))-1",float,doc="(supercluster transverse energy)/pt-1",precision=8),
379 
380  mvaIso = Var("userFloat('mvaIso')",float,doc="MVA Iso ID V2 score"),
381  mvaIso_WP80 = Var("userInt('mvaIso_WP80')",bool,doc="MVA Iso ID V2 WP80"),
382  mvaIso_WP90 = Var("userInt('mvaIso_WP90')",bool,doc="MVA Iso ID V2 WP90"),
383  mvaIso_WPL = Var("userInt('mvaIso_WPL')",bool,doc="MVA Iso ID V2 loose WP"),
384  mvaNoIso = Var("userFloat('mvaNoIso')",float,doc="MVA noIso ID V2 score"),
385  mvaNoIso_WP80 = Var("userInt('mvaNoIso_WP80')",bool,doc="MVA noIso ID V2 WP80"),
386  mvaNoIso_WP90 = Var("userInt('mvaNoIso_WP90')",bool,doc="MVA noIso ID V2 WP90"),
387  mvaNoIso_WPL = Var("userInt('mvaNoIso_WPL')",bool,doc="MVA noIso ID V2 loose WP"),
388  mvaHZZIso = Var("userFloat('mvaHZZIso')", float,doc="HZZ MVA Iso ID score"),
389 
390  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)"),
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?dr03HcalTowerSumEt(1):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  jetNDauCharged = Var("?userCand('jetForLepJetVar').isNonnull()?userFloat('jetNDauChargedMVASel'):0", "uint8", doc="number of charged daughters of the closest jet"),
411  ),
412  externalVariables = cms.PSet(
413  mvaTTH = ExtVar(cms.InputTag("electronMVATTH"),float, doc="TTH MVA lepton ID score",precision=14),
414  fsrPhotonIdx = ExtVar(cms.InputTag("leptonFSRphotons:eleFsrIndex"),int, doc="Index of the lowest-dR/ET2 among associated FSR photons"),
415  ),
416 )
417 
418 #for technical reasons
419 for modifier in run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_miniAOD_80XLegacy,run2_nanoAOD_102Xv1,run2_nanoAOD_106Xv1,run2_nanoAOD_106Xv2:
420  modifier.toModify(electronTable.variables,
421  pt = Var("pt*userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, precision=-1, doc="p_{T}"),
422  energyErr = Var("userFloat('ecalTrkEnergyErrPostCorrNew')", float, precision=6, doc="energy error of the cluster-track combination"),
423  eCorr = Var("userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, doc="ratio of the calibrated energy/miniaod energy"),
424  scEtOverPt = Var("(superCluster().energy()/(pt*userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')*cosh(superCluster().eta())))-1",float,doc="(supercluster transverse energy)/pt-1",precision=8),
425  dEscaleUp=Var("userFloat('ecalTrkEnergyPostCorrNew')-userFloat('energyScaleUpNew')", float, doc="ecal energy scale shifted 1 sigma up(adding gain/stat/syst in quadrature)", precision=8),
426  dEscaleDown=Var("userFloat('ecalTrkEnergyPostCorrNew')-userFloat('energyScaleDownNew')", float, doc="ecal energy scale shifted 1 sigma down (adding gain/stat/syst in quadrature)", precision=8),
427  dEsigmaUp=Var("userFloat('ecalTrkEnergyPostCorrNew')-userFloat('energySigmaUpNew')", float, doc="ecal energy smearing value shifted 1 sigma up", precision=8),
428  dEsigmaDown=Var("userFloat('ecalTrkEnergyPostCorrNew')-userFloat('energySigmaDownNew')", float, doc="ecal energy smearing value shifted 1 sigma up", precision=8),
429 
430 )
431 
432 (run2_nanoAOD_92X | run2_nanoAOD_94XMiniAODv1 | run2_nanoAOD_94XMiniAODv2 | run2_nanoAOD_94X2016 | run2_nanoAOD_102Xv1).toModify(electronTable.variables,
433  mvaFall17V1Iso = Var("userFloat('mvaFall17V1Iso')",float,doc="MVA Iso ID V1 score"),
434  mvaFall17V1Iso_WP80 = Var("userInt('mvaFall17V1Iso_WP80')",bool,doc="MVA Iso ID V1 WP80"),
435  mvaFall17V1Iso_WP90 = Var("userInt('mvaFall17V1Iso_WP90')",bool,doc="MVA Iso ID V1 WP90"),
436  mvaFall17V1Iso_WPL = Var("userInt('mvaFall17V1Iso_WPL')",bool,doc="MVA Iso ID V1 loose WP"),
437  mvaFall17V1noIso = Var("userFloat('mvaFall17V1noIso')",float,doc="MVA noIso ID V1 score"),
438  mvaFall17V1noIso_WP80 = Var("userInt('mvaFall17V1noIso_WP80')",bool,doc="MVA noIso ID V1 WP80"),
439  mvaFall17V1noIso_WP90 = Var("userInt('mvaFall17V1noIso_WP90')",bool,doc="MVA noIso ID V1 WP90"),
440  mvaFall17V1noIso_WPL = Var("userInt('mvaFall17V1noIso_WPL')",bool,doc="MVA noIso ID V1 loose WP"),
441  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)"),
442 )
443 
444 #the94X miniAOD V2 had a bug in the scale and smearing for electrons in the E/p comb
445 #therefore we redo it but but we need use a new name for the userFloat as we cant override existing userfloats
446 # scale and smearing only when available#ONLY needed for this era
447 run2_nanoAOD_94X2016.toModify(electronTable.variables,
448  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)"),
449  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)"),
450  #cutBased in 2016 corresponds to Spring16 not Fall17V2, so have to add in V2 ID explicitly
451  #it also doesnt exist in the miniAOD so have to redo it
452  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)"),
453  cutBased_HLTPreSel = Var("userInt('cutbasedID_HLT')",int,doc="cut-based HLT pre-selection ID"),
454  cutBased_HEEP = Var("electronID('heepElectronID-HEEPV70')",bool,doc="cut-based HEEP ID"),
455  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)"),
456  mvaSpring16GP = Var("userFloat('ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values')",float,doc="MVA Spring16 general-purpose ID score"),
457  mvaSpring16GP_WP80 = Var("electronID('mvaEleID-Spring16-GeneralPurpose-V1-wp80')",bool,doc="MVA Spring16 general-purpose ID WP80"),
458  mvaSpring16GP_WP90 = Var("electronID('mvaEleID-Spring16-GeneralPurpose-V1-wp90')",bool,doc="MVA Spring16 general-purpose ID WP90"),
459  mvaSpring16HZZ = Var("userFloat('ElectronMVAEstimatorRun2Spring16HZZV1Values')",float,doc="MVA Spring16 HZZ ID score"),
460  mvaSpring16HZZ_WPL = Var("electronID('mvaEleID-Spring16-HZZ-V1-wpLoose')",bool,doc="MVA Spring16 HZZ ID loose WP"),
461  mvaFall17V1Iso = Var("userFloat('ElectronMVAEstimatorRun2Fall17IsoV1Values')",float,doc="MVA Fall17 V1 Iso ID score"),
462  mvaFall17V1Iso_WP80 = Var("electronID('mvaEleID-Fall17-iso-V1-wp80')",bool,doc="MVA Fall17 V1 Iso ID WP80"),
463  mvaFall17V1Iso_WP90 = Var("electronID('mvaEleID-Fall17-iso-V1-wp90')",bool,doc="MVA Fall17 V1 Iso ID WP90"),
464  mvaFall17V1Iso_WPL = Var("electronID('mvaEleID-Fall17-iso-V1-wpLoose')",bool,doc="MVA Fall17 V1 Iso ID loose WP"),
465  mvaFall17V1noIso = Var("userFloat('ElectronMVAEstimatorRun2Fall17NoIsoV1Values')",float,doc="MVA Fall17 V1 noIso ID score"),
466  mvaFall17V1noIso_WP80 = Var("electronID('mvaEleID-Fall17-noIso-V1-wp80')",bool,doc="MVA Fall17 V1 noIso ID WP80"),
467  mvaFall17V1noIso_WP90 = Var("electronID('mvaEleID-Fall17-noIso-V1-wp90')",bool,doc="MVA Fall17 V1 noIso ID WP90"),
468  mvaFall17V1noIso_WPL = Var("electronID('mvaEleID-Fall17-noIso-V1-wpLoose')",bool,doc="MVA Fall17 V1 noIso ID loose WP"),
469  vidNestedWPBitmapSpring15 = Var("userInt('VIDNestedWPBitmapSpring15')",int,doc=_bitmapVIDForEleSpring15_docstring),
470  vidNestedWPBitmapSum16 = Var("userInt('VIDNestedWPBitmapSum16')",int,doc=_bitmapVIDForEleSum16_docstring),
471  pt = Var("pt*userFloat('ecalTrkEnergyPostCorr')/userFloat('ecalTrkEnergyPreCorr')", float, precision=-1, doc="p_{T}"),
472  energyErr = Var("userFloat('ecalTrkEnergyErrPostCorr')", float, precision=6, doc="energy error of the cluster-track combination"),
473  eCorr = Var("userFloat('ecalTrkEnergyPostCorr')/userFloat('ecalTrkEnergyPreCorr')", float, doc="ratio of the calibrated energy/miniaod energy"),
474  scEtOverPt = Var("(superCluster().energy()/(pt*userFloat('ecalTrkEnergyPostCorr')/userFloat('ecalTrkEnergyPreCorr')*cosh(superCluster().eta())))-1",float,doc="(supercluster transverse energy)/pt-1",precision=8),
475  dEscaleUp=Var("userFloat('ecalTrkEnergyPostCorr')-userFloat('energyScaleUp')", float, doc="ecal energy scale shifted 1 sigma up (adding gain/stat/syst in quadrature)", precision=8),
476  dEscaleDown=Var("userFloat('ecalTrkEnergyPostCorr')-userFloat('energyScaleDown')", float, doc="ecal energy scale shifted 1 sigma down (adding gain/stat/syst in quadrature)", precision=8),
477  dEsigmaUp=Var("userFloat('ecalTrkEnergyPostCorr')-userFloat('energySigmaUp')", float, doc="ecal energy smearing value shifted 1 sigma up", precision=8),
478  dEsigmaDown=Var("userFloat('ecalTrkEnergyPostCorr')-userFloat('energySigmaDown')", float, doc="ecal energy smearing value shifted 1 sigma up", precision=8),
479 )
480 
481 run2_miniAOD_80XLegacy.toModify(electronTable.variables,
482  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)"),
483  cutBased_HLTPreSel = Var("userInt('cutbasedID_HLT')",int,doc="cut-based HLT pre-selection ID"),
484  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)"),
485  mvaSpring16GP = Var("userFloat('mvaSpring16GP')",float,doc="MVA general-purpose ID score"),
486  mvaSpring16GP_WP80 = Var("userInt('mvaSpring16GP_WP80')",bool,doc="MVA general-purpose ID WP80"),
487  mvaSpring16GP_WP90 = Var("userInt('mvaSpring16GP_WP90')",bool,doc="MVA general-purpose ID WP90"),
488  mvaSpring16HZZ = Var("userFloat('mvaSpring16HZZ')",float,doc="MVA HZZ ID score"),
489  mvaSpring16HZZ_WPL = Var("userInt('mvaSpring16HZZ_WPL')",bool,doc="MVA HZZ ID loose WP"),
490 
491  vidNestedWPBitmapSpring15 = Var("userInt('VIDNestedWPBitmapSpring15')",int,doc=_bitmapVIDForEleSpring15_docstring),
492  vidNestedWPBitmapSum16 = Var("userInt('VIDNestedWPBitmapSum16')",int,doc=_bitmapVIDForEleSum16_docstring),
493 
494 )
495 
497 tautaggerForMatching = cms.EDProducer("GenJetTauTaggerProducer",
498  src = cms.InputTag('particleLevel:leptons')
499 )
500 
501 matchingElecPhoton = cms.EDProducer("GenJetGenPartMerger",
502  srcJet =cms.InputTag("particleLevel:leptons"),
503  srcPart=cms.InputTag("particleLevel:photons"),
504  cut = cms.string("pt > 3"),
505  hasTauAnc=cms.InputTag("tautaggerForMatching"),
506 )
507 electronsMCMatchForTableAlt = cms.EDProducer("GenJetMatcherDRPtByDR", # cut on deltaR, deltaPt/Pt; pick best by deltaR
508  src = electronTable.src, # final reco collection
509  matched = cms.InputTag("matchingElecPhoton:merged"), # final mc-truth particle collection
510  mcPdgId = cms.vint32(11,22), # one or more PDG ID (11 = el, 22 = pho); absolute values (see below)
511  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
512  mcStatus = cms.vint32(),
513  maxDeltaR = cms.double(0.3), # Minimum deltaR for the match
514  maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match
515  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
516  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
517 )
518 electronsMCMatchForTable = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
519  src = electronTable.src, # final reco collection
520  matched = cms.InputTag("finalGenParticles"), # final mc-truth particle collection
521  mcPdgId = cms.vint32(11,22), # one or more PDG ID (11 = el, 22 = pho); absolute values (see below)
522  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
523  mcStatus = cms.vint32(1), # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering)
524  maxDeltaR = cms.double(0.3), # Minimum deltaR for the match
525  maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match
526  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
527  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
528 )
529 #should be cloned from PhysicsTools/NanoAOD/python/candMcMatchTable_cfi.py
530 electronMCTable = cms.EDProducer("CandMCMatchTableProducer",
531  src = electronTable.src,
532  mcMapDressedLep = cms.InputTag("electronsMCMatchForTableAlt"),
533  mcMap = cms.InputTag("electronsMCMatchForTable"),
534  mapTauAnc = cms.InputTag("matchingElecPhoton:hasTauAnc"),
535  objName = electronTable.name,
536  objType = electronTable.name, #cms.string("Electron"),
537  branchName = cms.string("genPart"),
538  docString = cms.string("MC matching to status==1 electrons or photons"),
539  genparticles = cms.InputTag("finalGenParticles"),
540 )
541 
542 electronTask = cms.Task(bitmapVIDForEle,bitmapVIDForEleHEEP,isoForEle,ptRatioRelForEle,seedGainEle,calibratedPatElectronsNano,slimmedElectronsWithUserData,finalElectrons)
543 electronTablesTask = cms.Task(electronMVATTH, electronTable)
544 electronMCTask = cms.Task(tautaggerForMatching, matchingElecPhoton, electronsMCMatchForTable, electronsMCMatchForTableAlt, electronMCTable)
545 
546 # Revert back to AK4 CHS jets for Run 2
547 run2_nanoAOD_ANY.toModify(ptRatioRelForEle,srcJet="updatedJets")
548 
549 
550 #for NANO from reminAOD, no need to run slimmedElectronsUpdated, other modules of electron sequence will run on slimmedElectrons
551 for modifier in run2_miniAOD_80XLegacy,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_94X2016,run2_nanoAOD_102Xv1,run2_nanoAOD_106Xv1:
552  modifier.toModify(bitmapVIDForEle, src = "slimmedElectronsUpdated")
553  modifier.toModify(bitmapVIDForEleSpring15, src = "slimmedElectronsUpdated")
554  modifier.toModify(bitmapVIDForEleSum16, src = "slimmedElectronsUpdated")
555  modifier.toModify(bitmapVIDForEleHEEP, src = "slimmedElectronsUpdated")
556  modifier.toModify(isoForEle, src = "slimmedElectronsUpdated")
557  modifier.toModify(ptRatioRelForEle, srcLep = "slimmedElectronsUpdated")
558  modifier.toModify(seedGainEle, src = "slimmedElectronsUpdated")
559  modifier.toModify(slimmedElectronsWithUserData, src = "slimmedElectronsUpdated")
560  modifier.toModify(calibratedPatElectronsNano, src = "slimmedElectronsUpdated")
561 
562  _withULAndUpdate_Task = cms.Task(slimmedElectronsUpdated)
563  _withULAndUpdate_Task.add(electronTask.copy())
564  modifier.toReplaceWith(electronTask, _withULAndUpdate_Task)
565 
566 from RecoEgamma.ElectronIdentification.heepIdVarValueMapProducer_cfi import heepIDVarValueMaps
567 _withTo106XAndUpdate_Task = cms.Task(heepIDVarValueMaps,slimmedElectronsTo106X)
568 _withTo106XAndUpdate_Task.add(electronTask.copy())
569 heepIDVarValueMaps.dataFormat = 2
570 
571 for modifier in run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_94XMiniAODv1:
572  modifier.toReplaceWith(electronTask, _withTo106XAndUpdate_Task)
573 
574 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
575  _withTo106XAndUpdateAnd80XLegacyScale_Task = cms.Task(bitmapVIDForEleSpring15,bitmapVIDForEleSum16)
576  _withTo106XAndUpdateAnd80XLegacyScale_Task.add(_withTo106XAndUpdate_Task.copy())
577  modifier.toReplaceWith(electronTask, _withTo106XAndUpdateAnd80XLegacyScale_Task)
578 
579 _withTo106XAndUpdateAnd94XScale_Task = _withTo106XAndUpdate_Task.copy()
580 for modifier in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1:
581  modifier.toReplaceWith(electronTask, _withTo106XAndUpdate_Task)
constexpr int32_t ceil(float num)
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:19