#include <NTupleFCN.h>
Inheritance diagram for NTupleFCN:
It derives from StatedFCN to access the stated model function.
Definition at line 31 of file NTupleFCN.h.
Public Member Functions | |
virtual StatedFCN * | clone () const=0 |
Makes a copy of the derived class object. | |
virtual int | degreesOfFreedom () const |
Calculates 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 |
Gets the use of errors. | |
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 > &) |
Sets the data source, dimension, and indices into the columns. | |
void | setDataSource (const DataSource *source) |
Sets the data source. | |
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 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) |
Sets the use of errors on the data point. | |
virtual double | up () const=0 |
Protected Member Functions | |
bool | acceptRow (unsigned int row) const |
Returns true if the DataSource row row is within the fit Range. | |
virtual void | calcAlphaBeta (std::vector< std::vector< double > > &alpha, std::vector< double > &beta) |
Calculates alpha and beta. | |
virtual void | copyFrom (const StatedFCN *) |
Makes a copy of the relevant attributes from other object. | |
int | getErrorColumn () const |
Returns the index to the column containing error on the value coordinate. | |
NTupleFCN (const NTupleFCN &) | |
The copy constructor. | |
NTupleFCN () | |
The default constructor. | |
Protected Attributes | |
FunctionBase * | m_function |
A pointer to the model function to be used in fitting. | |
bool | m_has_errors |
Error use flag. | |
std::vector< int > | m_indices |
The indexes into the DataSource. | |
bool | m_needs_derivs |
Needs derivatives flag. | |
const DataSource * | m_ntuple |
The data source containing the data points for the fitter. | |
Private Member Functions | |
bool | hasErrors () const |
Examines state of error bars. | |
void | reset (std::vector< std::vector< double > > &alpha, std::vector< double > &beta, unsigned int size) |
Resets the matrix alpha and the vector beta. | |
Private Attributes | |
TupleCut * | m_fit_cut |
The cut that manages the range on X to be used for fitting. | |
bool | m_fit_range |
Set to true if the fitting range is turn on. |
NTupleFCN | ( | ) | [protected] |
The default constructor.
The default constructor which initializes points to objects it uses to the null pointer.
Definition at line 36 of file NTupleFCN.cxx.
bool acceptRow | ( | unsigned int | row | ) | const [protected] |
Returns true if the DataSource row row is within the fit Range.
Definition at line 255 of file NTupleFCN.cxx.
References NTupleFCN::m_fit_cut, NTupleFCN::m_fit_range, and NTupleFCN::m_ntuple.
Referenced by NTupleFCN::calcAlphaBeta(), NTuplePearsonFCN::objectiveValue(), NTupleLikeliHoodFCN::objectiveValue(), and NTupleChiSqFCN::objectiveValue().
void calcAlphaBeta | ( | std::vector< std::vector< double > > & | alpha, | |
std::vector< double > & | beta | |||
) | [protected, virtual] |
Calculates alpha and beta.
Calculates the matrix alpha and the vector beta based on the data and the function values and derivatives. Re-sizes them if required.
Implements StatedFCN.
Definition at line 194 of file NTupleFCN.cxx.
References NTupleFCN::acceptRow(), StatedFCN::fillFreeDerivatives(), StatedFCN::getNumberFreeParms(), StatedFCN::m_function, NTupleFCN::m_has_errors, NTupleFCN::m_indices, NTupleFCN::m_ntuple, StatedFCN::operator()(), NTupleFCN::reset(), hippodraw::DataPoint3DTuple::X, hippodraw::DataPoint3DTuple::Y, and hippodraw::DataPoint3DTuple::YERR.
virtual StatedFCN* clone | ( | ) | const [pure virtual, inherited] |
Makes a copy of the derived class object.
Implemented in NTupleChiSqFCN, NTupleLikeliHoodFCN, and NTuplePearsonFCN.
void copyFrom | ( | const StatedFCN * | other | ) | [protected, virtual] |
Makes a copy of the relevant attributes from other object.
Reimplemented from StatedFCN.
Definition at line 56 of file NTupleFCN.cxx.
References StatedFCN::copyFrom(), NTupleFCN::m_fit_cut, NTupleFCN::m_fit_range, NTupleFCN::m_has_errors, NTupleFCN::m_indices, and NTupleFCN::m_ntuple.
int degreesOfFreedom | ( | ) | const [virtual] |
Calculates the number of degrees of freedom.
Calculates the number of degrees of freedom. If the data points have error measurements, then points with zero error are ignored.
Implements StatedFCN.
Definition at line 158 of file NTupleFCN.cxx.
References NTupleFCN::getErrorColumn(), StatedFCN::getNumberFreeParms(), NTupleFCN::m_has_errors, and NTupleFCN::m_ntuple.
void fillFreeDerivatives | ( | std::vector< double > & | , | |
double | x | |||
) | [inherited] |
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 [inherited] |
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().
int getErrorColumn | ( | ) | const [protected] |
Returns the index to the column containing error on the value coordinate.
Definition at line 99 of file NTupleFCN.cxx.
References NTupleFCN::m_indices.
Referenced by NTupleFCN::degreesOfFreedom(), NTupleFCN::hasErrors(), and NTupleChiSqFCN::objectiveValue().
const vector< int > & getFixedFlags | ( | ) | const [inherited] |
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 [inherited] |
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 [inherited] |
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 [inherited] |
Returns the names of the model function's parameters.
Definition at line 86 of file StatedFCN.cxx.
References StatedFCN::m_function.
bool getUseErrors | ( | ) | const [virtual] |
Gets the use of errors.
If the there is no errors or ignore errors is chosen, return false. If the data points contain errors and errors is not ignored, return true.
Implements StatedFCN.
Definition at line 151 of file NTupleFCN.cxx.
References NTupleFCN::m_has_errors.
bool hasErrors | ( | ) | const [private] |
Examines state of error bars.
Returns true
if at least one data point in has non zero error, otherwise returns false
.
Definition at line 109 of file NTupleFCN.cxx.
References NTupleFCN::getErrorColumn(), and NTupleFCN::m_ntuple.
Referenced by NTupleFCN::setUseErrors().
bool hasFunction | ( | ) | const [inherited] |
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 [inherited] |
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, inherited] |
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, inherited] |
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, inherited] |
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().
void reset | ( | std::vector< std::vector< double > > & | alpha, | |
std::vector< double > & | beta, | |||
unsigned int | size | |||
) | [private] |
Resets the matrix alpha and the vector beta.
Resets the matrix and vector to the appropriate size, if needed, and sets the elements to zero.
Definition at line 175 of file NTupleFCN.cxx.
Referenced by NTupleFCN::calcAlphaBeta().
void setDataSource | ( | const DataSource * | source, | |
int | dimension, | |||
const std::vector< int > & | ||||
) | [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.
Implements StatedFCN.
Definition at line 89 of file NTupleFCN.cxx.
References NTupleFCN::m_indices, and NTupleFCN::m_ntuple.
void setDataSource | ( | const DataSource * | source | ) | [virtual] |
Sets the data source.
Sets the data source and uses indexes for one dimensional function from hippodraw::DataPoint2DTuple.
Implements StatedFCN.
Definition at line 75 of file NTupleFCN.cxx.
References num_util::size().
Referenced by hippodraw::Python::export_NTupleFCN().
void setFitCut | ( | TupleCut * | cut | ) | [virtual] |
Sets the cut to limit range of fitting.
Implements StatedFCN.
Definition at line 236 of file NTupleFCN.cxx.
References NTupleFCN::m_fit_cut, NTupleFCN::m_indices, and hippodraw::DataPoint3DTuple::X.
void setFitRange | ( | bool | yes = true |
) | [virtual] |
Sets use of a fitting range on or off.
Implements StatedFCN.
Definition at line 248 of file NTupleFCN.cxx.
References NTupleFCN::m_fit_range.
void setFixedFlags | ( | const std::vector< int > & | flags | ) | [virtual, inherited] |
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, inherited] |
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 | ) | [inherited] |
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 | ) | [inherited] |
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 | ) | [inherited] |
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().
bool setUseErrors | ( | bool | yes = true |
) | [virtual] |
Sets the use of errors on the data point.
If the data points contained in the DataSource contains errors, then set the use of errors on and return true
. If the data points do not contain errors, then set the use of errors off and return true
. If yes is false
, then always set use of errors off and return true
.
Implements StatedFCN.
Definition at line 132 of file NTupleFCN.cxx.
References NTupleFCN::hasErrors(), and NTupleFCN::m_has_errors.
The cut that manages the range on X to be used for fitting.
Definition at line 37 of file NTupleFCN.h.
Referenced by NTupleFCN::acceptRow(), NTupleFCN::copyFrom(), and NTupleFCN::setFitCut().
bool m_fit_range [private] |
Set to true
if the fitting range is turn on.
Definition at line 77 of file NTupleFCN.h.
Referenced by NTupleFCN::acceptRow(), NTupleFCN::copyFrom(), and NTupleFCN::setFitRange().
FunctionBase* m_function [protected, inherited] |
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_has_errors [protected] |
Error use flag.
A flag set to true
, if errors on measured points are to be used. When set true
, only data points with non-zero errors are used. When set false
, all error on data points is set to 1.0
Definition at line 71 of file NTupleFCN.h.
Referenced by NTupleFCN::calcAlphaBeta(), NTupleFCN::copyFrom(), NTupleFCN::degreesOfFreedom(), NTupleFCN::getUseErrors(), NTuplePearsonFCN::objectiveValue(), NTupleChiSqFCN::objectiveValue(), and NTupleFCN::setUseErrors().
std::vector< int > m_indices [protected] |
The indexes into the DataSource.
The first set are the coordinate variables. The next to last is the value and the last is the error on the value, or -1 if no errors available. Thus the size of the vector should be at least 3 and can be more for multi-dimensional coordinates.
Definition at line 60 of file NTupleFCN.h.
Referenced by NTupleFCN::calcAlphaBeta(), NTupleFCN::copyFrom(), NTupleFCN::getErrorColumn(), NTuplePearsonFCN::objectiveValue(), NTupleLikeliHoodFCN::objectiveValue(), NTupleChiSqFCN::objectiveValue(), NTupleFCN::setDataSource(), and NTupleFCN::setFitCut().
bool m_needs_derivs [protected, inherited] |
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().
const DataSource* m_ntuple [protected] |
The data source containing the data points for the fitter.
Definition at line 64 of file NTupleFCN.h.
Referenced by NTupleFCN::acceptRow(), NTupleFCN::calcAlphaBeta(), NTupleFCN::copyFrom(), NTupleFCN::degreesOfFreedom(), NTupleFCN::hasErrors(), NTuplePearsonFCN::objectiveValue(), NTupleLikeliHoodFCN::objectiveValue(), NTupleChiSqFCN::objectiveValue(), and NTupleFCN::setDataSource().