Fit errors with weighted events


I fill a mass distribution histogram (the left histogram in the attachements, yellow color - fit function). After that I fit it and check the extracted number of events.

If I don’t weight my events I obtain:
N_D0 = 209 +/ 19 <= both the value and its error are fine!

If events were weighted with weight>1:
N_D0 = 4444 +/- 86 <= the value is good, the error is too small

If events were weighted with weight<1:
N_D0 = 6 +/- 3 <= the value is good, the error is too big

Obviously I miss something in the options, but I don’t understand what…

The fit is done with:

pdf.fitTo(*data,RooFit::InitialHesse(1),RooFit::Extended(1),RooFit::Save(true),RooFit::SumW2Error(kTRUE),RooFit::Strategy(2) );

And another (but related) question.
I have read that likelihood fit cannot be used on weighted data, so I have tried to use the chi2-fit, but the strange thing is that the fit did not converge (with exactly the same fit function). Is there a simple reason for that?

Thanks a lot in advance!
unweighted.pdf (48.4 KB)
weighted1.pdf (48.8 KB)
weighted2.pdf (49.2 KB)

Sorry, one small correction. My fit is done like this:
pdf.fitTo(*data,RooFit::Extended(1),RooFit::Save(true),print_level );

I have tried to use SumW2Error(kTRUE) option, but it gave me very crazy results…


Hi Alexander,

I’ll look into your problem. Can you first tell me what ROOT version you are using?



My ROOT version is:
Version 5.26/00 14 December 2009

But it in principle I have read (in one of the example RooFit scripts) that standard fit uses maximum likelihood (ML) method, and ML ignores custom errors, assuming always the poisson distribution for them. And in addition the error bars shown by “plotOn” has nothing to do with errors used by the fit (which is quite confusing and difficult to debug).

So have tried to switch to “chi2” method of data fitting. It still does not work well, by I have ideas how to improve it…


Hi Alexander and Wouter,

is there any progress on this issue? I am using ROOT 5.26 as well and I have the same problem with the chi2 fit method. When using the ML fit the fit converges just fine, but the error coming from the fit is wrong since I fit a weighted distribution. Using the chi2 fit the fit does not converge.
When fitting the distribution with ROOT directly, i.e. without roofit everything works fine. The fit converges and the uncertainty is reasonable.
But, since I have done all my fits up to this point with roofit I would like to do the fits on weighted histograms with roofit.

My fit command looks as follows:

Please let me know if you need more information.

Thanks in advance for your help!


I did nothing from my side…