TMinuit::SetFCN(void *) - seek for clarification

Hi, rooters,
because I have troubles with the normal firring function, I want to use the TMinuit-Class. Reading the manual and the examples, I want to have the confirmation that I understood right what’s going on:
In my user-function void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag), f represents my chi_sqr and par my fitparameters. The other parameters of fcn are used by Minuit, and a priory I can ignore them. iflag is a flag given by root, which is 1 if I don’t fit (looking at the go-to in minexam.cxx)
So if I want to use TMinuit, I have to:

  • put my fitdata in a global TH1F, also my fit borders xmin, xmax
  • in fcn: calculate my theory according to the parameters par and calculate my chi_sqr in xmin, xmax
  • somehow get the fit-values, the chi_sqr etc

If this little guideline was right, You should rename f to chi_sqr, and add two or three lines to the manual about the meaning of this function…

You are nearly right, except that the function should not be renamed to chi_sqr !!
You can compute a chisquare if you like for the objective function. It could also be
a log likelihood function.

You can find examples of fitting with


ok, I didn’t think of logLikelihood, but as I dealt with some ch_sqr distributed numbers not so lang ago, I got confused about the comments in the examples. Somehow I missed a verb… As I’m a dummy anyway: is there any explanation on the meaning of plist in
virtual void mnexcm(const char
comand, Double_t* plist, Int_t llist, Int_t& ierflg)?
It’s used in the examples, but I don’t like to use black boxes.

plist is an array of length llist where the meaning of plist[0], [1], etc depends on the command you execute. You can use the Minuit help or see the doc of TMinuit, eg
root > Tminuit m;
root > m.mnhelp()
==>List of MINUIT Interactive commands:
CLEar Reset all parameter names and values undefined
CONtour Make contour map of the user function
EXIT Exit from Interactive Minuit
FIX Cause parameter(s) to remain constant
HESse Calculate the Hessian or error matrix.
IMPROVE Search for a new minimum around current minimum
MIGrad Minimize by the method of Migrad
MINImize MIGRAD + SIMPLEX method if Migrad fails
MINOs Exact (non-linear) parameter error analysis
MNContour Calculate one MINOS function contour
PARameter Define or redefine new parameters and values
RELease Make previously FIXed parameters variable again
REStore Release last parameter fixed
SAVe Save current parameter values on a file
SCAn Scan the user function by varying parameters
SEEk Minimize by the method of Monte Carlo
SET Set various MINUIT constants or conditions
SHOw Show values of current constants or conditions
SIMplex Minimize by the method of Simplex
root [4] m.mnhelp(“MIGRAD”)
**>MIGrad [maxcalls] [tolerance]
Causes minimization of the function by the method of Migrad,
the most efficient and complete single method, recommended
for general functions (see also MINImize).
The minimization produces as a by-product the error matrix
of the parameters, which is usually reliable unless warning
messages are produced.
The optional argument [maxcalls] specifies the (approximate)
maximum number of function calls after which the calculation
will be stopped even if it has not yet converged.
The optional argument [tolerance] specifies required tolerance
on the function value at the minimum.
The default tolerance is 0.1, and the minimization will stop
when the estimated vertical distance to the minimum (EDM) is
less than 0.001
[tolerance]*UP (see [SET ERRordef]).

You see that MIGRAD has 2 arguments.
Fill plist[0] with maxcalls
and plist[1] with tolerance
and set llist=2
then do
int ierr = 0

see minexam.cxx