test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
Muon.Muon Class Reference
Inheritance diagram for Muon.Muon:

Public Member Functions

def __init__
 
def absIsoWithFSR
 
def chargedAllIso
 
def chargedAllIsoR
 
def chargedHadronIsoR
 
def dxy
 
def dz
 
def edxy
 
def edz
 
def looseId
 
def muonID
 
def mvaId
 
def neutralHadronIsoR
 
def photonIsoR
 
def ptErr
 
def puChargedHadronIsoR
 
def setTrackForDxyDz
 
def tightId
 

Private Attributes

 _trackForDxyDz
 

Detailed Description

Definition at line 4 of file Muon.py.

Constructor & Destructor Documentation

def Muon.Muon.__init__ (   self,
  args,
  kwargs 
)

Definition at line 6 of file Muon.py.

6 
7  def __init__(self, *args, **kwargs):
8  super(Muon, self).__init__(*args, **kwargs)
9  self._trackForDxyDz = "muonBestTrack"
def __init__
Definition: Muon.py:6
_trackForDxyDz
Definition: Muon.py:8

Member Function Documentation

def Muon.Muon.absIsoWithFSR (   self,
  R = 0.4,
  puCorr = "deltaBeta",
  dBetaFactor = 0.5 
)
Calculate Isolation, subtract FSR, apply specific PU corrections" 

Definition at line 114 of file Muon.py.

References Muon.Muon.chargedHadronIsoR(), Electron.Electron.chargedHadronIsoR(), deltaR(), bookConverter.max, Muon.Muon.neutralHadronIsoR(), Electron.Electron.neutralHadronIsoR(), Muon.Muon.photonIsoR(), Electron.Electron.photonIsoR(), Muon.Muon.puChargedHadronIsoR(), Electron.Electron.puChargedHadronIsoR(), python.rootplot.root2matplotlib.replace(), Photon.Photon.rho, Electron.Electron.rho, BinomialProbHelper.rho(), CalorimeterProperties.rho(), PreshowerProperties.rho(), ECALProperties.rho(), TauValidation.rho, correctionValue_class.rho, TangentCircle.rho(), HCALProperties.rho(), TangentHelix.rho(), MaterialEffectsSimulator.rho(), RhoEtaPhi.rho(), QcdLowPtDQM::Pixel.rho(), FastCircle.rho(), reco::GhostTrackPrediction.rho(), StoredPileupJetIdentifier.rho(), fastjet::BackgroundEstimator.rho(), reco::CastorCell.rho(), CylindricalState.rho(), reco::CastorJet.rho(), reco::CastorEgamma.rho(), reco::CastorTower.rho(), reco::CastorCluster.rho(), GeometricDet.rho(), AlignmentMonitorMuonSystemMap1D::MyResidual.rho, and objects.JetAnalyzer.JetAnalyzer.rho.

115  def absIsoWithFSR(self, R=0.4, puCorr="deltaBeta", dBetaFactor=0.5):
116  '''
117  Calculate Isolation, subtract FSR, apply specific PU corrections"
118  '''
119  photonIso = self.photonIsoR(R)
120  if hasattr(self,'fsrPhotons'):
121  for gamma in self.fsrPhotons:
122  dr = deltaR(gamma.eta(), gamma.phi(), self.physObj.eta(), self.physObj.phi())
123  if dr > 0.01 and dr < R:
124  photonIso = max(photonIso-gamma.pt(),0.0)
125  if puCorr == "deltaBeta":
126  offset = dBetaFactor * self.puChargedHadronIsoR(R)
127  elif puCorr == "rhoArea":
128  offset = self.rho*getattr(self,"EffectiveArea"+(str(R).replace(".","")))
129  elif puCorr in ["none","None",None]:
130  offset = 0
131  else:
132  raise RuntimeError("Unsupported PU correction scheme %s" % puCorr)
133  return self.chargedHadronIsoR(R)+max(0.,photonIso+self.neutralHadronIsoR(R)-offset)
def chargedHadronIsoR
Definition: Muon.py:85
def absIsoWithFSR
Definition: Muon.py:114
def neutralHadronIsoR
Definition: Muon.py:90
def photonIsoR
Definition: Muon.py:95
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
def puChargedHadronIsoR
Definition: Muon.py:108
def Muon.Muon.chargedAllIso (   self)

