#include <MinuitMigrad.h>
Inheritance diagram for MinuitMigrad:
A Fitter class that uses the Simple version of Minuit for fitting.
The implementation here follows the example given in seal/Mathlibs/Minuit/tests/MnSim/SimpleGaussSim.cpp. However, one change is to not to use explicitly the MnUserParameter, but give the the initial vector of parameters and errors directly.
Definition at line 54 of file MinuitMigrad.h.
Public Member Functions | |
virtual bool | calcBestFit () |
Calculates the best fit. | |
virtual int | calcCovariance (std::vector< std::vector< double > > &cov) |
Calculates the covariance matrix. | |
virtual int | calcDegreesOfFreedom () const |
Returns the number of degrees of freedom in the fit. | |
virtual Fitter * | clone () const |
Makes a copy of the receiving object. | |
virtual void | copyFrom (const Fitter *other) |
Makes a copy of other. | |
void | fillFreeParameters (std::vector< double > &) const |
Fills the vector with the free parameters values. | |
StatedFCN * | getFCN () |
Returns the objective function object. | |
virtual const std::vector< int > & | getFixedFlags () const |
Returns a vector containing flags for which parameters are to be held fixed during objective function minimization. | |
bool | getUseErrors () const |
Returns true if error data from the DataSource will be used if available. | |
bool | isCompatible (const FunctionBase *) const |
Returns true if the function is compatible with the objective function. | |
MinuitMigrad (const char *name) | |
The constructor. | |
const std::string & | name () const |
Returns the name of the fitter. | |
bool | needsIntegrated () const |
Returns true if the Fitter needs integrated intervals. | |
virtual double | objectiveValue () const |
Calculates the value of the objective function at the current set of parameters. | |
void | setDataSource (const DataSource *source) |
Sets the source of data to be used. | |
virtual void | setFCN (StatedFCN *fcn) |
Sets the objective function object. | |
virtual void | setFitCut (TupleCut *cut) |
Sets the cut to limit range of fitting. | |
virtual void | setFitRange (bool yes=true) |
Sets use of a fitting range on or off. | |
virtual void | setFixedFlags (const std::vector< int > &flags) |
Sets the parameters that are to be held fixed during objective function minimization. | |
void | setFunction (FunctionBase *function) |
Sets the model function. | |
void | setLimits (const std::string &name, double lower, double upper) |
Sets the limits for the parameter of the model function with name name. | |
virtual void | setLimits (unsigned int i, double lower, double upper) |
Sets the upper and lower limits of the parameter. | |
void | setStepSize (const std::string &name, double size) |
Sets the minimization step size for model function parameter name. | |
virtual void | setStepSize (unsigned int i, double size) |
Sets the step size used by MnMigrad. | |
void | setUseErrors (bool yes=true) |
Sets the fitter to use error data from the DataSource, if available. | |
Protected Attributes | |
StatedFCN * | m_fcn |
The objective function. | |
int | m_max_iterations |
The maximum number of iterations allowed in attempting the fit. | |
std::string | m_name |
The name of the fitter. | |
Private Member Functions | |
void | checkIndex (unsigned int index) |
Checks the index and throws exception if out of range. | |
void | initialize () |
Initializes the Minuit Migrad minimizer. | |
void | initLimits () |
Initializes the limits. | |
MinuitMigrad (const MinuitMigrad &) | |
Private copy constructor to prevent user copying. | |
Private Attributes | |
std::vector< limit > | m_limits |
The limit parameters. | |
Classes | |
struct | limit |
Structure to hold limit values, if any. More... |
MinuitMigrad | ( | const MinuitMigrad & | ) | [private] |
Private copy constructor to prevent user copying.
Definition at line 48 of file MinuitMigrad.cxx.
Referenced by MinuitMigrad::clone().
MinuitMigrad | ( | const char * | name | ) |
bool calcBestFit | ( | ) | [virtual] |
Calculates the best fit.
Returns true
if the fit converged; otherwise it returns false
.
Implements Fitter.
Definition at line 180 of file MinuitMigrad.cxx.
References MinuitMigrad::initialize(), FunctionMinimum::isValid(), and Fitter::m_fcn.
int calcCovariance | ( | std::vector< std::vector< double > > & | cov | ) | [virtual] |
Calculates the covariance matrix.
Reimplemented from Fitter.
Definition at line 206 of file MinuitMigrad.cxx.
References MinuitMigrad::initialize(), MnUserCovariance::nrow(), and num_util::size().
int calcDegreesOfFreedom | ( | ) | const [virtual, inherited] |
Returns the number of degrees of freedom in the fit.
Definition at line 226 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by FunctionProjector::degreesOfFreedom(), and hippodraw::Python::export_Fitter().
void checkIndex | ( | unsigned int | index | ) | [private] |
Checks the index and throws exception if out of range.
Definition at line 115 of file MinuitMigrad.cxx.
References MinuitMigrad::initialize(), Fitter::m_fcn, Fitter::m_name, and num_util::size().
Referenced by MinuitMigrad::setLimits(), and MinuitMigrad::setStepSize().
Fitter * clone | ( | ) | const [virtual] |
Makes a copy of the receiving object.
Makes copy of receiving object by creating a new one with the only constructor.
Implements Fitter.
Definition at line 59 of file MinuitMigrad.cxx.
References MinuitMigrad::MinuitMigrad().
void copyFrom | ( | const Fitter * | other | ) | [virtual, inherited] |
void fillFreeParameters | ( | std::vector< double > & | ) | const [inherited] |
Fills the vector with the free parameters values.
Definition at line 139 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by LMFitter::calcBestFit(), and BFGSFitter::calcBestFit().
StatedFCN * getFCN | ( | ) | [inherited] |
Returns the objective function object.
Definition at line 70 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by hippodraw::Python::export_Fitter().
const vector< int > & getFixedFlags | ( | ) | const [virtual, inherited] |
Returns a vector containing flags for which parameters are to be held fixed during objective function minimization.
Definition at line 153 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by MinuitMigrad::initialize().
bool getUseErrors | ( | ) | const [inherited] |
Returns true
if error data from the DataSource will be used if available.
Definition at line 116 of file Fitter.cxx.
References Fitter::m_fcn.
void initialize | ( | ) | [private] |
Initializes the Minuit Migrad minimizer.
Definition at line 65 of file MinuitMigrad.cxx.
References MnUserParameters::add(), hippodraw::String::convert(), MnUserParameters::fix(), Fitter::getFixedFlags(), Fitter::m_fcn, MinuitMigrad::m_limits, Fitter::name(), MinuitMigrad::setLimits(), and num_util::size().
Referenced by MinuitMigrad::calcBestFit(), MinuitMigrad::calcCovariance(), and MinuitMigrad::checkIndex().
void initLimits | ( | ) | [private] |
Initializes the limits.
Definition at line 135 of file MinuitMigrad.cxx.
References Fitter::m_fcn, and MinuitMigrad::m_limits.
Referenced by MinuitMigrad::setLimits().
bool isCompatible | ( | const FunctionBase * | ) | const [inherited] |
Returns true
if the function is compatible with the objective function.
Definition at line 77 of file Fitter.cxx.
References Fitter::m_fcn.
const std::string & name | ( | ) | const [inherited] |
Returns the name of the fitter.
Definition at line 54 of file Fitter.cxx.
References Fitter::m_name.
Referenced by hippodraw::Python::export_Fitter(), and MinuitMigrad::initialize().
bool needsIntegrated | ( | ) | const [inherited] |
Returns true
if the Fitter needs integrated intervals.
Definition at line 128 of file Fitter.cxx.
References Fitter::m_fcn.
double objectiveValue | ( | ) | const [virtual, inherited] |
Calculates the value of the objective function at the current set of parameters.
Definition at line 219 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by LMFitter::calcBestFit(), hippodraw::Python::export_Fitter(), BFGSFitter::function(), BFGSFitter::gradient(), BFGSFitter::gradp(), and FunctionProjector::objectiveValue().
void setDataSource | ( | const DataSource * | source | ) | [inherited] |
Sets the source of data to be used.
Definition at line 97 of file Fitter.cxx.
References Fitter::m_fcn, and Fitter::setUseErrors().
void setFCN | ( | StatedFCN * | fcn | ) | [virtual, inherited] |
Sets the objective function object.
Sets the objective function object to be used and takes possession of it. That is, will delete an existing object, if there is one, and will delete the object in this object's destructor.
Reimplemented in LMFitter.
Definition at line 61 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by LMFitter::setFCN().
void setFitCut | ( | TupleCut * | cut | ) | [virtual, inherited] |
Sets the cut to limit range of fitting.
Definition at line 240 of file Fitter.cxx.
References Fitter::m_fcn.
void setFitRange | ( | bool | yes = true |
) | [virtual, inherited] |
Sets use of a fitting range on or off.
Definition at line 247 of file Fitter.cxx.
References Fitter::m_fcn.
void setFixedFlags | ( | const std::vector< int > & | flags | ) | [virtual, inherited] |
Sets the parameters that are to be held fixed during objective function minimization.
Definition at line 146 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by hippodraw::Python::export_Fitter().
void setFunction | ( | FunctionBase * | function | ) | [inherited] |
void setLimits | ( | const std::string & | name, | |
double | lower, | |||
double | upper | |||
) | [inherited] |
Sets the limits for the parameter of the model function with name name.
Definition at line 194 of file Fitter.cxx.
References Fitter::getParameterIndex(), and Fitter::setLimits().
void setLimits | ( | unsigned int | i, | |
double | lower, | |||
double | upper | |||
) | [virtual] |
Sets the upper and lower limits of the parameter.
Reimplemented from Fitter.
Definition at line 147 of file MinuitMigrad.cxx.
References MinuitMigrad::checkIndex(), MinuitMigrad::initLimits(), and MinuitMigrad::m_limits.
Referenced by MinuitMigrad::initialize().
void setStepSize | ( | const std::string & | name, | |
double | size | |||
) | [inherited] |
Sets the minimization step size for model function parameter name.
Definition at line 212 of file Fitter.cxx.
References Fitter::getParameterIndex(), and Fitter::setStepSize().
void setStepSize | ( | unsigned int | i, | |
double | size | |||
) | [virtual] |
Sets the step size used by MnMigrad.
Reimplemented from Fitter.
Definition at line 162 of file MinuitMigrad.cxx.
References MinuitMigrad::checkIndex().
void setUseErrors | ( | bool | yes = true |
) | [inherited] |
Sets the fitter to use error data from the DataSource, if available.
Definition at line 107 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by Fitter::setDataSource().
The objective function.
Definition at line 59 of file Fitter.h.
Referenced by LMFitter::calcAlpha(), MinuitMigrad::calcBestFit(), LMFitter::calcBestFit(), BFGSFitter::calcBestFit(), Fitter::calcDegreesOfFreedom(), MinuitMigrad::checkIndex(), Fitter::copyFrom(), Fitter::fillFreeParameters(), Fitter::Fitter(), BFGSFitter::function(), Fitter::getFCN(), Fitter::getFixedFlags(), Fitter::getParameterIndex(), Fitter::getUseErrors(), BFGSFitter::gradient(), BFGSFitter::gradp(), MinuitMigrad::initialize(), MinuitMigrad::initLimits(), Fitter::isCompatible(), Fitter::needsIntegrated(), Fitter::objectiveValue(), Fitter::setDataSource(), Fitter::setFCN(), Fitter::setFitCut(), Fitter::setFitRange(), Fitter::setFixedFlags(), Fitter::setFunction(), Fitter::setUseErrors(), and Fitter::~Fitter().
The limit parameters.
Definition at line 76 of file MinuitMigrad.h.
Referenced by MinuitMigrad::initialize(), MinuitMigrad::initLimits(), and MinuitMigrad::setLimits().
int m_max_iterations [protected, inherited] |
The maximum number of iterations allowed in attempting the fit.
Definition at line 62 of file Fitter.h.
Referenced by LMFitter::calcBestFit(), BFGSFitter::calcBestFit(), BFGSFitter::iterParam(), and BFGSFitter::setIterParam().
std::string m_name [protected, inherited] |
The name of the fitter.
Definition at line 51 of file Fitter.h.
Referenced by MinuitMigrad::checkIndex(), Fitter::name(), Fitter::setLimits(), and Fitter::setStepSize().