Hi, in my analysis program I write the output on two trees inside the same root file. Two different routines write on each tree, and the tree have to be aligned (ie., entry N on both trees is relative to event N). My doubt is about MaxTreeSize. Suppose that routine 1 writes event N on tree 1, which makes the file reach the maximum dimension set by SetMaxTreeSize: what happens next? My guess is that file is closed, a new file named filename_1.root is created and then routine 2 writes event N on tree 2 in this new file. In the end I will have N events in tree 1 and N-1 events in tree 2 inside the original file. Likewise, the trees in the new file will have M-1 and M events respectively.
Is my guess correct? In this case, how can I handle the two files so that I would see two trees both with N+M elements? Is it sufficient to create a TChain?
Thanks
[quote] Likewise, the trees in the new file will have M-1 and M events respectively.
Is my guess correct? [/quote]Yes.
[quote]In this case, how can I handle the two files so that I would see two trees both with N+M elements? Is it sufficient to create a TChain?[/quote]Yes, you would need to create 2 chains (one for each TTree).
Alternatively, you can set the max tree size to a very large number and deal with just one file.
Cheers,
Philippe.
Thanks Philippe.
Hi Philippe,
Is this still the preferred method to handle this? Our use case could result in a file many TB in size, which is not ideal.
yes … but you ought to close the file and start a new file on your own. I.e. once you reach the threshold you are comfortable with (for example ‘so many entries’ or ‘so many GBs’). You need to:
- Write the file
and either
- Close the file (which delete the TTrees) and create a new file and recreate the TTree objects
or
- Detach the 2 TTrees from the file (call
mytree->SetDirectory(nullptr);
) - Create the new file (and sub-directory if any)
- Reattach the 2 TTrees to the new file (call
mytree->SetDirectory(new_file_or_directory);
)
Cheers,
Philippe.