Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TMinuit.h
Go to the documentation of this file.
1 // @(#)root/minuit:$Id$
2 // Author: Rene Brun, Frederick James 12/08/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TMinuit //
15 // //
16 // The MINUIT minimisation package (base class) //
17 // //
18 //////////////////////////////////////////////////////////////////////////
19 
20 #ifndef ROOT_TMinuit
21 #define ROOT_TMinuit
22 
23 #include "TNamed.h"
24 
25 #include "TMethodCall.h"
26 
27 class TMinuit : public TNamed {
28 
29 private:
30  TMinuit(const TMinuit &m);
31  TMinuit& operator=(const TMinuit &m); // Not implemented
32 
33 // should become private....
34 public:
35  enum{kMAXWARN=100};
36 
37  Int_t fNpfix; //Number of fixed parameters
38  Int_t fEmpty; //Initialization flag (1 = Minuit initialized)
39  Int_t fMaxpar; //Maximum number of parameters
40  Int_t fMaxint; //Maximum number of internal parameters
41  Int_t fNpar; //Number of free parameters (total number of pars = fNpar + fNfix)
42  Int_t fMaxext; //Maximum number of external parameters
43  Int_t fMaxIterations; //Maximum number of iterations
44  Int_t fMaxpar5; // fMaxpar*(fMaxpar+1)/2
45  Int_t fMaxcpt;
46  Int_t fMaxpar2; // fMaxpar*fMaxpar
47  Int_t fMaxpar1; // fMaxpar*(fMaxpar+1)
48 
49  Double_t fAmin; //Minimum value found for FCN
50  Double_t fUp; //FCN+-UP defines errors (for chisquare fits UP=1)
51  Double_t fEDM; //Estimated vertical distance to the minimum
52  Double_t fFval3; //
53  Double_t fEpsi; //
54  Double_t fApsi; //
55  Double_t fDcovar; //Relative change in covariance matrix
56  Double_t fEpsmac; //machine precision for floating points:
57  Double_t fEpsma2; //sqrt(fEpsmac)
58  Double_t fVlimlo; //
59  Double_t fVlimhi; //
60  Double_t fUndefi; //Undefined number = -54321
61  Double_t fBigedm; //Big EDM = 123456
62  Double_t fUpdflt; //
63  Double_t fXmidcr; //
64  Double_t fYmidcr; //
65  Double_t fXdircr; //
66  Double_t fYdircr; //
67 
68  Double_t *fU; //[fMaxpar2] External (visible to user in FCN) value of parameters
69  Double_t *fAlim; //[fMaxpar2] Lower limits for parameters. If zero no limits
70  Double_t *fBlim; //[fMaxpar2] Upper limits for parameters
71  Double_t *fErp; //[fMaxpar] Positive Minos errors if calculated
72  Double_t *fErn; //[fMaxpar] Negative Minos errors if calculated
73  Double_t *fWerr; //[fMaxpar] External parameters error (standard deviation, defined by UP)
74  Double_t *fGlobcc; //[fMaxpar] Global Correlation Coefficients
75  Double_t *fX; //[fMaxpar] Internal parameters values
76  Double_t *fXt; //[fMaxpar] Internal parameters values X saved as Xt
77  Double_t *fDirin; //[fMaxpar] (Internal) step sizes for current step
78  Double_t *fXs; //[fMaxpar] Internal parameters values saved for fixed params
79  Double_t *fXts; //[fMaxpar] Internal parameters values X saved as Xt for fixed params
80  Double_t *fDirins; //[fMaxpar] (Internal) step sizes for current step for fixed params
81  Double_t *fGrd; //[fMaxpar] First derivatives
82  Double_t *fG2; //[fMaxpar]
83  Double_t *fGstep; //[fMaxpar] Step sizes
84  Double_t *fGin; //[fMaxpar2]
85  Double_t *fDgrd; //[fMaxpar] Uncertainties
86  Double_t *fGrds; //[fMaxpar]
87  Double_t *fG2s; //[fMaxpar]
88  Double_t *fGsteps; //[fMaxpar]
89  Double_t *fVhmat; //[fMaxpar5] (Internal) error matrix stored as Half MATrix, since it is symmetric
90  Double_t *fVthmat; //[fMaxpar5] VHMAT is sometimes saved in VTHMAT, especially in MNMNOT
91  Double_t *fP; //[fMaxpar1]
92  Double_t *fPstar; //[fMaxpar2]
93  Double_t *fPstst; //[fMaxpar]
94  Double_t *fPbar; //[fMaxpar]
95  Double_t *fPrho; //[fMaxpar] Minimum point of parabola
96  Double_t *fWord7; //[fMaxpar]
97  Double_t *fXpt; //[fMaxcpt] X array of points for contours
98  Double_t *fYpt; //[fMaxcpt] Y array of points for contours
99 
100  Double_t *fCONTgcc; //[fMaxpar] array used in mncont
101  Double_t *fCONTw; //[fMaxpar] array used in mncont
102  Double_t *fFIXPyy; //[fMaxpar] array used in mnfixp
103  Double_t *fGRADgf; //[fMaxpar] array used in mngrad
104  Double_t *fHESSyy; //[fMaxpar] array used in mnhess
105  Double_t *fIMPRdsav; //[fMaxpar] array used in mnimpr
106  Double_t *fIMPRy; //[fMaxpar] array used in mnimpr
107  Double_t *fMATUvline; //[fMaxpar] array used in mnmatu
108  Double_t *fMIGRflnu; //[fMaxpar] array used in mnmigr
109  Double_t *fMIGRstep; //[fMaxpar] array used in mnmigr
110  Double_t *fMIGRgs; //[fMaxpar] array used in mnmigr
111  Double_t *fMIGRvg; //[fMaxpar] array used in mnmigr
112  Double_t *fMIGRxxs; //[fMaxpar] array used in mnmigr
113  Double_t *fMNOTxdev; //[fMaxpar] array used in mnmnot
114  Double_t *fMNOTw; //[fMaxpar] array used in mnmnot
115  Double_t *fMNOTgcc; //[fMaxpar] array used in mnmnot
116  Double_t *fPSDFs; //[fMaxpar] array used in mnpsdf
117  Double_t *fSEEKxmid; //[fMaxpar] array used in mnseek
118  Double_t *fSEEKxbest; //[fMaxpar] array used in mnseek
119  Double_t *fSIMPy; //[fMaxpar] array used in mnsimp
120  Double_t *fVERTq; //[fMaxpar] array used in mnvert
121  Double_t *fVERTs; //[fMaxpar] array used in mnvert
122  Double_t *fVERTpp; //[fMaxpar] array used in mnvert
123  Double_t *fCOMDplist; //[fMaxpar] array used in mncomd
124  Double_t *fPARSplist; //[fMaxpar] array used in mnpars
125 
126  Int_t *fNvarl; //[fMaxpar2] parameters flag (-1=undefined, 0=constant..)
127  Int_t *fNiofex; //[fMaxpar2] Internal parameters number, or zero if not currently variable
128  Int_t *fNexofi; //[fMaxpar] External parameters number for currently variable parameters
129  Int_t *fIpfix; //[fMaxpar] List of fixed parameters
130  Int_t fNu; //
131  Int_t fIsysrd; //standardInput unit
132  Int_t fIsyswr; //standard output unit
133  Int_t fIsyssa; //
134  Int_t fNpagwd; //Page width
135  Int_t fNpagln; //Number of lines per page
136  Int_t fNewpag; //
137  Int_t fIstkrd[10]; //
138  Int_t fNstkrd; //
139  Int_t fIstkwr[10]; //
140  Int_t fNstkwr; //
141  Int_t fISW[7]; //Array of switches
142  Int_t fIdbg[11]; //Array of internal debug switches
143  Int_t fNblock; //Number of Minuit data blocks
144  Int_t fIcomnd; //Number of commands
145  Int_t fNfcn; //Number of calls to FCN
146  Int_t fNfcnmx; //Maximum number of calls to FCN
147  Int_t fNfcnlc; //
148  Int_t fNfcnfr; //
149  Int_t fItaur; //
150  Int_t fIstrat; //
151  Int_t fNwrmes[2]; //
152  Int_t fNfcwar[20]; //
153  Int_t fIcirc[2]; //
154  Int_t fStatus; //Status flag for the last called Minuit function
155  Int_t fKe1cr; //
156  Int_t fKe2cr; //
157  Bool_t fLwarn; //true if warning messages are to be put out (default=true)
158  Bool_t fLrepor; //true if exceptional conditions are put out (default=false)
159  Bool_t fLimset; //true if a parameter is up against limits (for MINOS)
160  Bool_t fLnolim; //true if there are no limits on any parameters (not yet used)
161  Bool_t fLnewmn; //true if the previous process has unexpectedly improved FCN
162  Bool_t fLphead; //true if a heading should be put out for the next parameter definition
163  Bool_t fGraphicsMode; //true if graphics mode on (default)
164  char *fChpt; //!Character to be plotted at the X,Y contour positions
165  TString *fCpnam; //[fMaxpar2] Array of parameters names
166  TString fCfrom; //
167  TString fCstatu; //
168  TString fCtitl; //
169  TString fCword; //
170  TString fCundef; //
171  TString fCvrsn; //
172  TString fCovmes[4]; //
173  TString fOrigin[kMAXWARN]; //
174  TString fWarmes[kMAXWARN]; //
175  TObject *fObjectFit; //Pointer to object being fitted
176  TObject *fPlot; //Pointer to TGraph object created by mncont
177  TMethodCall *fMethodCall; //Pointer to MethodCall in case of interpreted function
178  void (*fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag); //!
179 
180 // methods performed on TMinuit class
181 public:
182  TMinuit();
183  TMinuit(Int_t maxpar);
184  virtual ~TMinuit();
185  virtual void BuildArrays(Int_t maxpar=15);
186  virtual TObject *Clone(const char *newname="") const; //Clone-Method to copy the function-pointer fFCN
187  virtual Int_t Command(const char *command);
188  virtual TObject *Contour(Int_t npoints=10, Int_t pa1=0, Int_t pa2=1);
189  virtual Int_t DefineParameter( Int_t parNo, const char *name, Double_t initVal, Double_t initErr, Double_t lowerLimit, Double_t upperLimit );
190  virtual void DeleteArrays();
191  virtual Int_t Eval(Int_t npar, Double_t *grad, Double_t &fval, Double_t *par, Int_t flag);
192  virtual Int_t FixParameter( Int_t parNo );
193  TMethodCall *GetMethodCall() const {return fMethodCall;}
194  TObject *GetObjectFit() const {return fObjectFit;}
195  Int_t GetMaxIterations() const {return fMaxIterations;}
196  virtual Int_t GetNumFixedPars() const;
197  virtual Int_t GetNumFreePars() const;
198  virtual Int_t GetNumPars() const;
199  virtual Int_t GetParameter( Int_t parNo, Double_t &currentValue, Double_t &currentError ) const;
200  virtual TObject *GetPlot() const {return fPlot;}
201  Int_t GetStatus() const {return fStatus;}
202  virtual Int_t Migrad();
203  virtual void mnamin();
204  virtual void mnbins(Double_t a1, Double_t a2, Int_t naa, Double_t &bl, Double_t &bh, Int_t &nb, Double_t &bwid);
205  virtual void mncalf(Double_t *pvec, Double_t &ycalf);
206  virtual void mncler();
207  virtual void mncntr(Int_t ke1, Int_t ke2, Int_t &ierrf);
208  virtual void mncomd(const char *crdbin, Int_t &icondn);
209  virtual void mncont(Int_t ke1, Int_t ke2, Int_t nptu, Double_t *xptu, Double_t *yptu, Int_t &ierrf);
210  virtual void mncrck(TString crdbuf, Int_t maxcwd, TString &comand, Int_t &lnc
211  , Int_t mxp, Double_t *plist, Int_t &llist, Int_t &ierr, Int_t isyswr);
212  virtual void mncros(Double_t &aopt, Int_t &iercr);
213  virtual void mncuve();
214  virtual void mnderi();
215  virtual void mndxdi(Double_t pint, Int_t ipar, Double_t &dxdi);
216  virtual void mneig(Double_t *a, Int_t ndima, Int_t n, Int_t mits, Double_t *work, Double_t precis, Int_t &ifault);
217  virtual void mnemat(Double_t *emat, Int_t ndim);
218  virtual void mnerrs(Int_t number, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &gcc);
219  virtual void mneval(Double_t anext, Double_t &fnext, Int_t &ierev);
220  virtual void mnexcm(const char *comand, Double_t *plist, Int_t llist, Int_t &ierflg) ;
221  virtual void mnexin(Double_t *pint);
222  virtual void mnfixp(Int_t iint, Int_t &ierr);
223  virtual void mnfree(Int_t k);
224  virtual void mngrad();
225  virtual void mnhelp(TString comd);
226  virtual void mnhelp(const char *command="");
227  virtual void mnhess();
228  virtual void mnhes1();
229  virtual void mnimpr();
230  virtual void mninex(Double_t *pint);
231  virtual void mninit(Int_t i1, Int_t i2, Int_t i3);
232  virtual void mnlims();
233  virtual void mnline(Double_t *start, Double_t fstart, Double_t *step, Double_t slope, Double_t toler);
234  virtual void mnmatu(Int_t kode);
235  virtual void mnmigr();
236  virtual void mnmnos();
237  virtual void mnmnot(Int_t ilax, Int_t ilax2, Double_t &val2pl, Double_t &val2mi);
238  virtual void mnparm(Int_t k, TString cnamj, Double_t uk, Double_t wk, Double_t a, Double_t b, Int_t &ierflg);
239  virtual void mnpars(TString &crdbuf, Int_t &icondn);
240  virtual void mnpfit(Double_t *parx2p, Double_t *pary2p, Int_t npar2p, Double_t *coef2p, Double_t &sdev2p);
241  virtual void mnpint(Double_t &pexti, Int_t i, Double_t &pinti);
242  virtual void mnplot(Double_t *xpt, Double_t *ypt, char *chpt, Int_t nxypt, Int_t npagwd, Int_t npagln);
243  virtual void mnpout(Int_t iuext, TString &chnam, Double_t &val, Double_t &err, Double_t &xlolim, Double_t &xuplim, Int_t &iuint) const;
244  virtual void mnprin(Int_t inkode, Double_t fval);
245  virtual void mnpsdf();
246  virtual void mnrazz(Double_t ynew, Double_t *pnew, Double_t *y, Int_t &jh, Int_t &jl);
247  virtual void mnrn15(Double_t &val, Int_t &inseed);
248  virtual void mnrset(Int_t iopt);
249  virtual void mnsave();
250  virtual void mnscan();
251  virtual void mnseek();
252  virtual void mnset();
253  virtual void mnsimp();
254  virtual void mnstat(Double_t &fmin, Double_t &fedm, Double_t &errdef, Int_t &npari, Int_t &nparx, Int_t &istat);
255  virtual void mntiny(volatile Double_t epsp1, Double_t &epsbak);
256  Bool_t mnunpt(TString &cfname);
257  virtual void mnvert(Double_t *a, Int_t l, Int_t m, Int_t n, Int_t &ifail);
258  virtual void mnwarn(const char *copt, const char *corg, const char *cmes);
259  virtual void mnwerr();
260  virtual Int_t Release( Int_t parNo );
261  virtual Int_t SetErrorDef( Double_t up );
262  virtual void SetFCN(void (*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t));
263  virtual void SetGraphicsMode(Bool_t mode=kTRUE) {fGraphicsMode = mode;}
264  virtual void SetMaxIterations(Int_t maxiter=500) {fMaxIterations = maxiter;}
265  virtual void SetObjectFit(TObject *obj) {fObjectFit=obj;}
266  virtual Int_t SetPrintLevel( Int_t printLevel=0 );
267 
268  ClassDef(TMinuit,1) //The MINUIT minimisation package
269 };
270 
271 R__EXTERN TMinuit *gMinuit;
272 
273 #endif
274