Saving dataset generated by MC in roofit

Dear RoOt

I generated dataset like following.
=> RooDataSet* data = model(x,1000);

And, I would like to know how one can save the dataset generated above and access the individual event value.

:slight_smile:

Hi,

You can save a RooDataSet to a ROOT file like you can save any ROOT object

TFIle f(“myfile.root”,“RECREATE”) ;
data->Write()
f.Close()

If you want to write multiple datasets and/or pdfs as well it may be more convenient
to import all data and models first into a RooWorkspace object and then write that
to file, see e.g.

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

Concerning your second question: You can access the individual event values using data->get(i) where i is the event number, e.g.

  RooArgSet* event = data.get(i) ;
  event->Print("v") ;

Wouter