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_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
3 from Configuration.Eras.Modifier_run2_nanoAOD_92X_cff import run2_nanoAOD_92X
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
9 from math import ceil,log
10 
11 # this below is used only in some eras
12 slimmedElectronsUpdated = cms.EDProducer("PATElectronUpdater",
13  src = cms.InputTag("slimmedElectrons"),
14  vertices = cms.InputTag("offlineSlimmedPrimaryVertices"),
15  computeMiniIso = cms.bool(False),
16  pfCandsForMiniIso = cms.InputTag("packedPFCandidates"),
17  miniIsoParamsB = PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi.patElectrons.miniIsoParamsB, # so they're in sync
18  miniIsoParamsE = PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi.patElectrons.miniIsoParamsE, # so they're in sync
19 )
20 run2_miniAOD_80XLegacy.toModify( slimmedElectronsUpdated, computeMiniIso = True )
21 
22 from PhysicsTools.SelectorUtils.tools.vid_id_tools import setupVIDSelection
25 
26 electronMVAValueMapProducer.srcMiniAOD = cms.InputTag("slimmedElectrons")
27 run2_miniAOD_80XLegacy.toModify(electronMVAValueMapProducer, srcMiniAOD = "slimmedElectronsUpdated")
28 run2_nanoAOD_92X.toModify(electronMVAValueMapProducer, srcMiniAOD = "slimmedElectronsUpdated")
29 
30 electronMVAVariableHelper.srcMiniAOD = cms.InputTag("slimmedElectrons")
31 run2_miniAOD_80XLegacy.toModify(electronMVAVariableHelper, srcMiniAOD = "slimmedElectronsUpdated")
32 run2_nanoAOD_92X.toModify(electronMVAVariableHelper, srcMiniAOD = "slimmedElectronsUpdated")
33 
34 egmGsfElectronIDs.physicsObjectIDs = cms.VPSet()
35 egmGsfElectronIDs.physicsObjectSrc = cms.InputTag('slimmedElectrons')
36 run2_miniAOD_80XLegacy.toModify(egmGsfElectronIDs, physicsObjectSrc = "slimmedElectronsUpdated")
37 run2_nanoAOD_92X.toModify(egmGsfElectronIDs, physicsObjectSrc = "slimmedElectronsUpdated")
38 
39 heepIDVarValueMaps.elesMiniAOD = cms.InputTag('slimmedElectrons')
40 run2_miniAOD_80XLegacy.toModify(heepIDVarValueMaps, elesMiniAOD = "slimmedElectronsUpdated")
41 run2_nanoAOD_92X.toModify(heepIDVarValueMaps, elesMiniAOD = "slimmedElectronsUpdated")
42 
43 _electron_id_modules_WorkingPoints = cms.PSet(
44  modules = cms.vstring(
45  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
46  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
47  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
48  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
49  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
50  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
51  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_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 run2_miniAOD_80XLegacy.toModify(_electron_id_modules_WorkingPoints,
61  modules = cms.vstring(
62  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
63  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronHLTPreselecition_Summer16_V1_cff',
64  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
65  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff',
66  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff',
67  ),
68  WorkingPoints = cms.vstring(
69  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose",
70  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium",
71  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight",
72  )
73 )
74 run2_nanoAOD_94X2016.toModify(_electron_id_modules_WorkingPoints,
75  modules = cms.vstring(
76  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
77  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronHLTPreselecition_Summer16_V1_cff',
78  ),
79  WorkingPoints = cms.vstring(
80  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto",
81  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose",
82  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium",
83  "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight",
84  )
85 )
86 
87 
88 _bitmapVIDForEle_docstring = ''
89 for modname in _electron_id_modules_WorkingPoints.modules:
90  ids= __import__(modname, globals(), locals(), ['idName','cutFlow'])
91  for name in dir(ids):
92  _id = getattr(ids,name)
93  if hasattr(_id,'idName') and hasattr(_id,'cutFlow'):
94  setupVIDSelection(egmGsfElectronIDs,_id)
95  if (len(_electron_id_modules_WorkingPoints.WorkingPoints)>0 and _id.idName==_electron_id_modules_WorkingPoints.WorkingPoints[0].split(':')[-1]):
96  _bitmapVIDForEle_docstring = 'VID compressed bitmap (%s), %d bits per cut'%(','.join([cut.cutName.value() for cut in _id.cutFlow]),int(ceil(log(len(_electron_id_modules_WorkingPoints.WorkingPoints)+1,2))))
97 
98 bitmapVIDForEle = cms.EDProducer("EleVIDNestedWPBitmapProducer",
99  src = cms.InputTag("slimmedElectrons"),
100  WorkingPoints = _electron_id_modules_WorkingPoints.WorkingPoints,
101 )
102 run2_miniAOD_80XLegacy.toModify(bitmapVIDForEle, src = "slimmedElectronsUpdated")
103 run2_nanoAOD_92X.toModify(bitmapVIDForEle, src = "slimmedElectronsUpdated")
104 
105 isoForEle = cms.EDProducer("EleIsoValueMapProducer",
106  src = cms.InputTag("slimmedElectrons"),
107  relative = cms.bool(False),
108  rho_MiniIso = cms.InputTag("fixedGridRhoFastjetAll"),
109  rho_PFIso = cms.InputTag("fixedGridRhoFastjetAll"),
110  EAFile_MiniIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
111  EAFile_PFIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
112 )
113 run2_miniAOD_80XLegacy.toModify(isoForEle, src = "slimmedElectronsUpdated",
114  EAFile_MiniIso = "RecoEgamma/ElectronIdentification/data/Spring15/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_25ns.txt",
115  EAFile_PFIso = "RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_80X.txt")
116 run2_nanoAOD_92X.toModify(isoForEle, src = "slimmedElectronsUpdated")
117 
118 ptRatioRelForEle = cms.EDProducer("ElectronJetVarProducer",
119  srcJet = cms.InputTag("updatedJets"),
120  srcLep = cms.InputTag("slimmedElectrons"),
121  srcVtx = cms.InputTag("offlineSlimmedPrimaryVertices"),
122 )
123 run2_miniAOD_80XLegacy.toModify(ptRatioRelForEle, srcLep = "slimmedElectronsUpdated")
124 run2_nanoAOD_92X.toModify(ptRatioRelForEle, srcLep = "slimmedElectronsUpdated")
125 
126 import EgammaAnalysis.ElectronTools.calibratedElectronsRun2_cfi
127 calibratedPatElectrons80X = EgammaAnalysis.ElectronTools.calibratedElectronsRun2_cfi.calibratedPatElectrons.clone(
128  electrons = cms.InputTag("slimmedElectronsUpdated"),
129  correctionFile = cms.string("PhysicsTools/NanoAOD/data/80X_ichepV1_2016_ele"),
130  semiDeterministic = cms.bool(True)
131 )
132 energyCorrForEle80X = cms.EDProducer("ElectronEnergyVarProducer",
133  srcRaw = cms.InputTag("slimmedElectronsUpdated"),
134  srcCorr = cms.InputTag("calibratedPatElectrons80X"),
135 )
136 import RecoEgamma.EgammaTools.calibratedEgammas_cff
137 calibratedPatElectrons94Xv1 = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatElectrons.clone(
138  produceCalibratedObjs = False
139 )
140 
141 slimmedElectronsWithUserData = cms.EDProducer("PATElectronUserDataEmbedder",
142  src = cms.InputTag("slimmedElectrons"),
143  userFloats = cms.PSet(
144  mvaFall17V1Iso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV1Values"),
145  mvaFall17V1noIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV1Values"),
146  mvaFall17V2Iso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV2Values"),
147  mvaFall17V2noIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV2Values"),
148  miniIsoChg = cms.InputTag("isoForEle:miniIsoChg"),
149  miniIsoAll = cms.InputTag("isoForEle:miniIsoAll"),
150  PFIsoChg = cms.InputTag("isoForEle:PFIsoChg"),
151  PFIsoAll = cms.InputTag("isoForEle:PFIsoAll"),
152  PFIsoAll04 = cms.InputTag("isoForEle:PFIsoAll04"),
153  ptRatio = cms.InputTag("ptRatioRelForEle:ptRatio"),
154  ptRel = cms.InputTag("ptRatioRelForEle:ptRel"),
155  jetNDauChargedMVASel = cms.InputTag("ptRatioRelForEle:jetNDauChargedMVASel"),
156  ),
157  userIntFromBools = cms.PSet(
158 
159  mvaFall17V1Iso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp90"),
160  mvaFall17V1Iso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp80"),
161  mvaFall17V1Iso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wpLoose"),
162  mvaFall17V1noIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp90"),
163  mvaFall17V1noIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp80"),
164  mvaFall17V1noIso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wpLoose"),
165 
166  mvaFall17V2Iso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp90"),
167  mvaFall17V2Iso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp80"),
168  mvaFall17V2Iso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wpLoose"),
169  mvaFall17V2noIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp90"),
170  mvaFall17V2noIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp80"),
171  mvaFall17V2noIso_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wpLoose"),
172 
173  cutbasedID_Fall17_V1_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-veto"),
174  cutbasedID_Fall17_V1_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-loose"),
175  cutbasedID_Fall17_V1_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-medium"),
176  cutbasedID_Fall17_V1_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-tight"),
177  cutbasedID_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto"),
178  cutbasedID_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose"),
179  cutbasedID_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium"),
180  cutbasedID_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight"),
181  cutbasedID_HEEP = cms.InputTag("egmGsfElectronIDs:heepElectronID-HEEPV70"),
182  ),
183  userInts = cms.PSet(
184  VIDNestedWPBitmap = cms.InputTag("bitmapVIDForEle"),
185  ),
186  userCands = cms.PSet(
187  jetForLepJetVar = cms.InputTag("ptRatioRelForEle:jetForLepJetVar") # warning: Ptr is null if no match is found
188  ),
189 )
190 run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData, src = "slimmedElectronsUpdated")
191 run2_nanoAOD_92X.toModify(slimmedElectronsWithUserData, src = "slimmedElectronsUpdated")
192 run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userFloats,
193  mvaSpring16GP = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values"),
194  mvaSpring16HZZ = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16HZZV1Values"),
195  mvaFall17V1Iso = None,
196  mvaFall17V1noIso = None,
197  mvaFall17V2Iso = None,
198  mvaFall17V2noIso = None,
199  eCorr = cms.InputTag("energyCorrForEle80X","eCorr")
200 )
201 run2_nanoAOD_94X2016.toModify(slimmedElectronsWithUserData.userFloats,
202  mvaFall17V1Iso = None,
203  mvaFall17V1noIso = None,
204  mvaFall17V2Iso = None,
205  mvaFall17V2noIso = None,
206 )
207 run2_nanoAOD_94XMiniAODv1.toModify(slimmedElectronsWithUserData.userFloats,
208  ecalTrkEnergyErrPostCorr = cms.InputTag("calibratedPatElectrons94Xv1","ecalTrkEnergyErrPostCorr"),
209  ecalTrkEnergyPreCorr = cms.InputTag("calibratedPatElectrons94Xv1","ecalTrkEnergyPreCorr"),
210  ecalTrkEnergyPostCorr = cms.InputTag("calibratedPatElectrons94Xv1","ecalTrkEnergyPostCorr"),
211 )
212 run2_miniAOD_80XLegacy.toReplaceWith(slimmedElectronsWithUserData.userIntFromBools,
213  cms.PSet(
214  mvaSpring16GP_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp90"),
215  mvaSpring16GP_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-GeneralPurpose-V1-wp80"),
216  mvaSpring16HZZ_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Spring16-HZZ-V1-wpLoose"),
217  cutbasedID_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto"),
218  cutbasedID_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose"),
219  cutbasedID_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium"),
220  cutbasedID_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight"),
221  cutbasedID_HLT = cms.InputTag("egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1"),
222  cutbasedID_HEEP = cms.InputTag("egmGsfElectronIDs:heepElectronID-HEEPV70"),
223  )
224 )
225 run2_nanoAOD_94X2016.toReplaceWith(slimmedElectronsWithUserData.userIntFromBools,
226  cms.PSet(
227  # MVAs and HEEP are already pre-computed. Cut-based too, but we re-add it for consistency with the nested bitmap
228  cutbasedID_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto"),
229  cutbasedID_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose"),
230  cutbasedID_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium"),
231  cutbasedID_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight"),
232  cutbasedID_HLT = cms.InputTag("egmGsfElectronIDs:cutBasedElectronHLTPreselection-Summer16-V1"),
233  )
234 )
235 finalElectrons = cms.EDFilter("PATElectronRefSelector",
236  src = cms.InputTag("slimmedElectronsWithUserData"),
237  cut = cms.string("pt > 5 ")
238 )
239 
240 electronMVATTH= cms.EDProducer("EleBaseMVAValueMapProducer",
241  src = cms.InputTag("linkedObjects","electrons"),
242  weightFile = cms.FileInPath("PhysicsTools/NanoAOD/data/el_BDTG_94X.weights.xml"),
243  name = cms.string("electronMVATTH"),
244  isClassifier = cms.bool(True),
245  variablesOrder = cms.vstring(["LepGood_pt","LepGood_eta","LepGood_jetNDauChargedMVASel","LepGood_miniRelIsoCharged","LepGood_miniRelIsoNeutral","LepGood_jetPtRelv2","LepGood_jetBTagCSV","LepGood_jetPtRatio","LepGood_sip3d","LepGood_dxy","LepGood_dz","LepGood_mvaIdFall17noIso"]),
246  variables = cms.PSet(
247  LepGood_pt = cms.string("pt"),
248  LepGood_eta = cms.string("eta"),
249  LepGood_jetNDauChargedMVASel = cms.string("?userCand('jetForLepJetVar').isNonnull()?userFloat('jetNDauChargedMVASel'):0"),
250  LepGood_miniRelIsoCharged = cms.string("userFloat('miniIsoChg')/pt"),
251  LepGood_miniRelIsoNeutral = cms.string("(userFloat('miniIsoAll')-userFloat('miniIsoChg'))/pt"),
252  LepGood_jetPtRelv2 = cms.string("?userCand('jetForLepJetVar').isNonnull()?userFloat('ptRel'):0"),
253  LepGood_jetPtRatio = cms.string("?userCand('jetForLepJetVar').isNonnull()?min(userFloat('ptRatio'),1.5):1.0/(1.0+userFloat('PFIsoAll04')/pt)"),
254  LepGood_jetBTagCSV = cms.string("?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags'),0.0):0.0"),
255  LepGood_sip3d = cms.string("abs(dB('PV3D')/edB('PV3D'))"),
256  LepGood_dxy = cms.string("log(abs(dB('PV2D')))"),
257  LepGood_dz = cms.string("log(abs(dB('PVDZ')))"),
258  LepGood_mvaIdFall17noIso = cms.string("userFloat('mvaFall17V1noIso')"),
259  )
260 )
261 for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
262  modifier.toModify(electronMVATTH.variables,
263  LepGood_jetPtRatio = cms.string("?userCand('jetForLepJetVar').isNonnull()?min(userFloat('ptRatio'),1.5):1"),
264  LepGood_mvaIdSpring16HZZ = cms.string("userFloat('%s')" % ('mvaSpring16HZZ' if modifier == run2_miniAOD_80XLegacy else 'ElectronMVAEstimatorRun2Spring16HZZV1Values')),
265  LepGood_mvaIdFall17noIso = None)
266  modifier.toModify(electronMVATTH,
267  weightFile = "PhysicsTools/NanoAOD/data/el_BDTG.weights.xml",
268  variablesOrder = ["LepGood_pt","LepGood_eta","LepGood_jetNDauChargedMVASel","LepGood_miniRelIsoCharged","LepGood_miniRelIsoNeutral","LepGood_jetPtRelv2","LepGood_jetPtRatio","LepGood_jetBTagCSV","LepGood_sip3d","LepGood_dxy","LepGood_dz","LepGood_mvaIdSpring16HZZ"])
269 
270 electronTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
271  src = cms.InputTag("linkedObjects","electrons"),
272  cut = cms.string(""), #we should not filter on cross linked collections
273  name= cms.string("Electron"),
274  doc = cms.string("slimmedElectrons after basic selection (" + finalElectrons.cut.value()+")"),
275  singleton = cms.bool(False), # the number of entries is variable
276  extension = cms.bool(False), # this is the main table for the electrons
277  variables = cms.PSet(CandVars,
278  jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"),
279  photonIdx = Var("?overlaps('photons').size()>0?overlaps('photons')[0].key():-1", int, doc="index of the associated photon (-1 if none)"),
280  energyErr = Var("p4Error('P4_COMBINATION')",float,doc="energy error of the cluster-track combination",precision=6),
281  dz = Var("dB('PVDZ')",float,doc="dz (with sign) wrt first PV, in cm",precision=10),
282  dzErr = Var("abs(edB('PVDZ'))",float,doc="dz uncertainty, in cm",precision=6),
283  dxy = Var("dB('PV2D')",float,doc="dxy (with sign) wrt first PV, in cm",precision=10),
284  dxyErr = Var("edB('PV2D')",float,doc="dxy uncertainty, in cm",precision=6),
285  ip3d = Var("abs(dB('PV3D'))",float,doc="3D impact parameter wrt first PV, in cm",precision=10),
286  sip3d = Var("abs(dB('PV3D')/edB('PV3D'))",float,doc="3D impact parameter significance wrt first PV, in cm",precision=10),
287  deltaEtaSC = Var("superCluster().eta()-eta()",float,doc="delta eta (SC,ele) with sign",precision=10),
288  r9 = Var("full5x5_r9()",float,doc="R9 of the supercluster, calculated with full 5x5 region",precision=10),
289  sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10),
290  eInvMinusPInv = Var("(1-eSuperClusterOverP())/ecalEnergy()",float,doc="1/E_SC - 1/p_trk",precision=10),
291 
292  mvaFall17V1Iso = Var("userFloat('mvaFall17V1Iso')",float,doc="MVA Iso ID V1 score"),
293  mvaFall17V1Iso_WP80 = Var("userInt('mvaFall17V1Iso_WP80')",bool,doc="MVA Iso ID V1 WP80"),
294  mvaFall17V1Iso_WP90 = Var("userInt('mvaFall17V1Iso_WP90')",bool,doc="MVA Iso ID V1 WP90"),
295  mvaFall17V1Iso_WPL = Var("userInt('mvaFall17V1Iso_WPL')",bool,doc="MVA Iso ID V1 loose WP"),
296  mvaFall17V1noIso = Var("userFloat('mvaFall17V1noIso')",float,doc="MVA noIso ID V1 score"),
297  mvaFall17V1noIso_WP80 = Var("userInt('mvaFall17V1noIso_WP80')",bool,doc="MVA noIso ID V1 WP80"),
298  mvaFall17V1noIso_WP90 = Var("userInt('mvaFall17V1noIso_WP90')",bool,doc="MVA noIso ID V1 WP90"),
299  mvaFall17V1noIso_WPL = Var("userInt('mvaFall17V1noIso_WPL')",bool,doc="MVA noIso ID V1 loose WP"),
300 
301  mvaFall17V2Iso = Var("userFloat('mvaFall17V2Iso')",float,doc="MVA Iso ID V2 score"),
302  mvaFall17V2Iso_WP80 = Var("userInt('mvaFall17V2Iso_WP80')",bool,doc="MVA Iso ID V2 WP80"),
303  mvaFall17V2Iso_WP90 = Var("userInt('mvaFall17V2Iso_WP90')",bool,doc="MVA Iso ID V2 WP90"),
304  mvaFall17V2Iso_WPL = Var("userInt('mvaFall17V2Iso_WPL')",bool,doc="MVA Iso ID V2 loose WP"),
305  mvaFall17V2noIso = Var("userFloat('mvaFall17V2noIso')",float,doc="MVA noIso ID V2 score"),
306  mvaFall17V2noIso_WP80 = Var("userInt('mvaFall17V2noIso_WP80')",bool,doc="MVA noIso ID V2 WP80"),
307  mvaFall17V2noIso_WP90 = Var("userInt('mvaFall17V2noIso_WP90')",bool,doc="MVA noIso ID V2 WP90"),
308  mvaFall17V2noIso_WPL = Var("userInt('mvaFall17V2noIso_WPL')",bool,doc="MVA noIso ID V2 loose WP"),
309 
310  cutBased = Var("userInt('cutbasedID_veto')+userInt('cutbasedID_loose')+userInt('cutbasedID_medium')+userInt('cutbasedID_tight')",int,doc="cut-based ID (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
311  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)"),
312  vidNestedWPBitmap = Var("userInt('VIDNestedWPBitmap')",int,doc=_bitmapVIDForEle_docstring),
313  cutBased_HEEP = Var("userInt('cutbasedID_HEEP')",bool,doc="cut-based HEEP ID"),
314  miniPFRelIso_chg = Var("userFloat('miniIsoChg')/pt",float,doc="mini PF relative isolation, charged component"),
315  miniPFRelIso_all = Var("userFloat('miniIsoAll')/pt",float,doc="mini PF relative isolation, total (with scaled rho*EA PU corrections)"),
316  pfRelIso03_chg = Var("userFloat('PFIsoChg')/pt",float,doc="PF relative isolation dR=0.3, charged component"),
317  pfRelIso03_all = Var("userFloat('PFIsoAll')/pt",float,doc="PF relative isolation dR=0.3, total (with rho*EA PU corrections)"),
318  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),
319  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),
320  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),
321  hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8),
322  tightCharge = Var("isGsfCtfScPixChargeConsistent() + isGsfScPixChargeConsistent()",int,doc="Tight charge criteria (0:none, 1:isGsfScPixChargeConsistent, 2:isGsfCtfScPixChargeConsistent)"),
323  convVeto = Var("passConversionVeto()",bool,doc="pass conversion veto"),
324  lostHits = Var("gsfTrack.hitPattern.numberOfLostHits('MISSING_INNER_HITS')","uint8",doc="number of missing inner hits"),
325  isPFcand = Var("pfCandidateRef().isNonnull()",bool,doc="electron is PF candidate"),
326  ),
327  externalVariables = cms.PSet(
328  mvaTTH = ExtVar(cms.InputTag("electronMVATTH"),float, doc="TTH MVA lepton ID score",precision=14),
329  ),
330 )
331 # scale and smearing only when available
332 for modifier in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016:
333  modifier.toModify(electronTable.variables,
334  pt = Var("pt*userFloat('ecalTrkEnergyPostCorr')/userFloat('ecalTrkEnergyPreCorr')", float, precision=-1, doc="p_{T}"),
335  energyErr = Var("userFloat('ecalTrkEnergyErrPostCorr')", float, precision=6, doc="energy error of the cluster-track combination"),
336  eCorr = Var("userFloat('ecalTrkEnergyPostCorr')/userFloat('ecalTrkEnergyPreCorr')", float, doc="ratio of the calibrated energy/miniaod energy"),
337  )
338 run2_nanoAOD_94X2016.toModify(electronTable.variables,
339  cutBased = Var("userInt('cutbasedID_veto')+userInt('cutbasedID_loose')+userInt('cutbasedID_medium')+userInt('cutbasedID_tight')",int,doc="cut-based Summer16 ID (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
340  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)"),
341  cutBased_HLTPreSel = Var("userInt('cutbasedID_HLT')",int,doc="cut-based HLT pre-selection ID"),
342  cutBased_HEEP = Var("electronID('heepElectronID-HEEPV70')",bool,doc="cut-based HEEP ID"),
343  mvaSpring16GP = Var("userFloat('ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values')",float,doc="MVA Spring16 general-purpose ID score"),
344  mvaSpring16GP_WP80 = Var("electronID('mvaEleID-Spring16-GeneralPurpose-V1-wp80')",bool,doc="MVA Spring16 general-purpose ID WP80"),
345  mvaSpring16GP_WP90 = Var("electronID('mvaEleID-Spring16-GeneralPurpose-V1-wp90')",bool,doc="MVA Spring16 general-purpose ID WP90"),
346  mvaSpring16HZZ = Var("userFloat('ElectronMVAEstimatorRun2Spring16HZZV1Values')",float,doc="MVA Spring16 HZZ ID score"),
347  mvaSpring16HZZ_WPL = Var("electronID('mvaEleID-Spring16-HZZ-V1-wpLoose')",bool,doc="MVA Spring16 HZZ ID loose WP"),
348  mvaFall17V1Iso = Var("userFloat('ElectronMVAEstimatorRun2Fall17IsoV1Values')",float,doc="MVA Fall17 V1 Iso ID score"),
349  mvaFall17V1Iso_WP80 = Var("electronID('mvaEleID-Fall17-iso-V1-wp80')",bool,doc="MVA Fall17 V1 Iso ID WP80"),
350  mvaFall17V1Iso_WP90 = Var("electronID('mvaEleID-Fall17-iso-V1-wp90')",bool,doc="MVA Fall17 V1 Iso ID WP90"),
351  mvaFall17V1Iso_WPL = Var("electronID('mvaEleID-Fall17-iso-V1-wpLoose')",bool,doc="MVA Fall17 V1 Iso ID loose WP"),
352  mvaFall17V1noIso = Var("userFloat('ElectronMVAEstimatorRun2Fall17NoIsoV1Values')",float,doc="MVA Fall17 V1 noIso ID score"),
353  mvaFall17V1noIso_WP80 = Var("electronID('mvaEleID-Fall17-noIso-V1-wp80')",bool,doc="MVA Fall17 V1 noIso ID WP80"),
354  mvaFall17V1noIso_WP90 = Var("electronID('mvaEleID-Fall17-noIso-V1-wp90')",bool,doc="MVA Fall17 V1 noIso ID WP90"),
355  mvaFall17V1noIso_WPL = Var("electronID('mvaEleID-Fall17-noIso-V1-wpLoose')",bool,doc="MVA Fall17 V1 noIso ID loose WP"),
356  mvaFall17V2Iso = None,
357  mvaFall17V2Iso_WP80 = None,
358  mvaFall17V2Iso_WP90 = None,
359  mvaFall17V2Iso_WPL = None,
360  mvaFall17V2noIso = None,
361  mvaFall17V2noIso_WP80 = None,
362  mvaFall17V2noIso_WP90 = None,
363  mvaFall17V2noIso_WPL = None,
364 )
365 run2_miniAOD_80XLegacy.toModify(electronTable.variables,
366  cutBased_HLTPreSel = Var("userInt('cutbasedID_HLT')",int,doc="cut-based HLT pre-selection ID"),
367  mvaSpring16GP = Var("userFloat('mvaSpring16GP')",float,doc="MVA general-purpose ID score"),
368  mvaSpring16GP_WP80 = Var("userInt('mvaSpring16GP_WP80')",bool,doc="MVA general-purpose ID WP80"),
369  mvaSpring16GP_WP90 = Var("userInt('mvaSpring16GP_WP90')",bool,doc="MVA general-purpose ID WP90"),
370  mvaSpring16HZZ = Var("userFloat('mvaSpring16HZZ')",float,doc="MVA HZZ ID score"),
371  mvaSpring16HZZ_WPL = Var("userInt('mvaSpring16HZZ_WPL')",bool,doc="MVA HZZ ID loose WP"),
372 
373  mvaFall17V1Iso = None,
374  mvaFall17V1Iso_WP80 = None,
375  mvaFall17V1Iso_WP90 = None,
376  mvaFall17V1Iso_WPL = None,
377  mvaFall17V1noIso = None,
378  mvaFall17V1noIso_WP80 = None,
379  mvaFall17V1noIso_WP90 = None,
380  mvaFall17V1noIso_WPL = None,
381 
382  mvaFall17V2Iso = None,
383  mvaFall17V2Iso_WP80 = None,
384  mvaFall17V2Iso_WP90 = None,
385  mvaFall17V2Iso_WPL = None,
386  mvaFall17V2noIso = None,
387  mvaFall17V2noIso_WP80 = None,
388  mvaFall17V2noIso_WP90 = None,
389  mvaFall17V2noIso_WPL = None,
390 
391  cutBased_Fall17_V1 = None,
392 
393  pt = Var("pt*userFloat('eCorr')", float, precision=-1, doc="p_{T} after energy correction & smearing"),
394  energyErr = Var("p4Error('P4_COMBINATION')*userFloat('eCorr')",float,doc="energy error of the cluster-track combination",precision=6),
395  eCorr = Var("userFloat('eCorr')",float,doc="ratio of the calibrated energy/miniaod energy"),
396 )
397 
398 electronsMCMatchForTable = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
399  src = electronTable.src, # final reco collection
400  matched = cms.InputTag("finalGenParticles"), # final mc-truth particle collection
401  mcPdgId = cms.vint32(11,22), # one or more PDG ID (11 = el, 22 = pho); absolute values (see below)
402  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
403  mcStatus = cms.vint32(1), # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering)
404  maxDeltaR = cms.double(0.3), # Minimum deltaR for the match
405  maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match
406  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
407  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
408 )
409 
410 electronMCTable = cms.EDProducer("CandMCMatchTableProducer",
411  src = electronTable.src,
412  mcMap = cms.InputTag("electronsMCMatchForTable"),
413  objName = electronTable.name,
414  objType = electronTable.name, #cms.string("Electron"),
415  branchName = cms.string("genPart"),
416  docString = cms.string("MC matching to status==1 electrons or photons"),
417 )
418 
419 electronSequence = cms.Sequence(heepIDVarValueMaps + egmGsfElectronIDSequence + bitmapVIDForEle + isoForEle + ptRatioRelForEle + slimmedElectronsWithUserData + finalElectrons)
420 electronTables = cms.Sequence (electronMVATTH + electronTable)
421 electronMC = cms.Sequence(electronsMCMatchForTable + electronMCTable)
422 
423 _withUpdate_sequence = cms.Sequence(slimmedElectronsUpdated + electronSequence.copy())
424 run2_nanoAOD_92X.toReplaceWith(electronSequence, _withUpdate_sequence)
425 
426 _withUpdateAnd80XScale_sequence = _withUpdate_sequence.copy()
427 _withUpdateAnd80XScale_sequence.replace(slimmedElectronsWithUserData, calibratedPatElectrons80X + energyCorrForEle80X + slimmedElectronsWithUserData)
428 run2_miniAOD_80XLegacy.toReplaceWith(electronSequence, _withUpdateAnd80XScale_sequence)
429 
430 _with94Xv1Scale_sequence = electronSequence.copy()
431 _with94Xv1Scale_sequence.replace(slimmedElectronsWithUserData, calibratedPatElectrons94Xv1 + slimmedElectronsWithUserData)
432 run2_nanoAOD_94XMiniAODv1.toReplaceWith(electronSequence, _with94Xv1Scale_sequence)
433 
def ExtVar(tag, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:31
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
def setupVIDSelection(vidproducer, cutflow)
Definition: vid_id_tools.py:11
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
dbl *** dir
Definition: mlp_gen.cc:35
double split
Definition: MVATrainer.cc:139