Likelihood minimisation with a conditional model/pdf

Dear all,

I am using ROOT 6.07/07 and the latest version of RooFit.

I have a Roodataset (data) and a model (model).

As a simplified example of my problem, let’s say the model depends on 2 parameters, a and b.

I want to minimise the likelihood and calculate the “best” values of a and b given the data I have.

This seems to be quite simple usually:

// Construct unbinned likelihood
RooAbsReal* nll = model.createNLL(*data,NumCPU(2)) ;
// Minimize likelihood w.r.t all parameters
RooMinuit(*nll).migrad() ;

However, in this case, I have a model that contains a conditional factor.


  • if c = 1 and d = 0, model = (1-ab)*gaussian
  • else if c = 1 and d = 1, model = (1+ab)*gaussian

Is it possible to do the likelihood minimisation using a conditional model like this? I can’t see how to do this, but I’m sure it’s possible.

Best and thanks in advance!

In theory it is possible, but what are c and d ? Two discrete parameter of your model that you are trying to fit (vary) in the likelihood minimisation ?


Dear Lorenzo,

Please see the attached screenshot to better understand what I am trying to do… (perhaps I am not explaining very well :wink: )

The variable tau is the one that changes based on the value of x and y in the data (which will have their pdfs fitted)



I believe this problem can be solved by leveraging the RooSimPdfBuilder class with multiple prototype pdfs

See here: