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
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();
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.