How to fit histograms with error bars set by user in RooFit?

Hi, guys.
I’m fitting a histogram with error bars in RooFit.
First, I set bin contents an bin errors for TH1F* h1;
Then
RooAbsData* data=new RooAbsData(“data”,“data”, x, h1);
model.fitTo(*data);
It seems that whether I set bin errors or not, the fit results are the same.

Hi,

If you are setting yourself bini errors, you must use the option, when fitting, RooFit::SumW2Error(true).
It would probably also make more sense to use the chi2 fit instead of the default likelihood, by using
model.chi2FitTo(…) instead of model.fitTo(…)

Lorenzo

Thanks for your help!
It works for me.
When I use model.chi2FitTo(), the errors of fit results are very large even if the fit status is OK.
Maybe I need to tune my parameters.

Hi,

The errors should be correct. If you are using RooFit::SumW2Error(true) and your data statistics is not too small, the error from the chi2 method or the likelihood one should be similar

Lorenzo

Thanks for your patience!

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