I have some difficulties understanding how the various options to allow or disallow splitting of objects written to a TTree work together. I hope you can help me to understand a few things:
The object I want to write to the tree is an Event object, it contains a STL vector of Samples (around 20000 samples per event). A Sample has a member variable to save an IdCollection, which contains a STL vector of Ids. The Id class itself is empty in this example, also all other members of the classes have been removed. When the branch is created, I set the splitlevel of the Event to 0.
Now a few cases:
1.) The (simplified) program in the attachment creates 20 such events, and fills them into a ROOT tree. Only the samples are created; the IdCollection is never actually filled. Running the program with time, I find that it takes about 1 second per event. Profiling the program, I see that most of the time is actually spent in routines underneath the call to TTree::Fill. Most time consuming seems to be the part that should find out whether a vector (the only member of IdCollection) can be written memberwise.
2.) If I run the same program, but replace the definition of the member of IdCollection with
std::vector<Id> fIDs; //! the program only takes about 0.05 seconds per event, but the content of IdCollection is not saved to the tree (in the example program the vector was in any case always empty!).
3.) If I replace the definition with
std::vector<Id> fIDs; //|| which to my understanding should disable the splitting for the vector, the time spent per event is still 1 second.
4.) Also with the same way trying to stop the IdCollection as a member of Sample from being split does not change the event per time.
5.) If I specifically ask ROOT not to write the vector memberwise by
TClass::GetClass("vector<Id>")->GetStreamerInfo()->SetStreamMemberWise(false); (depending on the ROOT version) the time per event is again 0.05 seconds per event (as for case 3.)).
- Where does the difference in time per event come from?
- What is the difference between 5.) and 3.)? I expected the only difference to be that 5.) has an effect for all vector, while 3.) should only affect the one inside Sample, obviously that is not the case.
- When the branch is created, I set the split-level of the Event object to 0 (meaning it should not be split). Why is this not applied to the members of the Event.
- What is considered to be the best way to achieve a small processing time per event?