Home | News | Documentation | Download

How to get PyROOT to recognize my TFile's TBranches?

ROOT Version: Not Provided
Platform: Linux
Compiler: Not Provided

Hello, I am attempting to iterate over the values of one TBranch in a TTree that is located in a TDirectory under a TFile. I am fairly new to ROOT, though I have history with Python, so I thought it best to use PyROOT to complete the iteration. However, if anyone can help me get this to work in either PyROOT or ROOT, it would be very helpful.

so far I have this:
"
myfile = ROOT.TFile("/home/hilary/root/compile/Research/GENIE_atm.root")
mytree = ROOT.TDirectory(myfile.GENIE/Event) # this is the name of the tree in the file
for e in mytree:
print (e.mc_Momentum) # mc_Momentum is the name of branch of the tree
)
"
I know this does not work and the issue is mainly to do with my lack of understanding of how to tell PyROOT that I want to values of the TBranch named mc_Momentum. The location of the TBranch (mc_Momentum) I am interested in is: GENIE_atm.root/GENIE/Event/mc_Momentum

I am not sure how I need to write the code such that PyROOT knows that I am interested in the values of mc_Momentum. Any ideas?

For clarification, the TFile is is GENIE_atm.root, the TDirectory is GENIE, the TTree is Event, and the TBranch is mc_Momentum.

Dear @Hilary,

Please see my answer here: