Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TLinearMinimizer.h
Go to the documentation of this file.
1 // @(#)root/minuit:$Id$
2 // Author: L. Moneta Wed Oct 25 16:28:55 2006
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Header file for class TLinearMinimizer
12 
13 #ifndef ROOT_TLinearMinimizer
14 #define ROOT_TLinearMinimizer
15 
16 #include "Math/Minimizer.h"
17 
18 #include "Rtypes.h"
19 
20 #include <vector>
21 
22 class TLinearFitter;
23 
24 
25 
26 
27 /**
28  TLinearMinimizer class: minimizer implementation based on TMinuit.
29 */
30 class TLinearMinimizer : public ROOT::Math::Minimizer {
31 
32 public:
33 
34  /**
35  Default constructor
36  */
37  TLinearMinimizer (int type = 0);
38 
39  /**
40  Constructor from a char * (used by PM)
41  */
42  TLinearMinimizer ( const char * type );
43 
44  /**
45  Destructor (no operations)
46  */
47  virtual ~TLinearMinimizer ();
48 
49 private:
50  // usually copying is non trivial, so we make this unaccessible
51 
52  /**
53  Copy constructor
54  */
55  TLinearMinimizer(const TLinearMinimizer &);
56 
57  /**
58  Assignment operator
59  */
60  TLinearMinimizer & operator = (const TLinearMinimizer & rhs);
61 
62 public:
63 
64  /// set the fit model function
65  virtual void SetFunction(const ROOT::Math::IMultiGenFunction & func);
66 
67  /// set the function to minimize
68  virtual void SetFunction(const ROOT::Math::IMultiGradFunction & func);
69 
70  /// set free variable (dummy impl. )
71  virtual bool SetVariable(unsigned int , const std::string & , double , double ) { return false; }
72 
73  /// set fixed variable (override if minimizer supports them )
74  virtual bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */);
75 
76  /// method to perform the minimization
77  virtual bool Minimize();
78 
79  /// return minimum function value
80  virtual double MinValue() const { return fMinVal; }
81 
82  /// return expected distance reached from the minimum
83  virtual double Edm() const { return 0; }
84 
85  /// return pointer to X values at the minimum
86  virtual const double * X() const { return &fParams.front(); }
87 
88  /// return pointer to gradient values at the minimum
89  virtual const double * MinGradient() const { return 0; } // not available in Minuit2
90 
91  /// number of function calls to reach the minimum
92  virtual unsigned int NCalls() const { return 0; }
93 
94  /// this is <= Function().NDim() which is the total
95  /// number of variables (free+ constrained ones)
96  virtual unsigned int NDim() const { return fDim; }
97 
98  /// number of free variables (real dimension of the problem)
99  /// this is <= Function().NDim() which is the total
100  virtual unsigned int NFree() const { return fNFree; }
101 
102  /// minimizer provides error and error matrix
103  virtual bool ProvidesError() const { return true; }
104 
105  /// return errors at the minimum
106  virtual const double * Errors() const { return (fErrors.empty()) ? 0 : &fErrors.front(); }
107 
108  /** return covariance matrices elements
109  if the variable is fixed the matrix is zero
110  The ordering of the variables is the same as in errors
111  */
112  virtual double CovMatrix(unsigned int i, unsigned int j) const {
113  return (fCovar.empty()) ? 0 : fCovar[i + fDim* j];
114  }
115 
116  /// return covariance matrix status
117  virtual int CovMatrixStatus() const {
118  if (fCovar.size() == 0) return 0;
119  return (fStatus ==0) ? 3 : 1;
120  }
121 
122  /// return reference to the objective function
123  ///virtual const ROOT::Math::IGenFunction & Function() const;
124 
125 
126 
127 
128 protected:
129 
130 private:
131 
132  bool fRobust;
133  unsigned int fDim;
134  unsigned int fNFree;
135  double fMinVal;
136  std::vector<double> fParams;
137  std::vector<double> fErrors;
138  std::vector<double> fCovar;
139 
140  const ROOT::Math::IMultiGradFunction * fObjFunc;
141  TLinearFitter * fFitter;
142 
143  ClassDef(TLinearMinimizer,1) //Implementation of the Minimizer interface using TLinearFitter
144 
145 };
146 
147 
148 
149 #endif /* ROOT_TLinearMinimizer */