Quickly access all entries for a variable

Hi,

I am interested in quickly accessing all the entries for a few variables in a tree.

Let’s say I have a TFile file called f, a TTree called tree, and an interesting variable called v. Here is how I currently know how to fill a list with the value of v for all entries:

v_vals=[]
for e in range(f.tree.GetEntries()):
    f.tree.GetEntry(e)
    v_vals.append( f.tree.v )

Is there a quicker way to fill this list?

Thanks for your help,

Peter

Hi Peter,

it was recently discussed here: Iteration over a tree in pyroot - performance issue. You can see there some tips for performance improvements. Unfortunatelly, even with all the improvements it is still far behind the speed of run in C++.

Cheers,
Jiri

Thanks Jiri. This is exactly what I was looking for.

Cheers,

Peter