ROOT logo
// @(#)root/minuit:$Id$
// Author: Rene Brun, Frederick James   12/08/95

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/
// ---------------------------------- minuit.h



//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TMinuit                                                              //
//                                                                      //
// The MINUIT minimisation package (base class)                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TMinuit
#define ROOT_TMinuit

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif

#ifndef ROOT_TMethodCall
#include "TMethodCall.h"
#endif

class TMinuit : public TNamed {

private:
   TMinuit(const TMinuit &m);
   TMinuit& operator=(const TMinuit &m); // Not implemented

// should become private....
public:
        enum{kMAXWARN=100};
          
        Int_t        fNpfix;            //Number of fixed parameters
        Int_t        fEmpty;            //Initialization flag (1 = Minuit initialized)
        Int_t        fMaxpar;           //Maximum number of parameters
        Int_t        fMaxint;           //Maximum number of internal parameters
        Int_t        fNpar;             //Number of free parameters (total number of pars = fNpar + fNfix)
        Int_t        fMaxext;           //Maximum number of external parameters
        Int_t        fMaxIterations;    //Maximum number of iterations
        Int_t        fMaxpar5;          // fMaxpar*(fMaxpar+1)/2
        Int_t        fMaxcpt;
        Int_t        fMaxpar2;          // fMaxpar*fMaxpar
        Int_t        fMaxpar1;          // fMaxpar*(fMaxpar+1)
        
        Double_t     fAmin;             //Minimum value found for FCN
        Double_t     fUp;               //FCN+-UP defines errors (for chisquare fits UP=1)
        Double_t     fEDM;              //Estimated vertical distance to the minimum
        Double_t     fFval3;            //
        Double_t     fEpsi;             //
        Double_t     fApsi;             //
        Double_t     fDcovar;           //Relative change in covariance matrix
        Double_t     fEpsmac;           //machine precision for floating points:
        Double_t     fEpsma2;           //sqrt(fEpsmac)
        Double_t     fVlimlo;           //
        Double_t     fVlimhi;           //
        Double_t     fUndefi;           //Undefined number = -54321
        Double_t     fBigedm;           //Big EDM = 123456
        Double_t     fUpdflt;           //
        Double_t     fXmidcr;           //
        Double_t     fYmidcr;           //
        Double_t     fXdircr;           //
        Double_t     fYdircr;           //
        
        Double_t     *fU;               //[fMaxpar2] External (visible to user in FCN) value of parameters
        Double_t     *fAlim;            //[fMaxpar2] Lower limits for parameters. If zero no limits
        Double_t     *fBlim;            //[fMaxpar2] Upper limits for parameters
        Double_t     *fErp;             //[fMaxpar] Positive Minos errors if calculated
        Double_t     *fErn;             //[fMaxpar] Negative Minos errors if calculated
        Double_t     *fWerr;            //[fMaxpar] External parameters error (standard deviation, defined by UP)
        Double_t     *fGlobcc;          //[fMaxpar] Global Correlation Coefficients
        Double_t     *fX;               //[fMaxpar] Internal parameters values
        Double_t     *fXt;              //[fMaxpar] Internal parameters values X saved as Xt
        Double_t     *fDirin;           //[fMaxpar] (Internal) step sizes for current step
        Double_t     *fXs;              //[fMaxpar] Internal parameters values saved for fixed params
        Double_t     *fXts;             //[fMaxpar] Internal parameters values X saved as Xt for fixed params
        Double_t     *fDirins;          //[fMaxpar] (Internal) step sizes for current step for fixed params
        Double_t     *fGrd;             //[fMaxpar] First derivatives
        Double_t     *fG2;              //[fMaxpar] 
        Double_t     *fGstep;           //[fMaxpar] Step sizes
        Double_t     *fGin;             //[fMaxpar2] 
        Double_t     *fDgrd;            //[fMaxpar] Uncertainties
        Double_t     *fGrds;            //[fMaxpar] 
        Double_t     *fG2s;             //[fMaxpar] 
        Double_t     *fGsteps;          //[fMaxpar] 
        Double_t     *fVhmat;           //[fMaxpar5] (Internal) error matrix stored as Half MATrix, since it is symmetric
        Double_t     *fVthmat;          //[fMaxpar5] VHMAT is sometimes saved in VTHMAT, especially in MNMNOT
        Double_t     *fP;               //[fMaxpar1] 
        Double_t     *fPstar;           //[fMaxpar2] 
        Double_t     *fPstst;           //[fMaxpar] 
        Double_t     *fPbar;            //[fMaxpar] 
        Double_t     *fPrho;            //[fMaxpar] Minimum point of parabola
        Double_t     *fWord7;           //[fMaxpar] 
        Double_t     *fXpt;             //[fMaxcpt] X array of points for contours
        Double_t     *fYpt;             //[fMaxcpt] Y array of points for contours
        
