ROOT logo
// @(#)root/fumili:$Id$
// Author: Rene Brun   31/08/99

/////////////////////////////////////////////////////////////////////////
//                                                                     //
//  TFumili                                                            //
//                                                                     //
//  The FUMILI Minimization package                                    //
//                                                                     //
///////////////////////////////////////////////////////////////////////// 

#ifndef ROOT_TFumili
#define ROOT_TFumili

#ifndef ROOT_TVirtualFitter
#include "TVirtualFitter.h"
#endif

class TF1;
 
class TFumili : public  TVirtualFitter {
private:
   Int_t fMaxParam;     //
   Int_t fNlog;         //
   Int_t fNfcn;         // Number of FCN calls;
   Int_t fNED1;         // Number of experimental vectors X=(x1,x2,...xK)
   Int_t fNED2;         // K - Length of vector X plus 2 (for chi2)
   Int_t fNED12;        // fNED1+fNED2
   Int_t fNpar;         //  fNpar - number of parameters
   Int_t fNstepDec;     //  fNstepDec - maximum number of step decreasing counter
   Int_t fNlimMul;      //  fNlimMul - after fNlimMul successful iterations permits four-fold increasing of fPL
   Int_t fNmaxIter;     //  fNmaxIter - maximum number of iterations
   Int_t fLastFixed;    // Last fixed parameter number
   Int_t fENDFLG;       // End flag of fit 
   Int_t fINDFLG[5];    // internal flags;
  
  
   Bool_t fGRAD;        // user calculated gradients  
   Bool_t fWARN;        // warnings
   Bool_t fDEBUG;       // debug info
   Bool_t fLogLike;     // LogLikelihood flag
   Bool_t fNumericDerivatives; //

   Double_t *fZ0;       //[fMaxParam2] Matrix of approximate second derivatives of objective function
                        // This matrix is diagonal and always contain only variable parameter's
                        // derivatives
   Double_t *fZ;        //[fMaxParam2] Invers fZ0 matrix - covariance matrix
   Double_t *fGr;       //[fMaxParam] Gradients of objective function
   Double_t *fParamError; //[fMaxParam] Parameter errors
   Double_t *fSumLog;   //[fNlog]
   Double_t *fEXDA;     //[fNED12] experimental data poInt_ter
  
   //  don't calculate parameter errors - take them from fParamError array
   Double_t *fA;        //[fMaxParam] Fit parameter array
   Double_t *fPL0;      //[fMaxParam] Step initial bounds
   Double_t *fPL;       //[fMaxParam] Limits for parameters step. If <0, then parameter is fixed
 
   // Defines multidimensional parallelepiped with center in param. vector
   Double_t *fDA;       //[fMaxParam] Parameter step
   Double_t *fAMX;      //[fMaxParam] Maximum param value
   Double_t *fAMN;      //[fMaxParam] Minimum param value
   Double_t *fR;        //[fMaxParam] Correlation factors
  
   Double_t *fDF;       //[fMaxParam] // First derivatives of theoretical function 
   Double_t *fCmPar;    //[fMaxParam] parameters of commands

   Double_t fS;         //  fS - objective function value (return)
   Double_t fEPS;       //  fEPS - required precision of parameters. If fEPS<0 then 
   Double_t fRP;        // Precision of fit ( machine zero on CDC 6000) quite old yeh?
   Double_t fAKAPPA;    //
   Double_t fGT;        // Expected function change in next iteration
   TString *fANames;    //[fMaxParam] Parameter names
   TString fCword;      //  Command string


//  TF1 *fTFNF1;         //Pointer to theoretical function
//  void (*fFCN) (Int_t &, Double_t *, Double_t &f, Double_t *, Int_t); //
//  //wrapper function to calculate functional value, gradients and Z-matrix
//  Double_t (*fTFN)(Double_t *, Double_t *, Double_t*); // Wrapper function for TFN

public:

   TFumili(Int_t maxpar=25);
   virtual  ~TFumili();

