Howto save a RooHistPdf into a root file?

Hi,

I create RooHistPdfs from datasets, which due to the size of the dataset takes quite some time. Is there a way to save the PDF into a file to speed up things? I tried Root’s Write() mechanism, but I can’t access the RooHistPdf object (via gDirectory->Get()) after I loaded the root file back in.

  • Moritz

Hi Moritz,

You should use the RooWorkspace container class to persist RooFit objects, i.e.

RooWorkspace w(“w”) ;
w.import(myPdf) ;

TFile f(“wspace.root”,“RECREATE”);
w.Write() ;
f.Close() ;

Then to read back

TFile f(“wspace.root”) ;
RooWorkspace* w = f.Get(“w”) ;
RooAbsPdf* myPdf = w.pdf(“myPdf”) ;

See also tutorial macros

root.cern.ch/root/html/tutorials … ite.C.html
root.cern.ch/root/html/tutorials … ead.C.html
root.cern.ch/root/html/tutorials … ive.C.html

Wouter