Warning, file /include/root/TMinuitMinimizer.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ROOT_TMinuitMinimizer
0014 #define ROOT_TMinuitMinimizer
0015
0016 #include "Math/Minimizer.h"
0017
0018 #include "Rtypes.h"
0019
0020 #include <vector>
0021 #include <string>
0022
0023 class TMinuit;
0024
0025 namespace ROOT {
0026
0027 namespace Minuit {
0028
0029
0030
0031 enum EMinimizerType {
0032 kMigrad,
0033 kSimplex,
0034 kCombined,
0035 kMigradImproved,
0036 kScan,
0037 kSeek
0038 };
0039
0040 }
0041 }
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 class TMinuitMinimizer : public ROOT::Math::Minimizer {
0052
0053 public:
0054
0055
0056
0057
0058 TMinuitMinimizer ( ROOT::Minuit::EMinimizerType type = ROOT::Minuit::kMigrad, unsigned int ndim = 0);
0059
0060
0061
0062
0063 TMinuitMinimizer ( const char * type , unsigned int ndim = 0);
0064
0065
0066
0067
0068 ~TMinuitMinimizer () override;
0069
0070 private:
0071
0072
0073
0074
0075
0076 TMinuitMinimizer(const TMinuitMinimizer &);
0077
0078
0079
0080
0081 TMinuitMinimizer & operator = (const TMinuitMinimizer & rhs);
0082
0083 public:
0084
0085
0086 void SetFunction(const ROOT::Math::IMultiGenFunction & func) override;
0087
0088
0089 bool SetVariable(unsigned int ivar, const std::string & name, double val, double step) override;
0090
0091
0092 bool SetLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double , double ) override;
0093
0094
0095 bool SetLowerLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double lower ) override;
0096
0097
0098 bool SetUpperLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double upper ) override;
0099
0100
0101 bool SetFixedVariable(unsigned int , const std::string & , double ) override;
0102
0103
0104 bool SetVariableValue(unsigned int , double ) override;
0105
0106
0107 bool SetVariableStepSize(unsigned int , double ) override;
0108
0109 bool SetVariableLowerLimit(unsigned int , double ) override;
0110
0111 bool SetVariableUpperLimit(unsigned int , double ) override;
0112
0113 bool SetVariableLimits(unsigned int ivar, double lower, double upper) override;
0114
0115 bool FixVariable(unsigned int) override;
0116
0117 bool ReleaseVariable(unsigned int) override;
0118
0119
0120 bool IsFixedVariable(unsigned int) const override;
0121
0122 bool GetVariableSettings(unsigned int, ROOT::Fit::ParameterSettings & ) const override;
0123
0124
0125
0126 bool Minimize() override;
0127
0128
0129 double MinValue() const override;
0130
0131
0132 double Edm() const override;
0133
0134
0135 const double * X() const override { return &fParams.front(); }
0136
0137
0138 const double * MinGradient() const override { return nullptr; }
0139
0140
0141 unsigned int NCalls() const override;
0142
0143
0144
0145 unsigned int NDim() const override { return fDim; }
0146
0147
0148
0149 unsigned int NFree() const override;
0150
0151
0152 bool ProvidesError() const override { return true; }
0153
0154
0155 const double * Errors() const override { return &fErrors.front(); }
0156
0157
0158
0159
0160
0161 double CovMatrix(unsigned int i, unsigned int j) const override {
0162 return ( fCovar.size() > (i + fDim* j) ) ? fCovar[i + fDim* j] : 0;
0163 }
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173 bool GetCovMatrix(double * cov) const override;
0174
0175
0176
0177
0178
0179
0180
0181
0182 bool GetHessianMatrix(double * h) const override;
0183
0184
0185 int CovMatrixStatus() const override;
0186
0187
0188 double GlobalCC(unsigned int ) const override;
0189
0190
0191 bool GetMinosError(unsigned int i, double & errLow, double & errUp, int = 0) override;
0192
0193
0194
0195
0196
0197 int MinosStatus() const override { return fMinosStatus; }
0198
0199
0200
0201
0202 bool Hesse() override;
0203
0204
0205
0206
0207
0208 bool Scan(unsigned int i, unsigned int &nstep, double * x, double * y, double xmin = 0, double xmax = 0) override;
0209
0210
0211
0212
0213
0214 bool Contour(unsigned int i, unsigned int j, unsigned int & npoints, double *xi, double *xj) override;
0215
0216
0217 void PrintResults() override;
0218
0219
0220
0221
0222
0223 std::string VariableName(unsigned int ivar) const override;
0224
0225
0226
0227 int VariableIndex(const std::string & name) const override;
0228
0229
0230
0231 bool static UseStaticMinuit(bool on = true);
0232
0233
0234
0235 void SuppressMinuitWarnings(bool nowarn=true);
0236
0237
0238 bool SetDebug(bool on = true);
0239
0240 protected:
0241
0242
0243 static void Fcn( int &, double * , double & f, double * , int);
0244
0245 static void FcnGrad( int &, double * g, double & f, double * , int);
0246
0247
0248 void InitTMinuit(int ndim);
0249
0250
0251 void DoClear();
0252
0253
0254 void DoReleaseFixParameter( int ivar);
0255
0256
0257 void RetrieveParams();
0258
0259
0260 void RetrieveErrorMatrix();
0261
0262
0263 bool CheckMinuitInstance() const;
0264
0265
0266 bool CheckVarIndex(unsigned int ivar) const;
0267
0268
0269 private:
0270
0271 bool fUsed;
0272 bool fMinosRun;
0273 unsigned int fDim;
0274 int fMinosStatus = -1;
0275 std::vector<double> fParams;
0276 std::vector<double> fErrors;
0277 std::vector<double> fCovar;
0278
0279 ROOT::Minuit::EMinimizerType fType;
0280 TMinuit * fMinuit;
0281
0282 static TMinuit * fgMinuit;
0283
0284 static bool fgUsed;
0285 static bool fgUseStaticMinuit;
0286
0287 ClassDef(TMinuitMinimizer,1)
0288
0289 };
0290
0291
0292
0293 #endif