Using CopyTree() in python

From: Tim Head <betatim_at_gmail.com>
Date: Tue, 19 Jan 2010 10:53:57 -0600


Hello,

I am trying to use CopyTree() split a tree up into several trees. It works as expected when I do it once but fails on calling CopyTree() the second time.

I implemented the same as a root macro and can't reproduce the problem. Any ideas where I am going wrong or need to modify things?

Using root 5.24 and python 2.6.4

Thanks,
Tim

from array import array
import ROOT as R

def make_tree():

    ntup = R.TTree("e", "we")

    a = array("f", [0])
    ntup.Branch("a", a, "a/F")
    b = array("f", [0])
    ntup.Branch("b", b, "b/F")
    c = array("f", [0])
    ntup.Branch("c", c, "c/F")

    for i in xrange(20):
        a[0] = 3. * i
        b[0] = 4. * i
        c[0] = 5. * i

        ntup.Fill()

    return ntup

if __name__ == "__main__":

    ntup = make_tree()

    print "One"
    ntup1 = ntup.CopyTree("Entry$ % 2")
    print "Two"
    ntup2 = ntup.CopyTree("(Entry$ % 2) != 1")     print "Three"
    print "Done."

-- 
http://tim.jottit.com/
Received on Tue Jan 19 2010 - 17:54:01 CET

This archive was generated by hypermail 2.2.0 : Sat Jan 23 2010 - 23:50:01 CET