1 from PhysicsTools.Heppy.physicsobjects.Lepton
import Lepton
7 super(Muon, self).
__init__(*args, **kwargs)
11 if not hasattr(self,what):
12 raise RuntimeError(
"I don't have a track called "+what)
16 '''Loose ID as recommended by mu POG.'''
20 '''Tight ID as recommended by mu POG
21 (unless redefined in the lepton analyzer).
23 If not using the LeptonAnalyzer, make sure to set self.associatedVertex,
24 that is necessary for tight muon identification.
26 return getattr(self,
"tightIdResult",self.
muonID(
"POG_ID_Tight"))
29 if name ==
"" or name
is None:
31 if name.startswith(
"POG_"):
32 if name ==
"POG_ID_Loose":
return self.physObj.
isLooseMuon()
34 vertex = getattr(self,
'associatedVertex',
None)
35 if name ==
"POG_ID_Tight":
return self.physObj.
isTightMuon(vertex)
36 if name ==
"POG_ID_HighPt":
return self.physObj.
isHighPtMuon(vertex)
37 if name ==
"POG_ID_Soft":
return self.physObj.
isSoftMuon(vertex)
38 if name ==
"POG_ID_TightNoVtx":
return self.
looseId()
and \
39 self.isGlobalMuon()
and \
41 self.globalTrack().hitPattern().numberOfValidMuonHits() > 0
and \
42 self.numberOfMatchedStations()>1
and \
44 self.innerTrack().hitPattern().trackerLayersWithMeasurement() > 5
45 if name ==
"POG_ID_Medium":
46 if not self.
looseId():
return False
47 goodGlb = self.physObj.isGlobalMuon()
and self.physObj.
globalTrack().
normalizedChi2() < 3
and self.physObj.combinedQuality().chi2LocalPosition < 12
and self.physObj.combinedQuality().trkKink < 20;
49 if name ==
"POG_Global_OR_TMArbitrated":
50 return self.physObj.isGlobalMuon()
or (self.physObj.isTrackerMuon()
and self.physObj.numberOfMatchedStations() > 0)
51 return self.physObj.
muonID(name)
54 '''For a transparent treatment of electrons and muons. Returns -99'''
58 def dxy(self, vertex=None):
59 '''either pass the vertex, or set associatedVertex before calling the function.
60 note: the function does not work with standalone muons as innerTrack
64 vertex = self.associatedVertex
68 '''returns the uncertainty on dxy (from gsf track)'''
72 def dz(self, vertex=None):
73 '''either pass the vertex, or set associatedVertex before calling the function.
74 note: the function does not work with standalone muons as innerTrack
78 vertex = self.associatedVertex
82 '''returns the uncertainty on dxz (from gsf track)'''
86 if R == 0.3:
return self.physObj.
pfIsolationR03().sumChargedHadronPt
87 elif R == 0.4:
return self.physObj.
pfIsolationR04().sumChargedHadronPt
88 raise RuntimeError(
"Muon chargedHadronIso missing for R=%s" % R)
91 if R == 0.3:
return self.physObj.
pfIsolationR03().sumNeutralHadronEt
92 elif R == 0.4:
return self.physObj.
pfIsolationR04().sumNeutralHadronEt
93 raise RuntimeError(
"Muon neutralHadronIso missing for R=%s" % R)
98 raise RuntimeError(
"Muon photonIso missing for R=%s" % R)
101 if R == 0.3:
return self.physObj.
pfIsolationR03().sumChargedParticlePt
102 elif R == 0.4:
return self.physObj.
pfIsolationR04().sumChargedParticlePt
103 raise RuntimeError(
"Muon chargedAllIso missing for R=%s" % R)
111 raise RuntimeError(
"Muon chargedHadronIso missing for R=%s" % R)
116 Calculate Isolation, subtract FSR, apply specific PU corrections"
119 if hasattr(self,
'fsrPhotons'):
120 for gamma
in self.fsrPhotons:
121 dr =
deltaR(gamma.eta(), gamma.phi(), self.physObj.
eta(), self.physObj.phi())
122 if dr > 0.01
and dr < R:
123 photonIso =
max(photonIso-gamma.pt(),0.0)
124 if puCorr ==
"deltaBeta":
126 elif puCorr ==
"rhoArea":
127 offset = self.rho*getattr(self,
"EffectiveArea"+(
str(R).
replace(
".",
"")))
128 elif puCorr
in [
"none",
"None",
None]:
131 raise RuntimeError(
"Unsupported PU correction scheme %s" % puCorr)
135 if "_ptErr" in self.__dict__:
return self.__dict__[
'_ptErr']
136 return self.bestTrack().ptError()