RooProdPdf changes behaviour after Print() call


I have a very peculiar bug, which I could use help figuring out. I make a constrained fit by multiplying my mass shape pdf with a set of Gaussians PDFs that include the variable to be constrained. I removed a Print() statement on the constraint pdf, and suddenly the fits stopped working. They were still fitting, but as if the constraint was not there.

I have managed to find a minimal example where RooProdPdf changes behaviour after a Print() statement:

  RooRealVar * m1 = new RooRealVar("m1","m1", 2, 0, 4);
  RooRealVar * m2 = new RooRealVar("m2","m2", 3, 0, 4);

  RooRealVar * mu1 = new RooRealVar("mu1","mu1", 2);
  RooRealVar * mu2 = new RooRealVar("mu2","mu2", 2.2);

  RooRealVar * s1 = new RooRealVar("s1","s1", 1);
  RooRealVar * s2 = new RooRealVar("s2","s2", 1.2);

  RooGaussian * g1 = new RooGaussian("g1","g1", *m1, *mu1, *s1);
  RooGaussian * g2 = new RooGaussian("g2","g2", *m2, *mu2, *s2);

  RooProdPdf * p = new RooProdPdf("p","p",RooArgList(*g1, *g2));

  // if this Print() is left out ...

  // .. this evaluate() causes a seg fault ...
  std::cout << "p evaluated to: " << p->evaluate() << std::endl;

  // but if Print() is called everything works fine

I am seeing this in both 6.08.02 and 6.06.02.

Is this just a ROOT bug or is there something I am completely missing? I would like to understand this.

(I did not use the evaluate( ) in my original application, the point was just to show an example where RooProdPdf changes behaviour due to a Print( ) call).


This is a bug in RooProdPdf, a data member was not correct;y initialised.
It is now fixe din the master. If you need I could back port this fix for an old release.
However there is a trivial workaround. Just use RooProdPdf::getVal instead of evaluate(). In reality this is the interface to use, for some pdf’s (e.g. RooGaussian) evaluate is not a public member function.



Hi Lorenzo,

Thanks a lot for answering! I fixed it via simply Print()'ing all of my PDF’s (I did not use evaluate() in the main application), so I think I am set.



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