Re: Re: pyroot objects

From: Yngve Inntjore Levinsen <yngve.inntjore.levinsen_at_cern.ch>
Date: Thu, 11 Aug 2011 13:30:42 +0200


On Wed. 10. of August 2011, wlavrijsen_at_lbl.gov wrote:
> Yngve,
>
> TTree's already have a __iter__, but its implementation is differently from
> your choice: it iterates over entries, not over branches.
>
> As for getting all entries into a numpy array, I can't think of anything
> faster, as one has to read them, but one optimization usually helps, which
> is to switch off any branches not used in the iteration (so that their values
> are not loaded during the loop) and/or to use those branches directly instead
> of the tree (the TTree::GetEntry loops over all branches, which is a waste if
> you're only interested in a few branches).
>
> Best regards,
> Wim
>

Hi,

Well no, to get it faster in a python script will be difficult I guess (unless I did some stupid mistakes which slows things down), but one could write a c implementation (or cython as suggested), since numpy is also written in C...

Was not aware that TTree already was iterating. Chosing entries over branches probably makes sense, I have a very narrow view of what kind of use-cases one should account for, and how to think properly in ROOT-terms.

Cheers,
Yngve Received on Thu Aug 11 2011 - 13:30:50 CEST

This archive was generated by hypermail 2.2.0 : Thu Aug 11 2011 - 17:50:02 CEST