void plots() { TCanvas *c1 = new TCanvas("c1","c1",700,500); Int_t n = 20; // mu_Errm Double_t x[20] = {0.002723, 0.003313, 0.003625, 0.003854, 0.004033, 0.004178, 0.004296, 0.004406, 0.00451, 0.004618, 0.004739, 0.004873, 0.005035, 0.005227, 0.005451, 0.005723, 0.006051, 0.006504, 0.007195, 0.008657 }; Double_t ex[20] = {7.95421e-06, 3.22325e-06, 2.15406e-06, 1.68393e-06, 1.34469e-06, 1.06632e-06, 9.06832e-07, 8.99227e-07, 8.64925e-07, 9.82474e-07, 1.02539e-06, 1.21688e-06, 1.44946e-06, 1.70204e-06, 2.06965e-06, 2.45717e-06, 3.07269e-06, 4.33906e-06, 7.71312e-06, 2.26849e-05}; //mu Double_t y[20] = {0.133272, 0.133216, 0.132721, 0.133115, 0.132929, 0.13309, 0.133172, 0.133511, 0.134002, 0.133885, 0.134082, 0.133912, 0.134082, 0.134029, 0.133757, 0.133861, 0.1339, 0.134151, 0.134143, 0.135025}; Double_t ey[20] ={0.000161737, 0.000152217, 0.000162193, 0.00015672, 0.000157651, 0.000155043, 0.000140698, 0.000156755, 0.000155863, 0.000147582, 0.000161245, 0.000161151, 0.000167271, 0.000171133, 0.000184189, 0.000188711, 0.000194533, 0.000202275, 0.000229766, 0.000231429}; // TGraph TGraph *gr1 = new TGraphErrors(n,x,y,ex,ey); gr1->SetMarkerStyle(20); gr1->SetMarkerColor(kBlue); gr1->SetDrawOption("P"); gr1->SetLineColor(4); gr1->SetLineWidth(2); gr1->GetXaxis()->SetRangeUser(0,0.015); gr1->GetYaxis()->SetRangeUser(0.130,0.137); gr1->GetXaxis()->SetTitle("pi0_ErrM"); gr1->GetYaxis()->SetTitle("#mu of pi0_M_prefit"); gr1->GetXaxis()->CenterTitle(); gr1->GetYaxis()->CenterTitle(); gr1->GetXaxis()->SetTitleSize(0.05); gr1->GetYaxis()->SetTitleSize(0.04); // polynomial function gr1->Sort(); // make sure points are in the "increasing order in x" Int_t ifirst = 0, ilast = 19; TF1 *f = ((TF1*)(gROOT->GetFunction("pol4"))); gr1->Fit(f, "F", "", gr1->GetX()[ifirst], gr1->GetX()[ilast]); gr1->Draw("AP"); // // fourth order poly // gr1->Sort(); // make sure points are in the "increasing order in x" // Int_t ifirst = 0, ilast = 19; // TF1 *fit = new TF1("fit","([0] + [1]*x + [2]*TMath::Power(x,2) + [3]*TMath::Power(x,3) + [4]*TMath::Power(x,4))", 0, 0.015); // // fit->SetParName(0,"a"); // // fit->SetParName(1,"b"); // fit->SetParameter(0, 0.1586); // fit->SetParameter(1, -22.00); // fit->SetParameter(2, 6582); // fit->SetParameter(3, -8.27527e+05); // fit->SetParameter(4, 3.71736e+07); // gr1->Fit("fit","F", "", gr1->GetX()[ifirst], gr1->GetX()[ilast]); // gr1->Draw("AP"); c1->Update(); //c1->GetFrame()->SetFillColor(21); c1->GetFrame()->SetBorderSize(12); c1->Modified(); }