Generate with RooSimultaneous

Hello,

I want to generate data from a RooSimultaneous, the problem is: how can I set the amount of generated data for every category?

What I am doing now is to generate separately for every pdf composing the simultaneous pdf

data1 = pdf1.generate(100)
data2 = pdf2.generate(200)

data = ROOT.RooDataSet("data", "combined data", ROOT.RooArgSet(x),
                      ROOT.RooFit.Index(cat),
                      ROOT.RooFit.Import("cat1", data1),
                      ROOT.RooFit.Import("cat2", data2),

I don’t like it because I have tens of categories. I am also trying to using append

data = ROOT.RooDataSet("data", "combined data", ROOT.RooArgSet(x, cat))
cat.setLabel("cat1")
data1.generate(100)
data1.addColumn(cat)
data.append(data1)
... same for data2 ...

in this last case the code crash when I try to fit data to the combined model.

Hi,

If your pdf is extended, the simultaneous pdf can automatically find the data needs to generate for each category, using the category expected events.
Otherwise I think you can use the ProtoData option of RooAbsPdf::generate

Best Regards

Lorenzo

[quote=“moneta”]Hi,

If your pdf is extended, the simultaneous pdf can automatically find the data needs to generate for each category, using the category expected events.
Otherwise I think you can use the ProtoData option of RooAbsPdf::generate

Best Regards

Lorenzo[/quote]

Hello, thank you for your reply.

My pdf is not extended. Protodata seems to be a very strange way to generate day… I have to generate first data with the correct shape (N1 events for the first category, N2 for the second, …)

At the end I have solved as I said, fixing the problem (bug?)

Before:

data = ROOT.RooDataSet("data", "combined data", ROOT.RooArgSet(x, cat))
cat.defineType("cat1")
cat.setLabel("cat1")
data1.generate(100)
data1.addColumn(cat)
data.append(data1)
... same for data2 ...

now I define first all the categories:

data = ROOT.RooDataSet("data", "combined data", ROOT.RooArgSet(x, cat))
cat.defineType("cat1")
cat.defineType("cat2")
...
cat.setLabel("cat1")
data1.generate(100)
data1.addColumn(cat)
data.append(data1)
... same for data2 ...

I don’t know why the first approach crash, while the second works