1

I have several ROOT files containing a TTree with (among others) some branches that are TVector3 objects. I am trying to load the vector components (x, y, z) into a Pandas DataFrame, but I keep getting this error, no matter what I try:

ValueError: cannot interpret branch b'hitPosExtrap' as a Python type

I am trying to use uproot.pandas.iterate, but also tried with the tree's f[tree_name].array('hitPosExtrap') method to no avail. Reading the uproot README it looked to me as if it would be able to understand TVector3 objects, but but I guess I am missing something.

Does anyone know a way for me to get the vector components (or some TVector3-like objects) out of these trees?

Lukas Koch
  • 31
  • 4

1 Answers1

2

The issue seems to be that the TVector3 is stored as a subbranch in this particular root file. The vector components are accessible as leaves of that subbranch:

f[tree_name]["hitPosExtrap"]["fX"].array()
f[tree_name]["hitPosExtrap"]["fY"].array()
f[tree_name]["hitPosExtrap"]["fZ"].array()

After some discussion (https://github.com/scikit-hep/uproot/issues/443) it seems like uproot does currently not directly support providing the names of branches+subbranches when using the pandas.iterate function. For now one has to access the subbranches explicitly.

Lukas Koch
  • 31
  • 4