Logo ROOT   6.08/07
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 #ifndef ROOT_Math_Minimizer
17 #include "Math/Minimizer.h"
18 #endif
19 
20 #ifndef ROOT_Rtypes
21 #include "Rtypes.h"
22 #endif
23 
24 #include <vector>
25 
26 class TLinearFitter;
27 
28 
29 
30 
31 /**
32  TLinearMinimizer class: minimizer implementation based on TMinuit.
33 */
35 
36 public:
37 
38  /**
39  Default constructor
40  */
41  TLinearMinimizer (int type = 0);
42 
43  /**
44  Constructor from a char * (used by PM)
45  */
46  TLinearMinimizer ( const char * type );
47 
48  /**
49  Destructor (no operations)
50  */
51  virtual ~TLinearMinimizer ();
52 
53 private:
54  // usually copying is non trivial, so we make this unaccessible
55 
56  /**
57  Copy constructor
58  */
60 
61  /**
62  Assignment operator
63  */
65 
66 public:
67 
68  /// set the fit model function
69  virtual void SetFunction(const ROOT::Math::IMultiGenFunction & func);
70 
71  /// set the function to minimize
72  virtual void SetFunction(const ROOT::Math::IMultiGradFunction & func);
73 
74  /// set free variable (dummy impl. )
75  virtual bool SetVariable(unsigned int , const std::string & , double , double ) { return false; }
76 
77  /// set fixed variable (override if minimizer supports them )
78  virtual bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */);
79 
80  /// method to perform the minimization
81  virtual bool Minimize();
82 
83  /// return minimum function value
84  virtual double MinValue() const { return fMinVal; }
85 
86  /// return expected distance reached from the minimum
87  virtual double Edm() const { return 0; }
88 
89  /// return pointer to X values at the minimum
90  virtual const double * X() const { return &fParams.front(); }
91 
92  /// return pointer to gradient values at the minimum
93  virtual const double * MinGradient() const { return 0; } // not available in Minuit2
94 
95  /// number of function calls to reach the minimum
96  virtual unsigned int NCalls() const { return 0; }
97 
98  /// this is <= Function().NDim() which is the total
99  /// number of variables (free+ constrained ones)
100  virtual unsigned int NDim() const { return fDim; }
101 
102  /// number of free variables (real dimension of the problem)
103  /// this is <= Function().NDim() which is the total
104  virtual unsigned int NFree() const { return fNFree; }
105 
106  /// minimizer provides error and error matrix
107  virtual bool ProvidesError() const { return true; }
108 
109  /// return errors at the minimum
110  virtual const double * Errors() const { return (fErrors.empty()) ? 0 : &fErrors.front(); }
111 
112  /** return covariance matrices elements
113  if the variable is fixed the matrix is zero
114  The ordering of the variables is the same as in errors
115  */
116  virtual double CovMatrix(unsigned int i, unsigned int j) const {
117  return (fCovar.empty()) ? 0 : fCovar[i + fDim* j];
118  }
119 
120  /// return covariance matrix status
121  virtual int CovMatrixStatus() const {
122  if (fCovar.size() == 0) return 0;
123  return (fStatus ==0) ? 3 : 1;
124  }
125 
126  /// return reference to the objective function
127  ///virtual const ROOT::Math::IGenFunction & Function() const;
128 
129 
130 
131 
132 protected:
133 
134 private:
135 
136  bool fRobust;
137  unsigned int fDim;
138  unsigned int fNFree;
139  double fMinVal;
140  std::vector<double> fParams;
141  std::vector<double> fErrors;
142  std::vector<double> fCovar;
143 
146 
147  ClassDef(TLinearMinimizer,1) //Implementation of the Minimizer interface using TLinearFitter
148 
149 };
150 
151 
152 
153 #endif /* ROOT_TLinearMinimizer */
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Definition: IFunction.h:322
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) ...
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.
#define ClassDef(name, id)
Definition: Rtypes.h:254
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:86
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. )
const ROOT::Math::IMultiGradFunction * fObjFunc
virtual bool ProvidesError() const
minimizer provides error and error matrix
TLinearMinimizer(int type=0)
Default constructor.
int type
Definition: TGX11.cxx:120
double func(double *x, double *p)
Definition: stressTF1.cxx:213
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)
Documentation for the abstract class IBaseFunctionMultiDim.
Definition: IFunction.h:63
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...