StatedFCN Class Reference

#include <StatedFCN.h>

Inheritance diagram for StatedFCN:

Inheritance graph
NTupleFCNFCNBaseNTupleChiSqFCNNTupleLikeliHoodFCNNTuplePearsonFCN
[legend]
Collaboration diagram for StatedFCN:

Collaboration graph
FCNBaseFunctionBase
[legend]
List of all members.

Detailed Description

A derived class for FCNBase class.

This class uses a stated function derived from FunctionBase. That is, it assumes the function maintains the state of all its parameters.

Note:
If HippoDraw is built with Minuit or Minuit2, then this class is derived from the Minuit's FCNBase class, otherwise it derives from HippoDraw's FCNBase. The difference between Minuit and Minuit2 is the capitialization of the member function names. There's no difference between HippoDraw's and Minuit's FCNBase class. If you derive from this class, you need to supply a config.h file which contains a define HAVE_MINUIT or define HAVE_MINUIT2 depending on how HippoDraw was built. HippoDraw doesn't install its autoconf generated config.h file since it may conflict with a file of the same name from other packages.
Author:
Paul F. Kunz <Paul_Kunz@slac.stanford.edu>

Definition at line 69 of file StatedFCN.h.

Public Member Functions

virtual void calcAlphaBeta (std::vector< std::vector< double > > &alpha, std::vector< double > &beta)=0
virtual StatedFCNclone () const=0
 Makes a copy of the derived class object.
virtual void copyFrom (const StatedFCN *other)
 Makes a copy of the relevant attributes from other object.
virtual int degreesOfFreedom () const=0
 Returns the number of degrees of freedom.
virtual double errorDef () const
void fillFreeDerivatives (std::vector< double > &, double x)
 Clears and fills the vector with the derivatives of the function a coordinate value x.
void fillFreeParameters (std::vector< double > &free_parms) const
 Fills the vector with the values of the free parameters.
const std::vector< int > & getFixedFlags () const
 Returns the vector of which of the model function's parameters are considered fixed and not to be changed during minimization of this objective function.
unsigned int getNumberFreeParms () const
 Returns the number of free parameters.
const std::vector< double > & getParameters () const
 Returns the current state of the model function's parameters.
const std::vector< std::string > & getParmNames () const
 Returns the names of the model function's parameters.
virtual bool getUseErrors () const=0
 Returns true if error data from the DataSource is to be used.
bool hasFunction () const
 Returns true if model function has been set, otherwise returns false.
bool isCompatible (const FunctionBase *) const
 Returns true if function is compatible this objective function.
virtual bool needsIntegrated () const=0
 Returns true if data points were integrated.
virtual double objectiveValue () const=0
 Returns the value of the objective function.
virtual double operator() (const std::vector< double > &parms) const
 Sets the model function parameters to parms and returns the objective value.
virtual void setDataSource (const DataSource *source, int dimension, const std::vector< int > &)=0
 Sets the data source, dimension, and indices into the columns.
virtual void setDataSource (const DataSource *source)=0
 Sets the data source.
virtual void setFitCut (TupleCut *cut)=0
 Sets the cut to limit range of fitting.
virtual void setFitRange (bool yes=true)=0
 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 minimization of this objective function.
virtual void setFreeParameters (const std::vector< double > &parms)
 Sets the free parameters from the vector parms.
void setFunction (FunctionBase *function)
 Sets the model function.
void setNeedsDerivatives (bool yes)
 Sets the needs derivatives flag.
void setParameters (const std::vector< double > &parms)
 Sets the values of the model function's parameters.
virtual bool setUseErrors (bool yes=true)=0
 Sets the FCN to use errors from the DataSource if they are available on all data points.
virtual double up () const=0

Protected Member Functions

 StatedFCN (const StatedFCN &)
 The copy constructor.
 StatedFCN ()
 The default constructor.

Protected Attributes

FunctionBasem_function
 A pointer to the model function to be used in fitting.
bool m_needs_derivs
 Needs derivatives flag.

Private Attributes

std::vector< int > m_fixed_flags
 The flags to indicated which parameters are to be held fixed during minimization of this objective function.


Constructor & Destructor Documentation

StatedFCN (  )  [protected]

The default constructor.

The default constructor initializes the pointer to the model function to the null pointer.

Definition at line 28 of file StatedFCN.cxx.

StatedFCN ( const StatedFCN  )  [protected]

The copy constructor.

