CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
Muon.Muon Class Reference
Inheritance diagram for Muon.Muon:

Public Member Functions

def __init__ (self, args, kwargs)
 
def absIsoWithFSR (self, R=0.4, puCorr="deltaBeta", dBetaFactor=0.5)
 
def chargedAllIso (self)
 
def chargedAllIsoR (self, R=0.4)
 
def chargedHadronIsoR (self, R=0.4)
 
def dxy (self, vertex=None)
 
def dz (self, vertex=None)
 
def edxy (self)
 
def edz (self)
 
def looseId (self)
 
def muonID (self, name, vertex=None)
 
def mvaId (self)
 
def neutralHadronIsoR (self, R=0.4)
 
def photonIsoR (self, R=0.4)
 
def ptErr (self)
 
def puChargedHadronIsoR (self, R=0.4)
 
def setTrackForDxyDz (self, what)
 
def tightId (self)
 

Private Attributes

 _trackForDxyDz
 

Detailed Description

Definition at line 4 of file Muon.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 6 of file Muon.py.

6  def __init__(self, *args, **kwargs):
7  super(Muon, self).__init__(*args, **kwargs)
8  self._trackForDxyDz = "muonBestTrack"
9 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ absIsoWithFSR()

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(), PbPb_ZMuSkimMuonDPG_cff.deltaR, PVValHelper.eta, SiStripPI.max, Muon.Muon.neutralHadronIsoR(), Electron.Electron.neutralHadronIsoR(), Muon.Muon.photonIsoR(), Electron.Electron.photonIsoR(), PhysicsObject.PhysicsObject.physObj, Muon.Muon.puChargedHadronIsoR(), Electron.Electron.puChargedHadronIsoR(), python.rootplot.root2matplotlib.replace(), Photon.Photon.rho, Electron.Electron.rho, CaloDetInfo.rho(), CalorimeterProperties.rho(), PreshowerProperties.rho(), TauValidation.rho, ECALProperties.rho(), correctionValue_class.rho, HCALProperties.rho(), ticl::PatternRecognitionbyCLUE3D< TILES >::ClustersOnLayer.rho, MaterialEffectsSimulator.rho(), TangentCircle.rho(), TangentHelix.rho(), FastCircle.rho(), RhoEtaPhi.rho(), reco::GhostTrackPrediction.rho(), fastjet::BackgroundEstimator.rho(), QcdLowPtDQM::Pixel.rho(), FastCircleFit.rho(), StoredPileupJetIdentifier.rho(), reco::CastorCell.rho(), CylindricalState.rho(), reco::CastorJet.rho(), reco::CastorEgamma.rho(), GeometricTimingDet.rho(), GeometricDet.rho(), reco::CastorTower.rho(), reco::CastorCluster.rho(), AlignmentMonitorMuonSystemMap1D::MyResidual.rho, DAClusterizerInZ_vect::vertex_t.rho, HGCalImagingAlgo::Hexel.rho, HGCalCLUEAlgoT< TILE >::CellsOnLayer.rho, DAClusterizerInZT_vect::vertex_t.rho, objects.JetAnalyzer.JetAnalyzer.rho, and str.

114  def absIsoWithFSR(self, R=0.4, puCorr="deltaBeta", dBetaFactor=0.5):
115  '''
116  Calculate Isolation, subtract FSR, apply specific PU corrections"
117  '''
118  photonIso = self.photonIsoR(R)
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":
125  offset = dBetaFactor * self.puChargedHadronIsoR(R)
126  elif puCorr == "rhoArea":
127  offset = self.rho*getattr(self,"EffectiveArea"+(str(R).replace(".","")))
128  elif puCorr in ["none","None",None]:
129  offset = 0
130  else:
131  raise RuntimeError("Unsupported PU correction scheme %s" % puCorr)
132  return self.chargedHadronIsoR(R)+max(0.,photonIso+self.neutralHadronIsoR(R)-offset)
133 
def replace(string, replacements)
#define str(s)

◆ chargedAllIso()

def Muon.Muon.chargedAllIso (   self)

Definition at line 105 of file Muon.py.

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

105  def chargedAllIso(self):
106  return self.chargedAllIsoR()
107 

◆ chargedAllIsoR()

def Muon.Muon.chargedAllIsoR (   self,
  R = 0.4 
)

Definition at line 100 of file Muon.py.

References displacedMuons_cfi.pfIsolationR03, displacedMuons_cfi.pfIsolationR04, and PhysicsObject.PhysicsObject.physObj.

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

100  def chargedAllIsoR(self,R=0.4):
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)
104 

◆ chargedHadronIsoR()

def Muon.Muon.chargedHadronIsoR (   self,
  R = 0.4 
)

Definition at line 85 of file Muon.py.

References displacedMuons_cfi.pfIsolationR03, displacedMuons_cfi.pfIsolationR04, and PhysicsObject.PhysicsObject.physObj.

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

85  def chargedHadronIsoR(self,R=0.4):
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)
89 

◆ dxy()

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().

Referenced by ntupleDataFormat.Track.dxyPull().

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
61  is not available.
62  '''
63  if vertex is None:
64  vertex = self.associatedVertex
65  return getattr(self,self._trackForDxyDz)().dxy( vertex.position() )
66 

◆ dz()

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().

Referenced by ntupleDataFormat.Track.dzPull().

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
75  is not available.
76  '''
77  if vertex is None:
78  vertex = self.associatedVertex
79  return getattr(self,self._trackForDxyDz)().dz( vertex.position() )
80 