        Double_t     *fCONTgcc;         //[fMaxpar] array used in mncont
        Double_t     *fCONTw;           //[fMaxpar] array used in mncont
        Double_t     *fFIXPyy;          //[fMaxpar] array used in mnfixp
        Double_t     *fGRADgf;          //[fMaxpar] array used in mngrad
        Double_t     *fHESSyy;          //[fMaxpar] array used in mnhess
        Double_t     *fIMPRdsav;        //[fMaxpar] array used in mnimpr
        Double_t     *fIMPRy;           //[fMaxpar] array used in mnimpr
        Double_t     *fMATUvline;       //[fMaxpar] array used in mnmatu
        Double_t     *fMIGRflnu;        //[fMaxpar] array used in mnmigr
        Double_t     *fMIGRstep;        //[fMaxpar] array used in mnmigr
        Double_t     *fMIGRgs;          //[fMaxpar] array used in mnmigr
        Double_t     *fMIGRvg;          //[fMaxpar] array used in mnmigr
        Double_t     *fMIGRxxs;         //[fMaxpar] array used in mnmigr
        Double_t     *fMNOTxdev;        //[fMaxpar] array used in mnmnot
        Double_t     *fMNOTw;           //[fMaxpar] array used in mnmnot
        Double_t     *fMNOTgcc;         //[fMaxpar] array used in mnmnot
        Double_t     *fPSDFs;           //[fMaxpar] array used in mnpsdf
        Double_t     *fSEEKxmid;        //[fMaxpar] array used in mnseek
        Double_t     *fSEEKxbest;       //[fMaxpar] array used in mnseek
        Double_t     *fSIMPy;           //[fMaxpar] array used in mnsimp
        Double_t     *fVERTq;           //[fMaxpar] array used in mnvert
        Double_t     *fVERTs;           //[fMaxpar] array used in mnvert
        Double_t     *fVERTpp;          //[fMaxpar] array used in mnvert
        Double_t     *fCOMDplist;       //[fMaxpar] array used in mncomd
        Double_t     *fPARSplist;       //[fMaxpar] array used in mnpars
        
