Reading C Array From a Tree

Hi All,

I am new to using Python combined with C++ and especially ROOT. I am loading a simple ROOT tree and have no issue reading in simple int, floats and doubles but for some entries there are int arrays saved within trees. These variables turn up as empty string type Python objects.

Is there some way in which I can read these in arrays in without some C struct or class?

Cheers,

Ben

Ben,

do you have an example script? Arrays of int should just work (arrays of char would become strings, though). Otherwise, yes, using a C struct with an array data member or a python array would do the trick.

Cheers,
Wim

Hi Wim,

Thanks for replying so promptly. It is my mistake, the variables have actually been saved as an array of UChar_t. IS there some way to read this in other than creating a C struct?

Cheers,

Ben

Ben,

yes, using python’s array from module array. But it still means that SetBranchAddress() is needed then. At issue is that all char* and equivalent are turned into str objects, because that is the most common use case.

Cheers,
Wim