Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 free variable (dummy impl. since there is no need to set variables in the Linear Fitter)
69 bool SetVariable(unsigned int , const std::string & , double , double ) override { return true; }
70
71 /// set fixed variable (override if minimizer supports them )
72 bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */) override;
73
74 /// method to perform the minimization
75 bool Minimize() override;
76
77 /// return minimum function value
78 double MinValue() const override { return fMinVal; }
79
80 /// return expected distance reached from the minimum
81 double Edm() const override { return 0; }
82
83 /// return pointer to X values at the minimum
84 const double * X() const override { return &fParams.front(); }
85
86 /// return pointer to gradient values at the minimum
87 const double * MinGradient() const override { return nullptr; } // not available in Minuit2
88
89 /// number of function calls to reach the minimum
90 unsigned int NCalls() const override { return 0; }
91
92 /// this is <= Function().NDim() which is the total
93 /// number of variables (free+ constrained ones)
94 unsigned int NDim() const override { return fDim; }
95
96 /// number of free variables (real dimension of the problem)
97 /// this is <= Function().NDim() which is the total
98 unsigned int NFree() const override { return fNFree; }
99
100 /// minimizer provides error and error matrix
101 bool ProvidesError() const override { return true; }
102
103 /// return errors at the minimum
104 const double * Errors() const override { return fErrors.empty() ? nullptr : &fErrors.front(); }
105
106 /** return covariance matrices elements
107 if the variable is fixed the matrix is zero
108 The ordering of the variables is the same as in errors
109 */
110 double CovMatrix(unsigned int i, unsigned int j) const override {
111 return (fCovar.empty()) ? 0 : fCovar[i + fDim* j];
112 }
113
114 /// return covariance matrix status
115 int CovMatrixStatus() const override {
116 if (fCovar.empty()) return 0;
117 return (fStatus ==0) ? 3 : 1;
118 }
119
120 /// return reference to the objective function
121 ///virtual const ROOT::Math::IGenFunction & Function() const;
122
123
124
125
126protected:
127
128private:
129
131 unsigned int fDim;
132 unsigned int fNFree;
133 double fMinVal;
134 std::vector<double> fParams;
135 std::vector<double> fErrors;
136 std::vector<double> fCovar;
137
140
141 ClassDef(TLinearMinimizer,1) //Implementation of the Minimizer interface using TLinearFitter
142
143};
144
145
146
147#endif /* ROOT_TLinearMinimizer */
#define ClassDef(name, id)
Definition Rtypes.h:337
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:61
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Definition IFunction.h:168
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
Definition Minimizer.h:117
int fStatus
status of minimizer
Definition Minimizer.h:391
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
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. since there is no need to set variables in the Linear Fitter)
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
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 )