scikit-hep/root_numpy

Reading TVector3 Object

maluethi opened this issue · 2 comments

Hi there,

I was wondering if there was a way or a work around to read TVector3 objects. Even if its manually selecting the available leafs.

Cheers

ndawe commented

Yes, you can access the members through formula expressions:

from root_numpy import root2array
from root_numpy.testdata import get_filepath

print root2array(get_filepath('object1.root'),
                 branches=['vect.X()', 'vect.Y()', 'vect.Z()'])

output:

[(1.0, 0.0, 1.1752011936438014) (2.0, 0.0, 7.253720815694038)
 (3.0, 0.0, 30.053624782229708) (4.0, 0.0, 109.159668788511)
 (5.0, 0.0, 371.01605288894376) (6.0, 0.0, 1210.2789442216754)
 (7.0, 0.0, 3838.2128629127255) (8.0, 0.0, 11923.830606316402)
 (9.0, 0.0, 36463.877118745106) (10.0, 0.0, 110132.32874703393)]

Ok, that seems straightforward and actually is what I tried. And I just figured out that my TVector is just that large that it takes forever to load. Anyway thanks for the help.