Fit statistics from two fits of the same TGraph

Hi,

I would like to fit a TGraph with two different functions and show the fit statistics from the two fits.

Somehow I do not manage to achieve it, since I only the information from the first fit…

Below is an example:

{
float x[5]={1,2,3,4,5};
float y[5]={1,2,5,4,5};

TGraph *gr = new TGraph(5,x,y);
gr->SetMarkerStyle(20);
gr->SetMarkerSize(1.3);
gr->SetMarkerColor(2);
gr->Fit(“pol1”,“Q0”);
gr->Fit(“pol2”,“Q0+”);

TF1 *fit1 = gr->GetFunction(“pol1”);
TF1 *fit2 = gr->GetFunction(“pol2”);

gStyle->SetOptFit(1111);
gr->Draw(“AP”);
fit1->Draw(“sames”);
fit2->Draw(“sames”);
}

Any suggestion is appreciated.

Cheers,
Sergio

I suggest the following procedure:

[code]{
gStyle->SetOptFit(1111);
float x[5]={1,2,3,4,5};
float y[5]={1,2,5,4,5};

TGraph *gr = new TGraph(5,x,y);
gr->SetMarkerStyle(20);
gr->SetMarkerSize(1.3);
gr->SetMarkerColor(2);
gr->Fit(“pol1”,“Q”);
gr->DrawClone(“ap”);
gr->Fit(“pol2”,“Q”);
gr->Draw(“p”);
gPad->Update(); //to force the creation of "stats"
TPaveStats st = (TPaveStats)gr->FindObject(“stats”);
st->SetX1NDC(0.2); //new x start position
st->SetX2NDC(0.5); //new x end position
gPad->Modified();
}
[/code]

Rene