        Int_t        *fNvarl;           //[fMaxpar2] parameters flag (-1=undefined, 0=constant..)
        Int_t        *fNiofex;          //[fMaxpar2] Internal parameters number, or zero if not currently variable
        Int_t        *fNexofi;          //[fMaxpar] External parameters number for currently variable parameters
        Int_t        *fIpfix;           //[fMaxpar] List of fixed parameters
        Int_t        fNu;               //
        Int_t        fIsysrd;           //standardInput unit
        Int_t        fIsyswr;           //standard output unit
        Int_t        fIsyssa;           //
        Int_t        fNpagwd;           //Page width
        Int_t        fNpagln;           //Number of lines per page
        Int_t        fNewpag;           //
        Int_t        fIstkrd[10];       //
        Int_t        fNstkrd;           //
        Int_t        fIstkwr[10];       //
        Int_t        fNstkwr;           //
        Int_t        fISW[7];           //Array of switches
        Int_t        fIdbg[11];         //Array of internal debug switches
        Int_t        fNblock;           //Number of Minuit data blocks
        Int_t        fIcomnd;           //Number of commands
        Int_t        fNfcn;             //Number of calls to FCN
        Int_t        fNfcnmx;           //Maximum number of calls to FCN
        Int_t        fNfcnlc;           //
        Int_t        fNfcnfr;           //
        Int_t        fItaur;            //
        Int_t        fIstrat;           //
        Int_t        fNwrmes[2];        //
        Int_t        fNfcwar[20];       //
        Int_t        fIcirc[2];         //
        Int_t        fStatus;           //Status flag for the last called Minuit function
        Int_t        fKe1cr;            //
        Int_t        fKe2cr;            //
        Bool_t       fLwarn;            //true if warning messges are to be put out (default=true)
        Bool_t       fLrepor;           //true if exceptional conditions are put out (default=false)
        Bool_t       fLimset;           //true if a parameter is up against limits (for MINOS)
        Bool_t       fLnolim;           //true if there are no limits on any parameters (not yet used)
        Bool_t       fLnewmn;           //true if the previous process has unexpectedly improved FCN
        Bool_t       fLphead;           //true if a heading should be put out for the next parameter definition
        Bool_t       fGraphicsMode;     //true if graphics mode on (default)
        char         *fChpt;            //!Character to be plotted at the X,Y contour positions
        TString      *fCpnam;           //[fMaxpar2] Array of parameters names
        TString      fCfrom;            //
        TString      fCstatu;           //
        TString      fCtitl;            //
        TString      fCword;            //
        TString      fCundef;           //
        TString      fCvrsn;            //
        TString      fCovmes[4];        //
        TString      fOrigin[kMAXWARN]; //
        TString      fWarmes[kMAXWARN]; //
        TObject      *fObjectFit;       //Pointer to object being fitted
        TObject      *fPlot;            //Pointer to TGraph object created by mncont
        TMethodCall  *fMethodCall;      //Pointer to MethodCall in case of interpreted function
        void         (*fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag); //!

// methods performed on TMinuit class
public:
   TMinuit();
   TMinuit(Int_t maxpar);
   virtual       ~TMinuit();
   virtual void   BuildArrays(Int_t maxpar=15);
   virtual TObject *Clone(const char *newname="") const;   //Clone-Method to copy the function-pointer fFCN
   virtual Int_t  Command(const char *command);
   virtual TObject *Contour(Int_t npoints=10, Int_t pa1=0, Int_t pa2=1);
   virtual Int_t  DefineParameter( Int_t parNo, const char *name, Double_t initVal, Double_t initErr, Double_t lowerLimit, Double_t upperLimit );
   virtual void   DeleteArrays();
   virtual Int_t  Eval(Int_t npar, Double_t *grad, Double_t &fval, Double_t *par, Int_t flag);
   virtual Int_t  FixParameter( Int_t parNo );
   TMethodCall   *GetMethodCall() const {return fMethodCall;}
   TObject       *GetObjectFit() const {return fObjectFit;}
   Int_t          GetMaxIterations() const {return fMaxIterations;}
   virtual Int_t  GetNumFixedPars() const;
   virtual Int_t  GetNumFreePars() const;
   virtual Int_t  GetNumPars() const;
   virtual Int_t  GetParameter( Int_t parNo, Double_t &currentValue, Double_t &currentError ) const;
   virtual TObject *GetPlot() const {return fPlot;}
   Int_t          GetStatus() const {return fStatus;}
   virtual Int_t  Migrad();
   virtual void   mnamin();
   virtual void   mnbins(Double_t a1, Double_t a2, Int_t naa, Double_t &bl, Double_t &bh, Int_t &nb, Double_t &bwid);
   virtual void   mncalf(Double_t *pvec, Double_t &ycalf);
   virtual void   mncler();
   virtual void   mncntr(Int_t ke1, Int_t ke2, Int_t &ierrf);
   virtual void   mncomd(const char *crdbin, Int_t &icondn);
   virtual void   mncont(Int_t ke1, Int_t ke2, Int_t nptu, Double_t *xptu, Double_t *yptu, Int_t &ierrf);
   virtual void   mncrck(TString crdbuf, Int_t maxcwd, TString &comand, Int_t &lnc
                    ,  Int_t mxp, Double_t *plist, Int_t &llist, Int_t &ierr, Int_t isyswr);
   virtual void   mncros(Double_t &aopt, Int_t &iercr);
   virtual void   mncuve();
   virtual void   mnderi();
   virtual void   mndxdi(Double_t pint, Int_t ipar, Double_t &dxdi);
   virtual void   mneig(Double_t *a, Int_t ndima, Int_t n, Int_t mits, Double_t *work, Double_t precis, Int_t &ifault);
   virtual void   mnemat(Double_t *emat, Int_t ndim);
   virtual void   mnerrs(Int_t number, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &gcc);
   virtual void   mneval(Double_t anext, Double_t &fnext, Int_t &ierev);
   virtual void   mnexcm(const char *comand, Double_t *plist, Int_t llist, Int_t &ierflg) ;
   virtual void   mnexin(Double_t *pint);
   virtual void   mnfixp(Int_t iint, Int_t &ierr);
   virtual void   mnfree(Int_t k);
   virtual void   mngrad();
   virtual void   mnhelp(TString comd);
   virtual void   mnhelp(const char *command="");
   virtual void   mnhess();
   virtual void   mnhes1();
   virtual void   mnimpr();
   virtual void   mninex(Double_t *pint);
   virtual void   mninit(Int_t i1, Int_t i2, Int_t i3);
   virtual void   mnlims();
   virtual void   mnline(Double_t *start, Double_t fstart, Double_t *step, Double_t slope, Double_t toler);
   virtual void   mnmatu(Int_t kode);
   virtual void   mnmigr();
   virtual void   mnmnos();
   virtual void   mnmnot(Int_t ilax, Int_t ilax2, Double_t &val2pl, Double_t &val2mi);
   virtual void   mnparm(Int_t k, TString cnamj, Double_t uk, Double_t wk, Double_t a, Double_t b, Int_t &ierflg);
   virtual void   mnpars(TString &crdbuf, Int_t &icondn);
   virtual void   mnpfit(Double_t *parx2p, Double_t *pary2p, Int_t npar2p, Double_t *coef2p, Double_t &sdev2p);
   virtual void   mnpint(Double_t &pexti, Int_t i, Double_t &pinti);
   virtual void   mnplot(Double_t *xpt, Double_t *ypt, char *chpt, Int_t nxypt, Int_t npagwd, Int_t npagln);
   virtual void   mnpout(Int_t iuext, TString &chnam, Double_t &val, Double_t &err, Double_t &xlolim, Double_t &xuplim, Int_t &iuint) const;
   virtual void   mnprin(Int_t inkode, Double_t fval);
   virtual void   mnpsdf();
   virtual void   mnrazz(Double_t ynew, Double_t *pnew, Double_t *y, Int_t &jh, Int_t &jl);
   virtual void   mnrn15(Double_t &val, Int_t &inseed);
   virtual void   mnrset(Int_t iopt);
   virtual void   mnsave();
   virtual void   mnscan();
   virtual void   mnseek();
   virtual void   mnset();
   virtual void   mnsimp();
   virtual void   mnstat(Double_t &fmin, Double_t &fedm, Double_t &errdef, Int_t &npari, Int_t &nparx, Int_t &istat);
   virtual void   mntiny(Double_t epsp1, Double_t &epsbak);
   Bool_t         mnunpt(TString &cfname);
   virtual void   mnvert(Double_t *a, Int_t l, Int_t m, Int_t n, Int_t &ifail);
   virtual void   mnwarn(const char *copt, const char *corg, const char *cmes);
   virtual void   mnwerr();
   virtual Int_t  Release( Int_t parNo );
   virtual Int_t  SetErrorDef( Double_t up );
   virtual void   SetFCN(void *fcn);
   virtual void   SetFCN(void (*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t));
   virtual void   SetGraphicsMode(Bool_t mode=kTRUE) {fGraphicsMode = mode;}
   virtual void   SetMaxIterations(Int_t maxiter=500) {fMaxIterations = maxiter;}
   virtual void   SetObjectFit(TObject *obj) {fObjectFit=obj;}
   virtual Int_t  SetPrintLevel( Int_t printLevel=0 );

