Double_t myfunction10(Double_t *x, Double_t *par) { Float_t xx=x[0]; Double_t fbckgnd=splineBkgd10->Eval(xx); //cos(xx); Double_t fpeak=splinePeak10->Eval(xx); Double_t f=(par[0]*fpeak)+(par[1]*fbckgnd); return f; } void myfuncTest10() { // set the coefficients and plot the spline to check. TF1 *f1 = new TF1("myfuncTest10",myfunction10,0.45, 2.5, 2); f1->SetParameters(1,2); f1->SetParNames("peak","background"); f1->Draw(); } void myfit10(TH1 *histname) { // Now use the spline curve to fit the histogram in the argument. TF1 *f1 = (TF1 *)gROOT->GetFunction("myfuncTest10"); f1->SetParameters(1,1); histname->Fit("myfuncTest10"); Double_t par0 = f1->GetParameter(0); Double_t dpar0 = f1->GetParError(0); Double_t par1 = f1->GetParameter(1); Double_t dpar1 = f1->GetParError(1); cout << endl; cout << "For myfit10 par0= " << par0 << " +/- " << dpar0 << "; par1= " << par1 << " +/- " << dpar1 << endl << endl; }