Hello all,
I fit my histogram using Gaussian and asymmetric Lorentzian function.
I would like to obtain the Integral and Integralerror of the fit using the covariance matrix which I obtain from the fit.
The result seems fine but I got the following message.
“TF1Helper::IntegralError:0: RuntimeWarning: numerical error from integration is too large. Integral error = 1.28333 +/- 10.7145 - eps = 0.01”
Can someone explain what is the issue here and why I get this message?
My code Here:
def VoigtAsymmB(x, par):
#//Fit parameters:
#//par[0]=Amp of Gaussian
#//par[1]=mean of Gaussian
#//par[2]=width (sigma) of Gaussian
#//par[3]=relative amplitude of left-side Lorentzian
#//par[4]=left-side Lorentzian width
#//par[5]=right-side Lorentzian width
#//Lamp=amplitude of Lorentzian
xx=x[0];
if xx > par[1]:
width = par[5]
Lamp=par[3]*par[5]*par[5]/(par[4]*par[4])
else:
width = par[4]
Lamp = par[3]
# Define Gaussian
arg1 = ROOT.pow(((xx-par[1])/par[2]),2)
gaus = ROOT.exp(-0.5*arg1)
#Define Lorentzian
arg2 = ROOT.pow((xx-par[1]),2)
loren = 1./(width*width+arg2)
return par[0]*(gaus+Lamp*loren)
fit = TF1('fit', VoigtAsymmB, y_fit_range[0], y_fit_range[1], 6)
fit.SetParameters(fit_par[0], fit_par[1], fit_par[2], fit_par[3], fit_par[4], fit_par[5]) # mean, sigma1, sigma2, amp
fit.SetLineWidth(1)
fit.SetParName(0,"AmpG");
fit.SetParName(1,"meanG");
fit.SetParName(2,"widthG");
fit.SetParName(3,"AL");
fit.SetParName(4,"widthLL");
fit.SetParName(5,"widthLR");
hist_fit = histos.get(title_det, default_histo).Fit(fit,"LRS")
# # # get cov Matrix to find error
covMatrix = hist_fit.GetCovarianceMatrix()
N_hist = histos.get(title_det, default_histo).Integral()
N_histErr = ROOT.sqrt(N_hist)
N_tot = (abs(fit.Integral(y_fit_range[0], y_fit_range[1])))/histos.get(title_det, default_histo).GetBinWidth(1)
N_totErr = (fit.IntegralError(y_fit_range[0], y_fit_range[1], hist_fit.GetParams(), covMatrix.GetMatrixArray()))/histos.get(title_det, default_histo).GetBinWidth(1)
label.DrawLatex(0.55, 0.40, 'hist = {0:6.4f} +/- {1:6.4f}'.format(N_hist, N_histErr))
label.DrawLatex(0.55, 0.30, 'fit Yield = {0:6.4f} +/- {1:6.4f}'.format(N_tot, N_totErr))
print(' N_tot = ', N_tot, ' +/- ', N_totErr)
print(' N_hist = ', N_hist, ' +/- ', N_histErr)
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.20.02
Platform: Not Provided
Compiler: Not Provided