void grapherrorfit() { TFile *_file1 = new TFile("~/Desktop/grapherror.root","READ"); TGraphErrors *g; g = (TGraphErrors*)_file1->Get("g1_MMGA09L1"); auto *expfunc = new TF1("Exponential fit","[0]+[1]*exp(-x*[2])",0,500); expfunc->SetParameters(200,7e03,0.01); g->Fit(expfunc,"RMS+"); g->Draw("AP"); expfunc->Draw("SAME"); double * p = expfunc->GetParameters(); cout << p[0] << " " << p[1] << " " << p[2] << endl; _file1->Close(); }