Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:28

0001 from PhysicsTools.Heppy.physicsobjects.PhysicsObject import *
0002 import ROOT
0003 
0004 class Lepton( PhysicsObject):
0005     def ip3D(self):
0006         '''3D impact parameter value.'''
0007         return abs(self.dB(self.PV3D))
0008 
0009     def sip3D(self):
0010         '''3D impact parameter significance.'''
0011         db, edb = self.dB(self.PV3D), self.edB(self.PV3D)
0012         return abs(db/edb) if edb > 0 else 999.
0013 
0014     def absIsoFromEA(self, area='04'):
0015         '''Calculate Isolation using the effective area approach.'''
0016         photonIso = self.photonIso()
0017         offset = self.rho*getattr(self,"EffectiveArea"+area)
0018         return self.chargedHadronIso()+max(0.,photonIso+self.neutralHadronIso()-offset)            
0019 
0020     def relIsoFromEA(self, area='04'):
0021         return self.absIsoFromEA(area)/self.pt()
0022 
0023     def relIso(self, dBetaFactor=0, allCharged=0):
0024         '''Relative isolation with default cone size of 0.4.'''
0025         rel = self.absIsoR(dBetaFactor=dBetaFactor, allCharged=allCharged)/self.pt()
0026         return rel
0027 
0028     def absIsoR(self, R=0.4, dBetaFactor=0, allCharged=False):
0029         '''Isolation in given cone with optional delta-beta subtraction.'''
0030         if dBetaFactor>0 and self.puChargedHadronIsoR(R)<0:
0031             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') 
0032         neutralIso = self.neutralHadronIsoR(R) + self.photonIsoR(R)
0033         corNeutralIso = neutralIso - dBetaFactor * self.puChargedHadronIsoR(R)
0034         charged = self.chargedHadronIsoR(R)
0035         if allCharged:
0036             charged = self.chargedAllIsoR(R)
0037         return charged + max(corNeutralIso, 0.)
0038 
0039     def relIsoR(self, R=0.4, dBetaFactor=0, allCharged=False):
0040         return self.absIsoR(R, dBetaFactor, allCharged)/self.pt()
0041 
0042     def lostInner(self):
0043         if hasattr(self.innerTrack(),"trackerExpectedHitsInner") :
0044             return self.innerTrack().trackerExpectedHitsInner().numberOfLostHits()
0045         else :  
0046             return self.innerTrack().hitPattern().numberOfLostHits(ROOT.reco.HitPattern.MISSING_INNER_HITS) 
0047 
0048     def p4WithFSR(self):
0049         ret = self.p4()
0050         for p in getattr(self, 'ownFsrPhotons', getattr(self, 'fsrPhotons', [])):
0051             ret += p.p4()
0052         return ret
0053 
0054     def __str__(self):
0055         ptc = super(Lepton, self).__str__()
0056         return '{ptc}, iso={iso:5.2f}'.format(ptc=ptc, iso=self.relIso())