Definition at line 105 of file Muon.py.

References Muon.Muon.chargedAllIsoR(), and Electron.Electron.chargedAllIsoR().

106  def chargedAllIso(self):
107  return self.chargedAllIsoR()
def chargedAllIso
Definition: Muon.py:105
def chargedAllIsoR
Definition: Muon.py:100
def Muon.Muon.chargedAllIsoR (   self,
  R = 0.4 
)

Definition at line 100 of file Muon.py.

Referenced by Lepton.Lepton.absIsoR(), and Muon.Muon.chargedAllIso().

101  def chargedAllIsoR(self,R=0.4):
102  if R == 0.3: return self.physObj.pfIsolationR03().sumChargedParticlePt
103  elif R == 0.4: return self.physObj.pfIsolationR04().sumChargedParticlePt
104  raise RuntimeError("Muon chargedAllIso missing for R=%s" % R)
def chargedAllIsoR
Definition: Muon.py:100
def Muon.Muon.chargedHadronIsoR (   self,
  R = 0.4 
)

Definition at line 85 of file Muon.py.

Referenced by Lepton.Lepton.absIsoR(), and Muon.Muon.absIsoWithFSR().

85 
86  def chargedHadronIsoR(self,R=0.4):
87  if R == 0.3: return self.physObj.pfIsolationR03().sumChargedHadronPt
88  elif R == 0.4: return self.physObj.pfIsolationR04().sumChargedHadronPt
89  raise RuntimeError("Muon chargedHadronIso missing for R=%s" % R)
def chargedHadronIsoR
Definition: Muon.py:85
def Muon.Muon.dxy (   self,
  vertex = None 
)
either pass the vertex, or set associatedVertex before calling the function.
note: the function does not work with standalone muons as innerTrack
is not available.

Definition at line 58 of file Muon.py.

References Muon.Muon._trackForDxyDz, Electron.Electron.associatedVertex, and reco::tau::RecoTauVertexAssociator.associatedVertex().

58 
59  def dxy(self, vertex=None):
60  '''either pass the vertex, or set associatedVertex before calling the function.
61  note: the function does not work with standalone muons as innerTrack
62  is not available.
63  '''
64  if vertex is None:
65  vertex = self.associatedVertex
66  return getattr(self,self._trackForDxyDz)().dxy( vertex.position() )
def dxy
Definition: Muon.py:58
_trackForDxyDz
Definition: Muon.py:8
def Muon.Muon.dz (   self,
  vertex = None 
)
either pass the vertex, or set associatedVertex before calling the function.
note: the function does not work with standalone muons as innerTrack
is not available.

Definition at line 72 of file Muon.py.

References Muon.Muon._trackForDxyDz, Electron.Electron.associatedVertex, and reco::tau::RecoTauVertexAssociator.associatedVertex().

72 
73  def dz(self, vertex=None):
74  '''either pass the vertex, or set associatedVertex before calling the function.
75  note: the function does not work with standalone muons as innerTrack
76  is not available.
77  '''
78  if vertex is None:
79  vertex = self.associatedVertex
80  return getattr(self,self._trackForDxyDz)().dz( vertex.position() )
_trackForDxyDz
Definition: Muon.py:8
def dz
Definition: Muon.py:72
def Muon.Muon.edxy (   self)
returns the uncertainty on dxy (from gsf track)

Definition at line 67 of file Muon.py.

References Muon.Muon._trackForDxyDz.

67 
68  def edxy(self):
69  '''returns the uncertainty on dxy (from gsf track)'''
70  return getattr(self,self._trackForDxyDz)().dxyError()
71 
def edxy
Definition: Muon.py:67
_trackForDxyDz
Definition: Muon.py:8
def Muon.Muon.edz (   self)
returns the uncertainty on dxz (from gsf track)

Definition at line 81 of file Muon.py.

References Muon.Muon._trackForDxyDz.

