Plotting variable binning and PDF RooFit

Hi,

I am generating an unbinned data set from a model which them I am fitting it to it. When I am plotting the model on the data in a RooPlot this is working fine. Afterwards I need to plot my data with variable bins so I create a RooDataHist from a TH1*. Then I plot on the top of that the RooAbsPdf I used in the unbinned PDF in order to do a chi2 calculation. However, the plotting of the PDF on the top of the RooDataHist with the variable bins seems to get confused with the normalization.

Similar problem to the one reported here: Fitting and plotting variable bins histogram in roofit
and
here: Roofit Variable binning

Is there any way to plot a PDF on a variable binning histogram ?

Thanks a lot in advance
Kind Regards
–John

I guess you suffer from the problem that PDFs are densities, but histograms display counts, i.e. your histograms needs to be normalised using the bin width.
I remember that somebody asked for this, so I proposed some code in this post

to normalise the data by bin width. Could you try if this gives the expected result? If yes, I can make this option more easily available when plotting a histogram.
The plotting code also looks like the results might differ based on the data error that you request (see the first post you linked to). I never got a reply, so could you check if this makes a difference?
It seems logical to me, because Poisson errors cannot be computed for non-integer quantities. Therefore, when you scale bins, you need a different error model.

Hi @StephanH

thank you for the fast reply, due to the errors that is the reason why I wanted to avoid scaling the Histogram but I will try what you posted and let you know.
Another solution would be if it’s possible to have the PDF normalized in different regions of the same RooPlot. Like if I have n bins of a given size, have the PDF normalized to those bin widths and then if I have m bins of another size normalize it to those accordingly. I guess the PDF will not look great but at least it will be the correct representation of it. Can this happen ?

Cheers
–John

You can plot the PDF in ranges, and you can manually choose its normalisation. That can be done with a combination of Normalization and Range arguments documented here:
https://root.cern.ch/doc/master/classRooAbsPdf.html#a7f01ccfb4f3bc3ad3b2bc1e3f30af535

You will, however, have to compute the “target normalisation” by hand, i.e. sum over the bins in the histogram, and multiply/divide this value by the bin width.

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