The type of a GetCovarianceMatrix() and GetMatrixArray() and how to get them in a multiple fitted functions case?

TFitResultPtr r_total = h1->Fit(total, "LRS");
TMatrixD c_total = r_total->GetCovarianceMatrix();
TMatrixD c_g1 = c_total.GetSub(0, 2, 0, 2); // gausn(0)
TMatrixD c_g2 = c_total.GetSub(3, 5, 3, 5); // gausn(3)
TMatrixD c_bg = c_total.GetSub(6, 8, 6, 8); // pol2(6) or "broken line" (6)
Double_t *p_total = total->GetParameters();
Double_t *p_g1 = p_total + 0; // gausn(0)
Double_t *p_g2 = p_total + 3; // gausn(3)
Double_t *p_bg = p_total + 6; // pol2(6) or "broken line" (6)

Then, e.g., for the “bg” function:

cout << bg->Integral(xVmin, xVmax, p_bg) << endl;
cout << bg->IntegralError(xVmin, xVmax, p_bg, c_bg.GetMatrixArray()) << endl;

BTW. Looking at the “total” fit plot, it seems to me that you would get a better result with a “broken line” background (see this old post), instead of a “pol2” background.