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