-
I am using uproot to read root files. My files are such that I am doing this: ifile = uproot.open(path_to_root_file)
metadata = ifile['Metadata']
waveforms = ifile['Waveforms']
waveforms.show()
waveforms_of_event_50 = waveforms['voltages'].array()[50]
print(waveforms_of_event_50) and I get as output
Since the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The best you can do is waveforms_of_event_50 = waveforms['voltages'].array(entry_start=50, entry_stop=51)[0] This will read the minimum physically possible, which is one TBasket. The TBasket might be several kB or maybe a few MB of data. Data in TTrees are not stored in smaller granularity than this, and each chunk is generally compressed, so you have to read the whole thing to decompress it. It will definitely solve you problem with tens of GB, though: I don't think it's possible for a single TBasket to get that large. This is not a good pattern if, right after this, you want to read the waveform of event 51, because it's probably in the same TBasket that you just read, and waveforms_of_event_51 = waveforms['voltages'].array(entry_start=51, entry_stop=52)[0] would read it again. If you want to load just one TBasket at a time, see TBranch.basket_entry_start_stop to know where to put your |
Beta Was this translation helpful? Give feedback.
The best you can do is
This will read the minimum physically possible, which is one TBasket. The TBasket might be several kB or maybe a few MB of data. Data in TTrees are not stored in smaller granularity than this, and each chunk is generally compressed, so you have to read the whole thing to decompress it. It will definitely solve you problem with tens of GB, though: I don't think it's possible for a single TBasket to get that large.
This is not a good pattern if, right after this, you want to read the waveform of event 51, because it's probably in the same TBasket that you just read, and
waveforms_of_…