81 
82  def edz(self):
83  '''returns the uncertainty on dxz (from gsf track)'''
84  return getattr(self,self._trackForDxyDz)().dzError()
def edz
Definition: Muon.py:81
_trackForDxyDz
Definition: Muon.py:8
def Muon.Muon.looseId (   self)
Loose ID as recommended by mu POG.

Definition at line 15 of file Muon.py.

Referenced by Muon.Muon.muonID().

15 
16  def looseId( self ):
17  '''Loose ID as recommended by mu POG.'''
18  return self.physObj.isLooseMuon()
def looseId
Definition: Muon.py:15
def Muon.Muon.muonID (   self,
  name,
  vertex = None 
)

Definition at line 28 of file Muon.py.

References reco::MuonTrackLinks.globalTrack(), reco::Muon.globalTrack(), pat::Muon.globalTrack(), reco::CaloMuon.innerTrack(), reco::ME0Muon.innerTrack(), reco::Muon.innerTrack(), pat::Muon.innerTrack(), HcalRaddamMuon.innerTrack, HcalHBHEMuonAnalyzer.innerTrack, ScoutingMuon.isGlobalMuon(), reco::ShallowClonePtrCandidate.isGlobalMuon(), reco::ShallowCloneCandidate.isGlobalMuon(), reco::LeafRefCandidateT.isGlobalMuon(), reco::Muon.isGlobalMuon(), CandidateWithRef< Ref >.isGlobalMuon(), reco::LeafCandidate.isGlobalMuon(), reco::Candidate.isGlobalMuon(), pat::PackedGenParticle.isGlobalMuon(), pat::PackedCandidate.isGlobalMuon(), Muon.Muon.looseId(), L1Analysis::L1AnalysisRecoMuonDataFormat.numberOfMatchedStations, and reco::Muon.numberOfMatchedStations().

Referenced by Muon.Muon.tightId().

28 
29  def muonID(self, name, vertex=None):
30  if name == "" or name is None:
31  return True
32  if name.startswith("POG_"):
33  if name == "POG_ID_Loose": return self.physObj.isLooseMuon()
34  if vertex is None:
35  vertex = getattr(self, 'associatedVertex', None)
36  if name == "POG_ID_Tight": return self.physObj.isTightMuon(vertex)
37  if name == "POG_ID_HighPt": return self.physObj.isHighPtMuon(vertex)
38  if name == "POG_ID_Soft": return self.physObj.isSoftMuon(vertex)
39  if name == "POG_ID_TightNoVtx": return self.looseId() and \
40  self.isGlobalMuon() and \
41  self.globalTrack().normalizedChi2() < 10 and \
42  self.globalTrack().hitPattern().numberOfValidMuonHits() > 0 and \
43  self.numberOfMatchedStations()>1 and \
44  self.innerTrack().hitPattern().numberOfValidPixelHits()>0 and \
45  self.innerTrack().hitPattern().trackerLayersWithMeasurement() > 5
46  if name == "POG_ID_Medium":
47  if not self.looseId(): return False
48  goodGlb = self.physObj.isGlobalMuon() and self.physObj.globalTrack().normalizedChi2() < 3 and self.physObj.combinedQuality().chi2LocalPosition < 12 and self.physObj.combinedQuality().trkKink < 20;
49  return self.physObj.innerTrack().validFraction() > 0.8 and self.physObj.segmentCompatibility() >= (0.303 if goodGlb else 0.451)
50  if name == "POG_Global_OR_TMArbitrated":
51  return self.physObj.isGlobalMuon() or (self.physObj.isTrackerMuon() and self.physObj.numberOfMatchedStations() > 0)
52  return self.physObj.muonID(name)
def looseId
Definition: Muon.py:15
def muonID
Definition: Muon.py:28
def Muon.Muon.mvaId (   self)
For a transparent treatment of electrons and muons. Returns -99

Definition at line 53 of file Muon.py.

53 
54  def mvaId(self):
55  '''For a transparent treatment of electrons and muons. Returns -99'''
56  return -99
57 
def mvaId
Definition: Muon.py:53
def Muon.Muon.neutralHadronIsoR (   self,
  R = 0.4 
)

