14 : TMinuit(
max_index(pdfPointer->getParameters()) + 1)
15 , pdfPointer(pdfPointer)
16 , vars(pdfPointer->getParameters()) {
20 var.setFitterIndex(counter);
22 Int_t err = DefineParameter(
23 counter, var.getName().c_str(), var.getValue(), var.getError(), var.getLowerLimit(), var.getUpperLimit());
25 if(GetNumPars() != counter + 1)
27 "Error when implementing param {} (possibly invalid error/lowerlimit/upperlimit values)!",
34 FixParameter(counter);
42 Int_t
Minuit1::Eval(
int npar,
double *gin,
double &fun,
double *fp,
int iflag) {
43 std::vector<double> pars{fp, fp + GetNumPars()};
45 std::vector<double> gooPars;
49 if(std::isnan(pars.at(var.getFitterIndex())))
50 GOOFIT_WARN(
"Variable {} at {} is NaN", var.getName(), var.getIndex());
52 var.setChanged(var.getValue() != pars.at(var.getFitterIndex()));
53 var.setValue(pars.at(var.getFitterIndex()));
54 gooPars.at(var.getIndex()) = var.getValue() - var.getBlind(
Variable::Key());
68 for(
Variable &var : minuit_.getVaraibles())
73 if(0 < overrideCallLimit) {
74 std::cout <<
"Calling MIGRAD with call limit " << overrideCallLimit << std::endl;
75 double plist[1] = {overrideCallLimit};
79 minuit_.mnexcm(
"HESSE", plist, 1, err);
81 minuit_.mnexcm(
"MIGRAD", plist, 1, err);
84 minuit_.mnexcm(
"HESSE", plist, 1, err);
87 minuit_.mnexcm(
"MINOS", plist, 1, err);
90 minuit_.mnexcm(
"IMPROVE", plist, 1, err);
96 double tmp_value, tmp_error;
97 for(
Variable &var : minuit_.getVaraibles()) {
98 minuit_.GetParameter(var.getFitterIndex(), tmp_value, tmp_error);
99 var.setValue(tmp_value);
100 var.setError(tmp_error);
105 double &fmin,
double &fedm,
double &errdef,
int &npari,
int &nparx,
int &istat) {
106 minuit_.mnstat(fmin, fedm, errdef, npari, nparx, istat);
107 std::cout <<
"mnstat(fmin = " << fmin <<
", fedm = " << fedm <<
", errdef = " << errdef <<
", npari = " << npari
108 <<
", nparx = " << nparx <<
", istat = " << istat <<
")" << std::endl;
Thrown when a general error is encountered.
virtual __host__ double calculateNLL() const =0
Int_t Eval(Int_t npar, Double_t *grad, Double_t &fval, Double_t *par, Int_t flag) override
Fit function for Minuit.
#define GOOFIT_TRACE(...)
Minuit1(PdfBase *pdfPointer)
void getMinuitStatus(double &fmin, double &fedm, double &errdef, int &npari, int &nparx, int &istat)
constexpr rang::style const bold
int max_index(const std::vector< Variable > &vars)
Get the max index of a variable from a list.
constexpr rang::style const reset
constexpr rang::fg const gray
__host__ void copyParams(const std::vector< double > &pars) const
This provides a key for some special classes to access blind info (passkey)