Am I accessing the Cov from a fit right?

I have been trying to do some fitting and I am curious if I am accessing the cov correctly…

  TF1 *total_func = new TF1("total", total_function, 0, 300, 8);

  // Setup appropriate values

  total_func->SetParameter(0, 1.0);
  total_func->SetParameter(1, 20);
  total_func->SetParameter(2, 2.5);
  total_func->SetParameter(3, -0.05);
  total_func->SetParameter(4, 0);

  total_func->SetParLimits(0, 0, 1000);
  total_func->SetParLimits(2, 0, 10);
  total_func->SetParLimits(3, -2, 2);

  total_func->FixParameter(1, 20);
  total_func->FixParameter(4, 0);

  total_func->SetParameter(5, 1.0);
  total_func->SetParameter(6, 80);
  total_func->SetParameter(7, 10);

  total_func->SetParLimits(5, 0, 10000);
  total_func->SetParLimits(6, 50, 100);
  total_func->SetParLimits(7, 0, 30);

  if(!background) {
    total_func->SetParameter(0, 0.0);
    total_func->FixParameter(0, 0.0);
  }

  if(!usesignal) {
    total_func->SetParameter(5, 0.0);
    total_func->FixParameter(5, 0.0);
  }

  // Now lets do the fits to the histos...

  cout << "Starting the fits for configuration: " << tmpname << endl;

  jj_histo->Fit("total", "LM");

  Double_t jj_mean           = jj_histo->GetFunction("total")->GetParameter(6);
  Double_t jj_mean_error     = jj_histo->GetFunction("total")->GetParError(6);
  Double_t jj_sigma          = jj_histo->GetFunction("total")->GetParameter(7);
  Double_t jj_sigma_error    = jj_histo->GetFunction("total")->GetParError(7);

  TVirtualFitter *jj_fitter  = TVirtualFitter::GetFitter();
  Double_t jj_mean_sigma_cov = jj_fitter->GetCovarianceMatrixElement(6,7);
  cout << "The jj cov is: " << jj_mean_sigma_cov << endl;

Does it matter that I have set some of the parameters to fixed? i.e. The cov is only calculated between unfixed quantities so I should be looking for element 4,5?

Justace

Hi,

the cov matrix returned by the fitting contains only the free parameters, not the fixed one.

So if you fix parameter 1 and 4 then you need to ask for

Double_t jj_mean_sigma_cov = jj_fitter->GetCovarianceMatrixElement(4,5); 

while if you fix also both 0 and 5 then you need to ask for (2,3)

I know, this is not very nice for the user to remember the fixed parameters and it will be fixed in the new version of the fitter

Best Regards

Lorenzo