GooFit  v2.1.3
Public Member Functions | Protected Attributes | List of all members
GooFit::Params Class Reference

#include <Params.h>

Inheritance diagram for GooFit::Params:

Public Member Functions

 Params (PdfBase &pdf)
 
void SetGooFitParams (const Minuit2::MnUserParameterState &input)
 Read the values back into GooFit. More...
 
size_t size () const
 Get the number of params in the fit. More...
 
std::vector< double > make_minuit_vector () const
 Make a parameter array with the current variable values. More...
 
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. More...
 
void set_record (bool do_record=true)
 Set recording of Minuit parameter changes. More...
 
std::vector< std::vector< double > > get_recorded () const
 Get recorded values array. More...
 

Protected Attributes

std::vector< Variablevars_
 
PdfBasepdf_
 
size_t num_
 
bool do_record_ {false}
 
std::vector< std::vector< double > > recorded_
 

Detailed Description

Definition at line 18 of file Params.h.

Constructor & Destructor Documentation

◆ Params()

GooFit::Params::Params ( PdfBase pdf)

Definition at line 8 of file Params.cpp.

References GooFit::PdfBase::getParameters(), pdf_, and vars_.

9  : pdf_(&pdf) {
11 
12  for(Variable &var : vars_) {
13  bool added;
14  if(var.IsFixed()) {
15  added = Add(var.getName(), var.getValue());
16  } else if(var.getLowerLimit() == var.getUpperLimit()) {
17  added = Add(var.getName(), var.getValue(), var.getError());
18  } else {
19  added = Add(var.getName(), var.getValue(), var.getError(), var.getLowerLimit(), var.getUpperLimit());
20  }
21 
22  if(!added)
23  throw std::runtime_error("The name " + var.getName() + " appears more than once!");
24 
25  var.setFitterIndex(Index(var.getName()));
26  }
27 }
std::vector< Variable > vars_
Definition: Params.h:22
PdfBase * pdf_
Definition: Params.h:23
virtual __host__ std::vector< Variable > getParameters() const
Definition: PdfBase.cpp:81

Member Function Documentation

◆ from_minuit_vector()

void GooFit::Params::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 at line 47 of file Params.cpp.

References GooFit::PdfBase::copyParams(), do_record_, GooFit::max_index(), pdf_, recorded_, and vars_.

Referenced by GooFit::FCN::operator()(), and size().

47  {
48  std::vector<double> gooPars(max_index(vars_) + 1);
49 
50  for(Variable &var : vars_) {
51  var.setChanged(force_changed ? true : var.getValue() != values.at(var.getFitterIndex()));
52  gooPars.at(var.getIndex()) = values.at(var.getFitterIndex()) - var.getBlind(Variable::Key());
53  }
54 
55  if(do_record_)
56  recorded_.push_back(values);
57 
58  pdf_->copyParams(gooPars);
59 }
std::vector< Variable > vars_
Definition: Params.h:22
int max_index(const std::vector< Variable > &vars)
Get the max index of a variable from a list.
Definition: Variable.cpp:8
PdfBase * pdf_
Definition: Params.h:23
__host__ void copyParams(const std::vector< double > &pars) const
std::vector< std::vector< double > > recorded_
Definition: Params.h:27
bool do_record_
Definition: Params.h:26

◆ get_recorded()

std::vector<std::vector<double> > GooFit::Params::get_recorded ( ) const
inline

Get recorded values array.

Definition at line 50 of file Params.h.

References recorded_.

50 { return recorded_; }
std::vector< std::vector< double > > recorded_
Definition: Params.h:27

◆ make_minuit_vector()

std::vector< double > GooFit::Params::make_minuit_vector ( ) const

Make a parameter array with the current variable values.

Definition at line 39 of file Params.cpp.

References GooFit::max_fitter_index(), and vars_.

Referenced by GooFit::FCN::operator()(), and size().

39  {
40  std::vector<double> minuitPars(max_fitter_index(vars_) + 1);
41  for(const Variable &var : vars_) {
42  minuitPars.at(var.getFitterIndex()) = var.getValue();
43  }
44  return minuitPars;
45 }
std::vector< Variable > vars_
Definition: Params.h:22
int max_fitter_index(const std::vector< Variable > &vars)
Get the max fitter index of a variable from a list.
Definition: Variable.cpp:28

◆ set_record()

void GooFit::Params::set_record ( bool  do_record = true)
inline

Set recording of Minuit parameter changes.

Definition at line 47 of file Params.h.

References do_record_.

47 { do_record_ = do_record; }
bool do_record_
Definition: Params.h:26

◆ SetGooFitParams()

void GooFit::Params::SetGooFitParams ( const Minuit2::MnUserParameterState &  input)

Read the values back into GooFit.

Definition at line 29 of file Params.cpp.

References vars_.

29  {
30  for(Variable &var : vars_) {
31  int counter = var.getFitterIndex();
32  var.setValue(input.Value(counter));
33  var.setError(input.Error(counter));
34  SetValue(counter, var.getValue());
35  SetError(counter, var.getError());
36  }
37 }
std::vector< Variable > vars_
Definition: Params.h:22

◆ size()

size_t GooFit::Params::size ( ) const
inline

Get the number of params in the fit.

Definition at line 38 of file Params.h.

References from_minuit_vector(), and make_minuit_vector().

38 { return vars_.size(); };
std::vector< Variable > vars_
Definition: Params.h:22

Member Data Documentation

◆ do_record_

bool GooFit::Params::do_record_ {false}
protected

Definition at line 26 of file Params.h.

Referenced by from_minuit_vector(), and set_record().

◆ num_

size_t GooFit::Params::num_
protected

Definition at line 24 of file Params.h.

◆ pdf_

PdfBase* GooFit::Params::pdf_
protected

Definition at line 23 of file Params.h.

Referenced by from_minuit_vector(), GooFit::FCN::operator()(), and Params().

◆ recorded_

std::vector<std::vector<double> > GooFit::Params::recorded_
protected

Definition at line 27 of file Params.h.

Referenced by from_minuit_vector(), and get_recorded().

◆ vars_

std::vector<Variable> GooFit::Params::vars_
protected

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