using namespace std; Double_t fitf(Double_t *x, Double_t *par) { Double_t arg =0.; arg = pow(x[0],par[1]); Double_t fitval = par[0] * arg; return fitval; } void fit_profile() { TCanvas *c1 = new TCanvas ("c1","",1600,800);//c1->Divide(2,1); TFile *f2 = TFile::Open("h_prof.root","read"); TH2D *h_prof = (TH2D*) f2->Get("h_prof"); TF1 *func = new TF1("fitf",fitf,0.05,0.20,2); func->SetParameter(1,-1.26); h_prof->Draw();h_prof->Fit("fitf","R"); c1->Print("profilefit.pdf"); }