◆ edxy()

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  def edxy(self):
68  '''returns the uncertainty on dxy (from gsf track)'''
69  return getattr(self,self._trackForDxyDz)().dxyError()
70 
71 

◆ edz()

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  def edz(self):
82  '''returns the uncertainty on dxz (from gsf track)'''
83  return getattr(self,self._trackForDxyDz)().dzError()
84 

◆ looseId()

def Muon.Muon.looseId (   self)
Loose ID as recommended by mu POG.

Definition at line 15 of file Muon.py.

References muon.isLooseMuon(), and PhysicsObject.PhysicsObject.physObj.

Referenced by Muon.Muon.muonID().

15  def looseId( self ):
16  '''Loose ID as recommended by mu POG.'''
17  return self.physObj.isLooseMuon()
18 
bool isLooseMuon(const reco::Muon &)

◆ muonID()

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(), cutBasedMuonId_MuonPOG_V0_cff.globalTrack, susybsm::HSCParticleType.innerTrack, reco::CaloMuon.innerTrack(), reco::Muon.innerTrack(), pat::Muon.innerTrack(), HcalRaddamMuon.innerTrack, Phase2L1GMT::MuonROI.isGlobalMuon(), Phase2L1GMT::PreTrackMatchedMuon.isGlobalMuon(), reco::ShallowClonePtrCandidate.isGlobalMuon(), reco::ShallowCloneCandidate.isGlobalMuon(), ScoutingMuon.isGlobalMuon(), reco::LeafRefCandidateT.isGlobalMuon(), Run3ScoutingMuon.isGlobalMuon(), reco::Candidate.isGlobalMuon(), reco::LeafCandidate.isGlobalMuon(), CandidateWithRef< Ref >.isGlobalMuon(), HGCalClusterT< C >.isGlobalMuon(), reco::Muon.isGlobalMuon(), pat::PackedGenParticle.isGlobalMuon(), pat::PackedCandidate.isGlobalMuon(), muon.isHighPtMuon(), muon.isLooseMuon(), muon.isSoftMuon(), muon.isTightMuon(), Muon.Muon.looseId(), TrackCollections2monitor_cff.normalizedChi2, L1Analysis::L1AnalysisRecoMuonDataFormat.numberOfMatchedStations, reco::Muon.numberOfMatchedStations(), TrackCollections2monitor_cff.numberOfValidPixelHits, PhysicsObject.PhysicsObject.physObj, and extraflags_cff.segmentCompatibility.

Referenced by Muon.Muon.tightId().

28  def muonID(self, name, vertex=None):
29  if name == "" or name is None:
30  return True
31  if name.startswith("POG_"):
32  if name == "POG_ID_Loose": return self.physObj.isLooseMuon()
33  if vertex is None:
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 \
40  self.globalTrack().normalizedChi2() < 10 and \
41  self.globalTrack().hitPattern().numberOfValidMuonHits() > 0 and \
42  self.numberOfMatchedStations()>1 and \
43  self.innerTrack().hitPattern().numberOfValidPixelHits()>0 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;
48  return self.physObj.innerTrack().validFraction() > 0.8 and self.physObj.segmentCompatibility() >= (0.303 if goodGlb else 0.451)
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)
52 
bool isLooseMuon(const reco::Muon &)
bool isSoftMuon(const reco::Muon &, const reco::Vertex &, bool run2016_hip_mitigation=false)
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
static const int muonID
Definition: TopGenEvent.h:19
bool isTightMuon(const reco::Muon &, const reco::Vertex &)

◆ mvaId()

def Muon.Muon.mvaId (   self)
For a transparent treatment of electrons and muons. Returns -99

Definition at line 53 of file Muon.py.

53  def mvaId(self):
54  '''For a transparent treatment of electrons and muons. Returns -99'''
55  return -99
56 
57 

◆ neutralHadronIsoR()

def Muon.Muon.neutralHadronIsoR (   self,
  R = 0.4 
)

Definition at line 90 of file Muon.py.

References displacedMuons_cfi.pfIsolationR03, displacedMuons_cfi.pfIsolationR04, and PhysicsObject.PhysicsObject.physObj.

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

90  def neutralHadronIsoR(self,R=0.4):
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)
94 

◆ photonIsoR()

def Muon.Muon.photonIsoR (   self,
  R = 0.4 
)

Definition at line 95 of file Muon.py.

References displacedMuons_cfi.pfIsolationR03, displacedMuons_cfi.pfIsolationR04, and PhysicsObject.PhysicsObject.physObj.

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

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

◆ ptErr()

def Muon.Muon.ptErr (   self)

◆ puChargedHadronIsoR()

def Muon.Muon.puChargedHadronIsoR (   self,
  R = 0.4 
)

Definition at line 108 of file Muon.py.

References displacedMuons_cfi.pfIsolationR03, displacedMuons_cfi.pfIsolationR04, and PhysicsObject.PhysicsObject.physObj.

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

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

◆ setTrackForDxyDz()

def Muon.Muon.setTrackForDxyDz (   self,
  what 
)

Definition at line 10 of file Muon.py.

References Muon.Muon._trackForDxyDz.

10  def setTrackForDxyDz(self,what):
11  if not hasattr(self,what):
12  raise RuntimeError("I don't have a track called "+what)
13  self._trackForDxyDz = what
14 

◆ tightId()

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

Member Data Documentation

◆ _trackForDxyDz

Muon.Muon._trackForDxyDz
private