1

I have a file that contains TGeoTracks on one branch element. TGeoTracks have two private members that I'm interested in, a number of points and an array that's 4*nPoints (https://root.cern.ch/doc/master/TGeoTrack_8h_source.html#l00040).

private :
   Int_t          fPointsSize; // capacity of points array
   Int_t          fNpoints;    // number of stored points
   Double_t      *fPoints;     //[fNpoints] array of points (x,y,z,t) belonging to this track

This is that the ROOT file looks like in the TBrowser:

enter image description here

Note that the interpretation in the TBrowser is slightly misleading since all four elements per event are stored in the same histogram.

Now, I'm trying to read the file with uproot. The default interpreation for this branch element was wrong:

mcFileThin1_5 = uproot.open("/media/CacheDrive2TB/Arbeit/PandaRoot/macro/detectors/lmd/testFullChain-thinKapton/mom-1_5/Lumi_MC_0.root")
startXarray = mcFileThin1_5["pndsim/GeoTracks.fPoints"]
print(startXarray.interpretation)


AsObjects(AsArray(True, False, AsArray(False, True, dtype('>f8'), ()), ()))

So i tried with a custom interpretation:

mcFileThin1_5 = uproot.open("/media/CacheDrive2TB/Arbeit/PandaRoot/macro/detectors/lmd/testFullChain-thinKapton/mom-1_5/Lumi_MC_0.root")
startXarray = mcFileThin1_5["pndsim/GeoTracks.fPoints"]

dtype = np.dtype([("x", ">f8"),("y", ">f8"),("z", ">f8"),("t", ">f8")])
interpret = uproot.AsDtype(dtype)
arr = mcFileThin1_5["pndsim/GeoTracks.fPoints"].array(interpret)

But that fails:

ValueError: basket 0 in tree/branch /pndsim;4:GeoTracks/GeoTracks.fPoints has the wrong number of bytes (22902) for interpretation AsDtype("[('x', '>f8'), ('y', '>f8'), ('z', '>f8'), ('t', '>f8')]")
in file /media/CacheDrive2TB/Arbeit/PandaRoot/macro/detectors/lmd/testFullChain-thinKapton/mom-1_5/Lumi_MC_0.root

How can I specify the interpretation of this branch element to be four doubles per point?

RemusKaos
  • 43
  • 8
  • I can't respond as an answer because I don't have enough information—could you post a small sample file, here or (maybe better) on https://github.com/scikit-hep/uproot4/issues as a bug report? My guess is that a proper interpretation is `uproot.AsObjects(uproot.AsArray(False, True, np.dtype('>f8'), ()))`, that the second, intermediate "`AsArray`" is because Uproot is not realizing that the data is split across multiple TBranches. – Jim Pivarski Jan 27 '22 at 21:16
  • Thanks for the reply (and sorry for answering so late myself). Will do! – RemusKaos Feb 04 '22 at 12:27

0 Answers0