Problem accessing subbranches and/or leaves #1030
-
Good afternoon everyone, I need help accessing the subbranches or leaves of a ROOT file. It is a problem that I have never encountered before. I uploaded the file (one of many) here: https://github.com/ivoschulthess/uprootProblem/blob/main/datafile.root. I am not very used to ROOT itself, but to look and access the data with ROOT, I can do the following:
This gives me the tree information and draws a histogram of the branch "CDT0.CDT0". If I try to do the same thing with uproot (5.0.7) using Python 3.11.5, I encounter the following problem:
Same thing happens when trying to access the other branch CDT1. I tried various things to access the content but it always gives me nothing or an error. It seems uproot does not recognize the leaves properly. Do you have an idea what the problem is or do you know other ways to access the data? Thanks in advance for your help and advice. Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
There does seem to be something wrong: just trying to look at the interpretation of >>> tree["CDT0"].interpretation
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jpivarski/irishep/uproot5/src/uproot/behaviors/TBranch.py", line 1935, in interpretation
self._interpretation = uproot.interpretation.identify.interpretation_of(
File "/home/jpivarski/irishep/uproot5/src/uproot/interpretation/identify.py", line 407, in interpretation_of
_leaf_to_dtype(leaf, getdims=True).newbyteorder(">"),
File "/home/jpivarski/irishep/uproot5/src/uproot/interpretation/identify.py", line 69, in _leaf_to_dtype
dims = tuple(eval(m.group(2).replace("][", ", ")))
File "<string>", line 1, in <module>
NameError: name 'nCDT0' is not defined (Which is true: there is no TBranch named From ROOT's own The title of the TBranches are both >>> tree["CDT0"].member("fLeaves")[0].member("fTitle")
'nCDT0'
>>> tree["CDT0"].member("fLeaves")[1].member("fTitle")
'CDT0[nCDT0]' That would be possible for branches, which are not interleaved, because the counter can have a different number of values than the counted. Specifically, there's one integer for the counter and who-knows-how-many integers for the counted. Data specified by multiple TLeafs, however, are interleaved—there has to be exactly as many of each. And yet, that seems to be exactly what this is saying. If I avoid Uproot's own interpretation and look at it through each TBasket's raw bytes, >>> tree["CDT0"].num_baskets
1
>>> tree["CDT0"].basket(0).data.view(">i4")
array([2048, 0, 0, ..., 0, 0, 0], dtype='>i4')
>>> tree["CDT1"].num_baskets
1
>>> tree["CDT1"].basket(0).data.view(">i4")
array([ 27, 53753945, 100000000, 100000000, 0, 0,
0, 5, 1, -1, -1, -1,
-1, -1, -1, -1, -1, 51338476,
2431479, 2756, 5420, 332, 0, 44542698,
7819608, 1200644, 215180, 6575], dtype='>i4') I see that the number of So this kind of multi-TLeaf TBranch is interleaved but not equal-sized, so it can't be interpreted as a NumPy structured array. I don't know what to make of it. Hopefully, though, this gives you a way to work with your data. I can't add the above to Uproot because I don't know how it generalizes, but it should work for your specific problem. |
Beta Was this translation helpful? Give feedback.
There does seem to be something wrong: just trying to look at the interpretation of
tree["CDT0"]
causes an exception inside of Uproot.