Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Fitter Class Reference

#include <Fitter.h>

Inheritance diagram for Fitter:

Inheritance graph
[legend]
Collaboration diagram for Fitter:

Collaboration graph
[legend]
List of all members.

Detailed Description

The base class for fitters.

Author:
Paul F. Kunz <Paul_Kunz@slac.stanford.edu>

Definition at line 29 of file Fitter.h.

Public Member Functions

virtual bool calcBestFit ()=0
 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 Fitterclone () const =0
 Makes a copy of the receiving object.
void fillFreeParameters (std::vector< double > &) const
 Fills the vector with the free parameters values.
StatedFCNgetFCN ()
 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.
const std::stringname () const
 Returns the name of the fitter.
virtual bool needsDerivatives () const =0
 Returns true if the fitter needs the function to calculate its partial derivatives.
virtual double objectiveValue () const
 Calculates the value of the objective function at the current set of parameters.
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 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 limits for the parameter of the model function indexed by i.
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 for parameter of the minimization.
virtual ~Fitter ()
 The virtual destructor.

Protected Member Functions

 Fitter (const char *name)
 The required constructor.
 Fitter (const Fitter &)
 The copy constructor.

Protected Attributes

StatedFCNm_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

unsigned int getParameterIndex (const std::string &name)
 Returns the index to the model function parameters name.


Constructor & Destructor Documentation

Fitter::Fitter const Fitter  )  [protected]
 

The copy constructor.

Makes a copy of the data members and a clone of the StatedFCN.

Definition at line 30 of file Fitter.cxx.

References clone(), and m_fcn.

Fitter::Fitter const char *  name  )  [protected]
 

The required constructor.

Definition at line 22 of file Fitter.cxx.

Fitter::~Fitter  )  [virtual]
 

The virtual destructor.

Definition at line 38 of file Fitter.cxx.

References m_fcn.


Member Function Documentation

virtual bool Fitter::calcBestFit  )  [pure virtual]
 

Calculates the best fit.

Returns true if the fit converged; otherwise it returns false.

Implemented in BFGSFitter, LMFitter, and MinuitMigrad.

Referenced by hippodraw::Python::export_Fitter(), and FunctionProjector::fitFunction().

int Fitter::calcCovariance std::vector< std::vector< double > > &  cov  )  [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 BFGSFitter, LMFitter, and MinuitMigrad.

Definition at line 172 of file Fitter.cxx.

int Fitter::calcDegreesOfFreedom  )  const [virtual]
 

Returns the number of degrees of freedom in the fit.

Definition at line 165 of file Fitter.cxx.

References m_fcn.

Referenced by FunctionProjector::degreesOfFreedom(), and hippodraw::Python::export_Fitter().

virtual Fitter* Fitter::clone  )  const [pure virtual]
 

Makes a copy of the receiving object.

Makes copy of receiving object by creating a new one with the only constructor.

Attention:
Objects created with this function may not be complete until the setFCN member function is called.

Implemented in BFGSFitter, LMFitter, and MinuitMigrad.

Referenced by Fitter().

void Fitter::fillFreeParameters std::vector< double > &   )  const
 

Fills the vector with the free parameters values.

Definition at line 68 of file Fitter.cxx.

References m_fcn.

Referenced by LMFitter::calcBestFit(), and BFGSFitter::calcBestFit().

StatedFCN * Fitter::getFCN  ) 
 

Returns the objective function object.

Definition at line 54 of file Fitter.cxx.

References m_fcn.

Referenced by hippodraw::Python::export_Fitter().

const vector< int > & Fitter::getFixedFlags  )  const [virtual]
 

Returns a vector containing flags for which parameters are to be held fixed during objective function minimization.

Definition at line 82 of file Fitter.cxx.

References m_fcn.

Referenced by MinuitMigrad::calcBestFit().

unsigned int Fitter::getParameterIndex const std::string name  )  [private]
 

Returns the index to the model function parameters name.

If name is not found, throws a FitterException.

Definition at line 99 of file Fitter.cxx.

References m_fcn, and num_util::size().

Referenced by setLimits(), and setStepSize().

const std::string & Fitter::name  )  const
 

