void fitproblem() { /* Reset Root environment */ gROOT->Reset(); // TGraphErrors. TGraphErrors * gr1 = new TGraphErrors("Run00088842_5st_lateral55.txt","%lg %lg %lg "); /* Make Canvas */ TCanvas *c1 = new TCanvas("c1","Study of Lateral distribution",200,10,700,900); c1->SetFillColor(10); c1->SetFillStyle(1001); // Fit //TF1 *fit = new TF1("fit","-[0]*(x-2)^2-[1]*(x-2)+[2]",-2,2.8); // this is a fit on the log-log scale TF1 *fit = new TF1("fit","pol2",-2,2.8); gr1->Fit("fit","R"); gr1->SetLineColor(kRed); // Plot graph on canvas; gStyle->SetOptFit(1111); gr1->Draw("A*"); }