1 from PhysicsTools.Heppy.physicsobjects.Lepton
import Lepton
2 from PhysicsTools.Heppy.physicsutils.ElectronMVAID
import ElectronMVAID_Trig, ElectronMVAID_NonTrig, ElectronMVAID_TrigNoIP
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)
20 if id
is None or id ==
"":
return True
22 if rho ==
None and hasattr(self,
'rho')
and self.
rho !=
None: rho = self.
rho
23 if id ==
"POG_MVA_ID_NonTrig":
return self.
mvaIDLoose()
24 elif id ==
"POG_MVA_ID_Trig":
return self.
mvaIDTight()
25 elif id ==
"POG_MVA_ID_NonTrig_full5x5":
return self.
mvaIDLoose(full5x5=
True)
26 elif id ==
"POG_MVA_ID_Trig_full5x5":
return self.
mvaIDTight(full5x5=
True)
27 elif id.startswith(
"POG_Cuts_ID_"):
28 return self.
cutBasedId(id.replace(
"POG_Cuts_ID_",
"POG_"))
29 raise RuntimeError,
"Electron id '%s' not yet implemented in Electron.py" % id
33 showerShapes =
"full5x5"
34 wp = wp.replace(
"_full5x5",
"")
35 elif showerShapes ==
"auto":
36 if "POG_CSA14_25ns_v1" in wp
or "POG_CSA14_50ns_v1" in wp:
37 showerShapes =
"full5x5"
39 'dEtaIn' :
abs(self.physObj.deltaEtaSuperClusterTrackAtVtx()),
40 'dPhiIn' :
abs(self.physObj.deltaPhiSuperClusterTrackAtVtx()),
41 'sigmaIEtaIEta' : self.physObj.full5x5_sigmaIetaIeta()
if showerShapes ==
"full5x5" else self.physObj.sigmaIetaIeta(),
42 'H/E' : self.physObj.hadronicOverEm(),
44 '1/E-1/p' :
abs(1.0/self.physObj.ecalEnergy() - self.physObj.eSuperClusterOverP()/self.physObj.ecalEnergy())
if self.physObj.ecalEnergy()>0.
else 9e9,
48 '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])],
49 '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])],
50 '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])],
51 '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])],
53 'POG_CSA14_25ns_v1_Veto' : [(
'dEtaIn', [0.012, 0.015]), (
'dPhiIn', [0.8, 0.7 ]), (
'sigmaIEtaIEta', [0.01 , 0.033]), (
'H/E', [0.15, 9e9 ]), (
'1/E-1/p', [9e9, 9e9])],
54 'POG_CSA14_25ns_v1_Loose' : [(
'dEtaIn', [0.012, 0.014]), (
'dPhiIn', [0.15, 0.1 ]), (
'sigmaIEtaIEta', [0.01 , 0.033]), (
'H/E', [0.12, 0.12]), (
'1/E-1/p', [0.05, 0.05])],
55 'POG_CSA14_25ns_v1_Medium' : [(
'dEtaIn', [0.009, 0.012]), (
'dPhiIn', [0.06, 0.03]), (
'sigmaIEtaIEta', [0.01 , 0.031]), (
'H/E', [0.12, 0.12]), (
'1/E-1/p', [0.05, 0.05])],
56 'POG_CSA14_25ns_v1_Tight' : [(
'dEtaIn', [0.009, 0.010]), (
'dPhiIn', [0.03, 0.02]), (
'sigmaIEtaIEta', [0.01 , 0.031]), (
'H/E', [0.12, 0.12]), (
'1/E-1/p', [0.05, 0.05])],
57 'POG_CSA14_50ns_v1_Veto' : [(
'dEtaIn', [0.012, 0.022]), (
'dPhiIn', [0.8, 0.7 ]), (
'sigmaIEtaIEta', [0.012, 0.033]), (
'H/E', [0.15, 9e9 ]), (
'1/E-1/p', [9e9, 9e9])],
58 'POG_CSA14_50ns_v1_Loose' : [(
'dEtaIn', [0.012, 0.021]), (
'dPhiIn', [0.15, 0.1 ]), (
'sigmaIEtaIEta', [0.012, 0.033]), (
'H/E', [0.12, 0.12]), (
'1/E-1/p', [0.05, 0.05])],
59 'POG_CSA14_50ns_v1_Medium' : [(
'dEtaIn', [0.009, 0.019]), (
'dPhiIn', [0.06, 0.03]), (
'sigmaIEtaIEta', [0.01 , 0.031]), (
'H/E', [0.12, 0.12]), (
'1/E-1/p', [0.05, 0.05])],
60 'POG_CSA14_50ns_v1_Tight' : [(
'dEtaIn', [0.009, 0.017]), (
'dPhiIn', [0.03, 0.02]), (
'sigmaIEtaIEta', [0.01 , 0.031]), (
'H/E', [0.12, 0.12]), (
'1/E-1/p', [0.05, 0.05])],
63 raise RuntimeError,
"Working point '%s' not yet implemented in Electron.py" % wp
64 for (cut_name,(cut_eb,cut_ee))
in WP[wp]:
65 if vars[cut_name] >= (cut_eb
if self.physObj.isEB()
else cut_ee):
71 Should have the same name as the function in the mother class.
72 Can call the mother class function with super.
74 return self.absIsoFromEA(rho,self.superCluster().
eta(),effectiveAreas.eGamma)
84 if self.
associatedVertex ==
None:
raise RuntimeError,
"You need to set electron.associatedVertex before calling any MVA"
85 if self.
rho ==
None:
raise RuntimeError,
"You need to set electron.rho before calling any MVA"
89 def mvaTrigV0( self, full5x5=False, debug = False ):
91 if self.
associatedVertex ==
None:
raise RuntimeError,
"You need to set electron.associatedVertex before calling any MVA"
92 if self.
rho ==
None:
raise RuntimeError,
"You need to set electron.rho before calling any MVA"
98 if self.
associatedVertex ==
None:
raise RuntimeError,
"You need to set electron.associatedVertex before calling any MVA"
99 if self.
rho ==
None:
raise RuntimeError,
"You need to set electron.rho before calling any MVA"
105 eta =
abs(self.superCluster().
eta())
107 if (eta < 0.8) :
return self.
mvaTrigV0(full5x5) > +0.00;
108 elif (eta < 1.479):
return self.
mvaTrigV0(full5x5) > +0.10;
109 else :
return self.
mvaTrigV0(full5x5) > +0.62;
111 if (eta < 0.8) :
return self.
mvaTrigV0(full5x5) > +0.94;
112 elif (eta < 1.479):
return self.
mvaTrigV0(full5x5) > +0.85;
113 else :
return self.
mvaTrigV0(full5x5) > +0.92;
116 eta =
abs(self.superCluster().
eta())
118 if (eta < 0.8) :
return self.
mvaNonTrigV0(full5x5) > +0.47;
119 elif (eta < 1.479):
return self.
mvaNonTrigV0(full5x5) > +0.004;
122 if (eta < 0.8) :
return self.
mvaNonTrigV0(full5x5) > -0.34;
123 elif (eta < 1.479):
return self.
mvaNonTrigV0(full5x5) > -0.65;
127 return self.
mvaIDLoose()
and (self.gsfTrack().trackerExpectedHitsInner().numberOfLostHits()<=1)
130 if R == 0.3:
return self.physObj.pfIsolationVariables().sumChargedHadronPt
131 elif R == 0.4:
return self.physObj.chargedHadronIso()
132 raise RuntimeError,
"Electron chargedHadronIso missing for R=%s" % R
135 if R == 0.3:
return self.physObj.pfIsolationVariables().sumNeutralHadronEt
136 elif R == 0.4:
return self.physObj.neutralHadronIso()
137 raise RuntimeError,
"Electron neutralHadronIso missing for R=%s" % R
140 if R == 0.3:
return self.physObj.pfIsolationVariables().sumPhotonEt
141 elif R == 0.4:
return self.physObj.photonIso()
142 raise RuntimeError,
"Electron photonIso missing for R=%s" % R
145 if R == 0.3:
return self.physObj.pfIsolationVariables().sumChargedParticlePt
146 raise RuntimeError,
"Electron chargedAllIso missing for R=%s" % R
149 if R == 0.3:
return self.physObj.pfIsolationVariables().sumPUPt
150 elif R == 0.4:
return self.physObj.puChargedHadronIso()
151 raise RuntimeError,
"Electron chargedHadronIso missing for R=%s" % R
157 '''This function is used in the isolation, see Lepton class.
158 Here, we replace the all charged isolation by the all charged isolation with cone veto'''
159 return self.chargedAllIsoWithConeVeto()
162 def dxy(self, vertex=None):
164 Computed using vertex (or self.associatedVertex if vertex not specified),
169 return self.gsfTrack().
dxy( vertex.position() )
172 def p4(self,kind=None):
173 return self.physObj.p4(self.physObj.candidateP4Kind()
if kind ==
None else kind)
175 def dz(self, vertex=None):
177 Computed using vertex (or self.associatedVertex if vertex not specified),
182 return self.gsfTrack().
dz( vertex.position() )
185 if hasattr(self.gsfTrack(),
"trackerExpectedHitsInner") :
186 return self.gsfTrack().trackerExpectedHitsInner().numberOfLostHits()
188 return self.gsfTrack().hitPattern().numberOfHits(ROOT.reco.HitPattern.MISSING_INNER_HITS)
tuple ElectronMVAID_NonTrig
tuple ElectronMVAID_TrigNoIP
Abs< T >::type abs(const T &t)