   ClassDef(TMinuit,1)  //The MINUIT minimisation package
};

R__EXTERN TMinuit  *gMinuit;

#endif

 TMinuit.h:1
 TMinuit.h:2
 TMinuit.h:3
 TMinuit.h:4
 TMinuit.h:5
 TMinuit.h:6
 TMinuit.h:7
 TMinuit.h:8
 TMinuit.h:9
 TMinuit.h:10
 TMinuit.h:11
 TMinuit.h:12
 TMinuit.h:13
 TMinuit.h:14
 TMinuit.h:15
 TMinuit.h:16
 TMinuit.h:17
 TMinuit.h:18
 TMinuit.h:19
 TMinuit.h:20
 TMinuit.h:21
 TMinuit.h:22
 TMinuit.h:23
 TMinuit.h:24
 TMinuit.h:25
 TMinuit.h:26
 TMinuit.h:27
 TMinuit.h:28
 TMinuit.h:29
 TMinuit.h:30
 TMinuit.h:31
 TMinuit.h:32
 TMinuit.h:33
 TMinuit.h:34
 TMinuit.h:35
 TMinuit.h:36
 TMinuit.h:37
 TMinuit.h:38
 TMinuit.h:39
 TMinuit.h:40
 TMinuit.h:41
 TMinuit.h:42
 TMinuit.h:43
 TMinuit.h:44
 TMinuit.h:45
 TMinuit.h:46
 TMinuit.h:47
 TMinuit.h:48
 TMinuit.h:49
 TMinuit.h:50
 TMinuit.h:51
 TMinuit.h:52
 TMinuit.h:53
 TMinuit.h:54
 TMinuit.h:55
 TMinuit.h:56
 TMinuit.h:57
 TMinuit.h:58
 TMinuit.h:59
 TMinuit.h:60
 TMinuit.h:61
 TMinuit.h:62
 TMinuit.h:63
 TMinuit.h:64
 TMinuit.h:65
 TMinuit.h:66
 TMinuit.h:67
 TMinuit.h:68
 TMinuit.h:69
 TMinuit.h:70
 TMinuit.h:71
 TMinuit.h:72
 TMinuit.h:73
 TMinuit.h:74
 TMinuit.h:75
 TMinuit.h:76
 TMinuit.h:77
 TMinuit.h:78
 TMinuit.h:79
 TMinuit.h:80
 TMinuit.h:81
 TMinuit.h:82
 TMinuit.h:83
 TMinuit.h:84
 TMinuit.h:85
 TMinuit.h:86
 TMinuit.h:87
 TMinuit.h:88
 TMinuit.h:89
 TMinuit.h:90
 TMinuit.h:91
 TMinuit.h:92
 TMinuit.h:93
 TMinuit.h:94
 TMinuit.h:95
 TMinuit.h:96
 TMinuit.h:97
 TMinuit.h:98
 TMinuit.h:99
 TMinuit.h:100
 TMinuit.h:101
 TMinuit.h:102
 TMinuit.h:103
 TMinuit.h:104
 TMinuit.h:105
 TMinuit.h:106
 TMinuit.h:107
 TMinuit.h:108
 TMinuit.h:109
 TMinuit.h:110
 TMinuit.h:111
 TMinuit.h:112
 TMinuit.h:113
 TMinuit.h:114
 TMinuit.h:115
 TMinuit.h:116
 TMinuit.h:117
 TMinuit.h:118
 TMinuit.h:119
 TMinuit.h:120
 TMinuit.h:121
 TMinuit.h:122
 TMinuit.h:123
 TMinuit.h:124
 TMinuit.h:125
 TMinuit.h:126
 TMinuit.h:127
 TMinuit.h:128
 TMinuit.h:129
 TMinuit.h:130
 TMinuit.h:131
 TMinuit.h:132
 TMinuit.h:133
 TMinuit.h:134
 TMinuit.h:135
 TMinuit.h:136
 TMinuit.h:137
 TMinuit.h:138
 TMinuit.h:139
 TMinuit.h:140
 TMinuit.h:141
 TMinuit.h:142
 TMinuit.h:143
 TMinuit.h:144
 TMinuit.h:145
 TMinuit.h:146
 TMinuit.h:147
 TMinuit.h:148
 TMinuit.h:149
 TMinuit.h:150
 TMinuit.h:151
 TMinuit.h:152
 TMinuit.h:153
 TMinuit.h:154
 TMinuit.h:155
 TMinuit.h:156
 TMinuit.h:157
 TMinuit.h:158
 TMinuit.h:159
 TMinuit.h:160
 TMinuit.h:161
 TMinuit.h:162
 TMinuit.h:163
 TMinuit.h:164
 TMinuit.h:165
 TMinuit.h:166
 TMinuit.h:167
 TMinuit.h:168
 TMinuit.h:169
 TMinuit.h:170
 TMinuit.h:171
 TMinuit.h:172
 TMinuit.h:173
 TMinuit.h:174
 TMinuit.h:175
 TMinuit.h:176
 TMinuit.h:177
 TMinuit.h:178
 TMinuit.h:179
 TMinuit.h:180
 TMinuit.h:181
 TMinuit.h:182
 TMinuit.h:183
 TMinuit.h:184
 TMinuit.h:185
 TMinuit.h:186
 TMinuit.h:187
 TMinuit.h:188
 TMinuit.h:189
 TMinuit.h:190
 TMinuit.h:191
 TMinuit.h:192
 TMinuit.h:193
 TMinuit.h:194
 TMinuit.h:195
 TMinuit.h:196
 TMinuit.h:197
 TMinuit.h:198
 TMinuit.h:199
 TMinuit.h:200
 TMinuit.h:201
 TMinuit.h:202
 TMinuit.h:203
 TMinuit.h:204
 TMinuit.h:205
 TMinuit.h:206
 TMinuit.h:207
 TMinuit.h:208
 TMinuit.h:209
 TMinuit.h:210
 TMinuit.h:211
 TMinuit.h:212
 TMinuit.h:213
 TMinuit.h:214
 TMinuit.h:215
 TMinuit.h:216
 TMinuit.h:217
 TMinuit.h:218
 TMinuit.h:219
 TMinuit.h:220
 TMinuit.h:221
 TMinuit.h:222
 TMinuit.h:223
 TMinuit.h:224
 TMinuit.h:225
 TMinuit.h:226
 TMinuit.h:227
 TMinuit.h:228
 TMinuit.h:229
 TMinuit.h:230
 TMinuit.h:231
 TMinuit.h:232
 TMinuit.h:233
 TMinuit.h:234
 TMinuit.h:235
 TMinuit.h:236
 TMinuit.h:237
 TMinuit.h:238
 TMinuit.h:239
 TMinuit.h:240
 TMinuit.h:241
 TMinuit.h:242
 TMinuit.h:243
 TMinuit.h:244
 TMinuit.h:245
 TMinuit.h:246
 TMinuit.h:247
 TMinuit.h:248
 TMinuit.h:249
 TMinuit.h:250
 TMinuit.h:251
 TMinuit.h:252
 TMinuit.h:253
 TMinuit.h:254
 TMinuit.h:255
 TMinuit.h:256
 TMinuit.h:257
 TMinuit.h:258
 TMinuit.h:259
 TMinuit.h:260
 TMinuit.h:261
 TMinuit.h:262
 TMinuit.h:263
 TMinuit.h:264
 TMinuit.h:265
 TMinuit.h:266
 TMinuit.h:267
 TMinuit.h:268
 TMinuit.h:269
 TMinuit.h:270
 TMinuit.h:271
 TMinuit.h:272
 TMinuit.h:273
 TMinuit.h:274
 TMinuit.h:275
 TMinuit.h:276
 TMinuit.h:277
 TMinuit.h:278
 TMinuit.h:279
 TMinuit.h:280
 TMinuit.h:281
 TMinuit.h:282