Trouble with TFitResultPtr::GetCovarianceMatrix

Hi Rooters,

I have a fitting routine where I am computing an integral error using the fit covariance matrix, following the example in … egralError. My code is:

TFitResultPtr fit = h1->Fit(fyAll,"QIROMES");
TMatrixDSym cov = fit->GetCovarianceMatrix();
T2_int_err = frT2->IntegralError(0.0,tCyc,par,cov.GetMatrixArray());

where frT2 is another function, having the same signature and parameters as the fitting function fyAll.

This has worked perfectly in the past, but I have made a lot of changes to fyAll recently. Now I am getting T2_int_err = 0. If I print the components of cov.GetMatrixArray() immediately after defining cov, I get all zeros there as well. However, I get believable non-zero values for the covariance matrix from the fit->Print(“V”) command.

I tried using IntegralError without passing it par and cov, which I believe should also work as I only do one fit, and got the same problem of 0 errors. I constructed a test code using a much simpler (gaussian) function regressing on a randomly generated histogram, and there the problem does not appear: I can print non-zero cov components and get the IntegralError. So it doesn’t seem to be a problem with ROOT.

So I am now trying to understand what I might have done within fyAll to make cov show all 0’s. If anyone has any insight it would be much appreciated!

Many thanks,

Here is the yAll function in case it helps:

[code]Double_t BFitNamespace::yAll(Double_t *t, Double_t *a) {
using namespace BFitNamespace;
// Global variables that are constant throughout the fit
extern char parNames[30][5];
extern BFitCase_t stBFitCases[FILE_ROWS_BFit];
extern Int_t iBFitCaseIndex, nPars;
extern Double_t iota, t1, t2, t3;
// Global variables that depend only on the parameters
extern Int_t nParChanges; // counts # of times pars have changed
extern Double_t *lastPar; // holds most recent paramter values for comparison
// Global variables that depend on t
extern Double_t T1val, T2val, T3val, U1val, U2val, U3val, V1val, V2val, V3val, W1val, W2val, W3val, Z1val, Z2val, Z3val, X2val, X3val, Y2val, Y3val;
// Local variables
static Double_t f;
static Int_t index; // index of parameter array

// When parameters change:
if (!CompareParArrays(a,lastPar,sizeof(Double_t),iota)) {
	// Print updated paramters
	printf("New pars (%4d): ",nParChanges);
	for (index = 0; index < nPars; index++) {
		if (stBFitCases[iBFitCaseIndex].pbToggle[index]) printf("%s=%.4e ",parNames[index],a[index]);
return yDC(t,a) + yT1(t,a) + yT2(t,a) + yT3(t,a) + a[epsU]*(yU1(t,a) + yU2(t,a) + yU3(t,a));

Any advice is most appreciated! Thanks,



Did you check that the status returned from the fit is zero (fit->Status() ) ? It could be the covariance matrix has not been computed due to convergence problems.
Otherwise I would need a running script to examine your problem

Best Regards


Hi Lorenzo,

Thanks for your reply.

With the code as shown above, I get:
fit->Status() returns 4000
fit->CovMatrixStatus returns 1
Output of this is attached with option string “QIROMES” in the filename.

If I remove the ‘M’ option, I get
fit->Status() returns 0
fit->CovMatrixStatus returns 3
Output of this is attached with option string “QIROES” in the filename.

Guide to the output files:
– Confirmation of options on line 28.
– Manually printed covariance matrix elements, starting line 235.
– Fitter-reported covariance matrix , starting line 274.
– IntegralError values, starting line 292 (all 0.0000’s).

I have found what the CovMatrixStatus codes mean, but I have yet to locate the minimizer status codes. Could you point me in the right direction?

I have learned that I was wrong in my initial post when I said cov.GetMatrixArray() gave me an array of zeros. Now that I have corrected how I handle the array, it has the right data in it. Nevertheless I don’t see what the problem is. I am running Root 5.32.03, by the way.

The files for the program are available here: … sp=sharing.

BMC_0005_QIROMES.txt (16 KB)
BMC_0005_QIROES.txt (15.6 KB)