Feature request for RDataFrame

Hi,

Can we get Snapshot command to save the histograms to the same file as the output tree?
Currently, I’m creating hundreds of histograms, saving the RResultPtr to a vector and then later cycling looping over them to save them to a file. It would be nice to have them in the same file as the Snapshot’d tree. May be I don’t know how to do this elegantly.


_ROOT Version: root-master 6.15.01
Platform: Not Provided
Compiler: Not Provided


Hi Suyong,
does this do?

auto h = d.Histo1D("x");
// this non-lazy Snapshot also runs the event loop:
// we need the file to be there in the next line
d.Snapshot("tree", "f.root");
// opens the Snapshotted file in append mode
TFile f("f.root", "update");
// saves h to `f.root`
h->Write();
f.Close();

Cheers,
Enrico

Hi Enrico,

Yes, that’s what I’m kind of doing. It would be nice if Snapshot did automatically :slight_smile:

Regards,
Suyong

It would be nice if Snapshot did automatically

I don’t think it could: Snapshot writes data per event to the output TTree at the same time as the histograms are filled.
You don’t want to write one histogram per event, but once the histograms are filled (i.e. after the event loop is over – and Snapshot with it) you want to add them to your output file.

Does this make sense?
Cheers,
Enrico

Yes, thank you.
Best,
Suyong

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