Returns the name of the fitter.

Definition at line 61 of file Fitter.cxx.

References m_name.

Referenced by hippodraw::Python::export_Fitter(), and MinuitMigrad::initialize().

virtual bool Fitter::needsDerivatives  )  const [pure virtual]
 

Returns true if the fitter needs the function to calculate its partial derivatives.

Implemented in BFGSFitter, LMFitter, and MinuitMigrad.

double Fitter::objectiveValue  )  const [virtual]
 

Calculates the value of the objective function at the current set of parameters.

Definition at line 158 of file Fitter.cxx.

References m_fcn.

Referenced by LMFitter::calcBestFit(), hippodraw::Python::export_Fitter(), BFGSFitter::function(), BFGSFitter::gradient(), BFGSFitter::gradp(), and FunctionProjector::objectiveValue().

void Fitter::setFCN StatedFCN fcn  ) 
 

Sets the objective function object.

Sets the objective function object to be used and takes possession of it. That is, will delete the current object, if there is one, and will delete the object in this object's destructor.

Definition at line 45 of file Fitter.cxx.

References m_fcn.

void Fitter::setFitCut TupleCut cut  )  [virtual]
 

Sets the cut to limit range of fitting.

Definition at line 179 of file Fitter.cxx.

References m_fcn.

void Fitter::setFitRange bool  yes = true  )  [virtual]
 

Sets use of a fitting range on or off.

Definition at line 186 of file Fitter.cxx.

References m_fcn.

void Fitter::setFixedFlags const std::vector< int > &  flags  )  [virtual]
 

Sets the parameters that are to be held fixed during objective function minimization.

Definition at line 75 of file Fitter.cxx.

References m_fcn.

Referenced by hippodraw::Python::export_Fitter().

void Fitter::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 123 of file Fitter.cxx.

References getParameterIndex(), and setLimits().

void Fitter::setLimits unsigned int  i,
double  lower,
double  upper
[virtual]
 

Sets the limits for the parameter of the model function indexed by i.

Reimplemented in MinuitMigrad.

Definition at line 89 of file Fitter.cxx.

References m_name.

Referenced by hippodraw::Python::export_Fitter(), and setLimits().

void Fitter::setStepSize const std::string name,
double  size
 

Sets the minimization step size for model function parameter name.

Definition at line 151 of file Fitter.cxx.

References getParameterIndex(), and setStepSize().

void Fitter::setStepSize unsigned int  i,
double  size
[virtual]
 

Sets the step size for parameter of the minimization.

This base class implementation throws FitterException. Derived classes that suport setting step size should override this member function.

Reimplemented in MinuitMigrad.

Definition at line 141 of file Fitter.cxx.

References m_name.

Referenced by hippodraw::Python::export_Fitter(), and setStepSize().


Member Data Documentation

StatedFCN* Fitter::m_fcn [protected]
 

The objective function.

Definition at line 55 of file Fitter.h.

Referenced by LMFitter::calcAlpha(), MinuitMigrad::calcBestFit(), LMFitter::calcBestFit(), BFGSFitter::calcBestFit(), calcDegreesOfFreedom(), MinuitMigrad::checkIndex(), fillFreeParameters(), Fitter(), BFGSFitter::function(), getFCN(), getFixedFlags(), getParameterIndex(), BFGSFitter::gradient(), BFGSFitter::gradp(), MinuitMigrad::initialize(), objectiveValue(), setFCN(), setFitCut(), setFitRange(), setFixedFlags(), and ~Fitter().

int Fitter::m_max_iterations [protected]
 

The maximum number of iterations allowed in attempting the fit.

Definition at line 58 of file Fitter.h.

Referenced by LMFitter::calcBestFit(), BFGSFitter::calcBestFit(), LMFitter::iterParam(), BFGSFitter::iterParam(), LMFitter::setIterParam(), and BFGSFitter::setIterParam().

std::string Fitter::m_name [protected]
 

The name of the fitter.

Definition at line 47 of file Fitter.h.

Referenced by MinuitMigrad::checkIndex(), name(), setLimits(), and setStepSize().


The documentation for this class was generated from the following files:
Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3