CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Muon.py
Go to the documentation of this file.
1 from PhysicsTools.Heppy.physicsobjects.Lepton import Lepton
2 
3 class Muon( Lepton ):
4 
5  def looseId( self ):
6  '''Loose ID as recommended by mu POG.'''
7  return self.physObj.isLooseMuon()
8 
9  def tightId( self ):
10  '''Tight ID as recommended by mu POG.'''
11  return self.muonID("POG_ID_Tight")
12 
13  def muonID(self, name, vertex=None):
14  if name == "" or name is None:
15  return True
16  if name.startswith("POG_"):
17  if name == "POG_ID_Loose": return self.physObj.isLooseMuon()
18  if vertex is None:
19  vertex = getattr(self, 'associatedVertex', None)
20  if name == "POG_ID_Tight": return self.physObj.isTightMuon(vertex)
21  if name == "POG_ID_HighPt": return self.physObj.isHighPtMuon(vertex)
22  if name == "POG_ID_Soft": return self.physObj.isSoftMuon(vertex)
23  if name == "POG_ID_TightNoVtx": return self.looseId() and \
24  self.isGlobalMuon() and \
25  self.globalTrack().normalizedChi2() < 10 and \
26  self.globalTrack().hitPattern().numberOfValidMuonHits() > 0 and \
27  self.numberOfMatchedStations()>1 and \
28  self.innerTrack().hitPattern().numberOfValidPixelHits()>0 and \
29  self.innerTrack().hitPattern().trackerLayersWithMeasurement() > 5
30  if name == "POG_ID_Medium":
31  if not self.looseId(): return False
32  goodGlb = self.physObj.isGlobalMuon() and self.physObj.globalTrack().normalizedChi2() < 3 and self.physObj.combinedQuality().chi2LocalPosition < 12 and self.physObj.combinedQuality().trkKink < 20;
33  return self.physObj.innerTrack().validFraction() >= 0.8 and self.physObj.segmentCompatibility() >= (0.303 if goodGlb else 0.451)
34  return self.physObj.muonID(name)
35 
36  def mvaId(self):
37  '''For a transparent treatment of electrons and muons. Returns -99'''
38  return -99
39 
40 
41 
42  def absEffAreaIso(self,rho,effectiveAreas):
43  return self.absIsoFromEA(rho,self.eta(),effectiveAreas.muon)
44 
45 
46 
47  def dxy(self, vertex=None):
48  '''either pass the vertex, or set associatedVertex before calling the function.
49  note: the function does not work with standalone muons as innerTrack
50  is not available.
51  '''
52  if vertex is None:
53  vertex = self.associatedVertex
54  return self.innerTrack().dxy( vertex.position() )
55 
56 
57  def dz(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
60  is not available.
61  '''
62  if vertex is None:
63  vertex = self.associatedVertex
64  return self.innerTrack().dz( vertex.position() )
65 
66  def chargedHadronIsoR(self,R=0.4):
67  if R == 0.3: return self.physObj.pfIsolationR03().sumChargedHadronPt
68  elif R == 0.4: return self.physObj.pfIsolationR04().sumChargedHadronPt
69  raise RuntimeError, "Muon chargedHadronIso missing for R=%s" % R
70 
71  def neutralHadronIsoR(self,R=0.4):
72  if R == 0.3: return self.physObj.pfIsolationR03().sumNeutralHadronEt
73  elif R == 0.4: return self.physObj.pfIsolationR04().sumNeutralHadronEt
74  raise RuntimeError, "Muon neutralHadronIso missing for R=%s" % R
75 
76  def photonIsoR(self,R=0.4):
77  if R == 0.3: return self.physObj.pfIsolationR03().sumPhotonEt
78  elif R == 0.4: return self.physObj.pfIsolationR04().sumPhotonEt
79  raise RuntimeError, "Muon photonIso missing for R=%s" % R
80 
81  def chargedAllIsoR(self,R=0.4):
82  if R == 0.3: return self.physObj.pfIsolationR03().sumChargedParticlePt
83  elif R == 0.4: return self.physObj.pfIsolationR04().sumChargedParticlePt
84  raise RuntimeError, "Muon chargedAllIso missing for R=%s" % R
85 
86  def chargedAllIso(self):
87  return self.chargedAllIsoR()
88 
89  def puChargedHadronIsoR(self,R=0.4):
90  if R == 0.3: return self.physObj.pfIsolationR03().sumPUPt
91  elif R == 0.4: return self.physObj.pfIsolationR04().sumPUPt
92  raise RuntimeError, "Muon chargedHadronIso missing for R=%s" % R
93 
94 
95 
96 
def chargedHadronIsoR
Definition: Muon.py:66
def dxy
Definition: Muon.py:47
def chargedAllIso
Definition: Muon.py:86
def neutralHadronIsoR
Definition: Muon.py:71
def photonIsoR
Definition: Muon.py:76
def mvaId
Definition: Muon.py:36
def absEffAreaIso
Definition: Muon.py:42
Definition: Muon.py:3
def looseId
Definition: Muon.py:5
def dz
Definition: Muon.py:57
def tightId
Definition: Muon.py:9
def puChargedHadronIsoR
Definition: Muon.py:89
Definition: Lepton.py:1
def chargedAllIsoR
Definition: Muon.py:81
def muonID
Definition: Muon.py:13