The copy constructor makes a copy of the pointer to the FunctionBase object it uses.

Definition at line 35 of file StatedFCN.cxx.


Member Function Documentation

virtual void calcAlphaBeta ( std::vector< std::vector< double > > &  alpha,
std::vector< double > &  beta 
) [pure virtual]

Implemented in NTupleFCN.

virtual StatedFCN* clone (  )  const [pure virtual]

Makes a copy of the derived class object.

Implemented in NTupleChiSqFCN, NTupleLikeliHoodFCN, and NTuplePearsonFCN.

void copyFrom ( const StatedFCN other  )  [virtual]

Makes a copy of the relevant attributes from other object.

Note:
This is similar to a copy constructor, but can be used between objects from different derived classes.

Reimplemented in NTupleFCN.

Definition at line 45 of file StatedFCN.cxx.

References StatedFCN::m_fixed_flags, and StatedFCN::m_function.

Referenced by NTupleFCN::copyFrom().

virtual int degreesOfFreedom (  )  const [pure virtual]

Returns the number of degrees of freedom.

Implemented in NTupleFCN.

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

void fillFreeDerivatives ( std::vector< double > &  ,
double  x 
)

Clears and fills the vector with the derivatives of the function a coordinate value x.

Definition at line 166 of file StatedFCN.cxx.

References StatedFCN::getParameters(), StatedFCN::m_fixed_flags, StatedFCN::m_function, and num_util::size().

Referenced by NTupleFCN::calcAlphaBeta().

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

Fills the vector with the values of the free parameters.

Definition at line 107 of file StatedFCN.cxx.

References StatedFCN::getParameters(), StatedFCN::m_fixed_flags, StatedFCN::m_function, and num_util::size().

const vector< int > & getFixedFlags (  )  const

Returns the vector of which of the model function's parameters are considered fixed and not to be changed during minimization of this objective function.

Definition at line 134 of file StatedFCN.cxx.

References StatedFCN::m_fixed_flags.

unsigned int getNumberFreeParms (  )  const

Returns the number of free parameters.

Definition at line 121 of file StatedFCN.cxx.

References StatedFCN::m_fixed_flags, and num_util::size().

Referenced by NTupleFCN::calcAlphaBeta(), and NTupleFCN::degreesOfFreedom().

const vector< double > & getParameters (  )  const

Returns the current state of the model function's parameters.

Definition at line 93 of file StatedFCN.cxx.

References StatedFCN::m_function.

Referenced by StatedFCN::fillFreeDerivatives(), StatedFCN::fillFreeParameters(), and StatedFCN::setFreeParameters().

const vector< string > & getParmNames (  )  const

Returns the names of the model function's parameters.

Definition at line 86 of file StatedFCN.cxx.

References StatedFCN::m_function.

virtual bool getUseErrors (  )  const [pure virtual]

Returns true if error data from the DataSource is to be used.

Implemented in NTupleFCN.

bool hasFunction (  )  const

Returns true if model function has been set, otherwise returns false.

Definition at line 54 of file StatedFCN.cxx.

References StatedFCN::m_function.

bool isCompatible ( const FunctionBase  )  const

Returns true if function is compatible this objective function.

Return false if the function is incompatible with this objective function. For example, if the fitter indicated it needs partial derivatives and the function can not provide them.

Definition at line 198 of file StatedFCN.cxx.

References StatedFCN::m_needs_derivs.

Referenced by StatedFCN::setFunction().

virtual bool needsIntegrated (  )  const [pure virtual]

Returns true if data points were integrated.

Return true if the FCN function needs data points were integrated over a range. An example would be a histogram. Returns false if the integrated data points are not needed.

Implemented in NTupleChiSqFCN, NTupleLikeliHoodFCN, and NTuplePearsonFCN.

virtual double objectiveValue (  )  const [pure virtual]

Returns the value of the objective function.

Returns the value of the objective function for the current state of the function. The state of the function's parameters is set by operator(). Other states the function may have is set by calling member functions of the function directly.

Implemented in NTupleChiSqFCN, NTupleLikeliHoodFCN, and NTuplePearsonFCN.

Referenced by hippodraw::Python::export_StatedFCN(), and StatedFCN::operator()().

double operator() ( const std::vector< double > &  parms  )  const [virtual]

Sets the model function parameters to parms and returns the objective value.

Implements FCNBase.

Definition at line 182 of file StatedFCN.cxx.

