CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  } // namespace Minuit2
32 } // namespace ROOT
33 
34 //_____________________________________________________________________________________________________
43 namespace PSFitter {
44 
45  class HybridMinimizer : public ROOT::Math::Minimizer {
46  public:
48 
53 
57  HybridMinimizer(const char *type);
58 
62  ~HybridMinimizer() override;
63 
64  private:
65  // usually copying is non trivial, so we make this unaccessible
66 
71 
76 
77  public:
78  // clear resources (parameters) for consecutives minimizations
79  void Clear() override;
80 
82  void SetFunction(const ROOT::Math::IMultiGenFunction &func) override;
83 
85  void SetFunction(const ROOT::Math::IMultiGradFunction &func) override;
86 
88  bool SetVariable(unsigned int ivar, const std::string &name, double val, double step) override;
89 
92  unsigned int ivar, const std::string &name, double val, double step, double lower) override;
95  unsigned int ivar, const std::string &name, double val, double step, double upper) override;
97  bool SetLimitedVariable(unsigned int ivar,
98  const std::string &name,
99  double val,
100  double step,
101  double /* lower */,
102  double /* upper */) override;
104  bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */) override;
106  bool SetVariableValue(unsigned int ivar, double val) override;
107  bool SetVariableValues(const double *val) override;
108 
110  std::string VariableName(unsigned int ivar) const override;
111 
114  int VariableIndex(const std::string &name) const override;
115 
128  bool Minimize() override;
129 
131  double MinValue() const override { return fState.Fval(); }
132 
134  double Edm() const override { return fState.Edm(); }
135 
137  const double *X() const override;
138 
140  const double *MinGradient() const override { return nullptr; } // not available in Minuit2
141 
143  unsigned int NCalls() const override { return fState.NFcn(); }
144 
147  unsigned int NDim() const override { return fDim; }
148 
151  unsigned int NFree() const override { return fState.VariableParameters(); }
152 
154  bool ProvidesError() const override { return true; }
155 
157  const double *Errors() const override;
158 
166  double CovMatrix(unsigned int i, unsigned int j) const override;
167 
176  bool GetCovMatrix(double *cov) const override;
177 
185  bool GetHessianMatrix(double *h) const override;
186 
196  int CovMatrixStatus() const override;
201  double Correlation(unsigned int i, unsigned int j) const override;
202 
209  double GlobalCC(unsigned int i) const override;
210 
223  bool GetMinosError(unsigned int i, double &errLow, double &errUp, int = 0) override;
224 
229  bool Scan(unsigned int i, unsigned int &nstep, double *x, double *y, double xmin = 0, double xmax = 0) override;
230 
235  bool Contour(unsigned int i, unsigned int j, unsigned int &npoints, double *xi, double *xj) override;
236 
247  bool Hesse() override;
248 
251 
253  void PrintResults() override;
254 
256  const ROOT::Minuit2::MnUserParameterState &State() { return fState; }
257 
259 
260  protected:
261  // protected function for accessing the internal Minuit2 object. Needed for derived classes
262 
263  virtual const ROOT::Minuit2::ModularFunctionMinimizer *GetMinimizer() const { return fMinimizer; }
264 
265  virtual void SetMinimizer(ROOT::Minuit2::ModularFunctionMinimizer *m) { fMinimizer = m; }
266 
267  virtual const ROOT::Minuit2::FCNBase *GetFCN() const { return fMinuitFCN; }
268 
270  bool ExamineMinimum(const ROOT::Minuit2::FunctionMinimum &min);
271 
272  private:
273  unsigned int fDim; // dimension of the function to be minimized
275 
276  ROOT::Minuit2::MnUserParameterState fState;
277  // std::vector<ROOT::Minuit2::MinosError> fMinosErrors;
278  ROOT::Minuit2::ModularFunctionMinimizer *fMinimizer;
279  ROOT::Minuit2::FCNBase *fMinuitFCN;
280  ROOT::Minuit2::FunctionMinimum *fMinimum;
281  mutable std::vector<double> fValues;
282  mutable std::vector<double> fErrors;
283  };
284 
285 } // namespace PSFitter
286 #endif
bool SetVariable(unsigned int ivar, const std::string &name, double val, double step) override
set free variable
unsigned int NCalls() const override
number of function calls to reach the minimum
bool Contour(unsigned int i, unsigned int j, unsigned int &npoints, double *xi, double *xj) override
ROOT::Minuit2::MnUserParameterState fState
ROOT::Minuit2::FCNBase * fMinuitFCN
ROOT::Minuit2::FunctionMinimum * fMinimum
HybridMinimizer(EMinimizerType type=kMigrad)
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t Func __host__ __device__ V int Func func
const double * MinGradient() const override
return pointer to gradient values at the minimum
void SetFunction(const ROOT::Math::IMultiGenFunction &func) override
set the function to minimize
bool SetVariableValue(unsigned int ivar, double val) override
set variable
bool SetLowerLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double lower) override
set lower limit variable (override if minimizer supports them )
unsigned int NFree() const override
void SetMinimizerType(EMinimizerType type)
bool GetMinosError(unsigned int i, double &errLow, double &errUp, int=0) override
std::vector< double > fErrors
const ROOT::Minuit2::MnUserParameterState & State()
return the minimizer state (containing values, step size , etc..)
const double * Errors() const override
return errors at the minimum
bool SetFixedVariable(unsigned int, const std::string &, double) override
set fixed variable (override if minimizer supports them )
double Edm() const override
return expected distance reached from the minimum
bool ExamineMinimum(const ROOT::Minuit2::FunctionMinimum &min)
examine the minimum result
bool GetCovMatrix(double *cov) const override
virtual void SetMinimizer(ROOT::Minuit2::ModularFunctionMinimizer *m)
double GlobalCC(unsigned int i) const override
bool GetHessianMatrix(double *h) const override
bool SetVariableValues(const double *val) override
static const int npoints
T min(T a, T b)
Definition: MathUtil.h:58
double Correlation(unsigned int i, unsigned int j) const override
unsigned int NDim() const override
std::string VariableName(unsigned int ivar) const override
get name of variables (override if minimizer support storing of variable names)
HybridMinimizer & operator=(const HybridMinimizer &rhs)
double MinValue() const override
return minimum function value
bool ProvidesError() const override
minimizer provides error and error matrix
int CovMatrixStatus() const override
int VariableIndex(const std::string &name) const override
std::vector< double > fValues
ROOT::Minuit2::ModularFunctionMinimizer * fMinimizer
bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double, double) override
set upper/lower limited variable (override if minimizer supports them )
virtual const ROOT::Minuit2::ModularFunctionMinimizer * GetMinimizer() const
double CovMatrix(unsigned int i, unsigned int j) const override
step
Definition: StallMonitor.cc:94
const double * X() const override
return pointer to X values at the minimum
void PrintResults() override
print result of minimization
virtual const ROOT::Minuit2::FCNBase * GetFCN() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
bool Scan(unsigned int i, unsigned int &nstep, double *x, double *y, double xmin=0, double xmax=0) override
bool SetUpperLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double upper) override
set upper limit variable (override if minimizer supports them )