Atomic Fill&GetEntries for TBranch

Hi Philippe,

sorry for the confusion, I am reviving some old code that I didn’t touch since long ago, so I messed up with the details. Starting with the big picture, what I am trying to solve is described in this thread: in few words, I need to stream data to the Root file during the event processing, since single-event data is too big to fit in memory. In this particular case I would need a method that can fill a branch containing a collection in an incremental way, i.e. by calling many times per event a hypothetical FillWithAppend method that appends entries to the collection contained in the current entry of the branch. After this I could re-use the in-memory buffers for the subsequent data instead of having to allocate more memory.

Lacking such a facility I guessed that I can call Fill multiple times per event the collection branch, and then take note of the branch entries that correspond to the current event for offline event rebuild during readout. But in an event-level multithreaded (i.e. Geant4) application several threads would need to do the same concurrently if operating on the same branch, or each one have a copy of the branch. In this last case however I guess that troubles could arise if the branches are recombined at the end in a single one, since the entry numbers in the merged branch will be different from those saved for event rebuild. If TBufferMerger actually does something similar then it could screw up all of my code.

About “Fill does not return the number of filled entry” it should have been written as “Fill does not return the number of the filled entry”, my bad. But even if it did then it would probably be useless in the above described branch-merging scenario.

Sorry for the long post, I hope the situation is more clear now. Any help or advice from your side will be greatly appreciated, so thanks in advance.