RooMCStudy with simultaneous fit

Hi all,
I am trying to use RooMCStudy in order to fit simultaneously many toy distributions, but I have a problem.

Basically when I run my code I get an error message which seems to be related to the difficulty of associating each category to the samples to be fitted simultaneously. In order to do the study I use the RooMCStudy::generateAndFit. I attach a simplified version of my code:

RooRealVar* numTrack = new RooRealVar("numTracks","numTracks",0,20);

RooCategory IDcat("IDcat","IDcat");

RooSimultaneous* simPDF = new RooSimultaneous("simPDF","simPDF",IDcat); simPDF->addPdf(*sumTemNoID,"NoID");
//sumTem is a RooAddPdf used to model the distibutions built adding RooHistPdfs


RooMCStudy* mgr = new RooMCStudy(*simPDF,*numTrack, Binned(kTRUE),FitOptions(Range("fitRange"),SplitRange(kTRUE),Minos(kTRUE)));


And the error message I get:

[#0] WARNING:Minization -- RooMinuit::RooMinuit: removing parameter IDcat from list because it is not of type RooRealVar
[#1] INFO:Minization -- RooMinuit::optimizeConst: activating const optimization
[#0] ERROR:InputArguments -- RooTreeData::split(genData) ERROR category IDcat doesn't depend on any variable in this dataset

[#0] ERROR:Fitting -- RooAbsTestStatistic::initSimMode(nll_simPDF_genData) ERROR: index category of simultaneous pdf is missing in dataset, aborting
Exception: RooAbsTestStatistic::initSimMode() ERROR, index category of simultaneous pdf is missing in dataset, aborting
*** Interpreter error recovered ***

What can I do in order to avoid the problem?
Is it possible to use RooMCStudy without generating and fitting in two separate steps with a simultaneous fit?

Thanks in advance,


I think the issue is because you didn’t provide the information of how many event of each category needs to be generated. If you make sumTemNoID and sumTemID extended PDF (with attached expected yields) then I think your code will work.

The issue should already be there without RooMCStudy but simply when using RooAbsPdf::generate …


– Gregory


did the proposal help?

I’m having the same problem as Frederico, and even adding

RooFit::Extended() RooFit::FitOptions( RooFit::Extended() ) to the RooMcStudy object still leads to the same error.

However, when I’m just validating my models in RooSimultaneous separately it works. The error just shows up when I’m trying to validate the combined model.

Thankful for every help,

Let me answer my own question here:

one needs to pass the variable as RooArgSet that contains the variable itself and the category to RooMcStudy. So it should look like this:

fitvar = RooRealVar( ... )
category = RooCategory( ... )
combined_model = RooSimultaneous( ... )

mcstudy = RooMCStudy( combined_model, RooArgSet( fitvar, category ), ... )