Question about TMinuit

Dear rooters,

I have some questions about TMinuit :
Actually I am using TMinuit to minimize a Chi2, which has a quite complicated formula (can have ~100 parameters). I can evaluate numerically the derivative at each iteration as a function of the parameters.
I am using the following commands (asking Minuit to minimize without giving him the derivative) :

TMinuit *gMinuit = new TMinuit(Neinc); //Neinc params gMinuit->SetFCN(Ki2); *arglist = 2.0; gMinuit->mnexcm("SET STR", arglist, 1, ierflg); arglist[0] = 1; gMinuit->mnexcm("SET ERR", arglist ,1,ierflg); // arglist[0] = ??; // ---> which value to put here, why ?? // gMinuit->mnexcm("SET EPS", arglist ,1,ierflg); for(Int_t ie=0;ie<Neinc;ie++) gMinuit->mnparm(ie , Form("N_%d",ie) , vstart[ie], step[ie],0,0,ierflg); arglist[0] = 10000; arglist[1] = 0.01; gMinuit->mnexcm("SIMPLEX", arglist ,2,ierflg); gMinuit->mnexcm("MIGRAD" , arglist ,2,ierflg); gMinuit->mnstat(fmin,fedm,errdef,npari,nparx,istat); if (3 == istat) gMinuit->mnexcm("HESSE",arglist, 0,ierflg); gMinuit->mnexcm("END", arglist, 0, ierflg);

How to proceede to use mngrad() ? Should/Can I call gMinuit->SetFCN(Ki2); with using the derivative as argument instead of Ki2 ?

For your help

Cheers

Lorenzo will process your mail once he will be back in a few days.

Rene

Hi,

for using the user derivative calculations in TMinuit, you need to call before
Migrad:

Minuit->mnexcm("SET GRAD",arglist,0,ierr);

and implement your fcn function to be passed in TMinuit::SetFCN the calculation of the derivatives :

void gradFcn( int &, double * g, double & f, double * x , int iflag ) { 

  f =  function_value(x)

   // derivative calculations 
   if (iflag == 2)   { 
       for ( int ipar = 0; ipar < npar; ++ipar)
                 g[ipar] = function_derivative(x, ipar);

   }
}

Best Regards

Lorenzo