Definition at line 90 of file Muon.py.

Referenced by Lepton.Lepton.absIsoR(), and Muon.Muon.absIsoWithFSR().

90 
91  def neutralHadronIsoR(self,R=0.4):
92  if R == 0.3: return self.physObj.pfIsolationR03().sumNeutralHadronEt
93  elif R == 0.4: return self.physObj.pfIsolationR04().sumNeutralHadronEt
94  raise RuntimeError("Muon neutralHadronIso missing for R=%s" % R)
def neutralHadronIsoR
Definition: Muon.py:90
def Muon.Muon.photonIsoR (   self,
  R = 0.4 
)

Definition at line 95 of file Muon.py.

Referenced by Lepton.Lepton.absIsoR(), and Muon.Muon.absIsoWithFSR().

95 
96  def photonIsoR(self,R=0.4):
97  if R == 0.3: return self.physObj.pfIsolationR03().sumPhotonEt
98  elif R == 0.4: return self.physObj.pfIsolationR04().sumPhotonEt
99  raise RuntimeError("Muon photonIso missing for R=%s" % R)
def photonIsoR
Definition: Muon.py:95
def Muon.Muon.ptErr (   self)

Definition at line 134 of file Muon.py.

References reco::RecoChargedRefCandidate.bestTrack(), reco::RecoCandidate.bestTrack(), reco::Muon.bestTrack(), pat::Muon.bestTrack(), reco::PFCandidate.bestTrack(), reco::Candidate.bestTrack(), CandidateWithRef< Ref >.bestTrack(), and pat::PackedCandidate.bestTrack().

135  def ptErr(self):
136  if "_ptErr" in self.__dict__: return self.__dict__['_ptErr']
137  return self.bestTrack().ptError()
def ptErr
Definition: Muon.py:134
def Muon.Muon.puChargedHadronIsoR (   self,
  R = 0.4 
)

Definition at line 108 of file Muon.py.

Referenced by Lepton.Lepton.absIsoR(), and Muon.Muon.absIsoWithFSR().

109  def puChargedHadronIsoR(self,R=0.4):
110  if R == 0.3: return self.physObj.pfIsolationR03().sumPUPt
111  elif R == 0.4: return self.physObj.pfIsolationR04().sumPUPt
112  raise RuntimeError("Muon chargedHadronIso missing for R=%s" % R)
113 
def puChargedHadronIsoR
Definition: Muon.py:108
def Muon.Muon.setTrackForDxyDz (   self,
  what 
)

Definition at line 10 of file Muon.py.

References Muon.Muon._trackForDxyDz.

10 
11  def setTrackForDxyDz(self,what):
12  if not hasattr(self,what):
13  raise RuntimeError("I don't have a track called "+what)
14  self._trackForDxyDz = what
def setTrackForDxyDz
Definition: Muon.py:10
_trackForDxyDz
Definition: Muon.py:8
def Muon.Muon.tightId (   self)
Tight ID as recommended by mu POG 
(unless redefined in the lepton analyzer).

If not using the LeptonAnalyzer, make sure to set self.associatedVertex, 
that is necessary for tight muon identification. 

Definition at line 19 of file Muon.py.

References Muon.Muon.muonID(), and pat::Muon.muonID().

19 
20  def tightId( self ):
21  '''Tight ID as recommended by mu POG
22  (unless redefined in the lepton analyzer).
23 
24  If not using the LeptonAnalyzer, make sure to set self.associatedVertex,
25  that is necessary for tight muon identification.
26  '''
27  return getattr(self,"tightIdResult",self.muonID("POG_ID_Tight"))
def tightId
Definition: Muon.py:19
def muonID
Definition: Muon.py:28

Member Data Documentation

Muon.Muon._trackForDxyDz
private

Definition at line 8 of file Muon.py.

Referenced by Muon.Muon.dxy(), Muon.Muon.dz(), Muon.Muon.edxy(), Muon.Muon.edz(), and Muon.Muon.setTrackForDxyDz().