TruthPaticle parent function

Hello I am Nam.

This is my code is related with ROOTCORE.

#!/usr/bin/env python
import ROOT
ROOT.gROOT.Macro( ‘$ROOTCOREDIR/scripts/load_packages.C’ )
if(not ROOT.xAOD.Init().isSuccess()): print “Failed xAOD.Init()”
read_file = “user.gabarone.8350793.EXT0._000003.DAOD_TRUTH0.truth.pool.root”
treeName = “CollectionTree”
rf = ROOT.TFile.Open(read_file)
t = ROOT.xAOD.MakeTransientTree(rf, treeName)
total = t.GetEntries()
for entry in xrange( 0,5):
t.GetEntry( entry )
mi = 0
for ni in xrange( t.TruthParticles.size()):
tr = t.TruthParticles[ni]
vtx = t.TruthVertices[ni]
tr_id = tr.pdgId()
tr_stat = tr.status()
tr_nparent = tr.nParents()
tr_mom =tr.parent()
tr_pt =
tr_bar = tr.barcode()
tr_prodvtx = tr.hasProdVtx()
tr_hasdecayvtx = tr.hasDecayVtx()
tr_p4_M = tr.p4().M()
if (abs(tr_id)==11 or abs(tr_id)==12 or abs(tr_id)==13 or abs(tr_id)==14 or abs(tr_id)==15 or abs(tr_id)==16):
if (tr_nparent>0):
print( " " )
print( entry, tr_id, tr_stat, tr_bar, tr_prodvtx, tr_hasdecayvtx,tr_mom)

In this code, I would like to know, mother or parent particles pdgid. But in my code, when I print “tr_mom”, I get the message “<ROOT.xAOD::TruthParticle_v1 object at 0xea4b600>”.
So how to use parent() in Pyroot. please help me. :frowning: #-o

Hi Nam,

this is perhaps something which is more suited for an Atlas forum as it is really relative to the xAOD.
What you are seeing is perfectly fine. You are trying to print an object which does not implement a repr operator, it is normal you get its type and pointer.
What you can do is to “use” this object, for example asking what is its pdgid or alike (see … 8a31e79a4c), but really here we fall in an ATLAS specific realm :slight_smile: