{ if(gROOT->GetListOfFunctions()->FindObject("g")) { TF1 *tmp = (TF1*)gROOT->GetListOfFunctions()->FindObject("g"); tmp->Delete(); } TF1 *g = new TF1("g","gaus"); g->SetParameter(0,10); g->SetParameter(1,5); g->SetParameter(2,1); g->SetRange(0,10); if(gROOT->GetList()->FindObject("fhTest")) (gROOT->GetList()->FindObject("fhTest")->Delete(); TH1F *fhTest = new TH1F("fhTest","fhTest",256,0,10); fhTest->FillRandom("g",2000); fhTest->Fit(g,"RN"); g->SetParameter(1,4.5); //Here scan the, in this, chi2 between fhTest and g as a function of parameter //one. In this example this is of course a somewhat stupid exercise... }