Produce Toy MC from RooDataSet

Dear experts,
Greetings,

Currently, I try to produce Toy MC from binned data. if there is only one category, I can do it by

    // RooWorkspace* w
    ModelConfig* mc = (ModelConfig*)w->obj("ModelConfig"); // Get model manually

    RooArgSet* obs = (RooArgSet*)mc->GetObservables();
    RooRealVar* x_val_MXs1 = (RooRealVar*)obs->find("obs_x_channel_MXs1");

    RooDataSet* data = (RooDataSet*)w->data("asimovData");
    TH1D* HistData = (TH1D*)data->createHistogram("HistData", *x_val_MXs1, Binning(RarityBins, BinMIN, BinMAX));
    RooDataHist DataHist("DataHist", "DataHist", *x_val_MXs1, HistData);
    RooHistPdf dataPDF("dataPDF", "dataPDF", RooArgSet(*x_val_MXs1, model->indexCat()), DataHist);

    RooDataSet* genData = dataPDF.generate(RooArgSet(*x_val_MXs1, model->indexCat()), 100, false, true, "", false, true);

The above code try to do
RooDataSet (asimovData) → TH1D → RooDataHist → RooHistPdf → RooDataSet

However, if there are more than one RooCategory, it is not simple:

The ranges and number of bins are taken from the input histogram and must be the same in all histograms

https://root.cern.ch/doc/master/classRooDataHist.html#a60ffc4da687de2eee9ac1696725fc175

However, for each category, the bin and range can be different.

    // RooWorkspace* w
    ModelConfig* mc = (ModelConfig*)w->obj("ModelConfig"); // Get model manually

    RooArgSet* obs = (RooArgSet*)mc->GetObservables();
    RooRealVar* x_val_MXs1 = (RooRealVar*)obs->find("obs_x_channel_MXs1");
    RooRealVar* x_val_MXs2 = (RooRealVar*)obs->find("obs_x_channel_MXs2");
    RooRealVar* x_val_MXs3 = (RooRealVar*)obs->find("obs_x_channel_MXs3");

    // ...?

So, what is the best way to produce MC from data (here, from asimovData)

Thank you

Hi,

Thanks for the interesting post. I am adding in the loop @jonas , who might have a suggestion.

Cheers,
Danilo

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