Re: list of unique values from a TTree

From: Tim Head <betatim_at_gmail.com>
Date: Fri, 25 May 2012 17:23:17 +0100


On Fri, May 25, 2012 at 5:13 PM, Rob Mahurin <rob_at_jlab.org> wrote:
>>
>> tree.Draw("scandata1>>h", "goff")
>> v1 = tree.GetV1() # gets an array of value you just drew
>> set(v1[n] for n in xrange(tree.GetEntries())
>
> Yes!  This does exactly what I want, and is quite fast.  It must move
> all the looping from interpreted code into compiled code, or something.
>

When using ROOT from python you suffer a large penalty for each C++ function you call. Lots of magic goes on to convert arguments, figure things out at runtime etc. I have never gone out to measure this in a scientific way so this is more of a hunch than anything else. Doing the Draw(); GetV1() thing basically means you are making two calls to C++ instead of calling GetEntry() a bazillion times.

Tim

-- 
http://tim.jottit.com/
Received on Fri May 25 2012 - 19:05:20 CEST

This archive was generated by hypermail 2.2.0 : Fri May 25 2012 - 23:50:02 CEST