CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
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 
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 
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
virtual bool GetHessianMatrix(double *h) const
type
Definition: HCALResponse.h:21
virtual bool GetMinosError(unsigned int i, double &errLow, double &errUp, int=0)
int i
Definition: DBlmapReader.cc:9
virtual bool SetVariableValue(unsigned int ivar, double val)
set variable
virtual double Edm() const
return expected distance reached from the minimum
ROOT::Minuit2::MnUserParameterState fState
ROOT::Minuit2::FCNBase * fMinuitFCN
ROOT::Minuit2::FunctionMinimum * fMinimum
HybridMinimizer(EMinimizerType type=kMigrad)
virtual unsigned int NFree() const
virtual double Correlation(unsigned int i, unsigned int j) const
virtual const double * X() const
return pointer to X values at the minimum
virtual bool ProvidesError() const
minimizer provides error and error matrix
void SetMinimizerType(EMinimizerType type)
virtual unsigned int NDim() const
virtual bool SetLowerLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double lower)
set lower limit variable (override if minimizer supports them )
std::vector< double > fErrors
const ROOT::Minuit2::MnUserParameterState & State()
return the minimizer state (containing values, step size , etc..)
bool ExamineMinimum(const ROOT::Minuit2::FunctionMinimum &min)
examine the minimum result
virtual double MinValue() const
return minimum function value
virtual bool Scan(unsigned int i, unsigned int &nstep, double *x, double *y, double xmin=0, double xmax=0)
virtual void SetMinimizer(ROOT::Minuit2::ModularFunctionMinimizer *m)
virtual std::string VariableName(unsigned int ivar) const
get name of variables (override if minimizer support storing of variable names)
int j
Definition: DBlmapReader.cc:9
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
static const int npoints
T min(T a, T b)
Definition: MathUtil.h:58
virtual bool SetFixedVariable(unsigned int, const std::string &, double)
set fixed variable (override if minimizer supports them )
virtual int VariableIndex(const std::string &name) const
HybridMinimizer & operator=(const HybridMinimizer &rhs)
virtual const double * MinGradient() const
return pointer to gradient values at the minimum
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)
set the function to minimize
std::vector< double > fValues
virtual bool SetUpperLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double upper)
set upper limit variable (override if minimizer supports them )
virtual void PrintResults()
print result of minimization
ROOT::Minuit2::ModularFunctionMinimizer * fMinimizer
virtual bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double, double)
set upper/lower limited variable (override if minimizer supports them )
virtual bool Contour(unsigned int i, unsigned int j, unsigned int &npoints, double *xi, double *xj)
virtual bool SetVariableValues(const double *val)
virtual double GlobalCC(unsigned int i) const
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)
set free variable
virtual const ROOT::Minuit2::ModularFunctionMinimizer * GetMinimizer() const
virtual bool GetCovMatrix(double *cov) const
virtual int CovMatrixStatus() const
virtual const ROOT::Minuit2::FCNBase * GetFCN() const
virtual double CovMatrix(unsigned int i, unsigned int j) const
virtual unsigned int NCalls() const
number of function calls to reach the minimum
virtual const double * Errors() const
return errors at the minimum