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 ~TLinearMinimizer () override;
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 void SetFunction(const ROOT::Math::IMultiGenFunction & func) override;
67
68 /// set the function to minimize
69 void SetFunction(const ROOT::Math::IMultiGradFunction & func) override;
70
71 /// set free variable (dummy impl. )
72 bool SetVariable(unsigned int , const std::string & , double , double ) override { return false; }
73
74 /// set fixed variable (override if minimizer supports them )
75 bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */) override;
76
77 /// method to perform the minimization
78 bool Minimize() override;
79
80 /// return minimum function value
81 double MinValue() const override { return fMinVal; }
82
83 /// return expected distance reached from the minimum
84 double Edm() const override { return 0; }
85
86 /// return pointer to X values at the minimum
87 const double * X() const override { return &fParams.front(); }
88
89 /// return pointer to gradient values at the minimum
90 const double * MinGradient() const override { return 0; } // not available in Minuit2
91
92 /// number of function calls to reach the minimum
93 unsigned int NCalls() const override { return 0; }
94
95 /// this is <= Function().NDim() which is the total
96 /// number of variables (free+ constrained ones)
97 unsigned int NDim() const override { return fDim; }
98
99 /// number of free variables (real dimension of the problem)
100 /// this is <= Function().NDim() which is the total
101 unsigned int NFree() const override { return fNFree; }
102
103 /// minimizer provides error and error matrix
104 bool ProvidesError() const override { return true; }
105
106 /// return errors at the minimum
107 const double * Errors() const override { 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 double CovMatrix(unsigned int i, unsigned int j) const override {
114 return (fCovar.empty()) ? 0 : fCovar[i + fDim* j];
115 }
116
117 /// return covariance matrix status
118 int CovMatrixStatus() const override {
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:335
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
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
int fStatus
status of minimizer
Definition: Minimizer.h:492
The Linear Fitter - For fitting functions that are LINEAR IN PARAMETERS.
TLinearMinimizer class: minimizer implementation based on TMinuit.
double CovMatrix(unsigned int i, unsigned int j) const override
return covariance matrices elements if the variable is fixed the matrix is zero The ordering of the v...
bool ProvidesError() const override
minimizer provides error and error matrix
unsigned int fNFree
void SetFunction(const ROOT::Math::IMultiGenFunction &func) override
set the fit model function
TLinearMinimizer & operator=(const TLinearMinimizer &rhs)
Assignment operator.
double MinValue() const override
return minimum function value
TLinearFitter * fFitter
~TLinearMinimizer() override
Destructor (no operations)
bool fRobust
return reference to the objective function virtual const ROOT::Math::IGenFunction & Function() const;
const double * X() const override
return pointer to X values at the minimum
unsigned int NDim() const override
this is <= Function().NDim() which is the total number of variables (free+ constrained ones)
bool SetVariable(unsigned int, const std::string &, double, double) override
set free variable (dummy impl. )
int CovMatrixStatus() const override
return covariance matrix status
const double * Errors() const override
return errors at the minimum
const ROOT::Math::IMultiGradFunction * fObjFunc
bool Minimize() override
method to perform the minimization
double Edm() const override
return expected distance reached from the minimum
std::vector< double > fParams
TLinearMinimizer(int type=0)
Default constructor.
std::vector< double > fCovar
std::vector< double > fErrors
unsigned int NFree() const override
number of free variables (real dimension of the problem) this is <= Function().NDim() which is the to...
const double * MinGradient() const override
return pointer to gradient values at the minimum
unsigned int NCalls() const override
number of function calls to reach the minimum
bool SetFixedVariable(unsigned int, const std::string &, double) override
set fixed variable (override if minimizer supports them )