Fitting and plotting variable bins histogram in roofit

I am testing RooFit with variable binned histograms. All is fine except when I try to set a fit range, then the normalization is all off and the fit fails. If I use an unbinned fit. The fit works, but again the normalization is off when plotted. I have tried using Range and NormRange with plotOn but they don’t seem to work (either no effect or just wrong to a different extent).

In short, the questions are:

  1. what to do with plotting pdf with range along with an unevenly binned histogram
  2. if it is possible for the binned fit to work

Thanks.

[*] A simple example of what I am trying to do. (with/ without range)
http://hepcms-hn.umd.edu/~kakw/2020_03_09_RooFit_variablebins.html
http://hepcms-hn.umd.edu/~kakw/2020_03_09_RooFit_variablebins-norm.html

Hi @sciencecw,

I don’t have time at the moment to read through the notebooks, but here are some ideas concerning the two questions:

  1. For the data, you have to decide whether you want to divide by bin width or not, i.e. if you want to plot the bare bin counts or the density of entries. When bin widths change, you have to plot the data density instead of the data counts, but now you cannot use Poisson errors, since they only work for bin counts. PDFs are by definition always densities.
    Therefore, try switching the DataError() to SumW2 when plotting the data.
    https://root.cern.ch/doc/master/classRooDataHist.html#a00a476834b0f2d246f85da34a915fcd9
    For plotting PDFs in ranges, I don’t think you have to do something special, unless it’s a binned PDF. Is that the case? In this case I can imagine that range boundaries can only be at the actual bin boundaries.

  2. I guess binned fits should work. I need a bit more details on what’s not working. Again, is it a binned PDF being fit to binned data, or is the PDF continuous?

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