Accessing fit results

Hello, I have trouble accessing the fit results of some simple pol0 and pol1 fits:

for example on my noise data, I want to use a simple pol0 fit to get the average:

TFitResult r = gr->Fit("fa1", "RS"); Double_t par0 = r->Parameter(0);
as it is used on the TGraph documentation page.

However the last line reports this error:

[quote]Warning: wrong member access operator ‘->’ C:…\xx.C(36)
Error: Symbol #include is not defined in current scope C:…\xx.C(36)
Error: Symbol exception is not defined in in current scope C:…\xx.C(36)
Syntax Error: #include (exception) C:…\xx.C(36)
Error: Symbol G__exception is not defined in current scope C:…\xx.C(36)
Error: type G__exception not defined FILE:C:…\xx.C(36)
*** Interpreter error recovered ***[/quote]

the fit works though, I get all the right data in the console output of Fit()

Hi,

which version of ROOT? Can you post the actual xx.C?

Cheers, Axel.

I use ROOT 5.27/04 on Windows7

rauschen.C

[code]void rauschen() {

char filename[] = "rauschen_1.txt";
static const Int_t n = 100000;	//max number of data points

float elapsed_seconds[n], voltage[n];
char line[80];
int i = 0;

fr = fopen (filename, "rt");
while(fgets(line, 80, fr) != NULL)
{
	sscanf (line, "%f\t%f", &elapsed_seconds[i], &voltage[i]);
	voltage[i] = voltage[i]/10*0.3*1000;
	i++;
}
fclose(fr);

printf("found data points: %d\n", i);

TCanvas *c1 = new TCanvas("rauschen","rauschen",200,10,1200,500);
TF1 *fa1 = new TF1("fa1", "pol0(0)",0,elapsed_seconds[i-1]);

//create graph for the data points:
gr = new TGraph(i, elapsed_seconds, voltage);
gr->SetMarkerColor(1);
gr->SetMarkerStyle(1);
gr->SetTitle("noise");
gr->SetEditable(kFALSE);
gr->GetXaxis()->SetTitle("Time in s");
gr->GetYaxis()->SetTitle("Noise in µV/sqrt(Hz)");
printf("\nFit:\n");
TFitResult r = gr->Fit("fa1", "RS");
gr->Draw("AP");

//TMatrixDSym cov = r->GetCovarianceMatrix();  //  to access the covariance matrix
Double_t par0   = r->Parameter(0); // retrieve the value for the parameter 0
//Double_t err0   = r->ParError(0); // retrieve the error for the parameter 0

c1->Update();
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(12);
c1->Modified();
c1->SaveAs(".png");
c1->SetFillColor(42);
c1->SetGrid();
c1->Update();

}[/code]
rauschen_1.txt (369 KB)

Hi,

use

Cheers, Axel.

thanks a lot!

maybe someone should change this on the documentation page :slight_smile:

Hi,

where did you find the wrong code? (note: I had to edit my code above!)

Cheers, Axel.

Hi,

oops - you are right! I found it! It’s going to be fixed soon, thanks for pointing it out!

Cheers, Axel.