Hi there,
first of all sorry for this basic question, but I after 2 hours of searching with Google and the Root User Guide I still didn’t find an answer. I’m using v5.34.
I have a TTree (named tree, contains all events) with some branches (e.g. momentum) and I want to access the value (float) for one event and one branch.
In a loop, I would do this:
datafile = ROOT.TFile.Open("filename.root", "read")
Tree = datafile.Get('tree')
Tree.SetBranchStatus("*",0)
Tree.SetBranchStatus("branch1",1)
for event in tree:
Par1 = event.branch1
But how do I access it without a loop?
Tree.GetEntry(i) only returns the number of bytes read, so that’s not useful. I’d like something in the sense of Tree.EventNr10.branch1.
In another thread I read this (Looping through TTree):
for i in range(myTree.GetEntriesFast()):
myTree.GetEntry(i)
val = myTree.myBranchName
How can this work? For me it’s always an attribute error, because Tree.GetEntry(i) is an int (number of bytes read), so ‘Tree.GetEntry(10).branch1’ does not work.
Thanks a lot!