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)
23 if id
is None or id ==
"":
return True
25 if rho ==
None and hasattr(self,
'rho')
and self.
rho !=
None: rho = self.
rho
26 if id ==
"POG_MVA_ID_NonTrig":
return self.
mvaIDLoose()
27 elif id ==
"POG_MVA_ID_Trig":
return self.
mvaIDTight()
28 elif id ==
"POG_MVA_ID_NonTrig_full5x5":
return self.
mvaIDLoose(full5x5=
True)
29 elif id ==
"POG_MVA_ID_Trig_full5x5":
return self.
mvaIDTight(full5x5=
True)
30 elif id.startswith(
"POG_Cuts_ID_"):
31 return self.
cutBasedId(id.replace(
"POG_Cuts_ID_",
"POG_"))
32 for ID
in self.electronIDs():
35 raise RuntimeError,
"Electron id '%s' not yet implemented in Electron.py" % id
39 showerShapes =
"full5x5"
40 wp = wp.replace(
"_full5x5",
"")
41 elif showerShapes ==
"auto":
42 if "POG_CSA14_25ns_v1" in wp
or "POG_CSA14_50ns_v1" in wp:
43 showerShapes =
"full5x5"
45 'dEtaIn' :
abs(self.physObj.deltaEtaSuperClusterTrackAtVtx()),
46 'dPhiIn' :
abs(self.physObj.deltaPhiSuperClusterTrackAtVtx()),
47 'sigmaIEtaIEta' : self.physObj.full5x5_sigmaIetaIeta()
if showerShapes ==
"full5x5" else self.physObj.sigmaIetaIeta(),
48 'H/E' : self.physObj.hadronicOverEm(),
50 '1/E-1/p' :
abs(1.0/self.physObj.ecalEnergy() - self.physObj.eSuperClusterOverP()/self.physObj.ecalEnergy())
if self.physObj.ecalEnergy()>0.
else 9e9,
54 '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])],
55 '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])],
56 '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])],
57 '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])],
59 '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])],
60 '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])],
61 '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])],
62 '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])],
63 '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])],
64 '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])],
65 '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])],
66 '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])],
69 raise RuntimeError,
"Working point '%s' not yet implemented in Electron.py" % wp
70 for (cut_name,(cut_eb,cut_ee))
in WP[wp]:
71 if vars[cut_name] >= (cut_eb
if self.physObj.isEB()
else cut_ee):
77 Should have the same name as the function in the mother class.
78 Can call the mother class function with super.
80 return self.absIsoFromEA(rho,self.superCluster().
eta(),effectiveAreas.eGamma)
90 if self.
associatedVertex ==
None:
raise RuntimeError,
"You need to set electron.associatedVertex before calling any MVA"
91 if self.
rho ==
None:
raise RuntimeError,
"You need to set electron.rho before calling any MVA"
95 def mvaTrigV0( self, full5x5=False, debug = False ):
97 if self.
associatedVertex ==
None:
raise RuntimeError,
"You need to set electron.associatedVertex before calling any MVA"
98 if self.
rho ==
None:
raise RuntimeError,
"You need to set electron.rho before calling any MVA"
104 if self.
associatedVertex ==
None:
raise RuntimeError,
"You need to set electron.associatedVertex before calling any MVA"
105 if self.
rho ==
None:
raise RuntimeError,
"You need to set electron.rho before calling any MVA"
111 eta =
abs(self.superCluster().
eta())
113 if (eta < 0.8) :
return self.
mvaTrigV0(full5x5) > +0.00;
114 elif (eta < 1.479):
return self.
mvaTrigV0(full5x5) > +0.10;
115 else :
return self.
mvaTrigV0(full5x5) > +0.62;
117 if (eta < 0.8) :
return self.
mvaTrigV0(full5x5) > +0.94;
118 elif (eta < 1.479):
return self.
mvaTrigV0(full5x5) > +0.85;
119 else :
return self.
mvaTrigV0(full5x5) > +0.92;
122 eta =
abs(self.superCluster().
eta())
124 if (eta < 0.8) :
return self.
mvaNonTrigV0(full5x5) > +0.47;
125 elif (eta < 1.479):
return self.
mvaNonTrigV0(full5x5) > +0.004;
128 if (eta < 0.8) :
return self.
mvaNonTrigV0(full5x5) > -0.34;
129 elif (eta < 1.479):
return self.
mvaNonTrigV0(full5x5) > -0.65;
133 return self.
mvaIDLoose()
and (self.gsfTrack().trackerExpectedHitsInner().numberOfLostHits()<=1)
136 if R == 0.3:
return self.physObj.pfIsolationVariables().sumChargedHadronPt
137 elif R == 0.4:
return self.physObj.chargedHadronIso()
138 raise RuntimeError,
"Electron chargedHadronIso missing for R=%s" % R
141 if R == 0.3:
return self.physObj.pfIsolationVariables().sumNeutralHadronEt
142 elif R == 0.4:
return self.physObj.neutralHadronIso()
143 raise RuntimeError,
"Electron neutralHadronIso missing for R=%s" % R
146 if R == 0.3:
return self.physObj.pfIsolationVariables().sumPhotonEt
147 elif R == 0.4:
return self.physObj.photonIso()
148 raise RuntimeError,
"Electron photonIso missing for R=%s" % R
151 if R == 0.3:
return self.physObj.pfIsolationVariables().sumChargedParticlePt
152 raise RuntimeError,
"Electron chargedAllIso missing for R=%s" % R
155 if R == 0.3:
return self.physObj.pfIsolationVariables().sumPUPt
156 elif R == 0.4:
return self.physObj.puChargedHadronIso()
157 raise RuntimeError,
"Electron chargedHadronIso missing for R=%s" % R
163 '''This function is used in the isolation, see Lepton class.
164 Here, we replace the all charged isolation by the all charged isolation with cone veto'''
165 return self.chargedAllIsoWithConeVeto()
168 def dxy(self, vertex=None):
170 Computed using vertex (or self.associatedVertex if vertex not specified),
175 return self.gsfTrack().
dxy( vertex.position() )
177 return ROOT.reco.Candidate.p4(self.physObj)
182 def dz(self, vertex=None):
184 Computed using vertex (or self.associatedVertex if vertex not specified),
189 return self.gsfTrack().
dz( vertex.position() )
192 if hasattr(self.gsfTrack(),
"trackerExpectedHitsInner") :
193 return self.gsfTrack().trackerExpectedHitsInner().numberOfLostHits()
195 return self.gsfTrack().hitPattern().numberOfHits(ROOT.reco.HitPattern.MISSING_INNER_HITS)
tuple ElectronMVAID_NonTrig
tuple ElectronMVAID_TrigNoIP
Abs< T >::type abs(const T &t)