Options for speeding up Tree Read

TTree are optimized for read in sequential order of entries. The entries are bunched in baskets (which are bunched in clusters) and each basket is compressed and stored individually. When reading out of sequence, for each entry read (in first approximation) you end up reading and decompressing a basket (that spans several entries) and then discard it. This result in reading and decompressing the data many times (in first approximation the cardinality of a basket).

If your TTree fits in memory you can significantly improve performance by using:

T1->SetMaxVirtualSize( some_amount_of_memory_larger_than_the_TTree );

This will make sure that once loaded and decompressed the baskets are kept in memory. You can even preload them via

T1->LoadBaskets( some_amount_of_memory_larger_than_the_TTree );

or given than

while the data for each individual channel is time ordered,

you could put each individual channel in a different TTree (or at least in a separate branch) and then you would be able to read the entries of each TTree (or branches) in order.

1 Like