Generate toy data using PDF

Dear Expert,

I have a 2D binned fit with different components. Now I want to test the fit using toy data generated directly from the PDFs.
I know that we can generate the toy data using PDF>generate(), but here I have ~5 PDfs of both variables (x and y).

Can you please help to do this?

Here is the script that I am using for 2D fit:
fit_2d.root (51.3 KB)
fit_2d_binned_final.C (13.1 KB)


Hi @chanchal!

I see in the script you already have your final RooAddPdf where you combine all the PDFs.

You can also use RooAbsPdf::generate() to create a toy dataset with two observables. Or maybe I’m missing the reason why you’re not just doing this?

std::unique_ptr<RooDataSet> toydata{model.generate({mD0, mD0pi})};

By the way, don’t forget to use the Extended() command argument if you also want to randomize the number of events in the toy dataset according to a Poisson distribution around the nominal sum of yields in the model.


Hii @jonas,

Thanks for the reply. yes, I did this, and working fine.
Now I want to check the distribution of (fitted yield - input yield)/fit uncertainty in each toy dataset.

As far as I know in RooMCStudy, we can do this using mcstudy->plotPull().
Is there any way to do this here?

Here is the script:
fit_2d_toy_data.C (18.1 KB)



Is this follow-up question in your last post in this thread still relevant, or should we just follow up here?

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