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

NTupleLikeliHoodFCN Class Reference

#include <NTupleLikeliHoodFCN.h>

Inheritance diagram for NTupleLikeliHoodFCN:

Inheritance graph
[legend]
Collaboration diagram for NTupleLikeliHoodFCN:

Collaboration graph
[legend]
List of all members.

Detailed Description

A Likelihood functor class.

A Likelihood objective function functor class compatible with C++ version of Minuit. This class gets its data points from a NTuple provided by a ProjectorBase object. It uses functions derived from FunctionBase.

Author:
Kaustuv <kaustuv@stanford.edu>

Definition at line 28 of file NTupleLikeliHoodFCN.h.

Public Member Functions

virtual StatedFCNclone () const
 Makes a copy of the 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.
bool hasFunction () const
 Returns true if model function has been set, otherwise returns false.
virtual bool needsIntegrated () const
 Returns true if data points were integrated.
 NTupleLikeliHoodFCN ()
 The default constructor.
virtual double objectiveValue () const
 Calculates and returns the Likelihood function for the 1D binned data.
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 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

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.
int getErrorColumn () const
 Returns the index to the column containing error on the value coordinate.

Protected Attributes

unsigned int m_dimen
 The dimension of the coordinate.
FunctionBasem_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.
const DataSourcem_ntuple
 The ntuple containing the data points for the fitter.

Private Member Functions

 NTupleLikeliHoodFCN (const NTupleLikeliHoodFCN &)
 The copy constructor.


Constructor & Destructor Documentation

NTupleLikeliHoodFCN::NTupleLikeliHoodFCN const NTupleLikeliHoodFCN  )  [private]
 

The copy constructor.

Definition at line 36 of file NTupleLikeliHoodFCN.cxx.

NTupleLikeliHoodFCN::NTupleLikeliHoodFCN  ) 
 

The default constructor.

Definition at line 31 of file NTupleLikeliHoodFCN.cxx.

Referenced by clone().


Member Function Documentation

bool NTupleFCN::acceptRow unsigned int  row  )  const [protected, inherited]
 

Returns true if the DataSource row row is within the fit Range.

Definition at line 249 of file NTupleFCN.cxx.

References NTupleFCN::m_fit_cut, NTupleFCN::m_fit_range, and NTupleFCN::m_ntuple.

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

void NTupleFCN::calcAlphaBeta std::vector< std::vector< double > > &  alpha,
std::vector< double > &  beta
[protected, virtual, inherited]
 

Calculates alpha and beta.

Calculates the matrix alpha and the vector beta based on the data and the function values and derivatives. Resizes them if required.

Requests:
Find out what these really are and document them.
They might be the gradients.

Implements StatedFCN.

Definition at line 190 of file NTupleFCN.cxx.

References NTupleFCN::acceptRow(), StatedFCN::fillFreeDerivatives(), StatedFCN::getNumberFreeParms(), StatedFCN::m_function, StatedFCN::m_has_errors, NTupleFCN::m_indices, NTupleFCN::m_ntuple, StatedFCN::operator()(), NTupleFCN::reset(), hippodraw::Axes::X, hippodraw::Axes::Y, and hippodraw::DataPoint2DTuple::YERR.

StatedFCN * NTupleLikeliHoodFCN::clone  )  const [virtual]
 

Makes a copy of the object.

Implements StatedFCN.

Definition at line 43 of file NTupleLikeliHoodFCN.cxx.

References NTupleLikeliHoodFCN().

int NTupleFCN::degreesOfFreedom  )  const [virtual, inherited]
 

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.

See also:
operator().

Implements StatedFCN.

Definition at line 154 of file NTupleFCN.cxx.

References std::count(), NTupleFCN::getErrorColumn(), StatedFCN::getNumberFreeParms(), StatedFCN::m_has_errors, and NTupleFCN::m_ntuple.

void StatedFCN::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 149 of file StatedFCN.cxx.

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

Referenced by NTupleFCN::calcAlphaBeta().

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

Fills the vector with the values of the free parameters.

Definition at line 89 of file StatedFCN.cxx.

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

int NTupleFCN::getErrorColumn  )  const [protected, inherited]
 

Returns the index to the column containing error on the value coordinate.

Bug:
Should make it general, not just 1 or 2 dimensional.

Definition at line 105 of file NTupleFCN.cxx.

References NTupleFCN::m_dimen, NTupleFCN::m_indices, hippodraw::DataPoint2DTuple::YERR, and hippodraw::DataPoint3DTuple::ZERR.

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

const vector< int > & StatedFCN::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 116 of file StatedFCN.cxx.

References StatedFCN::m_fixed_flags.

unsigned int StatedFCN::getNumberFreeParms  )  const [inherited]
 

Returns the number of free parameters.

Definition at line 103 of file StatedFCN.cxx.

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

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

const vector< double > & StatedFCN::getParameters  )  const [inherited]
 

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

Definition at line 75 of file StatedFCN.cxx.

