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

MinuitMigrad Class Reference

#include <MinuitMigrad.h>

Inheritance diagram for MinuitMigrad:

Inheritance graph
[legend]
Collaboration diagram for MinuitMigrad:

Collaboration graph
[legend]
List of all members.

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.
Requests:
Add support for using Minos to get asymmetric errors.

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

Definition at line 33 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 Fitterclone () const
 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.
 MinuitMigrad (const char *name)
 The constructor.
const std::stringname () const
 Returns the name of the fitter.
virtual bool needsDerivatives () const
 Returns false as this fitter does not need 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 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.

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 ()
 Initializes the Minuit Migrad minimizer.
 MinuitMigrad (const MinuitMigrad &)
 Private copy constructor to prevent user copying.

Private Attributes

MnMigradm_minimizer
 The Minuit Migrad minimizer.


Constructor & Destructor Documentation

MinuitMigrad::MinuitMigrad const MinuitMigrad  )  [private]
 

Private copy constructor to prevent user copying.

Definition at line 34 of file MinuitMigrad.cxx.

References m_minimizer.

Referenced by clone().

MinuitMigrad::MinuitMigrad const char *  name  ) 
 

The constructor.

Definition at line 27 of file MinuitMigrad.cxx.


Member Function Documentation

bool MinuitMigrad::calcBestFit  )  [virtual]
 

Calculates the best fit.

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

Implements Fitter.

Definition at line 116 of file MinuitMigrad.cxx.

References Fitter::getFixedFlags(), initialize(), MinuitParameter::isFixed(), FunctionMinimum::isValid(), Fitter::m_fcn, m_minimizer, and num_util::size().

int MinuitMigrad::calcCovariance std::vector< std::vector< double > > &  cov  )  [virtual]
 

Calculates the covariance matrix.

Reimplemented from Fitter.

Definition at line 150 of file MinuitMigrad.cxx.

References MnMigrad::covariance(), initialize(), m_minimizer, MnUserCovariance::nrow(), and num_util::size().

int Fitter::calcDegreesOfFreedom  )  const [virtual, inherited]
 

Returns the number of degrees of freedom in the fit.

Definition at line 165 of file Fitter.cxx.

References Fitter::m_fcn.

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

void MinuitMigrad::checkIndex unsigned int  index  )  [private]
 

Checks the index and throws exception if out of range.

Definition at line 80 of file MinuitMigrad.cxx.

References initialize(), Fitter::m_fcn, m_minimizer, Fitter::m_name, and num_util::size().

Referenced by setLimits(), and setStepSize().

Fitter * MinuitMigrad::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 45 of file MinuitMigrad.cxx.

References MinuitMigrad().

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

Fills the vector with the free parameters values.

Definition at line 68 of file Fitter.cxx.

References Fitter::m_fcn.

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

StatedFCN * Fitter::getFCN  )  [inherited]
 

Returns the objective function object.

Definition at line 54 of file Fitter.cxx.

References Fitter::m_fcn.

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

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

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 Fitter::m_fcn.

Referenced by calcBestFit().

void MinuitMigrad::initialize  )  [private]
 

Initializes the Minuit Migrad minimizer.

Definition at line 59 of file MinuitMigrad.cxx.

References MnUserParameters::add(), Fitter::m_fcn, m_minimizer, Fitter::name(), and num_util::size().

Referenced by calcBestFit(), calcCovariance(), and checkIndex().

const std::string & Fitter::name  )  const [inherited]
 

Returns the name of the fitter.

Definition at line 61 of file Fitter.cxx.

References Fitter::m_name.

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

bool MinuitMigrad::needsDerivatives  )  const [virtual]
 

Returns false as this fitter does not need the function to calculate its partial derivatives.

Implements Fitter.

Definition at line 52 of file MinuitMigrad.cxx.

double Fitter::objectiveValue  )  const [virtual, inherited]
 

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

Definition at line 158 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 Fitter::setFCN StatedFCN fcn  )  [inherited]
 

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 Fitter::m_fcn.

void Fitter::setFitCut TupleCut cut  )  [virtual, inherited]
 

Sets the cut to limit range of fitting.

Definition at line 179 of file Fitter.cxx.

References Fitter::m_fcn.

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

Sets use of a fitting range on or off.

Definition at line 186 of file Fitter.cxx.

References Fitter::m_fcn.

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

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

Definition at line 75 of file Fitter.cxx.

References Fitter::m_fcn.

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

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

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

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

Sets the upper and lower limits of the parameter.

Reimplemented from Fitter.

Definition at line 100 of file MinuitMigrad.cxx.

References checkIndex(), and m_minimizer.

void Fitter::setStepSize const std::string name,
double  size
[inherited]
 

Sets the minimization step size for model function parameter name.

Definition at line 151 of file Fitter.cxx.

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

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

Sets the step size used by MnMigrad.

Reimplemented from Fitter.

Definition at line 108 of file MinuitMigrad.cxx.

References checkIndex(), and m_minimizer.


Member Data Documentation

StatedFCN* Fitter::m_fcn [protected, inherited]
 

The objective function.

Definition at line 55 of file Fitter.h.

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

int Fitter::m_max_iterations [protected, inherited]
 

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().

MnMigrad* MinuitMigrad::m_minimizer [private]
 

The Minuit Migrad minimizer.

Note:
Needs to be held by pointer because it does not have default constructor.

Definition at line 47 of file MinuitMigrad.h.

Referenced by calcBestFit(), calcCovariance(), checkIndex(), initialize(), MinuitMigrad(), setLimits(), and setStepSize().

std::string Fitter::m_name [protected, inherited]
 

The name of the fitter.

Definition at line 47 of file Fitter.h.

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


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