CMS 3D CMS Logo

HybridMinimizer.h
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Author: L. Moneta Wed Oct 18 11:48:00 2006
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Header file for class HybridMinimizer
12 
13 #ifndef ROOT_Minuit2_HybridMinimizer
14 #define ROOT_Minuit2_HybridMinimizer
15 
16 #include "Math/Minimizer.h"
17 #include "Minuit2/MnUserParameterState.h"
18 #include "Math/IFunctionfwd.h"
19 #include "Minuit2/MinosError.h"
20 #include "Minuit2/ModularFunctionMinimizer.h"
21 #include "Minuit2/FumiliMinimizer.h"
22 
23 namespace ROOT {
24 
25  namespace Minuit2 {
26 
27  class ModularFunctionMinimizer;
28  class FCNBase;
29  class FunctionMinimum;
30 
31  }
32 }
33 
34 //_____________________________________________________________________________________________________
43 namespace PSFitter{
44 
45 class HybridMinimizer : public ROOT::Math::Minimizer {
46 
47 public:
48 
54  kFumili
55  };
56 
61 
65  HybridMinimizer (const char * type);
66 
70  virtual ~HybridMinimizer ();
71 
72 private:
73  // usually copying is non trivial, so we make this unaccessible
74 
79 
83  HybridMinimizer & operator = (const HybridMinimizer & rhs);
84 
85 public:
86 
87  // clear resources (parameters) for consecutives minimizations
88  virtual void Clear();
89 
91  virtual void SetFunction(const ROOT::Math::IMultiGenFunction & func);
92 
94  virtual void SetFunction(const ROOT::Math::IMultiGradFunction & func);
95 
97  virtual bool SetVariable(unsigned int ivar, const std::string & name, double val, double step);
98 
100  virtual bool SetLowerLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double lower );
102  virtual bool SetUpperLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double upper );
104  virtual bool SetLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double /* lower */, double /* upper */);
106  virtual bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */);
108  virtual bool SetVariableValue(unsigned int ivar, double val);
109  virtual bool SetVariableValues(const double * val);
110 
112  virtual std::string VariableName(unsigned int ivar) const;
113 
116  virtual int VariableIndex(const std::string & name) const;
117 
130  virtual bool Minimize();
131 
133  virtual double MinValue() const { return fState.Fval(); }
134 
136  virtual double Edm() const { return fState.Edm(); }
137 
139  virtual const double * X() const;
140 
142  virtual const double * MinGradient() const { return 0; } // not available in Minuit2
143 
145  virtual unsigned int NCalls() const { return fState.NFcn(); }
146 
149  virtual unsigned int NDim() const { return fDim; }
150 
153  virtual unsigned int NFree() const { return fState.VariableParameters(); }
154 
156  virtual bool ProvidesError() const { return true; }
157 
159  virtual const double * Errors() const;
160 
168  virtual double CovMatrix(unsigned int i, unsigned int j) const;
169 
170 
179  virtual bool GetCovMatrix(double * cov) const;
180 
188  virtual bool GetHessianMatrix(double * h) const;
189 
190 
200  virtual int CovMatrixStatus() const;
205  virtual double Correlation(unsigned int i, unsigned int j ) const;
206 
213  virtual double GlobalCC(unsigned int i) const;
214 
227  virtual bool GetMinosError(unsigned int i, double & errLow, double & errUp, int = 0);
228 
233  virtual bool Scan(unsigned int i, unsigned int & nstep, double * x, double * y, double xmin = 0, double xmax = 0);
234 
239  virtual bool Contour(unsigned int i, unsigned int j, unsigned int & npoints, double *xi, double *xj);
240 
241 
252  virtual bool Hesse();
253 
254 
257 
259  virtual void PrintResults();
260 
262  const ROOT::Minuit2::MnUserParameterState & State() { return fState; }
263 
264  void SetMinimizerType( EMinimizerType type);
265 
266 protected:
267 
268  // protected function for accessing the internal Minuit2 object. Needed for derived classes
269 
270  virtual const ROOT::Minuit2::ModularFunctionMinimizer * GetMinimizer() const { return fMinimizer; }
271 
272  virtual void SetMinimizer( ROOT::Minuit2::ModularFunctionMinimizer * m) { fMinimizer = m; }
273 
274  virtual const ROOT::Minuit2::FCNBase * GetFCN() const { return fMinuitFCN; }
275 
277  bool ExamineMinimum(const ROOT::Minuit2::FunctionMinimum & min);
278 
279 private:
280 
281  unsigned int fDim; // dimension of the function to be minimized
282  bool fUseFumili;
283 
284  ROOT::Minuit2::MnUserParameterState fState;
285  // std::vector<ROOT::Minuit2::MinosError> fMinosErrors;
286  ROOT::Minuit2::ModularFunctionMinimizer * fMinimizer;
287  ROOT::Minuit2::FCNBase * fMinuitFCN;
288  ROOT::Minuit2::FunctionMinimum * fMinimum;
289  mutable std::vector<double> fValues;
290  mutable std::vector<double> fErrors;
291 
292 };
293 
294 }
295 #endif
type
Definition: HCALResponse.h:21
virtual double Edm() const
return expected distance reached from the minimum
ROOT::Minuit2::MnUserParameterState fState
#define X(str)
Definition: MuonsGrabber.cc:48
ROOT::Minuit2::FCNBase * fMinuitFCN
ROOT::Minuit2::FunctionMinimum * fMinimum
virtual unsigned int NFree() const
virtual bool ProvidesError() const
minimizer provides error and error matrix
T x() const
Cartesian x coordinate.
virtual unsigned int NDim() const
std::vector< double > fErrors
const ROOT::Minuit2::MnUserParameterState & State()
return the minimizer state (containing values, step size , etc..)
virtual double MinValue() const
return minimum function value
virtual void SetMinimizer(ROOT::Minuit2::ModularFunctionMinimizer *m)
static const int npoints
T min(T a, T b)
Definition: MathUtil.h:58
virtual const double * MinGradient() const
return pointer to gradient values at the minimum
std::vector< double > fValues
const char * kMigrad
ROOT::Minuit2::ModularFunctionMinimizer * fMinimizer
virtual const ROOT::Minuit2::ModularFunctionMinimizer * GetMinimizer() const
step
virtual const ROOT::Minuit2::FCNBase * GetFCN() const
virtual unsigned int NCalls() const
number of function calls to reach the minimum