   void             BuildArrays();
   virtual Double_t Chisquare(Int_t npar, Double_t *params) const;
   virtual void     Clear(Option_t *opt=""); 
   void             DeleteArrays();
   void             Derivatives(Double_t*,Double_t*);
   Int_t            Eval(Int_t& npar, Double_t *grad, Double_t &fval, Double_t *par, Int_t flag); // Evaluate the minimisation function
   Double_t         EvalTFN(Double_t *,Double_t*);
   virtual Int_t    ExecuteCommand(const char *command, Double_t *args, Int_t nargs);
   Int_t            ExecuteSetCommand(Int_t ); 
   virtual void     FitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
   virtual void     FitChisquareI(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
   virtual void     FitLikelihood(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
   virtual void     FitLikelihoodI(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
   virtual void     FixParameter(Int_t ipar); 
   virtual Double_t *GetCovarianceMatrix() const;
   virtual Double_t GetCovarianceMatrixElement(Int_t i, Int_t j) const;
   virtual Int_t    GetErrors(Int_t ipar,Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const;
   virtual Int_t    GetNumberTotalParameters() const;
   virtual Int_t    GetNumberFreeParameters() const;
   Double_t*        GetPL0() const { return fPL0;} 
   virtual Double_t GetParError(Int_t ipar) const;
   virtual Double_t GetParameter(Int_t ipar) const ;
   virtual Int_t    GetParameter(Int_t ipar,char *name,Double_t &value,Double_t &verr,Double_t &vlow, Double_t &vhigh) const;
   virtual const char *GetParName(Int_t ipar) const;
   virtual Int_t    GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const;
   virtual Double_t GetSumLog(Int_t );
   Double_t*        GetZ() const { return fZ;}
   void             InvertZ(Int_t); 
   virtual Bool_t   IsFixed(Int_t ipar) const;
   Int_t            Minimize(); 
   virtual void     PrintResults(Int_t k,Double_t p) const;
   virtual void     ReleaseParameter(Int_t ipar); 
   Int_t            SGZ();
   void             SetData(Double_t *,Int_t,Int_t);
   virtual void     SetFitMethod(const char *name);
   virtual Int_t    SetParameter(Int_t ipar,const char *parname,Double_t value,Double_t verr,Double_t vlow, Double_t vhigh);
   void             SetParNumber(Int_t ParNum) { fNpar = ParNum;};

   ClassDef(TFumili,0) //The FUMILI Minimization package
};

R__EXTERN TFumili * gFumili;
#endif 




 TFumili.h:1
 TFumili.h:2
 TFumili.h:3
 TFumili.h:4
 TFumili.h:5
 TFumili.h:6
 TFumili.h:7
 TFumili.h:8
 TFumili.h:9
 TFumili.h:10
 TFumili.h:11
 TFumili.h:12
 TFumili.h:13
 TFumili.h:14
 TFumili.h:15
 TFumili.h:16
 TFumili.h:17
 TFumili.h:18
 TFumili.h:19
 TFumili.h:20
 TFumili.h:21
 TFumili.h:22
 TFumili.h:23
 TFumili.h:24
 TFumili.h:25
 TFumili.h:26
 TFumili.h:27
 TFumili.h:28
 TFumili.h:29
 TFumili.h:30
 TFumili.h:31
 TFumili.h:32
 TFumili.h:33
 TFumili.h:34
 TFumili.h:35
 TFumili.h:36
 TFumili.h:37
 TFumili.h:38
 TFumili.h:39
 TFumili.h:40
 TFumili.h:41
 TFumili.h:42
 TFumili.h:43
 TFumili.h:44
 TFumili.h:45
 TFumili.h:46
 TFumili.h:47
 TFumili.h:48
 TFumili.h:49
 TFumili.h:50
 TFumili.h:51
 TFumili.h:52
 TFumili.h:53
 TFumili.h:54
 TFumili.h:55
 TFumili.h:56
 TFumili.h:57
 TFumili.h:58
 TFumili.h:59
 TFumili.h:60
 TFumili.h:61
 TFumili.h:62
 TFumili.h:63
 TFumili.h:64
 TFumili.h:65
 TFumili.h:66
 TFumili.h:67
 TFumili.h:68
 TFumili.h:69
 TFumili.h:70
 TFumili.h:71
 TFumili.h:72
 TFumili.h:73
 TFumili.h:74
 TFumili.h:75
 TFumili.h:76
 TFumili.h:77
 TFumili.h:78
 TFumili.h:79
 TFumili.h:80
 TFumili.h:81
 TFumili.h:82
 TFumili.h:83
 TFumili.h:84
 TFumili.h:85
 TFumili.h:86
 TFumili.h:87
 TFumili.h:88
 TFumili.h:89
 TFumili.h:90
 TFumili.h:91
 TFumili.h:92
 TFumili.h:93
 TFumili.h:94
 TFumili.h:95
 TFumili.h:96
 TFumili.h:97
 TFumili.h:98
 TFumili.h:99
 TFumili.h:100
 TFumili.h:101
 TFumili.h:102
 TFumili.h:103
 TFumili.h:104
 TFumili.h:105
 TFumili.h:106
 TFumili.h:107
 TFumili.h:108
 TFumili.h:109
 TFumili.h:110
 TFumili.h:111
 TFumili.h:112
 TFumili.h:113
 TFumili.h:114
 TFumili.h:115
 TFumili.h:116
 TFumili.h:117
 TFumili.h:118
 TFumili.h:119
 TFumili.h:120
 TFumili.h:121
 TFumili.h:122
 TFumili.h:123
 TFumili.h:124
 TFumili.h:125
 TFumili.h:126
 TFumili.h:127
 TFumili.h:128
 TFumili.h:129
 TFumili.h:130
 TFumili.h:131
 TFumili.h:132