TTree containing vector


I have a TTree with a ‘vector(N)’ leaf and some other branches (for instance): (startX[nDims], endX[nDims] and 5 other branches).

So I just wonder if it wouldn’t better to store a int and fill N times the tree instead…
Filling a tree N times would might be inefficient due to the other branches and their redundancy, but I guess that there might have some internal mechanisms to optimize this maybe ?

Many thanks !

Hi @meyerma ,

in general ROOT handles vectors and arrays well. Storing one array element per row gets complicated quickly, as soon as you have two or more arrays with different sizes in an event. TTree data is usually compressed and that would get rid of most of the extra space occupied by the redundant values that you would have to insert in the tree, but reading and writing these trees would still use more RAM and CPU as there is simply more data (though redundant) around.

In a sense,

this is subjective. In general one or more arrays per event are completely fine, and very common in ROOT trees.

I hope this helps.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.