Snapshot several frames to the same file

Hello all!

I’m using RDataFrames to do my analysis by defining several different views on the parent tree to divide my large number of events into various control, validation, and signal regions. This is working fine for making histograms in each region and saving them to an output file, but now I’d like to save each smaller view as a TTree with only the events in that region. Snapshot works for this, of course, but I end up with a different file for each region which is pretty annoying. I’d much rather have all my trees in the same file, just with different names.

Is there a snapshot option to update an existing file instead of overwriting it each time? Or some other suggestion for how to do this elegantly?

Cheers,
Kate

Hi,
you can pass a ROOT::RDF::RSnapshotOptions object to a Snapshot call (reference is here) and you can set fMode to "UPDATE" to open the underlying TFile in append mode.

Haven’t tested this, but the usage is something like:

ROOT::RDF::RSnapshotOptions opts;
opts.fMode = "UPDATE";
df.Snapshot(..., opts);

That should work – let us know how it goes.
Cheers,
Enrico

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