1 from PhysicsTools.Heppy.physicsobjects.Lepton
import Lepton
6 super(Muon, self).
__init__(*args, **kwargs)
10 if not hasattr(self,what):
11 raise RuntimeError,
"I don't have a track called "+what
15 '''Loose ID as recommended by mu POG.'''
16 return self.physObj.isLooseMuon()
19 '''Tight ID as recommended by mu POG (unless redefined in the lepton analyzer).'''
20 return getattr(self,
"tightIdResult",self.
muonID(
"POG_ID_Tight"))
23 if name ==
"" or name
is None:
25 if name.startswith(
"POG_"):
26 if name ==
"POG_ID_Loose":
return self.physObj.isLooseMuon()
28 vertex = getattr(self,
'associatedVertex',
None)
29 if name ==
"POG_ID_Tight":
return self.physObj.isTightMuon(vertex)
30 if name ==
"POG_ID_HighPt":
return self.physObj.isHighPtMuon(vertex)
31 if name ==
"POG_ID_Soft":
return self.physObj.isSoftMuon(vertex)
32 if name ==
"POG_ID_TightNoVtx":
return self.
looseId()
and \
33 self.isGlobalMuon()
and \
34 self.globalTrack().normalizedChi2() < 10
and \
35 self.globalTrack().hitPattern().numberOfValidMuonHits() > 0
and \
36 self.numberOfMatchedStations()>1
and \
37 self.innerTrack().hitPattern().numberOfValidPixelHits()>0
and \
38 self.innerTrack().hitPattern().trackerLayersWithMeasurement() > 5
39 if name ==
"POG_ID_Medium":
40 if not self.
looseId():
return False
41 goodGlb = self.physObj.isGlobalMuon()
and self.physObj.globalTrack().normalizedChi2() < 3
and self.physObj.combinedQuality().chi2LocalPosition < 12
and self.physObj.combinedQuality().trkKink < 20;
42 return self.physObj.innerTrack().validFraction() > 0.8
and self.physObj.segmentCompatibility() >= (0.303
if goodGlb
else 0.451)
43 if name ==
"POG_Global_OR_TMArbitrated":
44 return self.physObj.isGlobalMuon()
or (self.physObj.isTrackerMuon()
and self.physObj.numberOfMatchedStations() > 0)
45 return self.physObj.muonID(name)
48 '''For a transparent treatment of electrons and muons. Returns -99'''
52 def dxy(self, vertex=None):
53 '''either pass the vertex, or set associatedVertex before calling the function.
54 note: the function does not work with standalone muons as innerTrack
58 vertex = self.associatedVertex
62 '''returns the uncertainty on dxy (from gsf track)'''
66 def dz(self, vertex=None):
67 '''either pass the vertex, or set associatedVertex before calling the function.
68 note: the function does not work with standalone muons as innerTrack
72 vertex = self.associatedVertex
76 '''returns the uncertainty on dxz (from gsf track)'''
80 if R == 0.3:
return self.physObj.pfIsolationR03().sumChargedHadronPt
81 elif R == 0.4:
return self.physObj.pfIsolationR04().sumChargedHadronPt
82 raise RuntimeError,
"Muon chargedHadronIso missing for R=%s" % R
85 if R == 0.3:
return self.physObj.pfIsolationR03().sumNeutralHadronEt
86 elif R == 0.4:
return self.physObj.pfIsolationR04().sumNeutralHadronEt
87 raise RuntimeError,
"Muon neutralHadronIso missing for R=%s" % R
90 if R == 0.3:
return self.physObj.pfIsolationR03().sumPhotonEt
91 elif R == 0.4:
return self.physObj.pfIsolationR04().sumPhotonEt
92 raise RuntimeError,
"Muon photonIso missing for R=%s" % R
95 if R == 0.3:
return self.physObj.pfIsolationR03().sumChargedParticlePt
96 elif R == 0.4:
return self.physObj.pfIsolationR04().sumChargedParticlePt
97 raise RuntimeError,
"Muon chargedAllIso missing for R=%s" % R
103 if R == 0.3:
return self.physObj.pfIsolationR03().sumPUPt
104 elif R == 0.4:
return self.physObj.pfIsolationR04().sumPUPt
105 raise RuntimeError,
"Muon chargedHadronIso missing for R=%s" % R
110 Calculate Isolation, subtract FSR, apply specific PU corrections"
113 if hasattr(self,
'fsrPhotons'):
114 for gamma
in self.fsrPhotons:
115 dr =
deltaR(gamma.eta(), gamma.phi(), self.physObj.eta(), self.physObj.phi())
116 if dr > 0.01
and dr < R:
117 photonIso =
max(photonIso-gamma.pt(),0.0)
118 if puCorr ==
"deltaBeta":
120 elif puCorr ==
"rhoArea":
121 offset = self.rho*getattr(self,
"EffectiveArea"+(str(R).
replace(
".",
"")))
122 elif puCorr
in [
"none",
"None",
None]:
125 raise RuntimeError,
"Unsupported PU correction scheme %s" % puCorr
double deltaR(double eta1, double eta2, double phi1, double phi2)