Different results for unbinned vs binned fit

Dear all

I am trying to perform a binned fit to a power-law, with the logarithm10 of the energy as the observable.
The PDF is then given as (bar normalization) E( log10(E) )^(gamma+1).

However, on running the fit 1000 times, I see that the binned reconstructed value is slightly but clearly shifted from the nominal value of -3.

I attach a pruned example of my problem, and a plot showing an unbinned fit in blue, and a binned one in red.


gammatest.C (1.7 KB)

Any help would be much appreciated,
Best regards;
Knut
cgammaPlot.pdf (14.4 KB)

Hi,
The problem you are having is due to the fact you are fitting in a range which does not correspond to the bin edges. Therefore the data set of the binned data is not exactly the same as unbinned data.
If you set the range exactly at the bin edges, as in this corrected attached macro, you will see that the results of the two fits are compatible.
It is true in some case would be better to fit the binned data using the integral of the bins. These you cannot do in RooFit, but you are able to do in ROOT using TH1::Fit by converting the RooDataHIst to a TH1 and the RooAbsPdf to a TF1. If you are interested I can send you an example for doing this.

Best Regards

Lorenzo
cgammaPlot.pdf (14.4 KB)
gammatest.C (1.85 KB)

Thanks a bunch for looking into this.
I would be interested in seeing the example with integration over bins- is it possible to use the result of such a fit with RooFits limit-setting machinery?

Cheers;
Knut