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