References StatedFCN::m_function, StatedFCN::objectiveValue(), and StatedFCN::setParameters().

Referenced by NTupleFCN::calcAlphaBeta(), NTuplePearsonFCN::objectiveValue(), and NTupleChiSqFCN::objectiveValue().

virtual void setDataSource ( const DataSource source,
int  dimension,
const std::vector< int > &   
) [pure virtual]

Sets the data source, dimension, and indices into the columns.

Sets the data source, dimension and indices into the column. For one dimensional data source, the order of the indices are as in The hippodraw::DataPoint2DTuple enumeration. For two dimensional data source as with hippodraw::DataPoint3DTuple enumeration. For higher dimensions, the pattern should repeat. A negative index value indicates that the variable is not used.

Implemented in NTupleFCN.

virtual void setDataSource ( const DataSource source  )  [pure virtual]

Sets the data source.

Sets the data source and uses indices from hippodraw::DataPoint2DTuple.

Implemented in NTupleFCN.

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

virtual void setFitCut ( TupleCut cut  )  [pure virtual]

Sets the cut to limit range of fitting.

Implemented in NTupleFCN.

virtual void setFitRange ( bool  yes = true  )  [pure virtual]

Sets use of a fitting range on or off.

Implemented in NTupleFCN.

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

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

Definition at line 141 of file StatedFCN.cxx.

References StatedFCN::m_fixed_flags.

void setFreeParameters ( const std::vector< double > &  parms  )  [virtual]

Sets the free parameters from the vector parms.

Definition at line 148 of file StatedFCN.cxx.

References StatedFCN::getParameters(), StatedFCN::m_fixed_flags, StatedFCN::m_function, StatedFCN::setParameters(), and num_util::size().

void setFunction ( FunctionBase function  ) 

Sets the model function.

Sets the model function object to function.

Definition at line 64 of file StatedFCN.cxx.

References StatedFCN::isCompatible(), StatedFCN::m_fixed_flags, StatedFCN::m_function, and num_util::size().

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

void setNeedsDerivatives ( bool  yes  ) 

Sets the needs derivatives flag.

Sets the needs derivatives flag to true if the Fitter needs partial derivatives from the FunctionBase object.

Definition at line 191 of file StatedFCN.cxx.

References StatedFCN::m_needs_derivs.

void setParameters ( const std::vector< double > &  parms  ) 

Sets the values of the model function's parameters.

Definition at line 100 of file StatedFCN.cxx.

References StatedFCN::m_function.

Referenced by StatedFCN::operator()(), and StatedFCN::setFreeParameters().

virtual bool setUseErrors ( bool  yes = true  )  [pure virtual]

Sets the FCN to use errors from the DataSource if they are available on all data points.

Implemented in NTupleFCN.

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


Member Data Documentation

std::vector< int > m_fixed_flags [private]

The flags to indicated which parameters are to be held fixed during minimization of this objective function.

Note:
The flags are held as int because it is more space and time efficient for the expected number of parameters.

Definition at line 82 of file StatedFCN.h.

Referenced by StatedFCN::copyFrom(), StatedFCN::fillFreeDerivatives(), StatedFCN::fillFreeParameters(), StatedFCN::getFixedFlags(), StatedFCN::getNumberFreeParms(), StatedFCN::setFixedFlags(), StatedFCN::setFreeParameters(), and StatedFCN::setFunction().

FunctionBase* m_function [protected]

A pointer to the model function to be used in fitting.

This object does not own the function.

Definition at line 89 of file StatedFCN.h.

Referenced by NTupleFCN::calcAlphaBeta(), StatedFCN::copyFrom(), StatedFCN::fillFreeDerivatives(), StatedFCN::fillFreeParameters(), StatedFCN::getParameters(), StatedFCN::getParmNames(), StatedFCN::hasFunction(), NTuplePearsonFCN::objectiveValue(), NTupleLikeliHoodFCN::objectiveValue(), NTupleChiSqFCN::objectiveValue(), StatedFCN::operator()(), StatedFCN::setFreeParameters(), StatedFCN::setFunction(), and StatedFCN::setParameters().

bool m_needs_derivs [protected]

Needs derivatives flag.

A flag set to true, if the Fitter needs partial derivatives from the FunctionBase.

Definition at line 94 of file StatedFCN.h.

Referenced by StatedFCN::isCompatible(), and StatedFCN::setNeedsDerivatives().


The documentation for this class was generated from the following files:
Generated for HippoDraw Class Library by doxygen