Skip to content

Commit

Permalink
reusing Particle.__str__ seem not to work. better would be to have a …
Browse files Browse the repository at this point in the history
…free function baseP4Printing to be shared for different cases
  • Loading branch information
arizzi committed Dec 19, 2014
1 parent 5be700a commit 35228a2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions PhysicsTools/Heppy/python/physicsobjects/GenParticle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
#add __str__ to reco::GenParticle python wrapper
import ROOT
def printGenParticle(self):
base = basePrint(self)
tmp = '{className} : {pdgId:>3}, pt = {pt:5.1f}, eta = {eta:5.2f}, phi = {phi:5.2f}, mass = {mass:5.2f}'
base= tmp.format( className = self.__class__.__name__,
pdgId = self.pdgId(),
pt = self.pt(),
eta = self.eta(),
phi = self.phi(),
mass = self.mass() )
theStr = '{base}, status = {status:>2}'.format(base=base, status=self.status())
return theStr
setattr(ROOT.reco.GenParticle,"basePrint",Particle.__str__)
setattr(ROOT.reco.GenParticle,"__str__",printGenParticle)

from ROOT.reco import GenParticle

0 comments on commit 35228a2

Please sign in to comment.