GooFit  v2.1.3
FitManagerMinuit1.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <TMinuit.h>
5 #include <goofit/Variable.h>
6 
7 namespace GooFit {
8 
9 class PdfBase;
10 
11 class Minuit1 : public TMinuit {
12  PdfBase *pdfPointer;
13  std::vector<Variable> vars;
14 
15  public:
16  Minuit1(PdfBase *pdfPointer);
18  Int_t Eval(Int_t npar, //< The number of parameters
19  Double_t *grad, //< The derivatives can be stored here if flag is 2 (output)
20  Double_t &fval, //< The value of the function at this point (output)
21  Double_t *par, //< The input parameters
22  Int_t flag //< This is 1 the first time, 2, for derivatives, and 3 after the fit is finished. It
23  // is something else if computing.
24  ) override;
25 
26  // Get a copy of the list of variables
27  std::vector<Variable> getVaraibles() const { return vars; };
28 };
29 
31  public:
33  : minuit_(dat) {}
34 
35  void setMaxCalls(double mxc) { overrideCallLimit = mxc; }
36  void useHesseBefore(bool use = true) { _useHesseBefore = use; }
37  void useHesse(bool use = true) { _useHesse = use; }
38  void useMinos(bool use = true) { _useMinos = use; }
39  void useImprove(bool use = true) { _useImprove = use; }
40  void setVerbosity(int v) { minuit_.SetPrintLevel(v - 1); }
41 
42  operator bool() const { return minuit_.GetStatus() == 0; }
43  operator int() const { return minuit_.GetStatus(); }
44 
45  // This runs the fit
46  void fit();
47 
48  Minuit1 *getMinuitObject() { return &minuit_; }
49 
50  void getMinuitStatus(double &fmin, double &fedm, double &errdef, int &npari, int &nparx, int &istat);
51 
52  private:
53  double overrideCallLimit{-1};
54  bool _useHesseBefore{true};
55  bool _useHesse{true};
56  bool _useMinos{false};
57  bool _useImprove{false};
58 
59  Minuit1 minuit_;
60 };
61 } // namespace GooFit
Int_t Eval(Int_t npar, Double_t *grad, Double_t &fval, Double_t *par, Int_t flag) override
Fit function for Minuit.
void setMaxCalls(double mxc)
Minuit1(PdfBase *pdfPointer)
void useImprove(bool use=true)
void useHesseBefore(bool use=true)
std::vector< Variable > getVaraibles() const
void useMinos(bool use=true)
void useHesse(bool use=true)