CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Lepton.py
Go to the documentation of this file.
2 import ROOT
3 
5  def ip3D(self):
6  '''3D impact parameter value.'''
7  return abs(self.dB(self.PV3D))
8 
9  def sip3D(self):
10  '''3D impact parameter significance.'''
11  db, edb = self.dB(self.PV3D), self.edB(self.PV3D)
12  return abs(db/edb) if edb > 0 else 999.
13 
14  def absIsoFromEA(self, area='04'):
15  '''Calculate Isolation using the effective area approach.'''
16  photonIso = self.photonIso()
17  offset = self.rho*getattr(self,"EffectiveArea"+area)
18  return self.chargedHadronIso()+max(0.,photonIso+self.neutralHadronIso()-offset)
19 
20  def relIsoFromEA(self, area='04'):
21  return self.absIsoFromEA(area)/self.pt()
22 
23  def relIso(self, dBetaFactor=0, allCharged=0):
24  '''Relative isolation with default cone size of 0.4.'''
25  rel = self.absIsoR(dBetaFactor=dBetaFactor, allCharged=allCharged)/self.pt()
26  return rel
27 
28  def absIsoR(self, R=0.4, dBetaFactor=0, allCharged=False):
29  '''Isolation in given cone with optional delta-beta subtraction.'''
30  if dBetaFactor>0 and self.puChargedHadronIsoR(R)<0:
31  raise ValueError('If you want to use dbeta corrections, you must make sure that the pu charged hadron iso is available. This should never happen')
32  neutralIso = self.neutralHadronIsoR(R) + self.photonIsoR(R)
33  corNeutralIso = neutralIso - dBetaFactor * self.puChargedHadronIsoR(R)
34  charged = self.chargedHadronIsoR(R)
35  if allCharged:
36  charged = self.chargedAllIsoR(R)
37  return charged + max(corNeutralIso, 0.)
38 
39  def relIsoR(self, R=0.4, dBetaFactor=0, allCharged=False):
40  return self.absIsoR(R, dBetaFactor, allCharged)/self.pt()
41 
42  def lostInner(self):
43  if hasattr(self.innerTrack(),"trackerExpectedHitsInner") :
44  return self.innerTrack().trackerExpectedHitsInner().numberOfLostHits()
45  else :
46  return self.innerTrack().hitPattern().numberOfHits(ROOT.reco.HitPattern.MISSING_INNER_HITS)
47 
48  def p4WithFSR(self):
49  ret = self.p4()
50  for p in getattr(self, 'ownFsrPhotons', getattr(self, 'fsrPhotons', [])):
51  ret += p.p4()
52  return ret
53 
54  def __str__(self):
55  ptc = super(Lepton, self).__str__()
56  return '{ptc}, iso={iso:5.2f}'.format(ptc=ptc, iso=self.relIso())
def relIso
Definition: Lepton.py:23
def lostInner
Definition: Lepton.py:42
def p4WithFSR
Definition: Lepton.py:48
def relIsoR
Definition: Lepton.py:39
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def sip3D
Definition: Lepton.py:9
def ip3D
Definition: Lepton.py:5
def relIsoFromEA
Definition: Lepton.py:20
def absIsoFromEA
Definition: Lepton.py:14
def __str__
Definition: Lepton.py:54
def absIsoR
Definition: Lepton.py:28