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  } // 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
274  bool fUseFumili;
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
npoints
static const int npoints
Definition: NuclearInteractionFTFSimulator.h:38
PSFitter::HybridMinimizer::SetVariable
bool SetVariable(unsigned int ivar, const std::string &name, double val, double step) override
set free variable
Definition: HybridMinimizer.cc:164
mps_fire.i
i
Definition: mps_fire.py:428
PSFitter::HybridMinimizer::operator=
HybridMinimizer & operator=(const HybridMinimizer &rhs)
Definition: HybridMinimizer.cc:146
PSFitter::HybridMinimizer::kFumili
Definition: HybridMinimizer.h:46
PSFitter::HybridMinimizer::PrintResults
void PrintResults() override
print result of minimization
Definition: HybridMinimizer.cc:473
PSFitter::HybridMinimizer::kCombined
Definition: HybridMinimizer.h:46
PSFitter::HybridMinimizer::State
const ROOT::Minuit2::MnUserParameterState & State()
return the minimizer state (containing values, step size , etc..)
Definition: HybridMinimizer.h:255
PSFitter::HybridMinimizer::GetCovMatrix
bool GetCovMatrix(double *cov) const override
Definition: HybridMinimizer.cc:560
PSFitter::HybridMinimizer::MinGradient
const double * MinGradient() const override
return pointer to gradient values at the minimum
Definition: HybridMinimizer.h:139
step
step
Definition: StallMonitor.cc:94
PSFitter::HybridMinimizer::NFree
unsigned int NFree() const override
Definition: HybridMinimizer.h:150
min
T min(T a, T b)
Definition: MathUtil.h:58
PSFitter::HybridMinimizer::CovMatrixStatus
int CovMatrixStatus() const override
Definition: HybridMinimizer.cc:978
PSFitter::HybridMinimizer::~HybridMinimizer
~HybridMinimizer() override
Definition: HybridMinimizer.cc:132
PSFitter::HybridMinimizer::fValues
std::vector< double > fValues
Definition: HybridMinimizer.h:280
PSFitter::HybridMinimizer::GetMinimizer
virtual const ROOT::Minuit2::ModularFunctionMinimizer * GetMinimizer() const
Definition: HybridMinimizer.h:262
PSFitter::HybridMinimizer::Correlation
double Correlation(unsigned int i, unsigned int j) const override
Definition: HybridMinimizer.cc:618
PSFitter
Definition: HybridMinimizer.cc:45
hybridSuperClusters_cfi.xi
xi
Definition: hybridSuperClusters_cfi.py:10
PSFitter::HybridMinimizer::NCalls
unsigned int NCalls() const override
number of function calls to reach the minimum
Definition: HybridMinimizer.h:142
PSFitter::HybridMinimizer::SetUpperLimitedVariable
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 )
Definition: HybridMinimizer.cc:201
PSFitter::HybridMinimizer::GetHessianMatrix
bool GetHessianMatrix(double *h) const override
Definition: HybridMinimizer.cc:588
PSFitter::HybridMinimizer::Errors
const double * Errors() const override
return errors at the minimum
Definition: HybridMinimizer.cc:524
PSFitter::HybridMinimizer::SetFunction
void SetFunction(const ROOT::Math::IMultiGenFunction &func) override
set the function to minimize
Definition: HybridMinimizer.cc:262
PSFitter::HybridMinimizer::fMinimum
ROOT::Minuit2::FunctionMinimum * fMinimum
Definition: HybridMinimizer.h:279
PSFitter::HybridMinimizer::fState
ROOT::Minuit2::MnUserParameterState fState
Definition: HybridMinimizer.h:275
PSFitter::HybridMinimizer::GetFCN
virtual const ROOT::Minuit2::FCNBase * GetFCN() const
Definition: HybridMinimizer.h:266
PSFitter::HybridMinimizer::MinValue
double MinValue() const override
return minimum function value
Definition: HybridMinimizer.h:130
PSFitter::HybridMinimizer::SetMinimizerType
void SetMinimizerType(EMinimizerType type)
Definition: HybridMinimizer.cc:100
PSFitter::HybridMinimizer::X
const double * X() const override
return pointer to X values at the minimum
Definition: HybridMinimizer.cc:507
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
PSFitter::HybridMinimizer::GetMinosError
bool GetMinosError(unsigned int i, double &errLow, double &errUp, int=0) override
Definition: HybridMinimizer.cc:653
PSFitter::HybridMinimizer::SetLowerLimitedVariable
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 )
Definition: HybridMinimizer.cc:192
h
PSFitter::HybridMinimizer::fDim
unsigned int fDim
Definition: HybridMinimizer.h:272
PSFitter::HybridMinimizer::SetMinimizer
virtual void SetMinimizer(ROOT::Minuit2::ModularFunctionMinimizer *m)
Definition: HybridMinimizer.h:264
PSFitter::HybridMinimizer::Scan
bool Scan(unsigned int i, unsigned int &nstep, double *x, double *y, double xmin=0, double xmax=0) override
Definition: HybridMinimizer.cc:806
PSFitter::HybridMinimizer::Hesse
bool Hesse() override
Definition: HybridMinimizer.cc:910
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PSFitter::HybridMinimizer::HybridMinimizer
HybridMinimizer(EMinimizerType type=kMigrad)
Definition: HybridMinimizer.cc:73
PSFitter::HybridMinimizer::Minimize
bool Minimize() override
Definition: HybridMinimizer.cc:298
PSFitter::HybridMinimizer::SetVariableValue
bool SetVariableValue(unsigned int ivar, double val) override
set variable
Definition: HybridMinimizer.cc:244
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
PSFitter::HybridMinimizer::fMinuitFCN
ROOT::Minuit2::FCNBase * fMinuitFCN
Definition: HybridMinimizer.h:278
PSFitter::HybridMinimizer::kScan
Definition: HybridMinimizer.h:46
PSFitter::HybridMinimizer::fErrors
std::vector< double > fErrors
Definition: HybridMinimizer.h:281
PSFitter::HybridMinimizer::fMinimizer
ROOT::Minuit2::ModularFunctionMinimizer * fMinimizer
Definition: HybridMinimizer.h:277
PSFitter::HybridMinimizer::kMigrad
Definition: HybridMinimizer.h:46
PSFitter::HybridMinimizer::SetLimitedVariable
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 )
Definition: HybridMinimizer.cc:210
PSFitter::HybridMinimizer::SetVariableValues
bool SetVariableValues(const double *val) override
Definition: HybridMinimizer.cc:252
TrackCollections2monitor_cff.func
func
Definition: TrackCollections2monitor_cff.py:359
PSFitter::HybridMinimizer::EMinimizerType
EMinimizerType
Definition: HybridMinimizer.h:46
PSFitter::HybridMinimizer
Definition: HybridMinimizer.h:44
PSFitter::HybridMinimizer::CovMatrix
double CovMatrix(unsigned int i, unsigned int j) const override
Definition: HybridMinimizer.cc:545
PSFitter::HybridMinimizer::kSimplex
Definition: HybridMinimizer.h:46
heppy_batch.val
val
Definition: heppy_batch.py:351
PSFitter::HybridMinimizer::Edm
double Edm() const override
return expected distance reached from the minimum
Definition: HybridMinimizer.h:133
PSFitter::HybridMinimizer::VariableName
std::string VariableName(unsigned int ivar) const override
get name of variables (override if minimizer support storing of variable names)
Definition: HybridMinimizer.cc:231
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
PSFitter::HybridMinimizer::Clear
void Clear() override
Definition: HybridMinimizer.cc:153
pileupCalc.upper
upper
Definition: pileupCalc.py:214
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
PSFitter::HybridMinimizer::ProvidesError
bool ProvidesError() const override
minimizer provides error and error matrix
Definition: HybridMinimizer.h:153
PSFitter::HybridMinimizer::VariableIndex
int VariableIndex(const std::string &name) const override
Definition: HybridMinimizer.cc:238
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PSFitter::HybridMinimizer::NDim
unsigned int NDim() const override
Definition: HybridMinimizer.h:146
PSFitter::HybridMinimizer::SetFixedVariable
bool SetFixedVariable(unsigned int, const std::string &, double) override
set fixed variable (override if minimizer supports them )
Definition: HybridMinimizer.cc:219
PSFitter::HybridMinimizer::fUseFumili
bool fUseFumili
Definition: HybridMinimizer.h:273
PSFitter::HybridMinimizer::GlobalCC
double GlobalCC(unsigned int i) const override
Definition: HybridMinimizer.cc:637
ROOT
Definition: Transform3DPJ.h:35
PSFitter::HybridMinimizer::Contour
bool Contour(unsigned int i, unsigned int j, unsigned int &npoints, double *xi, double *xj) override
Definition: HybridMinimizer.cc:863
PSFitter::HybridMinimizer::ExamineMinimum
bool ExamineMinimum(const ROOT::Minuit2::FunctionMinimum &min)
examine the minimum result
Definition: HybridMinimizer.cc:408