Hello everybody,
I fit 4 TGraphErrors with a 5 parameters function ( background and gaus)and then i add them to a multigraph.I use SetOptFit and i obtain the parameters for each fit in the same canvas which is good.
The problem is that i want to specify the decimal digits to this parameters and i cannot find a way.
Could you please help me with this? I tried with SetFitFormat(“3.1g”) (1 stands for decimal, what 3 stands for?)before and after drawing but nothing happended , i used gPad->Modified(); gPad->Update(); also i tried with TPaveStats. My script is more or less this one:
Could you please help me with this?
thank you,
Marios.
{
TCanvas *c1 = new TCanvas("c1","Fitting Demo",100,100,2000,2000);
c1->ToggleEventStatus();
c1->SetFillColor(38);
c1->SetFrameFillColor(29);
c1->SetGrid();
TMultiGraph *mg = new TMultiGraph();
//1
TGraphErrors *gr = new TGraphErrors("1");
TF1 *fitFcn = new TF1("fitFcn",fitFunction,emin1,emax1,5);
fitFcn->SetLineColor(kGreen);
fitFcn->SetParNames("1","2","Constant","Mean_value","Sigma");
gr->Fit("fitFcn","MV+","epv",emin1,emax1);
Double_t par1[5];
fitFcn->GetParameters(par1);
//2
TGraphErrors *gr2 = new TGraphErrors("2");
TF1 *fitFcn2 = new TF1("fitFcn",fitFunction,emin2,emax2,5);
fitFcn2->SetLineColor(kBlue);
fitFcn2->SetParNames("1","2","Constant","Mean_value","Sigma");
gr2->Fit("fitFcn","MV+","epv",emin2,emax2);
Double_t par2[5];
fitFcn2->GetParameters(par2);
//the same for the next 2 graphs , and then
mg->Add(gr);
mg->Add(gr2);
mg->Add(gr3);
mg->Add(gr4);
mg->Draw("AP");
fitFcn2->GetParameters(par2);
fitFcn1->GetParameters(par1);
fitFcn4->GetParameters(par4);
fitFcn3->GetParameters(par3);
mg-> GetXaxis()->SetRangeUser(emin4-5,emax4+5);
gStyle->SetOptFit(11);
gStyle->SetFitFormat("3.1g");
}