The base class for fitters. More...
#include <Fitter.h>


Public Member Functions | |
| virtual bool | calcBestFit ()=0 |
| Calculates the best fit. More... | |
| virtual int | calcCovariance (std::vector< std::vector< double > > &cov) |
| Calculates the covariance matrix. More... | |
| virtual int | calcDegreesOfFreedom () const |
| Returns the number of degrees of freedom in the fit. More... | |
| virtual Fitter * | clone () const =0 |
| Makes a copy of the receiving object. More... | |
| virtual void | copyFrom (const Fitter *other) |
| Makes a copy of other. More... | |
| void | fillFreeParameters (std::vector< double > &) const |
| Fills the vector with the free parameters values. More... | |
| StatedFCN * | getFCN () |
| Returns the objective function object. More... | |
| virtual const std::vector< int > & | getFixedFlags () const |
| Sets the limits of the model function parameter values. More... | |
| bool | getUseErrors () const |
Returns true if error data from the DataSource will be used if available. More... | |
| bool | isCompatible (const FunctionBase *) const |
Returns true if the function is compatible with the objective function. More... | |
| const std::string & | name () const |
| Returns the name of the fitter. More... | |
| bool | needsIntegrated () const |
Returns true if the Fitter needs integrated intervals. More... | |
| virtual double | objectiveValue () const |
| Calculates the value of the objective function at the current set of parameters. More... | |
| void | setDataSource (const DataSource *source) |
| Sets the source of data to be used. More... | |
| virtual void | setFCN (StatedFCN *fcn) |
| Sets the objective function object. More... | |
| virtual void | setFitCut (TupleCut *cut) |
| Sets the cut to limit range of fitting. More... | |
| virtual void | setFitRange (bool yes=true) |
| Sets use of a fitting range on or off. More... | |
| virtual void | setFixedFlags (const std::vector< int > &flags) |
| Sets the parameters that are to be held fixed during objective function minimization. More... | |
| void | setFunction (FunctionBase *function) |
| Sets the model function. More... | |
| virtual void | setLimits (unsigned int i, double lower, double upper) |
| Sets the limits for the parameter of the model function indexed by i. More... | |
| void | setLimits (const std::string &name, double lower, double upper) |
| Sets the limits for the parameter of the model function with name name. More... | |
| virtual void | setStepSize (unsigned int i, double size) |
| Sets the step size for parameter of the minimization. More... | |
| void | setStepSize (const std::string &name, double size) |
| Sets the minimization step size for model function parameter name. More... | |
| void | setUseErrors (bool yes=true) |
| Sets the fitter to use error data from the DataSource, if available. More... | |
| virtual | ~Fitter () |
| The virtual destructor. More... | |
Protected Member Functions | |
| Fitter (const Fitter &) | |
| The copy constructor. More... | |
| Fitter (const char *name) | |
| The required constructor. More... | |
Protected Attributes | |
| StatedFCN * | m_fcn |
| The objective function. More... | |
| int | m_max_iterations |
| The maximum number of iterations allowed in attempting the fit. More... | |
| std::string | m_name |
| The name of the fitter. More... | |
Private Member Functions | |
| unsigned int | getParameterIndex (const std::string &name) |
| Returns the index to the model function parameters name. More... | |
The copy constructor.
Makes a copy of the data members and a clone of the StatedFCN.
Definition at line 35 of file Fitter.cxx.
References Fitter::clone(), and Fitter::m_fcn.
|
protected |
The required constructor.
Definition at line 27 of file Fitter.cxx.
|
virtual |
|
pure virtual |
Calculates the best fit.
Returns true if the fit converged; otherwise it returns false.
Implemented in BFGSFitter, MinuitMigrad, and LMFitter.
Referenced by FunctionProjector::fitFunction().
|
virtual |
Calculates the covariance matrix.
Returns EXIT_SUCCESS if a minima of the objective functions is found, returns EXIT_FAILURE in case algorithm converges on other stationary points (i.e. on saddle points).
This member function should be overridden by a derived class if supported. The implementation in this base class returns EXIT_FAILURE.
Reimplemented in MinuitMigrad, BFGSFitter, and LMFitter.
Definition at line 236 of file Fitter.cxx.
|
virtual |
Returns the number of degrees of freedom in the fit.
Definition at line 229 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by FunctionProjector::degreesOfFreedom().
|
pure virtual |
Makes a copy of the receiving object.
Makes copy of receiving object by creating a new one with the only constructor.
Implemented in MinuitMigrad, BFGSFitter, and LMFitter.
Referenced by Fitter::Fitter().
|
virtual |
| void fillFreeParameters | ( | std::vector< double > & | free_parms | ) | const |
Fills the vector with the free parameters values.
Definition at line 142 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by LMFitter::calcBestFit(), and BFGSFitter::calcBestFit().
| StatedFCN * getFCN | ( | ) |
Returns the objective function object.
Definition at line 73 of file Fitter.cxx.
References Fitter::m_fcn.
|
virtual |
Sets the limits of the model function parameter values.
Attempts to set the limits of the model function parameter values. This base class implementation throws a FitterException. Derived classes that support setting limits of the parameter values should override this member function.Returns a vector containing flags for which parameters are to be held fixed during objective function minimization.
Definition at line 156 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by MinuitMigrad::initialize().
|
private |
Returns the index to the model function parameters name.
If name is not found, throws a std::runtime_error.
Definition at line 173 of file Fitter.cxx.
References i, index, Fitter::m_fcn, Fitter::name(), and num_util::size().
Referenced by Fitter::setLimits(), and Fitter::setStepSize().
| bool getUseErrors | ( | ) | const |
Returns true if error data from the DataSource will be used if available.
Definition at line 119 of file Fitter.cxx.
References Fitter::m_fcn, and yes.
| bool isCompatible | ( | const FunctionBase * | function | ) | const |
Returns true if the function is compatible with the objective function.
Definition at line 80 of file Fitter.cxx.
References Fitter::m_fcn, and yes.
| const std::string & name | ( | ) | const |
Returns the name of the fitter.
Definition at line 57 of file Fitter.cxx.
References Fitter::m_name.
Referenced by Fitter::getParameterIndex(), MinuitMigrad::initialize(), BFGSFitter::iterParam(), and BFGSFitter::setIterParam().
| bool needsIntegrated | ( | ) | const |
Returns true if the Fitter needs integrated intervals.
Definition at line 131 of file Fitter.cxx.
References Fitter::m_fcn, and yes.
|
virtual |
Calculates the value of the objective function at the current set of parameters.
Definition at line 222 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by LMFitter::calcBestFit(), BFGSFitter::function(), BFGSFitter::gradient(), BFGSFitter::gradp(), and FunctionProjector::objectiveValue().
| void setDataSource | ( | const DataSource * | source | ) |
Sets the source of data to be used.
Definition at line 100 of file Fitter.cxx.
References Fitter::m_fcn, and Fitter::setUseErrors().
|
virtual |
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 64 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by LMFitter::setFCN().
|
virtual |
Sets the cut to limit range of fitting.
Definition at line 243 of file Fitter.cxx.
References Fitter::m_fcn.
|
virtual |
Sets use of a fitting range on or off.
Definition at line 250 of file Fitter.cxx.
References Fitter::m_fcn.
|
virtual |
Sets the parameters that are to be held fixed during objective function minimization.
Definition at line 149 of file Fitter.cxx.
References Fitter::m_fcn.
| void setFunction | ( | FunctionBase * | function | ) |
|
virtual |
Sets the limits for the parameter of the model function indexed by i.
This base class implementation throws a std::runtime_error. Derived classes that implement this function should override it.
Reimplemented in MinuitMigrad.
Definition at line 163 of file Fitter.cxx.
References Fitter::m_name.
Referenced by Fitter::setLimits().
| void setLimits | ( | const std::string & | name, |
| double | lower, | ||
| double | upper | ||
| ) |
Sets the limits for the parameter of the model function with name name.
Definition at line 197 of file Fitter.cxx.
References Fitter::getParameterIndex(), index, and Fitter::setLimits().
|
virtual |
Sets the step size for parameter of the minimization.
This base class implementation throws FitterException. Derived classes that support setting step size should override this member function.
Reimplemented in MinuitMigrad.
Definition at line 205 of file Fitter.cxx.
References Fitter::m_name.
Referenced by Fitter::setStepSize().
| void setStepSize | ( | const std::string & | name, |
| double | size | ||
| ) |
Sets the minimization step size for model function parameter name.
Definition at line 215 of file Fitter.cxx.
References Fitter::getParameterIndex(), index, and Fitter::setStepSize().
| void setUseErrors | ( | bool | yes = true | ) |
Sets the fitter to use error data from the DataSource, if available.
Definition at line 110 of file Fitter.cxx.
References Fitter::m_fcn.
Referenced by Fitter::setDataSource().
|
protected |
The objective function.
Definition at line 59 of file Fitter.h.
Referenced by LMFitter::calcAlpha(), LMFitter::calcBestFit(), MinuitMigrad::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().
|
protected |
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().
|
protected |
The name of the fitter.
Definition at line 51 of file Fitter.h.
Referenced by MinuitMigrad::checkIndex(), Fitter::name(), Fitter::setLimits(), and Fitter::setStepSize().