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