References StatedFCN::m_function.

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

const vector< string > & StatedFCN::getParmNames  )  const [inherited]
 

Returns the names of the model function's parameters.

Definition at line 68 of file StatedFCN.cxx.

References StatedFCN::m_function.

bool StatedFCN::hasFunction  )  const [inherited]
 

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

Definition at line 48 of file StatedFCN.cxx.

References StatedFCN::m_function.

bool NTupleLikeliHoodFCN::needsIntegrated  )  const [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.

Implements StatedFCN.

Definition at line 116 of file NTupleLikeliHoodFCN.cxx.

double NTupleLikeliHoodFCN::objectiveValue  )  const [virtual]
 

Calculates and returns the Likelihood function for the 1D binned data.

This does not work with unbinned data. or 2Dbinned data.

Implements StatedFCN.

Definition at line 52 of file NTupleLikeliHoodFCN.cxx.

References NTupleFCN::acceptRow(), std::log(), StatedFCN::m_function, NTupleFCN::m_indices, NTupleFCN::m_ntuple, hippodraw::Axes::X, hippodraw::DataPoint2DTuple::XERR, and hippodraw::Axes::Y.

double StatedFCN::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 165 of file StatedFCN.cxx.

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

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

void NTupleFCN::setDataSource const DataSource source,
int  dimension,
const std::vector< int > & 
[virtual, inherited]
 

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 94 of file NTupleFCN.cxx.

References NTupleFCN::m_dimen, NTupleFCN::m_indices, and NTupleFCN::m_ntuple.

void NTupleFCN::setDataSource const DataSource source  )  [virtual, inherited]
 

Sets the data source.

Sets the data source and uses indexes for one dimensional function from hippodraw::DataPoint2DTuple.

Implements StatedFCN.

Definition at line 66 of file NTupleFCN.cxx.

References hippodraw::DataPoint2DTuple::SIZE, num_util::size(), hippodraw::Axes::X, hippodraw::DataPoint2DTuple::XERR, hippodraw::Axes::Y, hippodraw::DataPoint2DTuple::YERR, hippodraw::Axes::Z, and hippodraw::DataPoint3DTuple::ZERR.

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

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

Sets the cut to limit range of fitting.

Bug:
Works only for one dimensional coordinate.

Implements StatedFCN.

Definition at line 232 of file NTupleFCN.cxx.

References NTupleFCN::m_fit_cut, NTupleFCN::m_indices, and hippodraw::Axes::X.

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

Sets use of a fitting range on or off.

Implements StatedFCN.

Definition at line 242 of file NTupleFCN.cxx.

References NTupleFCN::m_fit_range.

void StatedFCN::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 124 of file StatedFCN.cxx.

References StatedFCN::m_fixed_flags.

void StatedFCN::setFreeParameters const std::vector< double > &  parms  )  [virtual, inherited]
 

Sets the free parameters from the vector parms.

Definition at line 131 of file StatedFCN.cxx.

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

void StatedFCN::setFunction FunctionBase function  )  [inherited]
 

Sets the model function.

Sets the model function object to function.

Definition at line 55 of file StatedFCN.cxx.

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

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

void StatedFCN::setParameters const std::vector< double > &  parms  )  [inherited]
 

Sets the values of the model function's parameters.

Definition at line 82 of file StatedFCN.cxx.

References StatedFCN::m_function.

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

bool NTupleFCN::setUseErrors bool  yes = true  )  [virtual, inherited]
 

Sets the use of errors on the data point.

If the data points contained in the NTuple 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 135 of file NTupleFCN.cxx.

References NTupleFCN::hasErrors(), and StatedFCN::m_has_errors.

virtual double NTupleLikeliHoodFCN::up  )  const [inline, virtual]
 

Implements FCNBase.

Definition at line 48 of file NTupleLikeliHoodFCN.h.


Member Data Documentation

unsigned int NTupleFCN::m_dimen [protected, inherited]
 

The dimension of the coordinate.

Definition at line 70 of file NTupleFCN.h.

Referenced by NTupleFCN::getErrorColumn(), NTupleChiSqFCN::objectiveValue(), and NTupleFCN::setDataSource().

FunctionBase* StatedFCN::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 64 of file StatedFCN.h.

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

bool StatedFCN::m_has_errors [protected, inherited]
 

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 StatedFCN.h.

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

std::vector< int > NTupleFCN::m_indices [protected, inherited]
 

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 66 of file NTupleFCN.h.

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

const DataSource* NTupleFCN::m_ntuple [protected, inherited]
 

The ntuple containing the data points for the fitter.

Definition at line 74 of file NTupleFCN.h.

Referenced by NTupleFCN::acceptRow(), NTupleFCN::calcAlphaBeta(), NTupleFCN::degreesOfFreedom(), NTupleFCN::hasErrors(), NTuplePearsonFCN::objectiveValue(), objectiveValue(), NTupleChiSqFCN::objectiveValue(), and NTupleFCN::setDataSource().


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