Problem with TF1::IntegralError

Hello.
I have a problem with the function IntegralError of TF1 class. I wrote a short code in order to fit a histogram containing signal + background and to extract the signal as the subtraction between two integrals: one coming from the fit function (f) signal+background, and the other from the function of background (b). I want to know both errors of f and b integrals in a specified interval. The problem is that after fitting the histogram with f and after giving to b the right parameters values and errors with TF1::SetParameters and TF1::SetParError coming from the previous fit, the function IntegralError called for b gives me the following error message

“Error in TF1Helper::IntegralError: Last used fitter is not compatible with the current TF1”

Looking at the TF1 documentation I saw that it is a problem concerning the fact that the function b is not the result of a fit, but I can not find any solution in order to avoid this problem…
Can anybody help me? Thank you.

Hi,

You need to define a separate function for the background and extract the covariance matrix parameter that you can pass to IntgeralError.

However, if you are using a more recent version of ROOT, you can use the new class TF1NormSum to perform directly a fit to the number of events.
See the tutorial

root.cern.ch/doc/master/fitNormSum_8C.html

Best Regards

Lorenzo