Dear experts,
I have use a TTree to store skimmed collisions events for my physics analysis, where each entry of the tree corresponds to one event. Two types of branches are used. Flat branches that contain only one float per event, e.g.:
fAnalysisTree->Branch("Event_Rho", &fBuffer_EventRho,"Event_Rho/F");
In addition, there are branches that contain std::vectors, where each entry of the vector corresponds to one particle from the event, e.g. for the energy:
fAnalysisTree->Branch("Cluster_E","std::vector<Float_t>",&fBuffer_ClusterE);
My code works as intended, however, I have a question regarding the compression. Since I do quite a bit of pre-selections, most of the events will be empty. i.e. you will always have something stored for the event (e.g. the aforementioned rho variable), but usually all the std::vector<Float_t> will be of size 0. To give you an example, running over 160k tree entries, only 64 events will have vectors that do not have size()=0.
The problem I encounter is this: The size of the tree gets quite large. While everything is as expected for the flat Float_t branch, I think even for the cases where the vectors have size()=0, the tree has to store the empty std::vector structure, which takes up more space than a simple float.
Do you see any way how I can make the storage more efficienct, i.e. dealing with the vast amount of entries where all the std::vector branches will be empty? Is there a way to “tell” the TTree to compress empty vectors in some way? Can I maybe simply store a nullptr if the vectors are empty and deal with this later when reading the tree? Should I get rid of std::vectors in my tree entirely?
Sorry for my ignorant questions, but maybe some of you can offer some hints for optimization. Currently the way I store things seems highly inefficient to me. I am happy to provide further examples if needed.
Best wishes,
Florian
_ROOT Version: 6.26/06
_Platform: manjaro
_Compiler: gcc