Fitting problems when using one-dimensional RooProdPdf

Dear experts,

I seem to have a problem when trying to fit a toy MC RooDataSet that has been generate from a RooProdPdf with only one random variable (using root 5.34). The problem is that the fitted parameters are completely off, while the fit seems to converge.

Minimum working example:

  RooRealVar x("x", "x", 0, -5, 5);
  RooRealVar y("y", "y", 0, -5, 5);
  RooRealVar m("m", "m", 0 , -1, 1);
  RooRealVar s("s", "s", 1, 0.7, 1.3);

  // here I try to multiply two PDFs which share the same random variable x
  RooGaussian g("g", "g", x, m, s);
  RooGenericPdf l("l", "x^2", x);
  RooProdPdf p("p", "p", RooArgSet(g,l));

  // the generated event distribution looks fine
  RooDataSet* d = p.generate(x, 10000);

  RooPlot* frame = x.frame();
  d->plotOn(frame);

  // the fit delivers wrong parameters for m and s
  p.fitTo(*d);
  p.plotOn(frame, RooFit::LineColor(kRed));
  l.plotOn(frame);
  g.plotOn(frame);
  frame->Draw();

I thought it would be possible to multiply two PDFs of the same random variable in this way. I want (need?) to do this because in real life one of the PDFs is a RooHistPdf, while the other one is a RooGenericPdf.

Am I doing something wrong?

Best greetings,
Christopher

Hi,

I can reproduce your problem. I will investigate it

Best Regards

Lorenzo

I can confirm that this is a problem in the ROoProdPdf and not in the fitting of that particular pdf.
If I define your pdf directly, for example using a TF1 object

 TF1 * f = new TF3("f","ROOT::Math::normal_pdf(x,z,y) * x * x");
 RooTFnPdfBinding p("p","p",f,RooArgList(x,m,s) );

Then the fit works fine

Lorenzo

Hi Lorenzo,

thanks for investigating. So it seems that there is a bug in RooProdPdf.

The problem is that my target PDF is a product of a histogram and a RooGenericPdf (of which I want to fit the parameters). If I understand correctly, the only (quick) work-around would be to implement the full PDF myself in C-code.

I’ll try to to this for the moment.

Best,
Christopher

Hi,

The bug seems to be in the optimisation of the likelihood computation when using a RooProdPdf.
The default is maximum optimisation (Optimize = 2) and causes this problem.
If you are using Optimize=1 the fit works fine.

p.fitTo(*d, Optimize(1), Minimizer("Minuit2"));

I have created a bug report for this, see sft.its.cern.ch/jira/browse/ROOT-7720

Best Regards

Lorenzo

Thanks a lot! I am traveling and will have a look as soon as I return.

Christopher