GooFit  v2.1.3
FCN.cpp
Go to the documentation of this file.
1 #include <goofit/Log.h>
2 #include <goofit/PDFs/GooPdf.h>
3 #include <goofit/PdfBase.h>
4 #include <goofit/Variable.h>
5 #include <goofit/fitting/FCN.h>
6 
7 namespace GooFit {
8 
9 FCN::FCN(Params &params)
10  : params_(&params) {
11  host_callnumber = 0;
12 
13  // Verify that all varaibles need to be recached
14  for(Variable &var : params_->vars_)
15  var.setChanged(true);
16 }
17 
18 double FCN::operator()(const std::vector<double> &pars) const {
19  // Translate from Minuit indexing to GooFit indexing
21 
22  GOOFIT_TRACE("Calculating NLL");
23  double nll = params_->pdf_->calculateNLL();
24 
26 
27  return nll;
28 }
29 
30 double FCN::operator()() const {
31  // Make a vector of current values, then force the recalculation step
32  std::vector<double> pars = params_->make_minuit_vector();
33  params_->from_minuit_vector(pars, true);
34 
35  GOOFIT_TRACE("Calculating NLL");
36  double nll = params_->pdf_->calculateNLL();
37 
39 
40  return nll;
41 }
42 
43 // Get the number of variable parameters
45 
46 } // namespace GooFit
virtual __host__ double calculateNLL() const =0
std::vector< Variable > vars_
Definition: Params.h:22
Params * params_
Definition: FCN.h:13
FCN(Params &params)
Create an FCN given parameters (PDF reference is inside params)
Definition: FCN.cpp:9
#define GOOFIT_TRACE(...)
Definition: Log.h:126
std::vector< double > make_minuit_vector() const
Make a parameter array with the current variable values.
Definition: Params.cpp:39
double operator()() const
produce the FCN value for the current values of the parameters
Definition: FCN.cpp:30
void setChanged(bool val=true)
Check to see if this has been changed since last iteration.
Definition: Variable.h:208
void from_minuit_vector(const std::vector< double > &values, bool force_changed=false)
Set from a minuit vector. Optional force_changed to force complete recalculation. ...
Definition: Params.cpp:47
PdfBase * pdf_
Definition: Params.h:23
Params * GetParams()
Get a pointer to the parameters.
Definition: FCN.cpp:44
int host_callnumber
Definition: PdfBase.cpp:33