Logo ROOT  
Reference Guide
MnApplication.h
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
10 #ifndef ROOT_Minuit2_MnApplication
11 #define ROOT_Minuit2_MnApplication
12 
14 #include "Minuit2/MnStrategy.h"
15 
16 #include <vector>
17 
18 namespace ROOT {
19 
20  namespace Minuit2 {
21 
22 
23 class FunctionMinimum;
24 class MinuitParameter;
25 class MnMachinePrecision;
26 class ModularFunctionMinimizer;
27 class FCNBase;
28 class FCNGradientBase;
29 
30 //___________________________________________________________________________
31 /**
32  application interface class for minimizers (migrad, simplex, Minimize,
33  Scan)
34  User normally instantiates the derived class like ROOT::Minuit2::MnMigrad
35  for using Migrad for minimization
36  */
37 
38 class MnApplication {
39 
40 public:
41 
42 
43  /// constructor from non-gradient functions
44  MnApplication(const FCNBase& fcn, const MnUserParameterState& state, const MnStrategy& stra, unsigned int nfcn = 0);
45 
46  /// constructor from gradient function
47  MnApplication(const FCNGradientBase& fcn, const MnUserParameterState& state, const MnStrategy& stra, unsigned int nfcn = 0);
48 
49  virtual ~MnApplication() { }
50 
51  /**
52  Minimize the function
53  @param maxfcn : max number of function calls (if = 0) default is used which is set to
54  200 + 100 * npar + 5 * npar**2
55  @param tolerance : value used for terminating iteration procedure.
56  For example, MIGRAD will stop iterating when edm (expected distance from minimum) will be:
57  edm < tolerance * 10**-3
58  Default value of tolerance used is 0.1
59  */
60  virtual FunctionMinimum operator()(unsigned int maxfcn = 0, double tolerance = 0.1);
61 
62  virtual ModularFunctionMinimizer& Minimizer() = 0;
63  virtual const ModularFunctionMinimizer& Minimizer() const = 0;
64 
65  const MnMachinePrecision& Precision() const {return fState.Precision();}
66  const MnUserParameterState& State() const {return fState;}
67  const MnUserParameters& Parameters() const {return fState.Parameters();}
68  const MnUserCovariance& Covariance() const {return fState.Covariance();}
69  virtual const FCNBase& Fcnbase() const {return fFCN;}
70  const MnStrategy& Strategy() const {return fStrategy;}
71  unsigned int NumOfCalls() const {return fNumCall;}
72 
73 protected:
74 
75  const FCNBase& fFCN;
78  unsigned int fNumCall;
79  bool fUseGrad;
80 
81 public:
82 
83 // facade: forward interface of MnUserParameters and MnUserTransformation
84 // via MnUserParameterState
85 
86  //access to parameters (row-wise)
87  const std::vector<ROOT::Minuit2::MinuitParameter>& MinuitParameters() const;
88  //access to parameters and errors in column-wise representation
89  std::vector<double> Params() const;
90  std::vector<double> Errors() const;
91 
92  //access to single Parameter
93  const MinuitParameter& Parameter(unsigned int i) const;
94 
95  //add free Parameter
96  void Add(const char* Name, double val, double err);
97  //add limited Parameter
98  void Add(const char* Name, double val, double err, double , double);
99  //add const Parameter
100  void Add(const char*, double);
101 
102  //interaction via external number of Parameter
103  void Fix(unsigned int);
104  void Release(unsigned int);
105  void SetValue(unsigned int, double);
106  void SetError(unsigned int, double);
107  void SetLimits(unsigned int, double, double);
108  void RemoveLimits(unsigned int);
109 
110  double Value(unsigned int) const;
111  double Error(unsigned int) const;
112 
113  //interaction via Name of Parameter
114  void Fix(const char*);
115  void Release(const char*);
116  void SetValue(const char*, double);
117  void SetError(const char*, double);
118  void SetLimits(const char*, double, double);
119  void RemoveLimits(const char*);
120  void SetPrecision(double);
121 
122  double Value(const char*) const;
123  double Error(const char*) const;
124 
125  //convert Name into external number of Parameter
126  unsigned int Index(const char*) const;
127  //convert external number into Name of Parameter
128  const char* Name(unsigned int) const;
129 
130  // transformation internal <-> external
131  double Int2ext(unsigned int, double) const;
132  double Ext2int(unsigned int, double) const;
133  unsigned int IntOfExt(unsigned int) const;
134  unsigned int ExtOfInt(unsigned int) const;
135  unsigned int VariableParameters() const;
136 
137 };
138 
139  } // namespace Minuit2
140 
141 } // namespace ROOT
142 
143 #endif // ROOT_Minuit2_MnApplication
ROOT::Minuit2::MinuitParameter
class for the individual Minuit Parameter with Name and number; contains the input numbers for the mi...
Definition: MinuitParameter.h:41
ROOT::Minuit2::MnApplication::Fix
void Fix(unsigned int)
Definition: MnApplication.cxx:131
ROOT::Minuit2::MnApplication::RemoveLimits
void RemoveLimits(unsigned int)
Definition: MnApplication.cxx:145
ROOT::Minuit2::MnApplication::SetError
void SetError(unsigned int, double)
Definition: MnApplication.cxx:137
ROOT::Minuit2::MnApplication::Add
void Add(const char *Name, double val, double err)
Definition: MnApplication.cxx:115
ROOT::Minuit2::MnApplication::fFCN
const FCNBase & fFCN
Definition: MnApplication.h:83
ROOT::Minuit2::MnApplication::fUseGrad
bool fUseGrad
Definition: MnApplication.h:87
ROOT::Minuit2::MnApplication::~MnApplication
virtual ~MnApplication()
Definition: MnApplication.h:57
MnStrategy.h
ROOT::Minuit2::MnApplication::SetLimits
void SetLimits(unsigned int, double, double)
Definition: MnApplication.cxx:141
ROOT::Minuit2::FCNBase
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
Definition: FCNBase.h:55
ROOT::Minuit2::MnApplication::Ext2int
double Ext2int(unsigned int, double) const
Definition: MnApplication.cxx:178
ROOT::Minuit2::MnApplication::Error
double Error(unsigned int) const
Definition: MnApplication.cxx:148
MnUserParameterState.h
ROOT::Minuit2::MnApplication::Release
void Release(unsigned int)
Definition: MnApplication.cxx:132
ROOT::Minuit2::MnApplication::MinuitParameters
const std::vector< ROOT::Minuit2::MinuitParameter > & MinuitParameters() const
Definition: MnApplication.cxx:100
ROOT::Minuit2::MnApplication::Fcnbase
virtual const FCNBase & Fcnbase() const
Definition: MnApplication.h:77
ROOT::Minuit2::MnApplication::Value
double Value(unsigned int) const
Definition: MnApplication.cxx:147
ROOT::Minuit2::MnApplication::SetPrecision
void SetPrecision(double)
Definition: MnApplication.cxx:157
ROOT::Minuit2::MnApplication::IntOfExt
unsigned int IntOfExt(unsigned int) const
Definition: MnApplication.cxx:182
ROOT::Minuit2::MnApplication::Precision
const MnMachinePrecision & Precision() const
Definition: MnApplication.h:73
ROOT::Minuit2::MnApplication::State
const MnUserParameterState & State() const
Definition: MnApplication.h:74
ROOT::Minuit2::MnApplication::NumOfCalls
unsigned int NumOfCalls() const
Definition: MnApplication.h:79
ROOT::Minuit2::MnApplication::Parameters
const MnUserParameters & Parameters() const
Definition: MnApplication.h:75
ROOT::Minuit2::MnApplication::operator()
virtual FunctionMinimum operator()(unsigned int maxfcn=0, double tolerance=0.1)
Minimize the function.
Definition: MnApplication.cxx:44
ROOT::Minuit2::MnApplication::Params
std::vector< double > Params() const
Definition: MnApplication.cxx:105
ROOT::Minuit2::MnApplication::ExtOfInt
unsigned int ExtOfInt(unsigned int) const
Definition: MnApplication.cxx:186
ROOT::Minuit2::MnApplication::fStrategy
MnStrategy fStrategy
Definition: MnApplication.h:85
ROOT::Minuit2::MnApplication::VariableParameters
unsigned int VariableParameters() const
Definition: MnApplication.cxx:190
ROOT::Minuit2::MnUserParameterState::Precision
const MnMachinePrecision & Precision() const
Definition: MnUserParameterState.cxx:437
ROOT::Minuit2::MnApplication::Index
unsigned int Index(const char *) const
Definition: MnApplication.cxx:163
ROOT::Minuit2::MnMachinePrecision
Sets the relative floating point (double) arithmetic precision.
Definition: MnMachinePrecision.h:41
ROOT::Minuit2::MnApplication::Minimizer
virtual ModularFunctionMinimizer & Minimizer()=0
ROOT::Minuit2::ModularFunctionMinimizer
Base common class providing the API for all the minimizer Various Minimize methods are provided varyi...
Definition: ModularFunctionMinimizer.h:51
ROOT::Minuit2::MnApplication::SetValue
void SetValue(unsigned int, double)
Definition: MnApplication.cxx:133
ROOT::Minuit2::MnApplication::fState
MnUserParameterState fState
Definition: MnApplication.h:84
ROOT::Minuit2::FunctionMinimum
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
Definition: FunctionMinimum.h:40
ROOT::Minuit2::FCNGradientBase
Extension of the FCNBase for providing the analytical Gradient of the function.
Definition: FCNGradientBase.h:42
ROOT::Minuit2::MnUserParameterState
class which holds the external user and/or internal Minuit representation of the parameters and error...
Definition: MnUserParameterState.h:42
ROOT::Minuit2::MnUserParameterState::Parameters
const MnUserParameters & Parameters() const
Definition: MnUserParameterState.h:94
ROOT::Minuit2::MnApplication::Errors
std::vector< double > Errors() const
Definition: MnApplication.cxx:106
ROOT::Minuit2::MnApplication::Covariance
const MnUserCovariance & Covariance() const
Definition: MnApplication.h:76
ROOT::Minuit2::MnStrategy
API class for defining three levels of strategies: low (0), medium (1), high (>=2); acts on: Migrad (...
Definition: MnStrategy.h:35
ROOT::Minuit2::MnApplication::fNumCall
unsigned int fNumCall
Definition: MnApplication.h:86
ROOT::Minuit2::MnUserParameterState::Covariance
const MnUserCovariance & Covariance() const
Definition: MnUserParameterState.h:95
ROOT::Minuit2::MnApplication::Parameter
const MinuitParameter & Parameter(unsigned int i) const
Definition: MnApplication.cxx:109
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Minuit2::MnApplication::Int2ext
double Int2ext(unsigned int, double) const
Definition: MnApplication.cxx:174
ROOT::Minuit2::MnApplication::Name
const char * Name(unsigned int) const
Definition: MnApplication.cxx:168
ROOT::Minuit2::MnApplication::Strategy
const MnStrategy & Strategy() const
Definition: MnApplication.h:78
ROOT::Minuit2::MnApplication::MnApplication
MnApplication(const FCNBase &fcn, const MnUserParameterState &state, const MnStrategy &stra, unsigned int nfcn=0)
constructor from non-gradient functions
Definition: MnApplication.cxx:34