{ TFile f("test.root"); TH1F* ratio = (TH1F*)f.Get("ratio"); TCanvas *c = new TCanvas(); //firstly, fit the histogram cout << "ORIGINAL FIT PARAMETERS:" << endl; ratio->Fit("pol9","","",-2.7, -1.5); //secondly, recreate fitted function (pol9, same parameters - check the printout) // parameters set simply by copy&paste the screen values from the old fit TF1* newfit = new TF1("newfit","pol9(0)",-2.7, -1.5); newfit->SetParameters(-1.018780e+04,-3.491464e+04,-4.678893e+04,-2.682289e+04,9.744418e+02,1.096072e+04,7.051491e+03,2.204937e+03,3.564453e+02,2.388579e+01); cout << "PARAMETERS OF RECREATED FUNCTION:" << endl; newfit->Print(); newfit->SetLineColor(kRed); newfit->Draw("same"); //result - newfit is a different function //possible reason would be that printout parameters of the original fitted function are ROUNDED ( = not precise enough to recreate new function!) //creating "newfitDouble" directly by reading original parameters as DOUBLE works! (blue function is equal to the original one (black)) TF1* newfitDouble = new TF1("newfitDouble","pol9(0)",-2.7, -1.5); cout << "PARAMETERS DIFFERENCE:" << endl; for (int i=0; i<= 9; i++) { double oldpar = ratio->GetFunction("pol9")->GetParameter(i); double newpar = newfit->GetParameter(i); cout << "difference in parameter " << i << " : " << oldpar-newpar << endl; newfitDouble->SetParameter(i, oldpar); } newfitDouble->SetLineColor(kBlue); newfitDouble->SetLineStyle(2); newfitDouble->Draw("same"); }