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.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)
pass
pass
ROOT.xAOD.ClearTransientTrees()
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.