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