Classes | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
MinuitMigrad Class Reference

A Fitter class. More...

#include <MinuitMigrad.h>

Inheritance diagram for MinuitMigrad:
Inheritance graph
[legend]
Collaboration diagram for MinuitMigrad:
Collaboration graph
[legend]

Classes

struct  limit
 Structure to hold limit values, if any. More...

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 Fitterclone () 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.
StatedFCNgetFCN ()
 Returns the objective function object.
virtual const std::vector< int > & getFixedFlags () const
 Sets the limits of the model function parameter values.
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.
virtual void setLimits (unsigned int i, double lower, double upper)
 Sets the upper and lower limits of the parameter.
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 setStepSize (unsigned int i, double size)
 Sets the step size used by MnMigrad.
void setStepSize (const std::string &name, double size)
 Sets the minimization step size for model function parameter name.
void setUseErrors (bool yes=true)
 Sets the fitter to use error data from the DataSource, if available.

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

void checkIndex (unsigned int index)
 Checks the index and throws exception if out of range.
void initialize ()
 The Minuit Migrad minimizer.
void initLimits ()
 Initializes the limits.
 MinuitMigrad (const MinuitMigrad &)
 Private copy constructor to prevent user copying.

Private Attributes

std::vector< limitm_limits
 The limit parameters.

Detailed Description

A Fitter class.

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.

Bug:
@ when fixxing a parameter, and doing a fit the tixed parameter doesn't show up as fixed in GUI, because the selected parameter changes.
Requests:
Add support for using Minos to get asymmetric errors.
Author
Paul F. Kunz Paul_.nosp@m.Kunz.nosp@m.@slac.nosp@m..sta.nosp@m.nford.nosp@m..edu

Definition at line 54 of file MinuitMigrad.h.

Constructor & Destructor Documentation

MinuitMigrad ( const MinuitMigrad mm)
private

Private copy constructor to prevent user copying.

Definition at line 48 of file MinuitMigrad.cxx.

Referenced by MinuitMigrad::clone().

MinuitMigrad ( const char *  name)

The constructor.

Definition at line 41 of file MinuitMigrad.cxx.

Member Function Documentation

bool calcBestFit ( )
virtual

Calculates the best fit.

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

Note
The implementation always creates a new MinuitMigrad object as there appears to be no way to add additional parameters once the MinuitMigrad object is created. Within HippoDraw, we allow adding of functions to the composite LinearSumFunction, which effectively adds parameters.

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
virtualinherited

Returns the number of degrees of freedom in the fit.

Definition at line 228 of file Fitter.cxx.

References Fitter::m_fcn.

Referenced by FunctionProjector::degreesOfFreedom().

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.

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

Implements Fitter.

Definition at line 59 of file MinuitMigrad.cxx.

References MinuitMigrad::MinuitMigrad().

void copyFrom ( const Fitter other)
virtualinherited

Makes a copy of other.

Definition at line 49 of file Fitter.cxx.

References Fitter::m_fcn.

void fillFreeParameters ( std::vector< double > &  free_parms) const
inherited

Fills the vector with the free parameters values.

Definition at line 141 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 72 of file Fitter.cxx.

References Fitter::m_fcn.

const vector< int > & getFixedFlags ( ) const
virtualinherited

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 155 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 118 of file Fitter.cxx.

References Fitter::m_fcn.

void initialize ( )
private

The Minuit Migrad minimizer.

Note
Needs to be held by pointer because it does not have default constructor.Initializes the Minuit Migrad minimizer.

Definition at line 65 of file MinuitMigrad.cxx.

References MnUserParameters::add(), hippodraw::Axes::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, MinuitMigrad::m_limits, and MinuitMigrad::limit::set.

Referenced by MinuitMigrad::setLimits().

bool isCompatible ( const FunctionBase function) const
inherited

Returns true if the function is compatible with the objective function.

Definition at line 79 of file Fitter.cxx.

References Fitter::m_fcn.

const std::string & name ( ) const
inherited

Returns the name of the fitter.

Definition at line 56 of file Fitter.cxx.

References Fitter::m_name.

Referenced by Fitter::getParameterIndex(), MinuitMigrad::initialize(), BFGSFitter::iterParam(), and BFGSFitter::setIterParam().

bool needsIntegrated ( ) const
inherited

Returns true if the Fitter needs integrated intervals.

Definition at line 130 of file Fitter.cxx.

References Fitter::m_fcn.

double objectiveValue ( ) const
virtualinherited

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

Definition at line 221 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)
inherited

Sets the source of data to be used.

Definition at line 99 of file Fitter.cxx.

References Fitter::m_fcn, and Fitter::setUseErrors().

void setFCN ( StatedFCN fcn)
virtualinherited

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.

Attention
A derived class that has special requirements, such as need for partial derivatives with respect to the parameters should override this method to set those requirements.

Reimplemented in LMFitter.

Definition at line 63 of file Fitter.cxx.

References Fitter::m_fcn.

void setFitCut ( TupleCut cut)
virtualinherited

Sets the cut to limit range of fitting.

Definition at line 242 of file Fitter.cxx.

References Fitter::m_fcn.

void setFitRange ( bool  yes = true)
virtualinherited

Sets use of a fitting range on or off.

Definition at line 249 of file Fitter.cxx.

References Fitter::m_fcn.

void setFixedFlags ( const std::vector< int > &  flags)
virtualinherited

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

Definition at line 148 of file Fitter.cxx.

References Fitter::m_fcn.

void setFunction ( FunctionBase function)
inherited

Sets the model function.

Definition at line 90 of file Fitter.cxx.

References Fitter::m_fcn.

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 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 196 of file Fitter.cxx.

References Fitter::getParameterIndex(), and Fitter::setLimits().

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 setStepSize ( const std::string &  name,
double  size 
)
inherited

Sets the minimization step size for model function parameter name.

Definition at line 214 of file Fitter.cxx.

References Fitter::getParameterIndex(), and Fitter::setStepSize().

void setUseErrors ( bool  yes = true)
inherited

Sets the fitter to use error data from the DataSource, if available.

Definition at line 109 of file Fitter.cxx.

References Fitter::m_fcn.

Referenced by Fitter::setDataSource().

Member Data Documentation

StatedFCN* m_fcn
protectedinherited
std::vector< limit > m_limits
private

The limit parameters.

Definition at line 76 of file MinuitMigrad.h.

Referenced by MinuitMigrad::initialize(), MinuitMigrad::initLimits(), and MinuitMigrad::setLimits().

int m_max_iterations
protectedinherited

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
protectedinherited

The name of the fitter.

Definition at line 51 of file Fitter.h.

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


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

Generated for HippoDraw Class Library by doxygen