RooPlot Normalisation and RooFit::Normalization

Hi all,

I’m not sure I understand what’s going on with the normalisation of the plots in the following MWE…

void SGTest1(void)
{
  RooRealVar x("x", "x", 0.0, -5.0, 5.0);
  RooRealVar m("m", "m", 0.0);
  RooRealVar s("s", "s", 1.0);

  //---

  RooGaussian G("G", "G", x, m, s);

  //---

  TCanvas *C = new TCanvas("C", "C", 800, 800);
  RooPlot *P = x.frame();

  //---

  std::cout << G.getVal() << std::endl;
  std::cout << G.getVal(RooArgSet(x)) << std::endl;

  //---

  G.plotOn(P,
	   RooFit::LineColor(kGreen),
	   RooFit::Normalization(1.0, RooAbsReal::NumEvent));

  P->Draw();
  C->SaveAs("SGTest1.pdf");
};

The two calls to std::cout give the values I expect, but the normalisation of the plot does not… Could someone explain why the plot does not match the output from the second call to getVal() at x = 0.0?

Thanks,
Andy.

@jonas Is this something you can help with?

Hi @AndyW! Since one usually plots histograms, the plotOn function takes the bin width into account.

The default bin width for x is 0.1 in your example, hence the unit on the y-axis has to be scaled up by a factor 1./0.1 = 10. This will get obvious when you plot data on the same frame, since the y-axis label will change to Events / (0.1).

I agree that this is not obvious if you don’t plot data. Does it bother you a lot?

If you want to make sure the PDFs are actually normalized to unity, you can just set the binning of x to something that has bin width one:

RooBinning b(10, -5, 5);
x.setBinning(b);

I hope this clarifies the situation!

Cheers,
Jonas

Hi @jonas,

Thank you for the explanation. I got it plotting a dataset with a single event in it this morning, and noticed the binning and thought that was going to be the problem.

Well… The default plot I get from that code is missing the y axis label (I think it’s trying to show it “Projection of G”, but it gets pushed off the side of the canvas), so if the axis label was shown, and the binning was shown on that label, that would make the plot make a lot more sense I think…

Thanks,
Andy.

Yes, I understand that it’s not optimal and agree with you that it’s confusing. But since it has always been like that in RooFit, is is also possible that somebody will be caught by surprise if the behavior changes now.

Maybe we can change RooFit to print an info message in the case where the y label is just “Projection of G” and it’s not clear that it’s multiplied by the bin with. Would hat be a fair compromise for you?

Jonas

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