Double_t myfunc(Double_t *x, Double_t *par) { Float_t xx = x[0]; Double_t f = TMath::Abs(par[0]*sin(par[1]*xx)/xx); cout << "xx = " << xx << "\tmyfunc value = " << f << endl; return f; } void TF1_test() { cout << endl << "Creating testFunc..." << endl; TF1* testFunc = new TF1("testFunc", myfunc, 1, 9, 2); testFunc->SetNpx(8); testFunc->SetParameters(2,1); cout << endl << "Creating testHist..." << endl; TH1D* testHist = new TH1D(); testHist = (TH1D*) testFunc->GetHistogram(); testHist->SetName("testHist"); testHist->SetTitle("testHist"); testHist->SetMarkerStyle(20); cout << endl << "Printing testHist..." << endl; testHist->Print("all"); TFile* f = new TFile("TF1.root", "recreate"); cout << endl << "Saving testFunc..." << endl; testFunc->Write(); testHist->Write(); f->Close(); f->Delete(); return; }