Skip to content

Getting the i-th element without loading whole array #924

Answered by jpivarski
SengerM asked this question in Q&A
Discussion options

You must be logged in to vote

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_…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by SengerM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants