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  ~HybridMinimizer () override;
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  void Clear() override;
89 
91  void SetFunction(const ROOT::Math::IMultiGenFunction & func) override;
92 
94  void SetFunction(const ROOT::Math::IMultiGradFunction & func) override;
95 
97  bool SetVariable(unsigned int ivar, const std::string & name, double val, double step) override;
98 
100  bool SetLowerLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double lower ) override;
102  bool SetUpperLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double upper ) override;
104  bool SetLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double /* lower */, double /* upper */) override;
106  bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */) override;
108  bool SetVariableValue(unsigned int ivar, double val) override;
109  bool SetVariableValues(const double * val) override;
110 
112  std::string VariableName(unsigned int ivar) const override;
113 
116  int VariableIndex(const std::string & name) const override;
117 
130  bool Minimize() override;
131 
133  double MinValue() const override { return fState.Fval(); }
134 
136  double Edm() const override { return fState.Edm(); }
137 
139  const double * X() const override;
140 
142  const double * MinGradient() const override { return nullptr; } // not available in Minuit2
143 
145  unsigned int NCalls() const override { return fState.NFcn(); }
146 
149  unsigned int NDim() const override { return fDim; }
150 
153  unsigned int NFree() const override { return fState.VariableParameters(); }
154 
156  bool ProvidesError() const override { return true; }
157 
159  const double * Errors() const override;
160 
168  double CovMatrix(unsigned int i, unsigned int j) const override;
169 
170 
179  bool GetCovMatrix(double * cov) const override;
180 
188  bool GetHessianMatrix(double * h) const override;
189 
190 
200  int CovMatrixStatus() const override;
205  double Correlation(unsigned int i, unsigned int j ) const override;
206 
213  double GlobalCC(unsigned int i) const override;
214 
227  bool GetMinosError(unsigned int i, double & errLow, double & errUp, int = 0) override;
228 
233  bool Scan(unsigned int i, unsigned int & nstep, double * x, double * y, double xmin = 0, double xmax = 0) override;
234 
239  bool Contour(unsigned int i, unsigned int j, unsigned int & npoints, double *xi, double *xj) override;
240 
241 
252  bool Hesse() override;
253 
254 
257 
259  void PrintResults() override;
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
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
double MinValue() const override
return minimum function value
ROOT::Minuit2::MnUserParameterState fState
#define X(str)
Definition: MuonsGrabber.cc:48
ROOT::Minuit2::FCNBase * fMinuitFCN
ROOT::Minuit2::FunctionMinimum * fMinimum
unsigned int NDim() const override
std::vector< double > fErrors
const ROOT::Minuit2::MnUserParameterState & State()
return the minimizer state (containing values, step size , etc..)
const double * MinGradient() const override
return pointer to gradient values at the minimum
virtual void SetMinimizer(ROOT::Minuit2::ModularFunctionMinimizer *m)
unsigned int NFree() const override
static const int npoints
T min(T a, T b)
Definition: MathUtil.h:58
unsigned int NCalls() const override
number of function calls to reach the minimum
std::vector< double > fValues
const char * kMigrad
ROOT::Minuit2::ModularFunctionMinimizer * fMinimizer
virtual const ROOT::Minuit2::ModularFunctionMinimizer * GetMinimizer() const
step
Definition: StallMonitor.cc:94
virtual const ROOT::Minuit2::FCNBase * GetFCN() const
double Edm() const override
return expected distance reached from the minimum
bool ProvidesError() const override
minimizer provides error and error matrix