Logo ROOT   6.13/01
Reference Guide
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 */
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  */
56 
57  /**
58  Assignment operator
59  */
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 
142 
143  ClassDef(TLinearMinimizer,1) //Implementation of the Minimizer interface using TLinearFitter
144 
145 };
146 
147 
148 
149 #endif /* ROOT_TLinearMinimizer */
std::vector< double > fErrors
virtual const double * MinGradient() const
return pointer to gradient values at the minimum
virtual unsigned int NDim() const
this is <= Function().NDim() which is the total number of variables (free+ constrained ones) ...
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Definition: IFunction.h:326
virtual unsigned int NFree() const
number of free variables (real dimension of the problem) this is <= Function().NDim() which is the to...
The Linear Fitter - For fitting functions that are LINEAR IN PARAMETERS.
std::vector< double > fParams
virtual const double * X() const
return pointer to X values at the minimum
TLinearFitter * fFitter
unsigned int fNFree
TLinearMinimizer class: minimizer implementation based on TMinuit.
virtual double Edm() const
return expected distance reached from the minimum
TLinearMinimizer & operator=(const TLinearMinimizer &rhs)
Assignment operator.
std::vector< double > fCovar
virtual const double * Errors() const
return errors at the minimum
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2, Minuit, GSL, etc..) Plug-in&#39;s exist in ROOT to be able to instantiate the derived classes like ROOT::Math::GSLMinimizer or ROOT::Math::Minuit2Minimizer via the plug-in manager.
Definition: Minimizer.h:78
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)
set the fit model function
virtual bool SetVariable(unsigned int, const std::string &, double, double)
set free variable (dummy impl. )
Documentation for the abstract class IBaseFunctionMultiDim.
Definition: IFunction.h:62
const ROOT::Math::IMultiGradFunction * fObjFunc
virtual bool ProvidesError() const
minimizer provides error and error matrix
TLinearMinimizer(int type=0)
Default constructor.
virtual bool Minimize()
method to perform the minimization
virtual int CovMatrixStatus() const
return covariance matrix status
bool fRobust
return reference to the objective function virtual const ROOT::Math::IGenFunction & Function() const;...
virtual ~TLinearMinimizer()
Destructor (no operations)
virtual unsigned int NCalls() const
number of function calls to reach the minimum
virtual bool SetFixedVariable(unsigned int, const std::string &, double)
set fixed variable (override if minimizer supports them )
virtual double MinValue() const
return minimum function value
virtual double CovMatrix(unsigned int i, unsigned int j) const
return covariance matrices elements if the variable is fixed the matrix is zero The ordering of the v...