GooFit  v2.1.3
Public Member Functions | List of all members
GooFit::FitManagerMinuit2 Class Reference

#include <FitManagerMinuit2.h>

Public Member Functions

 FitManagerMinuit2 (PdfBase *dat)
 
ROOT::Minuit2::FunctionMinimum fit ()
 This runs the fit. More...
 
void setMaxCalls (unsigned int max_calls=0)
 Set the maximum number of calls. 0 for Minuit2 default. More...
 
ParamsgetParams ()
 Get a pointer to the params. More...
 
FCNgetFCN ()
 Get a pointer to the fcn. More...
 
 operator bool () const
 Check to see if fit is valid. More...
 
 operator int () const
 Return value for program. More...
 
void setVerbosity (int value)
 Set the fitting verbosity. More...
 
int getVerbosity () const
 Get the fitting verbosity. More...
 

Detailed Description

Definition at line 16 of file FitManagerMinuit2.h.

Constructor & Destructor Documentation

◆ FitManagerMinuit2()

GooFit::FitManagerMinuit2::FitManagerMinuit2 ( PdfBase dat)

Definition at line 15 of file FitManagerMinuit2.cpp.

16  : upar_(*dat)
17  , fcn_(upar_) {}

Member Function Documentation

◆ fit()

Minuit2::FunctionMinimum GooFit::FitManagerMinuit2::fit ( )

This runs the fit.

Definition at line 19 of file FitManagerMinuit2.cpp.

References GooFit::bold, GooFit::gray, GooFit::green, GooFit::host_callnumber, GooFit::InValid, GooFit::magenta, GooFit::red, GooFit::reset, and GooFit::Valid.

Referenced by fitAndPlot(), main(), make1BinSigmaMap(), make4BinSigmaMap(), makeOverallSignal(), makeSigmaMap(), runBackgroundDalitzFit(), runBackgroundSigmaFit(), runCanonicalFit(), runEfficiencyFit(), runGeneratedMCFit(), runSigmaFit(), runToyFit(), and runTruthMCFit().

19  {
20  auto val = Minuit2::MnPrint::Level();
21  Minuit2::MnPrint::SetLevel(verbosity);
22 
23  // Setting global call number to 0
24  host_callnumber = 0;
25 
26  CLI::Timer timer{"The minimization took"};
27 
28  Minuit2::MnMigrad migrad{fcn_, upar_};
29 
30  // Do the minimization
31  if(verbosity > 0)
32  std::cout << GooFit::gray << GooFit::bold;
33 
34  CLI::Timer avetimer{"Average time per call"};
35  Minuit2::FunctionMinimum min = migrad(maxfcn_);
36 
37  // Print nice output
38  if(verbosity > 0) {
39  std::cout << GooFit::reset << (min.IsValid() ? GooFit::green : GooFit::red);
40  std::cout << min << GooFit::reset;
41  std::cout << GooFit::magenta << timer.to_string() << GooFit::reset << std::endl;
42  std::cout << (avetimer / min.NFcn()).to_string() << std::endl;
43  }
44 
45  if(min.IsValid()) {
46  retval_ = FitErrors::Valid;
47  } else {
48  if(verbosity > 0) {
49  std::cout << GooFit::red;
50  std::cout << "HesseFailed: " << min.HesseFailed() << std::endl;
51  std::cout << "HasCovariance: " << min.HasCovariance() << std::endl;
52  std::cout << "HasValidCovariance: " << min.HasValidCovariance() << std::endl;
53  std::cout << "HasValidParameters: " << min.HasValidParameters() << std::endl;
54  std::cout << "IsAboveMaxEdm: " << min.IsAboveMaxEdm() << std::endl;
55  std::cout << "HasReachedCallLimit: " << min.HasReachedCallLimit() << std::endl;
56  std::cout << "HasAccurateCovar: " << min.HasAccurateCovar() << std::endl;
57  std::cout << "HasPosDefCovar : " << min.HasPosDefCovar() << std::endl;
58  std::cout << "HasMadePosDefCovar : " << min.HasMadePosDefCovar() << std::endl;
59  std::cout << GooFit::reset;
60  }
61 
62  retval_ = FitErrors::InValid;
63  }
64 
65  // Set the parameters in GooFit to the new values
66  upar_.SetGooFitParams(min.UserState());
67 
68  Minuit2::MnPrint::SetLevel(val);
69  return min;
70 }
constexpr rang::style const bold
Definition: Color.h:17
constexpr rang::fg const red
Definition: Color.h:9
constexpr rang::style const reset
Definition: Color.h:16
constexpr rang::fg const gray
Definition: Color.h:15
constexpr rang::fg const magenta
Definition: Color.h:13
constexpr rang::fg const green
Definition: Color.h:10
int host_callnumber
Definition: PdfBase.cpp:33

◆ getFCN()

FCN* GooFit::FitManagerMinuit2::getFCN ( )
inline

Get a pointer to the fcn.

Definition at line 30 of file FitManagerMinuit2.h.

30 { return &fcn_; }

◆ getParams()

Params* GooFit::FitManagerMinuit2::getParams ( )
inline

Get a pointer to the params.

Definition at line 27 of file FitManagerMinuit2.h.

27 { return &upar_; }

◆ getVerbosity()

int GooFit::FitManagerMinuit2::getVerbosity ( ) const
inline

Get the fitting verbosity.

Definition at line 42 of file FitManagerMinuit2.h.

References GooFit::NotRun.

42 { return verbosity; }

◆ operator bool()

GooFit::FitManagerMinuit2::operator bool ( ) const
inline

Check to see if fit is valid.

Definition at line 33 of file FitManagerMinuit2.h.

References GooFit::Valid.

33 { return retval_ == FitErrors::Valid; }

◆ operator int()

GooFit::FitManagerMinuit2::operator int ( ) const
inline

Return value for program.

Definition at line 36 of file FitManagerMinuit2.h.

36 { return static_cast<int>(retval_); }

◆ setMaxCalls()

void GooFit::FitManagerMinuit2::setMaxCalls ( unsigned int  max_calls = 0)
inline

Set the maximum number of calls. 0 for Minuit2 default.

Definition at line 24 of file FitManagerMinuit2.h.

Referenced by runBackgroundDalitzFit(), runBackgroundSigmaFit(), runCanonicalFit(), runGeneratedMCFit(), and runToyFit().

24 { maxfcn_ = max_calls; }

◆ setVerbosity()

void GooFit::FitManagerMinuit2::setVerbosity ( int  value)
inline

Set the fitting verbosity.

Definition at line 39 of file FitManagerMinuit2.h.

Referenced by GooFit::PdfBase::fitTo().

39 { verbosity = value; }

The documentation for this class was generated from the following files: