1 from PhysicsTools.Heppy.physicsobjects.Lepton
import Lepton
8 '''Initializing tightIdResult to None. The user is responsible
9 for setting this attribute externally if he wants to use the tightId
11 super(Electron, self).
__init__(*args, **kwargs)
24 if id
is None or id ==
"":
return True
26 if rho ==
None and hasattr(self,
'rho')
and self.
rho !=
None: rho = self.
rho
27 if id ==
"POG_MVA_ID_NonTrig":
return self.
mvaIDLoose()
28 elif id ==
"POG_MVA_ID_Trig":
return self.
mvaIDTight()
29 elif id ==
"POG_MVA_ID_NonTrig_full5x5":
return self.
mvaIDLoose(full5x5=
True)
30 elif id ==
"POG_MVA_ID_Trig_full5x5":
return self.
mvaIDTight(full5x5=
True)
31 elif id ==
"POG_MVA_ID_Run2_NonTrig_VLoose":
return self.
mvaIDRun2(
"NonTrigPhys14",
"VLoose")
32 elif id ==
"POG_MVA_ID_Run2_NonTrig_Loose":
return self.
mvaIDRun2(
"NonTrigPhys14",
"Loose")
33 elif id ==
"POG_MVA_ID_Run2_NonTrig_Tight":
return self.
mvaIDRun2(
"NonTrigPhys14",
"Tight")
34 elif id.startswith(
"POG_Cuts_ID_"):
35 return self.
cutBasedId(id.replace(
"POG_Cuts_ID_",
"POG_"))
36 for ID
in self.electronIDs():
39 raise RuntimeError,
"Electron id '%s' not yet implemented in Electron.py" % id
43 showerShapes =
"full5x5"
44 wp = wp.replace(
"_full5x5",
"")
45 elif showerShapes ==
"auto":
46 if "POG_CSA14_25ns_v1" in wp
or "POG_CSA14_50ns_v1" in wp
or "POG_PHYS14_25ns_v1" in wp
or "POG_PHYS14_25ns_v1_ConvVeto" in wp
or "POG_PHYS14_25ns_v1_ConvVetoDxyDz" in wp:
47 showerShapes =
"full5x5"
49 'dEtaIn' :
abs(self.physObj.deltaEtaSuperClusterTrackAtVtx()),
50 'dPhiIn' :
abs(self.physObj.deltaPhiSuperClusterTrackAtVtx()),
51 'sigmaIEtaIEta' : self.physObj.full5x5_sigmaIetaIeta()
if showerShapes ==
"full5x5" else self.physObj.sigmaIetaIeta(),
52 'H/E' : self.physObj.hadronicOverEm(),
54 '1/E-1/p' :
abs(1.0/self.physObj.ecalEnergy() - self.physObj.eSuperClusterOverP()/self.physObj.ecalEnergy())
if self.physObj.ecalEnergy()>0.
else 9e9,
55 'conversionVeto' : self.physObj.passConversionVeto(),
56 'missingHits' : self.physObj.gsfTrack().hitPattern().numberOfHits(ROOT.reco.HitPattern.MISSING_INNER_HITS),
58 'dz' :
abs(self.
dz()),
62 'POG_2012_Veto' : [(
'dEtaIn', [0.007, 0.01]), (
'dPhiIn', [0.8, 0.7 ]), (
'sigmaIEtaIEta', [0.01, 0.03]), (
'H/E', [0.15, 9e9]), (
'1/E-1/p', [9e9, 9e9])],
63 'POG_2012_Loose' : [(
'dEtaIn', [0.007, 0.009]), (
'dPhiIn', [0.15, 0.1 ]), (
'sigmaIEtaIEta', [0.01, 0.03]), (
'H/E', [0.12, 0.1]), (
'1/E-1/p', [0.05, 0.05])],
64 'POG_2012_Medium' : [(
'dEtaIn', [0.004, 0.007]), (
'dPhiIn', [0.06, 0.03]), (
'sigmaIEtaIEta', [0.01, 0.03]), (
'H/E', [0.12, 0.1]), (
'1/E-1/p', [0.05, 0.05])],
65 'POG_2012_Tight' : [(
'dEtaIn', [0.004, 0.005]), (
'dPhiIn', [0.03, 0.02]), (
'sigmaIEtaIEta', [0.01, 0.03]), (
'H/E', [0.12, 0.1]), (
'1/E-1/p', [0.05, 0.05])],
69 'POG_CSA14_25ns_v1_Veto' : [(
'dEtaIn', [0.017938, 0.014569]), (
'dPhiIn', [0.182958, 0.230914]), (
'sigmaIEtaIEta', [0.012708, 0.036384]), (
'H/E', [0.335015, 0.200792]), (
'1/E-1/p', [0.198287, 0.146856])],
70 'POG_CSA14_25ns_v1_Loose' : [(
'dEtaIn', [0.014928, 0.013045]), (
'dPhiIn', [0.141050, 0.149017]), (
'sigmaIEtaIEta', [0.011304, 0.035536]), (
'H/E', [0.127690, 0.107898]), (
'1/E-1/p', [0.097806, 0.102261])],
71 'POG_CSA14_25ns_v1_Medium' : [(
'dEtaIn', [0.013071, 0.010006]), (
'dPhiIn', [0.132113, 0.052321]), (
'sigmaIEtaIEta', [0.010726, 0.032882]), (
'H/E', [0.109761, 0.101755]), (
'1/E-1/p', [0.032639, 0.041427])],
72 'POG_CSA14_25ns_v1_Tight' : [(
'dEtaIn', [0.012671, 0.008823]), (
'dPhiIn', [0.025218, 0.027286]), (
'sigmaIEtaIEta', [0.010061, 0.030222]), (
'H/E', [0.065085, 0.090710]), (
'1/E-1/p', [0.027873, 0.019404])],
73 'POG_CSA14_50ns_v1_Veto' : [(
'dEtaIn', [0.021, 0.028]), (
'dPhiIn', [0.25 , 0.23 ]), (
'sigmaIEtaIEta', [0.012, 0.035]), (
'H/E', [0.24 , 0.19 ]), (
'1/E-1/p', [0.32 , 0.13 ])],
74 'POG_CSA14_50ns_v1_Loose' : [(
'dEtaIn', [0.016, 0.025]), (
'dPhiIn', [0.080, 0.097]), (
'sigmaIEtaIEta', [0.012, 0.032]), (
'H/E', [0.15 , 0.12 ]), (
'1/E-1/p', [0.11 , 0.11 ])],
75 'POG_CSA14_50ns_v1_Medium' : [(
'dEtaIn', [0.015, 0.023]), (
'dPhiIn', [0.051, 0.056]), (
'sigmaIEtaIEta', [0.010, 0.030]), (
'H/E', [0.10 , 0.099]), (
'1/E-1/p', [0.053, 0.11 ])],
76 'POG_CSA14_50ns_v1_Tight' : [(
'dEtaIn', [0.012, 0.019]), (
'dPhiIn', [0.024, 0.043]), (
'sigmaIEtaIEta', [0.010, 0.029]), (
'H/E', [0.074, 0.080]), (
'1/E-1/p', [0.026, 0.076])],
78 'POG_PHYS14_25ns_v1_Veto' : [(
'dEtaIn', [0.016315, 0.010671]), (
'dPhiIn', [0.252044, 0.245263]), (
'sigmaIEtaIEta', [0.011100 , 0.033987]), (
'H/E', [0.345843, 0.134691]), (
'1/E-1/p', [0.248070, 0.157160])],
79 'POG_PHYS14_25ns_v1_Loose' : [(
'dEtaIn', [0.012442, 0.010654]), (
'dPhiIn', [0.072624, 0.145129]), (
'sigmaIEtaIEta', [0.010557 , 0.032602]), (
'H/E', [0.121476, 0.131862]), (
'1/E-1/p', [0.221803, 0.142283])],
80 'POG_PHYS14_25ns_v1_Medium' : [(
'dEtaIn', [0.007641, 0.009285]), (
'dPhiIn', [0.032643, 0.042447]), (
'sigmaIEtaIEta', [0.010399 , 0.029524]), (
'H/E', [0.060662, 0.104263]), (
'1/E-1/p', [0.153897, 0.137468])],
81 'POG_PHYS14_25ns_v1_Tight' : [(
'dEtaIn', [0.006574, 0.005681]), (
'dPhiIn', [0.022868, 0.032046]), (
'sigmaIEtaIEta', [0.010181 , 0.028766]), (
'H/E', [0.037553, 0.081902]), (
'1/E-1/p', [0.131191, 0.106055])],
83 WP_conversion_veto = {
86 'POG_CSA14_25ns_v1_ConvVeto_Veto' : WP[
'POG_CSA14_25ns_v1_Veto' ]+[(
'conversionVeto', [
True,
True]), (
'missingHits', [3, 4])],
87 'POG_CSA14_25ns_v1_ConvVeto_Loose' : WP[
'POG_CSA14_25ns_v1_Loose' ]+[(
'conversionVeto', [
True,
True]), (
'missingHits', [2, 2])],
88 'POG_CSA14_25ns_v1_ConvVeto_Medium' : WP[
'POG_CSA14_25ns_v1_Medium']+[(
'conversionVeto', [
True,
True]), (
'missingHits', [2, 2])],
89 'POG_CSA14_25ns_v1_ConvVeto_Tight' : WP[
'POG_CSA14_25ns_v1_Tight' ]+[(
'conversionVeto', [
True,
True]), (
'missingHits', [2, 2])],
90 'POG_CSA14_50ns_v1_ConvVeto_Veto' : WP[
'POG_CSA14_50ns_v1_Veto' ]+[(
'conversionVeto', [
True,
True]), (
'missingHits', [3, 4])],
91 'POG_CSA14_50ns_v1_ConvVeto_Loose' : WP[
'POG_CSA14_50ns_v1_Loose' ]+[(
'conversionVeto', [
True,
True]), (
'missingHits', [2, 2])],
92 'POG_CSA14_50ns_v1_ConvVeto_Medium' : WP[
'POG_CSA14_50ns_v1_Medium']+[(
'conversionVeto', [
True,
True]), (
'missingHits', [2, 2])],
93 'POG_CSA14_50ns_v1_ConvVeto_Tight' : WP[
'POG_CSA14_50ns_v1_Tight' ]+[(
'conversionVeto', [
True,
True]), (
'missingHits', [2, 2])],
95 'POG_PHYS14_25ns_v1_ConvVeto_Veto' : WP[
'POG_PHYS14_25ns_v1_Veto' ]+[(
'conversionVeto', [
True,
True]), (
'missingHits', [3, 4])],
96 'POG_PHYS14_25ns_v1_ConvVeto_Loose' : WP[
'POG_PHYS14_25ns_v1_Loose' ]+[(
'conversionVeto', [
True,
True]), (
'missingHits', [2, 2])],
97 'POG_PHYS14_25ns_v1_ConvVeto_Medium' : WP[
'POG_PHYS14_25ns_v1_Medium']+[(
'conversionVeto', [
True,
True]), (
'missingHits', [2, 2])],
98 'POG_PHYS14_25ns_v1_ConvVeto_Tight' : WP[
'POG_PHYS14_25ns_v1_Tight' ]+[(
'conversionVeto', [
True,
True]), (
'missingHits', [2, 2])],
101 WP.update(WP_conversion_veto)
103 WP_conversion_veto_DxyDz = {
106 'POG_PHYS14_25ns_v1_ConvVetoDxyDz_Veto' : WP[
'POG_PHYS14_25ns_v1_ConvVeto_Veto' ]+[(
'dxy',[0.060279, 0.273097]), (
'dz',[0.800538, 0.885860])],
107 'POG_PHYS14_25ns_v1_ConvVetoDxyDz_Loose' : WP[
'POG_PHYS14_25ns_v1_ConvVeto_Loose' ]+[(
'dxy',[0.022664, 0.097358]), (
'dz',[0.173670, 0.198444])],
108 'POG_PHYS14_25ns_v1_ConvVetoDxyDz_Medium' : WP[
'POG_PHYS14_25ns_v1_ConvVeto_Medium']+[(
'dxy',[0.011811, 0.051682]), (
'dz',[0.070775, 0.180720])],
109 'POG_PHYS14_25ns_v1_ConvVetoDxyDz_Tight' : WP[
'POG_PHYS14_25ns_v1_ConvVeto_Tight' ]+[(
'dxy',[0.009924, 0.027261]), (
'dz',[0.015310, 0.147154])],
112 WP.update(WP_conversion_veto_DxyDz)
116 raise RuntimeError,
"Working point '%s' not yet implemented in Electron.py" % wp
117 for (cut_name,(cut_eb,cut_ee))
in WP[wp]:
118 if cut_name ==
'conversionVeto':
119 if (cut_eb
if self.physObj.isEB()
else cut_ee)
and not vars[cut_name]:
121 elif vars[cut_name] >= (cut_eb
if self.physObj.isEB()
else cut_ee):
126 '''MIKE, missing doc.
127 Should have the same name as the function in the mother class.
128 Can call the mother class function with super.
130 return self.absIsoFromEA(rho,self.superCluster().
eta(),effectiveAreas.eGamma)
140 if self.
associatedVertex ==
None:
raise RuntimeError,
"You need to set electron.associatedVertex before calling any MVA"
141 if self.
rho ==
None:
raise RuntimeError,
"You need to set electron.rho before calling any MVA"
147 if self.
associatedVertex ==
None:
raise RuntimeError,
"You need to set electron.associatedVertex before calling any MVA"
148 if self.
rho ==
None:
raise RuntimeError,
"You need to set electron.rho before calling any MVA"
154 if self.
associatedVertex ==
None:
raise RuntimeError,
"You need to set electron.associatedVertex before calling any MVA"
155 if self.
rho ==
None:
raise RuntimeError,
"You need to set electron.rho before calling any MVA"
161 if name
not in ElectronMVAID_ByName:
raise RuntimeError,
"Unknown electron run2 mva id %s (known ones are: %s)\n" % (name, ElectronMVAID_ByName.keys())
162 if self.
associatedVertex ==
None:
raise RuntimeError,
"You need to set electron.associatedVertex before calling any MVA"
163 if self.
rho ==
None:
raise RuntimeError,
"You need to set electron.rho before calling any MVA"
168 eta =
abs(self.superCluster().
eta())
170 if (eta < 0.8) :
return self.
mvaTrigV0(full5x5) > +0.00;
171 elif (eta < 1.479):
return self.
mvaTrigV0(full5x5) > +0.10;
172 else :
return self.
mvaTrigV0(full5x5) > +0.62;
174 if (eta < 0.8) :
return self.
mvaTrigV0(full5x5) > +0.94;
175 elif (eta < 1.479):
return self.
mvaTrigV0(full5x5) > +0.85;
176 else :
return self.
mvaTrigV0(full5x5) > +0.92;
179 eta =
abs(self.superCluster().
eta())
181 if (eta < 0.8) :
return self.
mvaNonTrigV0(full5x5) > +0.47;
182 elif (eta < 1.479):
return self.
mvaNonTrigV0(full5x5) > +0.004;
185 if (eta < 0.8) :
return self.
mvaNonTrigV0(full5x5) > -0.34;
186 elif (eta < 1.479):
return self.
mvaNonTrigV0(full5x5) > -0.65;
190 eta =
abs(self.superCluster().
eta())
191 if name ==
"NonTrigPhys14":
193 if (eta < 0.8) :
return self.
mvaRun2(name) > +0.35;
194 elif (eta < 1.479):
return self.
mvaRun2(name) > +0.20;
195 else :
return self.
mvaRun2(name) > -0.52;
197 if (eta < 0.8) :
return self.
mvaRun2(name) > -0.11;
198 elif (eta < 1.479):
return self.
mvaRun2(name) > -0.35;
199 else :
return self.
mvaRun2(name) > -0.55;
201 if (eta < 0.8) :
return self.
mvaRun2(name) > 0.73;
202 elif (eta < 1.479):
return self.
mvaRun2(name) > 0.57;
203 else :
return self.
mvaRun2(name) > 0.05;
204 else:
raise RuntimeError,
"Ele MVA ID Working point not found"
205 else:
raise RuntimeError,
"Ele MVA ID type not found"
209 return self.
mvaIDLoose()
and (self.gsfTrack().trackerExpectedHitsInner().numberOfLostHits()<=1)
212 if R == 0.3:
return self.physObj.pfIsolationVariables().sumChargedHadronPt
213 elif R == 0.4:
return self.physObj.chargedHadronIso()
214 raise RuntimeError,
"Electron chargedHadronIso missing for R=%s" % R
217 if R == 0.3:
return self.physObj.pfIsolationVariables().sumNeutralHadronEt
218 elif R == 0.4:
return self.physObj.neutralHadronIso()
219 raise RuntimeError,
"Electron neutralHadronIso missing for R=%s" % R
222 if R == 0.3:
return self.physObj.pfIsolationVariables().sumPhotonEt
223 elif R == 0.4:
return self.physObj.photonIso()
224 raise RuntimeError,
"Electron photonIso missing for R=%s" % R
227 if R == 0.3:
return self.physObj.pfIsolationVariables().sumChargedParticlePt
228 raise RuntimeError,
"Electron chargedAllIso missing for R=%s" % R
231 raise RuntimeError,
"Electron chargedAllIso missing"
234 if R == 0.3:
return self.physObj.pfIsolationVariables().sumPUPt
235 elif R == 0.4:
return self.physObj.puChargedHadronIso()
236 raise RuntimeError,
"Electron chargedHadronIso missing for R=%s" % R
238 def dxy(self, vertex=None):
240 Computed using vertex (or self.associatedVertex if vertex not specified),
245 return self.gsfTrack().
dxy( vertex.position() )
248 '''returns the uncertainty on dxy (from gsf track)'''
249 return self.gsfTrack().dxyError()
252 return ROOT.reco.Candidate.p4(self.physObj)
257 def dz(self, vertex=None):
259 Computed using vertex (or self.associatedVertex if vertex not specified),
264 return self.gsfTrack().
dz( vertex.position() )
267 '''returns the uncertainty on dxz (from gsf track)'''
268 return self.gsfTrack().dzError()
272 if hasattr(self.gsfTrack(),
"trackerExpectedHitsInner") :
273 return self.gsfTrack().trackerExpectedHitsInner().numberOfLostHits()
275 return self.gsfTrack().hitPattern().numberOfHits(ROOT.reco.HitPattern.MISSING_INNER_HITS)
tuple ElectronMVAID_NonTrig
tuple ElectronMVAID_TrigNoIP
Abs< T >::type abs(const T &t)