Hello,
I’m currently working on putting together an array2tree method for my codebase to replace the now deprecated root_numpy method, and have come up with a brute-force method that mostly works:
def array2tree(arr, tree = None):
if tree == None:
tree = TTree("tree","tree")
b = tree.Branch(arr.dtype.names[0],arr, 'normal/D')
for i in range(len(arr)):
arr[0] = arr[i]
tree.Fill()
return tree
When I pass a Numpy array to this method, however, the first (and only the first) value of the array is affected. For reference, the sample dataset I’m testing on has the following values in the TTree generated:
While the associated Numpy arrays have values:
I’m suspecting there’s some strange wrapping happening here, but I’m not sure what’s causing it.
_ROOT Version: 6.24/06
Platform: Linux
Compiler: Not Provided