1 from PhysicsTools.Heppy.physicsobjects.Lepton
import Lepton
5 super(Muon, self).
__init__(*args, **kwargs)
9 if not hasattr(self,what):
10 raise RuntimeError,
"I don't have a track called "+what
14 '''Loose ID as recommended by mu POG.'''
15 return self.physObj.isLooseMuon()
18 '''Tight ID as recommended by mu POG (unless redefined in the lepton analyzer).'''
19 return getattr(self,
"tightIdResult",self.
muonID(
"POG_ID_Tight"))
22 if name ==
"" or name
is None:
24 if name.startswith(
"POG_"):
25 if name ==
"POG_ID_Loose":
return self.physObj.isLooseMuon()
27 vertex = getattr(self,
'associatedVertex',
None)
28 if name ==
"POG_ID_Tight":
return self.physObj.isTightMuon(vertex)
29 if name ==
"POG_ID_HighPt":
return self.physObj.isHighPtMuon(vertex)
30 if name ==
"POG_ID_Soft":
return self.physObj.isSoftMuon(vertex)
31 if name ==
"POG_ID_TightNoVtx":
return self.
looseId()
and \
32 self.isGlobalMuon()
and \
33 self.globalTrack().normalizedChi2() < 10
and \
34 self.globalTrack().hitPattern().numberOfValidMuonHits() > 0
and \
35 self.numberOfMatchedStations()>1
and \
36 self.innerTrack().hitPattern().numberOfValidPixelHits()>0
and \
37 self.innerTrack().hitPattern().trackerLayersWithMeasurement() > 5
38 if name ==
"POG_ID_Medium":
39 if not self.
looseId():
return False
40 goodGlb = self.physObj.isGlobalMuon()
and self.physObj.globalTrack().normalizedChi2() < 3
and self.physObj.combinedQuality().chi2LocalPosition < 12
and self.physObj.combinedQuality().trkKink < 20;
41 return self.physObj.innerTrack().validFraction() >= 0.8
and self.physObj.segmentCompatibility() >= (0.303
if goodGlb
else 0.451)
42 if name ==
"POG_Global_OR_TMArbitrated":
43 return self.physObj.isGlobalMuon()
or (self.physObj.isTrackerMuon()
and self.physObj.numberOfMatchedStations() > 0)
44 return self.physObj.muonID(name)
47 '''For a transparent treatment of electrons and muons. Returns -99'''
53 return self.absIsoFromEA(rho,self.eta(),effectiveAreas.muon)
57 def dxy(self, vertex=None):
58 '''either pass the vertex, or set associatedVertex before calling the function.
59 note: the function does not work with standalone muons as innerTrack
63 vertex = self.associatedVertex
67 '''returns the uncertainty on dxy (from gsf track)'''
71 def dz(self, vertex=None):
72 '''either pass the vertex, or set associatedVertex before calling the function.
73 note: the function does not work with standalone muons as innerTrack
77 vertex = self.associatedVertex
81 '''returns the uncertainty on dxz (from gsf track)'''
85 if R == 0.3:
return self.physObj.pfIsolationR03().sumChargedHadronPt
86 elif R == 0.4:
return self.physObj.pfIsolationR04().sumChargedHadronPt
87 raise RuntimeError,
"Muon chargedHadronIso missing for R=%s" % R
90 if R == 0.3:
return self.physObj.pfIsolationR03().sumNeutralHadronEt
91 elif R == 0.4:
return self.physObj.pfIsolationR04().sumNeutralHadronEt
92 raise RuntimeError,
"Muon neutralHadronIso missing for R=%s" % R
95 if R == 0.3:
return self.physObj.pfIsolationR03().sumPhotonEt
96 elif R == 0.4:
return self.physObj.pfIsolationR04().sumPhotonEt
97 raise RuntimeError,
"Muon photonIso missing for R=%s" % R
100 if R == 0.3:
return self.physObj.pfIsolationR03().sumChargedParticlePt
101 elif R == 0.4:
return self.physObj.pfIsolationR04().sumChargedParticlePt
102 raise RuntimeError,
"Muon chargedAllIso missing for R=%s" % R
108 if R == 0.3:
return self.physObj.pfIsolationR03().sumPUPt
109 elif R == 0.4:
return self.physObj.pfIsolationR04().sumPUPt
110 raise RuntimeError,
"Muon chargedHadronIso missing for R=%s" % R