I encounter some issues when trying to loop over a TTree using python. This simple script exits with
AttributeError: 'TTree' object has no attribute 'track'
import ROOT as r f = r.TFile.Open("ntuple.root") t = f.Get("trajTree") for i in range(10): t.GetEntry(i) print(t.track.quality)
The TTree does contain the “track” branch.
A workaround is to do
t.GetBranch("track").GetLeaf("quality").GetValue(). However, when I try to do it on a leaf which contains an array, for example
t.GetBranch("track").GetLeaf("validbpix").GetValue(), it only returns one value (I guess it’s the first one).
Why cannot the
tree.branch.leaf syntax be used? Or how can the workaround with getting a branch and a leaf work with arrays?
Attached is the .root file ntuple.root (92.6 KB)
I am also linking a data structure which, I believe,was used to create the file
SiPixelTools-PhaseIPixelNtuplizer/DataStructures_v9.h at master · CMSTrackerDPG/SiPixelTools-PhaseIPixelNtuplizer · GitHub
ROOT Version: 6.12/07