Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:16

0001 // @(#)root/minuit:$Id$
0002 // Author: Rene Brun, Frederick James   12/08/95
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 //////////////////////////////////////////////////////////////////////////
0013 //                                                                      //
0014 // TMinuit                                                              //
0015 //                                                                      //
0016 // The MINUIT minimisation package (base class)                         //
0017 //                                                                      //
0018 //////////////////////////////////////////////////////////////////////////
0019 
0020 #ifndef ROOT_TMinuit
0021 #define ROOT_TMinuit
0022 
0023 #include "TNamed.h"
0024 
0025 #include "TMethodCall.h"
0026 
0027 class TMinuit : public TNamed {
0028 
0029 private:
0030    TMinuit(const TMinuit &m);
0031    TMinuit& operator=(const TMinuit &m); // Not implemented
0032 
0033 // should become private....
0034 public:
0035         enum{kMAXWARN=100};
0036 
0037         Int_t        fNpfix;            //Number of fixed parameters
0038         Int_t        fEmpty;            //Initialization flag (1 = Minuit initialized)
0039         Int_t        fMaxpar;           //Maximum number of parameters
0040         Int_t        fMaxint;           //Maximum number of internal parameters
0041         Int_t        fNpar;             //Number of free parameters (total number of pars = fNpar + fNfix)
0042         Int_t        fMaxext;           //Maximum number of external parameters
0043         Int_t        fMaxIterations;    //Maximum number of iterations
0044         Int_t        fMaxpar5;          // fMaxpar*(fMaxpar+1)/2
0045         Int_t        fMaxcpt;
0046         Int_t        fMaxpar2;          // fMaxpar*fMaxpar
0047         Int_t        fMaxpar1;          // fMaxpar*(fMaxpar+1)
0048 
0049         Double_t     fAmin;             //Minimum value found for FCN
0050         Double_t     fUp;               //FCN+-UP defines errors (for chisquare fits UP=1)
0051         Double_t     fEDM;              //Estimated vertical distance to the minimum
0052         Double_t     fFval3;            //
0053         Double_t     fEpsi;             //
0054         Double_t     fApsi;             //
0055         Double_t     fDcovar;           //Relative change in covariance matrix
0056         Double_t     fEpsmac;           //machine precision for floating points:
0057         Double_t     fEpsma2;           //sqrt(fEpsmac)
0058         Double_t     fVlimlo;           //
0059         Double_t     fVlimhi;           //
0060         Double_t     fUndefi;           //Undefined number = -54321
0061         Double_t     fBigedm;           //Big EDM = 123456
0062         Double_t     fUpdflt;           //
0063         Double_t     fXmidcr;           //
0064         Double_t     fYmidcr;           //
0065         Double_t     fXdircr;           //
0066         Double_t     fYdircr;           //
0067 
0068         Double_t     *fU;               //[fMaxpar2] External (visible to user in FCN) value of parameters
0069         Double_t     *fAlim;            //[fMaxpar2] Lower limits for parameters. If zero no limits
0070         Double_t     *fBlim;            //[fMaxpar2] Upper limits for parameters
0071         Double_t     *fErp;             //[fMaxpar] Positive Minos errors if calculated
0072         Double_t     *fErn;             //[fMaxpar] Negative Minos errors if calculated
0073         Double_t     *fWerr;            //[fMaxpar] External parameters error (standard deviation, defined by UP)
0074         Double_t     *fGlobcc;          //[fMaxpar] Global Correlation Coefficients
0075         Double_t     *fX;               //[fMaxpar] Internal parameters values
0076         Double_t     *fXt;              //[fMaxpar] Internal parameters values X saved as Xt
0077         Double_t     *fDirin;           //[fMaxpar] (Internal) step sizes for current step
0078         Double_t     *fXs;              //[fMaxpar] Internal parameters values saved for fixed params
0079         Double_t     *fXts;             //[fMaxpar] Internal parameters values X saved as Xt for fixed params
0080         Double_t     *fDirins;          //[fMaxpar] (Internal) step sizes for current step for fixed params
0081         Double_t     *fGrd;             //[fMaxpar] First derivatives
0082         Double_t     *fG2;              //[fMaxpar]
0083         Double_t     *fGstep;           //[fMaxpar] Step sizes
0084         Double_t     *fGin;             //[fMaxpar2]
0085         Double_t     *fDgrd;            //[fMaxpar] Uncertainties
0086         Double_t     *fGrds;            //[fMaxpar]
0087         Double_t     *fG2s;             //[fMaxpar]
0088         Double_t     *fGsteps;          //[fMaxpar]
0089         Double_t     *fVhmat;           //[fMaxpar5] (Internal) error matrix stored as Half MATrix, since it is symmetric
0090         Double_t     *fVthmat;          //[fMaxpar5] VHMAT is sometimes saved in VTHMAT, especially in MNMNOT
0091         Double_t     *fP;               //[fMaxpar1]
0092         Double_t     *fPstar;           //[fMaxpar2]
0093         Double_t     *fPstst;           //[fMaxpar]
0094         Double_t     *fPbar;            //[fMaxpar]
0095         Double_t     *fPrho;            //[fMaxpar] Minimum point of parabola
0096         Double_t     *fWord7;           //[fMaxpar]
0097         Double_t     *fXpt;             //[fMaxcpt] X array of points for contours
0098         Double_t     *fYpt;             //[fMaxcpt] Y array of points for contours
0099 
0100         Double_t     *fCONTgcc;         //[fMaxpar] array used in mncont
0101         Double_t     *fCONTw;           //[fMaxpar] array used in mncont
0102         Double_t     *fFIXPyy;          //[fMaxpar] array used in mnfixp
0103         Double_t     *fGRADgf;          //[fMaxpar] array used in mngrad
0104         Double_t     *fHESSyy;          //[fMaxpar] array used in mnhess
0105         Double_t     *fIMPRdsav;        //[fMaxpar] array used in mnimpr
0106         Double_t     *fIMPRy;           //[fMaxpar] array used in mnimpr
0107         Double_t     *fMATUvline;       //[fMaxpar] array used in mnmatu
0108         Double_t     *fMIGRflnu;        //[fMaxpar] array used in mnmigr
0109         Double_t     *fMIGRstep;        //[fMaxpar] array used in mnmigr
0110         Double_t     *fMIGRgs;          //[fMaxpar] array used in mnmigr
0111         Double_t     *fMIGRvg;          //[fMaxpar] array used in mnmigr
0112         Double_t     *fMIGRxxs;         //[fMaxpar] array used in mnmigr
0113         Double_t     *fMNOTxdev;        //[fMaxpar] array used in mnmnot
0114         Double_t     *fMNOTw;           //[fMaxpar] array used in mnmnot
0115         Double_t     *fMNOTgcc;         //[fMaxpar] array used in mnmnot
0116         Double_t     *fPSDFs;           //[fMaxpar] array used in mnpsdf
0117         Double_t     *fSEEKxmid;        //[fMaxpar] array used in mnseek
0118         Double_t     *fSEEKxbest;       //[fMaxpar] array used in mnseek
0119         Double_t     *fSIMPy;           //[fMaxpar] array used in mnsimp
0120         Double_t     *fVERTq;           //[fMaxpar] array used in mnvert
0121         Double_t     *fVERTs;           //[fMaxpar] array used in mnvert
0122         Double_t     *fVERTpp;          //[fMaxpar] array used in mnvert
0123         Double_t     *fCOMDplist;       //[fMaxpar] array used in mncomd
0124         Double_t     *fPARSplist;       //[fMaxpar] array used in mnpars
0125 
0126         Int_t        *fNvarl;           //[fMaxpar2] parameters flag (-1=undefined, 0=constant..)
0127         Int_t        *fNiofex;          //[fMaxpar2] Internal parameters number, or zero if not currently variable
0128         Int_t        *fNexofi;          //[fMaxpar] External parameters number for currently variable parameters
0129         Int_t        *fIpfix;           //[fMaxpar] List of fixed parameters
0130         Int_t        fNu;               //
0131         Int_t        fIsysrd;           //standardInput unit
0132         Int_t        fIsyswr;           //standard output unit
0133         Int_t        fIsyssa;           //
0134         Int_t        fNpagwd;           //Page width
0135         Int_t        fNpagln;           //Number of lines per page
0136         Int_t        fNewpag;           //
0137         Int_t        fIstkrd[10];       //
0138         Int_t        fNstkrd;           //
0139         Int_t        fIstkwr[10];       //
0140         Int_t        fNstkwr;           //
0141         Int_t        fISW[7];           //Array of switches
0142         Int_t        fIdbg[11];         //Array of internal debug switches
0143         Int_t        fNblock;           //Number of Minuit data blocks
0144         Int_t        fIcomnd;           //Number of commands
0145         Int_t        fNfcn;             //Number of calls to FCN
0146         Int_t        fNfcnmx;           //Maximum number of calls to FCN
0147         Int_t        fNfcnlc;           //
0148         Int_t        fNfcnfr;           //
0149         Int_t        fItaur;            //
0150         Int_t        fIstrat;           //
0151         Int_t        fNwrmes[2];        //
0152         Int_t        fNfcwar[20];       //
0153         Int_t        fIcirc[2];         //
0154         Int_t        fStatus;           //Status flag for the last called Minuit function
0155         Int_t        fKe1cr;            //
0156         Int_t        fKe2cr;            //
0157         Bool_t       fLwarn;            //true if warning messages are to be put out (default=true)
0158         Bool_t       fLrepor;           //true if exceptional conditions are put out (default=false)
0159         Bool_t       fLimset;           //true if a parameter is up against limits (for MINOS)
0160         Bool_t       fLnolim;           //true if there are no limits on any parameters (not yet used)
0161         Bool_t       fLnewmn;           //true if the previous process has unexpectedly improved FCN
0162         Bool_t       fLphead;           //true if a heading should be put out for the next parameter definition
0163         Bool_t       fGraphicsMode;     //true if graphics mode on (default)
0164         char         *fChpt;            //!Character to be plotted at the X,Y contour positions
0165         TString      *fCpnam;           //[fMaxpar2] Array of parameters names
0166         TString      fCfrom;            //
0167         TString      fCstatu;           //
0168         TString      fCtitl;            //
0169         TString      fCword;            //
0170         TString      fCundef;           //
0171         TString      fCvrsn;            //
0172         TString      fCovmes[4];        //
0173         TString      fOrigin[kMAXWARN]; //
0174         TString      fWarmes[kMAXWARN]; //
0175         TObject      *fObjectFit;       //Pointer to object being fitted
0176         TObject      *fPlot;            //Pointer to TGraph object created by mncont
0177         TMethodCall  *fMethodCall;      //Pointer to MethodCall in case of interpreted function
0178         void         (*fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag); //!
0179 
0180 // methods performed on TMinuit class
0181 public:
0182    TMinuit();
0183    TMinuit(Int_t maxpar);
0184          ~TMinuit() override;
0185    virtual void   BuildArrays(Int_t maxpar=15);
0186    TObject *Clone(const char *newname="") const override;   //Clone-Method to copy the function-pointer fFCN
0187    virtual Int_t  Command(const char *command);
0188    virtual TObject *Contour(Int_t npoints=10, Int_t pa1=0, Int_t pa2=1);
0189    virtual Int_t  DefineParameter( Int_t parNo, const char *name, Double_t initVal, Double_t initErr, Double_t lowerLimit, Double_t upperLimit );
0190    virtual void   DeleteArrays();
0191    virtual Int_t  Eval(Int_t npar, Double_t *grad, Double_t &fval, Double_t *par, Int_t flag);
0192    virtual Int_t  FixParameter( Int_t parNo );
0193    TMethodCall   *GetMethodCall() const {return fMethodCall;}
0194    TObject       *GetObjectFit() const {return fObjectFit;}
0195    Int_t          GetMaxIterations() const {return fMaxIterations;}
0196    virtual Int_t  GetNumFixedPars() const;
0197    virtual Int_t  GetNumFreePars() const;
0198    virtual Int_t  GetNumPars() const;
0199    virtual Int_t  GetParameter( Int_t parNo, Double_t &currentValue, Double_t &currentError ) const;
0200    virtual TObject *GetPlot() const {return fPlot;}
0201    Int_t          GetStatus() const {return fStatus;}
0202    virtual Int_t  Migrad();
0203    virtual void   mnamin();
0204    virtual void   mnbins(Double_t a1, Double_t a2, Int_t naa, Double_t &bl, Double_t &bh, Int_t &nb, Double_t &bwid);
0205    virtual void   mncalf(Double_t *pvec, Double_t &ycalf);
0206    virtual void   mncler();
0207    virtual void   mncntr(Int_t ke1, Int_t ke2, Int_t &ierrf);
0208    virtual void   mncomd(const char *crdbin, Int_t &icondn);
0209    virtual void   mncont(Int_t ke1, Int_t ke2, Int_t nptu, Double_t *xptu, Double_t *yptu, Int_t &ierrf);
0210    virtual void   mncrck(TString crdbuf, Int_t maxcwd, TString &comand, Int_t &lnc
0211                     ,  Int_t mxp, Double_t *plist, Int_t &llist, Int_t &ierr, Int_t isyswr);
0212    virtual void   mncros(Double_t &aopt, Int_t &iercr);
0213    virtual void   mncuve();
0214    virtual void   mnderi();
0215    virtual void   mndxdi(Double_t pint, Int_t ipar, Double_t &dxdi);
0216    virtual void   mneig(Double_t *a, Int_t ndima, Int_t n, Int_t mits, Double_t *work, Double_t precis, Int_t &ifault);
0217    virtual void   mnemat(Double_t *emat, Int_t ndim);
0218    virtual void   mnerrs(Int_t number, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &gcc);
0219    virtual void   mneval(Double_t anext, Double_t &fnext, Int_t &ierev);
0220    virtual void   mnexcm(const char *comand, Double_t *plist, Int_t llist, Int_t &ierflg) ;
0221    virtual void   mnexin(Double_t *pint);
0222    virtual void   mnfixp(Int_t iint, Int_t &ierr);
0223    virtual void   mnfree(Int_t k);
0224    virtual void   mngrad();
0225    virtual void   mnhelp(TString comd);
0226    virtual void   mnhelp(const char *command="");
0227    virtual void   mnhess();
0228    virtual void   mnhes1();
0229    virtual void   mnimpr();
0230    virtual void   mninex(Double_t *pint);
0231    virtual void   mninit(Int_t i1, Int_t i2, Int_t i3);
0232    virtual void   mnlims();
0233    virtual void   mnline(Double_t *start, Double_t fstart, Double_t *step, Double_t slope, Double_t toler);
0234    virtual void   mnmatu(Int_t kode);
0235    virtual void   mnmigr();
0236    virtual void   mnmnos();
0237    virtual void   mnmnot(Int_t ilax, Int_t ilax2, Double_t &val2pl, Double_t &val2mi);
0238    virtual void   mnparm(Int_t k, TString cnamj, Double_t uk, Double_t wk, Double_t a, Double_t b, Int_t &ierflg);
0239    virtual void   mnpars(TString &crdbuf, Int_t &icondn);
0240    virtual void   mnpfit(Double_t *parx2p, Double_t *pary2p, Int_t npar2p, Double_t *coef2p, Double_t &sdev2p);
0241    virtual void   mnpint(Double_t &pexti, Int_t i, Double_t &pinti);
0242    virtual void   mnplot(Double_t *xpt, Double_t *ypt, char *chpt, Int_t nxypt, Int_t npagwd, Int_t npagln);
0243    virtual void   mnpout(Int_t iuext, TString &chnam, Double_t &val, Double_t &err, Double_t &xlolim, Double_t &xuplim, Int_t &iuint) const;
0244    virtual void   mnprin(Int_t inkode, Double_t fval);
0245    virtual void   mnpsdf();
0246    virtual void   mnrazz(Double_t ynew, Double_t *pnew, Double_t *y, Int_t &jh, Int_t &jl);
0247    virtual void   mnrn15(Double_t &val, Int_t &inseed);
0248    virtual void   mnrset(Int_t iopt);
0249    virtual void   mnsave();
0250    virtual void   mnscan();
0251    virtual void   mnseek();
0252    virtual void   mnset();
0253    virtual void   mnsimp();
0254    virtual void   mnstat(Double_t &fmin, Double_t &fedm, Double_t &errdef, Int_t &npari, Int_t &nparx, Int_t &istat);
0255    virtual void   mntiny(Double_t epsp1, Double_t &epsbak);
0256    Bool_t         mnunpt(TString &cfname);
0257    virtual void   mnvert(Double_t *a, Int_t l, Int_t m, Int_t n, Int_t &ifail);
0258    virtual void   mnwarn(const char *copt, const char *corg, const char *cmes);
0259    virtual void   mnwerr();
0260    virtual Int_t  Release( Int_t parNo );
0261    virtual Int_t  SetErrorDef( Double_t up );
0262    virtual void   SetFCN(void (*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t));
0263    virtual void   SetGraphicsMode(Bool_t mode=kTRUE) {fGraphicsMode = mode;}
0264    virtual void   SetMaxIterations(Int_t maxiter=500) {fMaxIterations = maxiter;}
0265    virtual void   SetObjectFit(TObject *obj) {fObjectFit=obj;}
0266    virtual Int_t  SetPrintLevel( Int_t printLevel=0 );
0267 
0268    ClassDefOverride(TMinuit,1)  //The MINUIT minimisation package
0269 };
0270 
0271 R__EXTERN TMinuit  *gMinuit;
0272 
0273 #endif
0274