Use of TMinuit

Hello, I am an absolute beginner in the use of c++!
I need to build a program to perform a minimization of a Chi Square in which the sigma are weighted and are themselves a function of the variable parameters to be found.
I want to do it using Minuit in a c++ program or root macro, but I need to learn from the beginning the structure itself that this program must have and look at an example on how to use the Minuit commands!
Is there, somewhere on the web, some EXAMPLE PROGRAM from which I can start?
Thank you very much!
Elena

see $ROOTSYS/test/minexam.cxx
Interactively you can do;

root > .x minexam.cxx
Rene

Hi,

Is there some more examples on how to use Minuit? There seem to be many alternatives, and I wonder what would be the best one. For instance, you can do

	TMinuit* minuit = new TMinuit(1);
	minuit->SetPrintLevel(-1);
	minuit->SetFCN(Chi2Minuit);
	minuit->SetErrorDef(1.0);
	minuit->DefineParameter(0, "gamma", gamma_pdg, 0.1,  -3.14, 3.14);
	minuit->Command("MIGRAD");
	minuit->Command("HESSE");
	minuit->Command("MINOS");
	minuit->GetParameter(0, gamma_fit, err);

rather than the more clumsy (imho) approach suggested in $ROOTSYS/test/minexam.cxx using TVirtualFitter:

	TVirtualFitter *minuit = TVirtualFitter::Fitter(0, 1);
	TFitter* f = (TFitter*)minuit->GetFitter();
	f->GetMinuit()->SetPrintLevel(-1);
	minuit->SetFCN(Chi2Minuit);
	minuit->SetErrorDef(1.0);
	minuit->SetParameter(0, "gamma", g0,         0.1,  -7, 7);
	Double_t arglist[100];
	arglist[0] = 0;
	minuit->ExecuteCommand("MIGRAD", arglist, 0);
	minuit->ExecuteCommand("HESSE", arglist, 0);
	minuit->ExecuteCommand("MINOS", arglist, 0);
	gamma_fit = minuit->GetParameter(0);

Cheers,

  • Moritz