#!/usr/bin/env python # Numpy is a popular numerics libary for python. We show here that # interfacing with aanet (and root) is particularly easy. import numpy from ROOT import * import aa from aa import aanumpy # this adds ROOT.TTree.DrawNumpy aa.i() # interactive: start prompt when done f = EventFile("../data/mc5.1.numuCC.ps10.aa.root") # The following function returns numpy arrays. tot, trel = E.DrawNumpy("hits[].tot:hits[].t-hits[0].t" ) print tot print sqrtt # So now you can do numpy with those vectors. (It's not so easy # to come up with a more useful example, though ). print numpy.sum( numpy.sqrt( numpy.abs( trel ))) t = numpy.copy(trel) # The numpy arrays have a pointer to the root-owned c arrays. # This pointer is valid until the next TTree::Draw commaond enu = E.DrawNumpy("mc_trks[0].E" ) # print tot # segfault!, tot not anymore good! print t # okay because it is a copy