LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar::util::GaussianFit< T > Class Template Referenceabstract

"Fast" Gaussian fit More...

#include "SimpleFits.h"

Inheritance diagram for lar::util::GaussianFit< T >:
lar::util::details::SimpleFitterInterface< T, 3 >

Classes

struct  EncodeExtractor
 
struct  EncodeExtractor< Pred, void >
 
struct  Value_t
 < type of value and error More...
 

Public Types

using Data_t = typename Base_t::Data_t
 type of the data More...
 
using Measurement_t = typename Fitter_t::Measurement_t
 type of measurement without uncertainty More...
 
using MeasurementAndUncertainty_t = typename Fitter_t::MeasurementAndUncertainty_t
 type of measurement with uncertainty More...
 
using FitParameters_t = typename Fitter_t::FitParameters_t
 
using FitMatrix_t = typename Fitter_t::FitMatrix_t
 
using MatrixOps = FastMatrixOperations< Data_t, NParams >
 

Public Member Functions

virtual bool FillResults (FitParameters_t &params, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override
 Fills the specified parameters. More...
 
virtual bool FillResults (FitParameters_t &params, FitParameters_t &paramerrors, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override
 Fills the specified parameters. More...
 
virtual bool FillResults (FitParameters_t &params, FitParameters_t &paramerrors) const override
 Fills the specified parameters. More...
 
virtual Data_t Evaluate (Data_t x) const override
 Evaluates the fitted function at the specified point. More...
 
virtual Fitter_t const & Fitter () const
 Returns the internal fitter (mostly for debugging) More...
 
virtual bool FillResults (FitParameters_t &params, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const =0
 Fills the specified parameters. More...
 
virtual bool FillResults (FitParameters_t &params, FitParameters_t &paramerrors, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const =0
 Fills the specified parameters. More...
 
virtual bool FillResults (FitParameters_t &params, FitParameters_t &paramerrors) const =0
 Fills the specified parameters. More...
 
virtual Data_t Evaluate (Data_t x) const =0
 Evaluates the fitted function at the specified point. More...
 
Data_t operator() (Data_t x) const
 Evaluates the fitted function; alias of Evaluate() More...
 
Add elements
See also
FitDataCollector
bool add (Data_t x, Data_t y, Data_t sy=Data_t(1.0))
 Clears all the input statistics. More...
 
bool add (Measurement_t value, Data_t sy=Data_t(1.0))
 Clears all the input statistics. More...
 
bool add (MeasurementAndUncertainty_t value)
 Clears all the input statistics. More...
 
template<typename Iter >
void add_without_uncertainty (Iter begin, Iter end)
 Clears all the input statistics. More...
 
template<typename Iter , typename Pred >
void add_without_uncertainty (Iter begin, Iter end, Pred extractor)
 Clears all the input statistics. More...
 
template<typename Cont , typename Pred >
void add_without_uncertainty (Cont cont, Pred extractor)
 Clears all the input statistics. More...
 
template<typename Cont >
void add_without_uncertainty (Cont cont)
 Clears all the input statistics. More...
 
template<typename VIter , typename UIter , typename VPred , typename UPred = identity>
unsigned int add_with_uncertainty (VIter begin_value, VIter end_value, UIter begin_uncertainty, VPred value_extractor, UPred uncertainty_extractor=UPred())
 Clears all the input statistics. More...
 
template<typename Iter >
unsigned int add_with_uncertainty (Iter begin, Iter end)
 Clears all the input statistics. More...
 
template<typename Cont >
unsigned int add_with_uncertainty (Cont cont)
 Clears all the input statistics. More...
 
void clear ()
 Clears all the input statistics. More...
 
int N () const
 Returns the number of (valid) points added. More...
 
template<typename Stream >
void PrintStats (Stream &out) const
 Prints the collected statistics into a stream. More...
 
Fitting
virtual bool isValid () const override
 Returns if the fit has valid results. More...
 
virtual FitParameters_t FitParameters () const override
 Computes and returns all the parameters of the fit result. More...
 
virtual FitParameters_t FitParameterErrors () const override
 Computes and returns all the parameter errors of the fit result. More...
 
virtual FitMatrix_t FitParameterCovariance () const override
 Computes and returns all the covariance matrix of the fit result. More...
 
virtual Data_t ChiSquare () const override
 Returns the $ \chi^{2} $ of the original fit. More...
 
virtual int NDF () const override
 Returns the degrees of freedom in the determination of the fit. More...
 
Fitting
virtual Data_t FitParameter (unsigned int n) const
 Returns the parameter n of the fit result. More...
 
virtual Data_t FitParameterError (unsigned int n) const
 Returns the error on parameter n of the fit result. More...
 

Static Public Member Functions

static Data_t Evaluate (Data_t x, Data_t const *params)
 Evaluates a Gaussian with given parameters at one point. More...
 
static constexpr Data_t sqr (Data_t v)
 Returns the square of the specified data value. More...
 
static constexpr Data_t cube (Data_t v)
 Returns the cube of the specified data value. More...
 

Static Public Attributes

static constexpr unsigned int NParams = Base_t::NParams
 Number of parameters in the fit. More...
 

Protected Member Functions

virtual Data_t Determinant (FitMatrix_t const &mat) const
 Computes the determinant of a matrix. More...
 
virtual FitMatrix_t InvertMatrix (FitMatrix_t const &mat, Data_t det) const
 Computes the inverse of a matrix (using provided determinant) More...
 
virtual FitMatrix_t InvertMatrix (FitMatrix_t const &mat) const
 Computes the inverse of a matrix. More...
 
virtual FitParameters_t MatrixProduct (FitMatrix_t const &mat, FitParameters_t const &vec) const
 Computes the product of a FitMatrix_t and a FitParameters_t. More...
 

Static Protected Member Functions

static FitParameters_t ConvertParameters (FitParameters_t const &qpars)
 Converts the specified quadratic fit parameters into Gaussian. More...
 
static void ConvertParametersAndErrors (FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t &params, FitParameters_t &paramerrors)
 Converts the specified quadratic fit parameters and errors. More...
 
static void ConvertParametersAndVariances (FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t &params, FitParameters_t &paramvariances)
 Converts the specified quadratic fit parameters and errors. More...
 
static void ConvertParametersAndErrorMatrix (FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t &params, FitMatrix_t &Smat)
 Converts the specified quadratic fit parameters and errors. More...
 
static bool isValid (FitParameters_t const &params, FitParameters_t const &qpars)
 Returns whether the specified parameters represent a valid fit. More...
 
static void ThrowNotImplemented (std::string method)
 
Mumbo-jumbo to convert the values for a quadratic fit
static Data_t EncodeValue (Data_t value)
 
static Data_t DecodeValue (Data_t value)
 Converts a value from the quadratic fit into a proper value. More...
 
static Value_t EncodeValue (Data_t value, Data_t error)
 Converts a value and error into a proper input for the quadratic fit. More...
 
static Value_t EncodeValue (Value_t const &value)
 Converts a value and error into a proper input for the quadratic fit. More...
 
static Value_t DecodeValue (Value_t const &value)
 Converts a value from the quadratic fit into a proper value. More...
 
static Measurement_t EncodeValue (Measurement_t const &meas)
 Converts a value and error into a proper input for the quadratic fit. More...
 
static MeasurementAndUncertainty_t EncodeValue (MeasurementAndUncertainty_t const &meas)
 Converts a value and error into a proper input for the quadratic fit. More...
 
static MeasurementAndUncertainty_t EncodeValue (Measurement_t const &meas, Data_t error)
 Converts a value and error into a proper input for the quadratic fit. More...
 
template<typename Pred >
static EncodeExtractor< Pred > Encoder (Pred &pred)
 
template<typename VPred , typename UPred >
static EncodeExtractor< VPred, UPred > Encoder (VPred &vpred, UPred &upred)
 

Protected Attributes

Fitter_t fitter
 the actual fitter and data holder More...
 

Private Types

using Base_t = details::SimpleFitterInterface< T, 3 >
 base class More...
 
using Fitter_t = QuadraticFit< T >
 base class More...
 

Detailed Description

template<typename T>
class lar::util::GaussianFit< T >

"Fast" Gaussian fit


Template Parameters
Tdata type

This class performs a Gaussian fit on demand. This fit translates the data to its logarithm and then internally performs a quadratic fit. Note that as a consequence this fitter does not accept negative values for the y variable. Negative values in input will be completely ignored.

Methods that do not change functionality respect to the base class are not documented here – see the base class(es) documentation (mostly SimplePolyFitterBase).

Definition at line 1018 of file SimpleFits.h.

Member Typedef Documentation

template<typename T>
using lar::util::GaussianFit< T >::Base_t = details::SimpleFitterInterface<T, 3>
private

base class

Definition at line 1019 of file SimpleFits.h.

template<typename T>
using lar::util::GaussianFit< T >::Data_t = typename Base_t::Data_t

type of the data

Definition at line 1026 of file SimpleFits.h.

template<typename T>
using lar::util::GaussianFit< T >::FitMatrix_t = typename Fitter_t::FitMatrix_t

Definition at line 1036 of file SimpleFits.h.

template<typename T>
using lar::util::GaussianFit< T >::FitParameters_t = typename Fitter_t::FitParameters_t

Definition at line 1035 of file SimpleFits.h.

template<typename T>
using lar::util::GaussianFit< T >::Fitter_t = QuadraticFit<T>
private

base class

Definition at line 1020 of file SimpleFits.h.

using lar::util::details::SimpleFitterInterface< T, N >::MatrixOps = FastMatrixOperations<Data_t, NParams>
inherited

Definition at line 466 of file SimpleFits.h.

template<typename T>
using lar::util::GaussianFit< T >::Measurement_t = typename Fitter_t::Measurement_t

type of measurement without uncertainty

Definition at line 1029 of file SimpleFits.h.

type of measurement with uncertainty

Definition at line 1033 of file SimpleFits.h.

Member Function Documentation

template<typename T >
bool lar::util::GaussianFit< T >::add ( Data_t  x,
Data_t  y,
Data_t  sy = Data_t(1.0) 
)

Clears all the input statistics.

Definition at line 1790 of file SimpleFits.h.

References lar::util::GaussianFit< T >::add_without_uncertainty(), lar::util::GaussianFit< T >::Value_t::error(), and lar::util::GaussianFit< T >::Value_t::value().

Referenced by lar::util::QuadraticFit< T >::ChiSquare(), and hit::CCHitFinderAlg::FastGaussianFit().

1791 {
1792  if (y <= Data_t(0)) return false; // ignore the non-positive values
1793  Value_t value = EncodeValue(Value_t(y, sy));
1794  return fitter.add(x, value.value(), value.error());
1795 } // GaussianFit<T>::add(Data_t, Data_t, Data_t)
Float_t x
Definition: compare.C:6
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1026
Float_t y
Definition: compare.C:6
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
std::string value(boost::any const &)
static Data_t EncodeValue(Data_t value)
Definition: SimpleFits.h:1265
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Definition: SimpleFits.h:366
template<typename T>
bool lar::util::GaussianFit< T >::add ( Measurement_t  value,
Data_t  sy = Data_t(1.0) 
)
inline

Clears all the input statistics.

Definition at line 1050 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::add().

1051  { return add(std::get<0>(value), std::get<1>(value), sy); }
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Clears all the input statistics.
Definition: SimpleFits.h:1790
std::string value(boost::any const &)
template<typename T>
bool lar::util::GaussianFit< T >::add ( MeasurementAndUncertainty_t  value)
inline

Clears all the input statistics.

Definition at line 1053 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::add().

1054  {
1055  return
1056  add(std::get<0>(value), std::get<1>(value), std::get<2>(value));
1057  }
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Clears all the input statistics.
Definition: SimpleFits.h:1790
std::string value(boost::any const &)
template<typename T >
template<typename VIter , typename UIter , typename VPred , typename UPred >
unsigned int lar::util::GaussianFit< T >::add_with_uncertainty ( VIter  begin_value,
VIter  end_value,
UIter  begin_uncertainty,
VPred  value_extractor,
UPred  uncertainty_extractor = UPred() 
)

Clears all the input statistics.

Definition at line 1812 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::add_with_uncertainty().

1818 {
1819  return add_with_uncertainty(
1820  begin_value, end_value, begin_uncertainty,
1821  Encoder(value_extractor, uncertainty_extractor)
1822  );
1823 } // GaussianFit<T>::add_with_uncertainty()
unsigned int add_with_uncertainty(VIter begin_value, VIter end_value, UIter begin_uncertainty, VPred value_extractor, UPred uncertainty_extractor=UPred())
Clears all the input statistics.
Definition: SimpleFits.h:1812
static EncodeExtractor< Pred > Encoder(Pred &pred)
Definition: SimpleFits.h:1364
template<typename T >
template<typename Iter >
unsigned int lar::util::GaussianFit< T >::add_with_uncertainty ( Iter  begin,
Iter  end 
)

Clears all the input statistics.

Definition at line 1829 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::add(), and lar::util::details::FitDataCollector< T, D >::N().

1830 {
1831  unsigned int old_n = N();
1832  std::for_each(begin, end, [this](auto p) { this->add(p); });
1833  return N() - old_n;
1834 } // GaussianFit<T>::add_with_uncertainty()
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Clears all the input statistics.
Definition: SimpleFits.h:1790
int N() const
Returns the number of (valid) points added.
Definition: SimpleFits.h:1100
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
template<typename T>
template<typename Cont >
unsigned int lar::util::GaussianFit< T >::add_with_uncertainty ( Cont  cont)
inline

Clears all the input statistics.

Definition at line 1092 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::add_with_uncertainty(), evd::details::begin(), and evd::details::end().

1093  { return add_with_uncertainty(std::begin(cont), std::end(cont)); }
unsigned int add_with_uncertainty(VIter begin_value, VIter end_value, UIter begin_uncertainty, VPred value_extractor, UPred uncertainty_extractor=UPred())
Clears all the input statistics.
Definition: SimpleFits.h:1812
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
template<typename T>
template<typename Iter >
void lar::util::GaussianFit< T >::add_without_uncertainty ( Iter  begin,
Iter  end 
)
inline

Clears all the input statistics.

Definition at line 1061 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::add_without_uncertainty(), evd::details::begin(), and evd::details::end().

Referenced by lar::util::GaussianFit< T >::add().

1062  { add_without_uncertainty(begin, end, identity()); }
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
void add_without_uncertainty(Iter begin, Iter end)
Clears all the input statistics.
Definition: SimpleFits.h:1061
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
template<typename T >
template<typename Iter , typename Pred >
void lar::util::GaussianFit< T >::add_without_uncertainty ( Iter  begin,
Iter  end,
Pred  extractor 
)

Clears all the input statistics.

Definition at line 1801 of file SimpleFits.h.

1802 {
1803  return fitter.add_without_uncertainty(begin, end, Encoder(extractor));
1804 } // GaussianFit<>::add_without_uncertainty(Iter, Iter, Pred)
void add_without_uncertainty(Iter begin, Iter end)
Definition: SimpleFits.h:377
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
static EncodeExtractor< Pred > Encoder(Pred &pred)
Definition: SimpleFits.h:1364
template<typename T>
template<typename Cont , typename Pred >
void lar::util::GaussianFit< T >::add_without_uncertainty ( Cont  cont,
Pred  extractor 
)
inline

Clears all the input statistics.

Definition at line 1068 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::add_without_uncertainty(), evd::details::begin(), and evd::details::end().

1069  { add_without_uncertainty(std::begin(cont), std::end(cont), extractor); }
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
void add_without_uncertainty(Iter begin, Iter end)
Clears all the input statistics.
Definition: SimpleFits.h:1061
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
template<typename T>
template<typename Cont >
void lar::util::GaussianFit< T >::add_without_uncertainty ( Cont  cont)
inline

Clears all the input statistics.

Definition at line 1072 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::add_with_uncertainty(), lar::util::details::FitDataCollector< T, D >::add_without_uncertainty(), evd::details::begin(), and evd::details::end().

1073  { add_without_uncertainty(std::begin(cont), std::end(cont)); }
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
void add_without_uncertainty(Iter begin, Iter end)
Clears all the input statistics.
Definition: SimpleFits.h:1061
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
template<typename T>
virtual Data_t lar::util::GaussianFit< T >::ChiSquare ( ) const
inlineoverridevirtual

Returns the $ \chi^{2} $ of the original fit.

Returns
the $ \chi^{2} $ of the original fit (not divided by NDF())

This is not defined in the space of the Gaussian, but in the space of the internal quadratic fit. Where one is minimum, the other also is, but the actual value is different.

Implements lar::util::details::SimpleFitterInterface< T, 3 >.

Definition at line 1161 of file SimpleFits.h.

Referenced by hit::CCHitFinderAlg::FastGaussianFit().

1161 { return fitter.ChiSquare(); }
virtual Data_t ChiSquare() const override
Returns the of the fit.
Definition: SimpleFits.h:1771
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
template<typename T>
void lar::util::GaussianFit< T >::clear ( )
inline

Clears all the input statistics.

Definition at line 1097 of file SimpleFits.h.

1097 { fitter.clear(); }
void clear()
Clears all the statistics.
Definition: SimpleFits.h:421
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
template<typename T >
auto lar::util::GaussianFit< T >::ConvertParameters ( FitParameters_t const &  qpars)
staticprotected

Converts the specified quadratic fit parameters into Gaussian.

Parameters
qparsthe quadratic fit parameters
Returns
Gaussian function parameters

Definition at line 1920 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::sqr().

1922 {
1923  FitParameters_t params;
1924 
1925 
1926  Data_t sigma2 = -0.5 / qpars[2]; // sigma^2 = -1 / (2 a2)
1927  params[2] = std::sqrt(sigma2); // sigma
1928 
1929  params[1] = sigma2 * qpars[1]; // mean = sigma2 a1
1930 
1931  params[0] = std::exp(qpars[0] - 0.25 * sqr(qpars[1])/qpars[2]);
1932 
1933  return params;
1934 } // GaussianFit<>::ConvertParameters()
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1026
static constexpr Data_t sqr(Data_t v)
Returns the square of the specified data value.
Definition: SimpleFits.h:607
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1035
template<typename T >
void lar::util::GaussianFit< T >::ConvertParametersAndErrorMatrix ( FitParameters_t const &  qpars,
FitMatrix_t const &  qparerrmat,
FitParameters_t params,
FitMatrix_t Smat 
)
staticprotected

Converts the specified quadratic fit parameters and errors.

Parameters
qparsthe quadratic fit parameters
qparerrmatthe quadratic fit parameter error matrix
paramsthe Gaussian fit parameters
Smatthe covariance matrix of the Gaussian fit parameters

Definition at line 1986 of file SimpleFits.h.

References lar::util::GaussianFit< T >::isValid(), and lar::util::details::FitDataCollector< T, D >::sqr().

1990 {
1991  FitParameters_t paramvariances;
1992  ConvertParametersAndVariances(qpars, qparerrmat, params, paramvariances);
1993 
1994  // let's call things with their names
1995  FitParameters_t const& a = qpars;
1996  Data_t const& A = params[0];
1997  Data_t const& mu = params[1];
1998  Data_t const& sigma = params[2];
1999 
2000  // variance on sigma
2001  Smat[3 * 2 + 2] = paramvariances[2];
2002 
2003  // variance on mu
2004  Smat[3 * 1 + 1] = paramvariances[1];
2005 
2006  // variance on A
2007  Smat[3 * 0 + 0] = paramvariances[0];
2008 
2009  // covariance on sigma and mu
2010  Smat[3 * 1 + 2] = Smat[3 * 2 + 1]
2011  = (qparerrmat[3 * 1 + 2] + 2 * mu * qparerrmat[3 * 2 + 2]) / sigma;
2012 
2013  // this is the sum of the derivatives of A vs. all a parameters, each one
2014  // multiplied by the covariance of that parameter with a2
2015  const Data_t dA_dak_cov_aka2 = A * (
2016  qparerrmat[3 * 0 + 2]
2017  + qparerrmat[3 * 1 + 2] * mu
2018  + qparerrmat[3 * 2 + 2] * sqr(mu)
2019  );
2020  // covariance on A and sigma
2021  Smat[3 * 0 + 2] = Smat[3 * 2 + 0]
2022  = dA_dak_cov_aka2 / cube(sigma);
2023 
2024  // this other is the same as dA_dak_cov_aka2, but for a1
2025  const Data_t dA_dak_cov_aka1 = A * (
2026  qparerrmat[3 * 0 + 1]
2027  + qparerrmat[3 * 1 + 1] * mu
2028  + qparerrmat[3 * 2 + 1] * sqr(mu)
2029  );
2030 
2031  // covariance on A and mu
2032  Smat[3 * 0 + 1] = Smat[3 * 1 + 0] = mu *
2033  (dA_dak_cov_aka1 / a[1] - dA_dak_cov_aka2 / a[2]);
2034 
2035 } // GaussianFit<>::ConvertParametersAndErrors()
static constexpr Data_t cube(Data_t v)
Returns the cube of the specified data value.
Definition: SimpleFits.h:610
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1026
static constexpr Data_t sqr(Data_t v)
Returns the square of the specified data value.
Definition: SimpleFits.h:607
static void ConvertParametersAndVariances(FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t &params, FitParameters_t &paramvariances)
Converts the specified quadratic fit parameters and errors.
Definition: SimpleFits.h:1938
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1035
template<typename T >
void lar::util::GaussianFit< T >::ConvertParametersAndErrors ( FitParameters_t const &  qpars,
FitMatrix_t const &  qparerrmat,
FitParameters_t params,
FitParameters_t paramerrors 
)
staticprotected

Converts the specified quadratic fit parameters and errors.

Parameters
qparsthe quadratic fit parameters
qparerrmatthe quadratic fit parameter error matrix
paramsthe Gaussian fit parameters
paramerrorsthe Gaussian fit parameter errors

Definition at line 1974 of file SimpleFits.h.

1978 {
1979  ConvertParametersAndVariances(qpars, qparerrmat, params, paramerrors);
1980  // paramerrors actually stores the square of the error; fix it:
1981  for (Data_t& paramerror: paramerrors) paramerror = std::sqrt(paramerror);
1982 } // GaussianFit<>::ConvertParametersAndErrors()
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1026
static void ConvertParametersAndVariances(FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t &params, FitParameters_t &paramvariances)
Converts the specified quadratic fit parameters and errors.
Definition: SimpleFits.h:1938
template<typename T >
void lar::util::GaussianFit< T >::ConvertParametersAndVariances ( FitParameters_t const &  qpars,
FitMatrix_t const &  qparerrmat,
FitParameters_t params,
FitParameters_t paramvariances 
)
staticprotected

Converts the specified quadratic fit parameters and errors.

Parameters
qparsthe quadratic fit parameters
qparerrmatthe quadratic fit parameter error matrix
paramsthe Gaussian fit parameters
paramvariancesthe Gaussian fit parameter variance

Definition at line 1938 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::sqr().

1942 {
1943  params = ConvertParameters(qpars);
1944 
1945  FitParameters_t const& a = qpars;
1946  Data_t const& A = params[0];
1947  Data_t const& mu = params[1];
1948  Data_t const& sigma = params[2];
1949 
1950  // error on sigma
1951  paramvariances[2] = qparerrmat[3 * 2 + 2] / sqr(cube(sigma));
1952 
1953  // error on mu
1954  paramvariances[1] = sqr(mu * (
1955  + qparerrmat[3 * 1 + 1] / sqr(a[1])
1956  - 2.*qparerrmat[3 * 2 + 1] / (a[1]*a[2])
1957  + qparerrmat[3 * 2 + 2] / sqr(a[2])
1958  ));
1959 
1960  // error on A
1961  paramvariances[0] = sqr(A * (
1962  + qparerrmat[3 * 0 + 0]
1963  + 2.*qparerrmat[3 * 0 + 1] * mu
1964  +( qparerrmat[3 * 1 + 1]
1965  + 2.*qparerrmat[3 * 0 + 2]) * sqr(mu)
1966  + 2.*qparerrmat[3 * 1 + 2] * cube(mu)
1967  + qparerrmat[3 * 2 + 2] * sqr(sqr(mu))
1968  ));
1969 
1970 } // GaussianFit<>::ConvertParametersAndVariances()
static constexpr Data_t cube(Data_t v)
Returns the cube of the specified data value.
Definition: SimpleFits.h:610
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1026
static constexpr Data_t sqr(Data_t v)
Returns the square of the specified data value.
Definition: SimpleFits.h:607
static FitParameters_t ConvertParameters(FitParameters_t const &qpars)
Converts the specified quadratic fit parameters into Gaussian.
Definition: SimpleFits.h:1920
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1035
static constexpr Data_t lar::util::details::SimpleFitterInterface< T, N >::cube ( Data_t  v)
inlinestaticinherited

Returns the cube of the specified data value.

Definition at line 610 of file SimpleFits.h.

610 { return v*v*v; }
template<typename T>
static Data_t lar::util::GaussianFit< T >::DecodeValue ( Data_t  value)
inlinestaticprotected

Converts a value from the quadratic fit into a proper value.

Definition at line 1268 of file SimpleFits.h.

1268 { return std::exp(value); }
std::string value(boost::any const &)
template<typename T>
static Value_t lar::util::GaussianFit< T >::DecodeValue ( Value_t const &  value)
inlinestaticprotected

Converts a value from the quadratic fit into a proper value.

Definition at line 1282 of file SimpleFits.h.

References lar::util::GaussianFit< T >::Value_t::error(), and lar::util::GaussianFit< T >::Value_t::value().

1283  {
1284  const Data_t v = std::exp(value.value());
1285  return { v, v * value.error() };
1286  } // DecodeValue()
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1026
std::string value(boost::any const &)
virtual Data_t lar::util::details::SimpleFitterInterface< T, N >::Determinant ( FitMatrix_t const &  mat) const
inlineprotectedvirtualinherited

Computes the determinant of a matrix.

Definition at line 615 of file SimpleFits.h.

616  { return MatrixOps::Determinant(mat); }
Float_t mat
Definition: plot.C:40
template<typename T>
template<typename Pred >
static EncodeExtractor<Pred> lar::util::GaussianFit< T >::Encoder ( Pred &  pred)
inlinestaticprotected

Converts a value into a proper input for the quadratic fit; does not accept 0 or negative values!

Definition at line 1364 of file SimpleFits.h.

1364 { return { pred }; }
template<typename T>
template<typename VPred , typename UPred >
static EncodeExtractor<VPred, UPred> lar::util::GaussianFit< T >::Encoder ( VPred &  vpred,
UPred &  upred 
)
inlinestaticprotected

Converts a value into a proper input for the quadratic fit; does not accept 0 or negative values!

Definition at line 1367 of file SimpleFits.h.

1368  { return { vpred, upred }; }
template<typename T>
static Data_t lar::util::GaussianFit< T >::EncodeValue ( Data_t  value)
inlinestaticprotected

Converts a value into a proper input for the quadratic fit; does not accept 0 or negative values!

Definition at line 1265 of file SimpleFits.h.

1265 { return std::log(value); }
std::string value(boost::any const &)
template<typename T>
static Value_t lar::util::GaussianFit< T >::EncodeValue ( Data_t  value,
Data_t  error 
)
inlinestaticprotected

Converts a value and error into a proper input for the quadratic fit.

Definition at line 1272 of file SimpleFits.h.

1273  { return { std::log(value), error / std::abs(value) }; }
std::string value(boost::any const &)
template<typename T>
static Value_t lar::util::GaussianFit< T >::EncodeValue ( Value_t const &  value)
inlinestaticprotected

Converts a value and error into a proper input for the quadratic fit.

Definition at line 1277 of file SimpleFits.h.

References lar::util::GaussianFit< T >::Value_t::error(), and lar::util::GaussianFit< T >::Value_t::value().

1278  { return EncodeValue(value.value(), value.error()); }
std::string value(boost::any const &)
static Data_t EncodeValue(Data_t value)
Definition: SimpleFits.h:1265
template<typename T>
static Measurement_t lar::util::GaussianFit< T >::EncodeValue ( Measurement_t const &  meas)
inlinestaticprotected

Converts a value and error into a proper input for the quadratic fit.

Definition at line 1289 of file SimpleFits.h.

1290  {
1291  return
1292  Measurement_t(std::get<0>(meas), EncodeValue(std::get<1>(meas)));
1293  }
typename Fitter_t::Measurement_t Measurement_t
type of measurement without uncertainty
Definition: SimpleFits.h:1029
static Data_t EncodeValue(Data_t value)
Definition: SimpleFits.h:1265
template<typename T>
static MeasurementAndUncertainty_t lar::util::GaussianFit< T >::EncodeValue ( MeasurementAndUncertainty_t const &  meas)
inlinestaticprotected

Converts a value and error into a proper input for the quadratic fit.

Definition at line 1297 of file SimpleFits.h.

References lar::util::GaussianFit< T >::Value_t::error(), and lar::util::GaussianFit< T >::Value_t::value().

1298  {
1299  Value_t value = EncodeValue(Value_t(meas));
1300  return { std::get<0>(meas), value.value(), value.error() };
1301  } // EncodeValue(MeasurementAndUncertainty_t)
std::string value(boost::any const &)
static Data_t EncodeValue(Data_t value)
Definition: SimpleFits.h:1265
template<typename T>
static MeasurementAndUncertainty_t lar::util::GaussianFit< T >::EncodeValue ( Measurement_t const &  meas,
Data_t  error 
)
inlinestaticprotected

Converts a value and error into a proper input for the quadratic fit.

Definition at line 1305 of file SimpleFits.h.

References lar::util::GaussianFit< T >::Value_t::error(), and lar::util::GaussianFit< T >::Value_t::value().

1306  {
1307  Value_t value = EncodeValue(Value_t(std::get<1>(meas), error));
1308  return { std::get<0>(meas), value.value(), value.error() };
1309  } // EncodeValue(Measurement_t, Data_t)
std::string value(boost::any const &)
static Data_t EncodeValue(Data_t value)
Definition: SimpleFits.h:1265
virtual Data_t lar::util::details::SimpleFitterInterface< T, N >::Evaluate ( Data_t  x) const
pure virtualinherited

Evaluates the fitted function at the specified point.

Parameters
xthe point where to evaluate the fit function
Returns
the value of the fit function

No check is performed whether the fit is valid.

template<typename T>
virtual Data_t lar::util::GaussianFit< T >::Evaluate ( Data_t  x) const
inlineoverridevirtual

Evaluates the fitted function at the specified point.

Parameters
xthe point where to evaluate the fit function
Returns
the value of the fit function

No check is performed whether the fit is valid.

Definition at line 1225 of file SimpleFits.h.

1226  { return Evaluate(x, FitParameters().data()); }
Float_t x
Definition: compare.C:6
virtual Data_t Evaluate(Data_t x) const override
Evaluates the fitted function at the specified point.
Definition: SimpleFits.h:1225
virtual FitParameters_t FitParameters() const override
Computes and returns all the parameters of the fit result.
Definition: SimpleFits.h:1841
template<typename T >
auto lar::util::GaussianFit< T >::Evaluate ( Data_t  x,
Data_t const *  params 
)
static

Evaluates a Gaussian with given parameters at one point.

Parameters
xthe point where to evaluate the fit function
paramsGaussian parameters: amplitude, mean, sigma
Returns
the Gaussian function evaluated at x

Definition at line 1911 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::sqr(), and z.

1913 {
1914  Data_t z = (x - params[1]) / params[2];
1915  return params[0] * std::exp(-0.5*sqr(z));
1916 } // GaussianFit<>::Evaluate()
Float_t x
Definition: compare.C:6
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1026
Double_t z
Definition: plot.C:279
static constexpr Data_t sqr(Data_t v)
Returns the square of the specified data value.
Definition: SimpleFits.h:607
virtual bool lar::util::details::SimpleFitterInterface< T, N >::FillResults ( FitParameters_t params,
FitMatrix_t Xmat,
Data_t det,
FitMatrix_t Smat 
) const
pure virtualinherited

Fills the specified parameters.

Parameters
paramsthe fitted values of the parameters
Xmatthe matrix of the x^n/s^2 sums
Smatthe covariance matrix
detthe determinant of Xmat
Returns
true if the fit is valid (i.e. if a unique solution exists)
virtual bool lar::util::details::SimpleFitterInterface< T, N >::FillResults ( FitParameters_t params,
FitParameters_t paramerrors,
FitMatrix_t Xmat,
Data_t det,
FitMatrix_t Smat 
) const
pure virtualinherited

Fills the specified parameters.

Parameters
paramsthe fitted values of the parameters
paramerrorsthe uncertainty on the fitted parameters
Xmatthe matrix of the x^n/s^2 sums
Smatthe covariance matrix
detthe determinant of Xmat
Returns
true if the fit is valid (i.e. if a unique solution exists)
virtual bool lar::util::details::SimpleFitterInterface< T, N >::FillResults ( FitParameters_t params,
FitParameters_t paramerrors 
) const
pure virtualinherited

Fills the specified parameters.

Parameters
paramsthe fitted values of the parameters
paramerrorsthe uncertainty on the fitted parameters
Returns
true if the fit is valid (i.e. if a unique solution exists)
template<typename T >
bool lar::util::GaussianFit< T >::FillResults ( FitParameters_t params,
FitMatrix_t Xmat,
Data_t det,
FitMatrix_t Smat 
) const
overridevirtual

Fills the specified parameters.

Parameters
paramsthe fitted values of the parameters
Xmatthe matrix of the x^n/s^2 sums
Smatthe covariance matrix
detthe determinant of Xmat
Returns
true if the fit is valid (i.e. if a unique solution exists)

Unsupported.

Definition at line 1888 of file SimpleFits.h.

Referenced by hit::CCHitFinderAlg::FastGaussianFit(), and lar::util::GaussianFit< T >::FitParameterCovariance().

1890  {
1891  FitParameters_t qpars;
1892  FitMatrix_t qparerrmat;
1893  if (!fitter.FillResults(qpars, Xmat, det, qparerrmat)) return false;
1894  ConvertParametersAndErrorMatrix(qpars, qparerrmat, params, Smat);
1895  return isValid(params, qpars);
1896 } // GaussianFit::FillResults()
typename Fitter_t::FitMatrix_t FitMatrix_t
Definition: SimpleFits.h:1036
bool FillResults(FitParameters_t &params, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override
Fills the specified parameters.
Definition: SimpleFits.h:1598
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
static void ConvertParametersAndErrorMatrix(FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t &params, FitMatrix_t &Smat)
Converts the specified quadratic fit parameters and errors.
Definition: SimpleFits.h:1986
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1035
virtual bool isValid() const override
Returns if the fit has valid results.
Definition: SimpleFits.h:1122
template<typename T >
bool lar::util::GaussianFit< T >::FillResults ( FitParameters_t params,
FitParameters_t paramerrors,
FitMatrix_t Xmat,
Data_t det,
FitMatrix_t Smat 
) const
overridevirtual

Fills the specified parameters.

Parameters
paramsthe fitted values of the parameters
paramerrorsthe uncertainty on the fitted parameters
Xmatthe matrix of the x^n/s^2 sums
Smatthe covariance matrix
detthe determinant of Xmat
Returns
true if the fit is valid (i.e. if a unique solution exists)

Unsupported.

Definition at line 1900 of file SimpleFits.h.

1903  {
1904  if (!FillResults(params, Xmat, det, Smat)) return false;
1905  paramerrors = fitter.ExtractParameterErrors(Smat);
1906  return true;
1907 } // GaussianFit::FillResults()
virtual bool FillResults(FitParameters_t &params, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override
Fills the specified parameters.
Definition: SimpleFits.h:1888
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
static FitParameters_t ExtractParameterErrors(FitMatrix_t const &Smat)
Extracts parameter errors from diagonal of the covarriance matrix.
Definition: SimpleFits.h:1715
template<typename T >
bool lar::util::GaussianFit< T >::FillResults ( FitParameters_t params,
FitParameters_t paramerrors 
) const
overridevirtual

Fills the specified parameters.

Parameters
paramsthe fitted values of the parameters
paramerrorsthe uncertainty on the fitted parameters
Returns
true if the fit is valid (i.e. if a unique solution exists)

Only the version returning the parameters and errors is supported.

Definition at line 1875 of file SimpleFits.h.

1876 {
1877  FitParameters_t qpars;
1878  FitMatrix_t qparerrmat;
1879  FitMatrix_t Xmat; // not used
1880  Data_t det; // not used
1881  if (!fitter.FillResults(qpars, Xmat, det, qparerrmat)) return false;
1882  ConvertParametersAndErrors(qpars, qparerrmat, params, paramerrors);
1883  return isValid(params, qpars);
1884 } // GaussianFit<>::FillResults()
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1026
typename Fitter_t::FitMatrix_t FitMatrix_t
Definition: SimpleFits.h:1036
bool FillResults(FitParameters_t &params, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override
Fills the specified parameters.
Definition: SimpleFits.h:1598
static void ConvertParametersAndErrors(FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t &params, FitParameters_t &paramerrors)
Converts the specified quadratic fit parameters and errors.
Definition: SimpleFits.h:1974
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1035
virtual bool isValid() const override
Returns if the fit has valid results.
Definition: SimpleFits.h:1122
virtual Data_t lar::util::details::SimpleFitterInterface< T, N >::FitParameter ( unsigned int  n) const
inlinevirtualinherited

Returns the parameter n of the fit result.

Parameters
ndegree of the parameter; must be no larger than Degree
Returns
the parameter of the fit, in y/x^n units
Exceptions
std::runtime_errorif there is no unique solution

Definition at line 524 of file SimpleFits.h.

525  { return FitParameters()[n]; }
virtual FitParameters_t FitParameters() const =0
Computes and returns all the parameters of the fit result.
Char_t n[5]
template<typename T >
auto lar::util::GaussianFit< T >::FitParameterCovariance ( ) const
overridevirtual

Computes and returns all the covariance matrix of the fit result.

Returns
the the covariance matrix of the fit
Exceptions
std::runtime_errorif there is no unique solution

Not supported. It's fairly too complicate to fill the whole matrix. Doable, on request.

Implements lar::util::details::SimpleFitterInterface< T, 3 >.

Definition at line 1858 of file SimpleFits.h.

References lar::util::GaussianFit< T >::FillResults().

1859 {
1860  // we need to go through the whole chain to get the error matrix
1861  FitParameters_t params;
1862  FitMatrix_t Xmat;
1863  Data_t det;
1864  FitMatrix_t Smat;
1865  if (!FillResults(params, Xmat, det, Smat)) {
1866  throw std::runtime_error
1867  ("GaussianFit::FitParameterCovariance() yielded invalid results");
1868  }
1869  return Smat;
1870 } // SimplePolyFitterBase<>::FitParameterCovariance()
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1026
typename Fitter_t::FitMatrix_t FitMatrix_t
Definition: SimpleFits.h:1036
virtual bool FillResults(FitParameters_t &params, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override
Fills the specified parameters.
Definition: SimpleFits.h:1888
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1035
virtual Data_t lar::util::details::SimpleFitterInterface< T, N >::FitParameterError ( unsigned int  n) const
inlinevirtualinherited

Returns the error on parameter n of the fit result.

Parameters
ndegree of the parameter; must be no larger than Degree
Returns
the error on the parameter of the fit, in y/x^n units
Exceptions
std::runtime_errorif there is no unique solution

Definition at line 533 of file SimpleFits.h.

534  { return std::sqrt(FitParameterCovariance()[n * (NParams + 1)]); }
virtual FitMatrix_t FitParameterCovariance() const =0
Computes and returns all the covariance matrix of the fit result.
static constexpr unsigned int NParams
Number of parameters in the fit.
Definition: SimpleFits.h:462
Char_t n[5]
template<typename T >
auto lar::util::GaussianFit< T >::FitParameterErrors ( ) const
overridevirtual

Computes and returns all the parameter errors of the fit result.

Returns
the full set of parameter errors of the fit
Exceptions
std::runtime_errorif there is no unique solution

Implements lar::util::details::SimpleFitterInterface< T, 3 >.

Definition at line 1847 of file SimpleFits.h.

1847  {
1848  FitParameters_t qpars, qparerrors;
1849  if (!FillResults(qpars, qparerrors)) {
1850  throw std::runtime_error
1851  ("GaussianFit::FitParameterErrors() yielded invalid results");
1852  }
1853  return qparerrors;
1854 } // GaussianFit<>::FitParameterErrors()
virtual bool FillResults(FitParameters_t &params, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override
Fills the specified parameters.
Definition: SimpleFits.h:1888
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1035
template<typename T >
auto lar::util::GaussianFit< T >::FitParameters ( ) const
overridevirtual

Computes and returns all the parameters of the fit result.

Returns
the full set of parameters of the fit
Exceptions
std::runtime_errorif there is no unique solution

Implements lar::util::details::SimpleFitterInterface< T, 3 >.

Definition at line 1841 of file SimpleFits.h.

1841  {
1843 } // GaussianFit<>::FitParameters()
static FitParameters_t ConvertParameters(FitParameters_t const &qpars)
Converts the specified quadratic fit parameters into Gaussian.
Definition: SimpleFits.h:1920
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
virtual FitParameters_t FitParameters() const override
Computes and returns all the parameters of the fit result.
Definition: SimpleFits.h:1564
template<typename T>
virtual Fitter_t const& lar::util::GaussianFit< T >::Fitter ( ) const
inlinevirtual

Returns the internal fitter (mostly for debugging)

Definition at line 1230 of file SimpleFits.h.

1230 { return fitter; }
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
virtual FitMatrix_t lar::util::details::SimpleFitterInterface< T, N >::InvertMatrix ( FitMatrix_t const &  mat,
Data_t  det 
) const
inlineprotectedvirtualinherited

Computes the inverse of a matrix (using provided determinant)

Definition at line 620 of file SimpleFits.h.

621  { return MatrixOps::InvertSymmetricMatrix(mat, det); }
Float_t mat
Definition: plot.C:40
virtual FitMatrix_t lar::util::details::SimpleFitterInterface< T, N >::InvertMatrix ( FitMatrix_t const &  mat) const
inlineprotectedvirtualinherited

Computes the inverse of a matrix.

Definition at line 624 of file SimpleFits.h.

625  { return MatrixOps::InvertSymmetricMatrix(mat); }
Float_t mat
Definition: plot.C:40
template<typename T>
virtual bool lar::util::GaussianFit< T >::isValid ( ) const
inlineoverridevirtual

Returns if the fit has valid results.

Returns
if the fit has valid results

The fit has no valid results if:

  1. insufficient data has been add()ed (no more than the fit Degree)
  2. if input points are vertically aligned

Note that checking point 2 is expensive in terms of time.

Implements lar::util::details::SimpleFitterInterface< T, 3 >.

Definition at line 1122 of file SimpleFits.h.

Referenced by lar::util::GaussianFit< T >::ConvertParametersAndErrorMatrix().

1122 { return fitter.isValid(); }
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
virtual bool isValid() const override
Returns if the fit has valid results.
Definition: SimpleFits.h:1540
template<typename T >
bool lar::util::GaussianFit< T >::isValid ( FitParameters_t const &  params,
FitParameters_t const &  qpars 
)
staticprotected

Returns whether the specified parameters represent a valid fit.

Parameters
paramsGaussian parameters
qparsquadratic fit parameters
Returns
whether specified parameters represent a valid Gaussian fit

Definition at line 2040 of file SimpleFits.h.

2041 {
2042  return (qpars[2] < Data_t(0)) && (params[0] >= Data_t(0));
2043 } // GaussianFit<>::isValid(FitParameters_t)
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1026
virtual FitParameters_t lar::util::details::SimpleFitterInterface< T, N >::MatrixProduct ( FitMatrix_t const &  mat,
FitParameters_t const &  vec 
) const
inlineprotectedvirtualinherited

Computes the product of a FitMatrix_t and a FitParameters_t.

Definition at line 629 of file SimpleFits.h.

630  { return MatrixOps::MatrixVectorProduct(mat, vec); }
Float_t mat
Definition: plot.C:40
template<typename T>
int lar::util::GaussianFit< T >::N ( ) const
inline

Returns the number of (valid) points added.

Definition at line 1100 of file SimpleFits.h.

1100 { return fitter.N(); }
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
template<typename T>
virtual int lar::util::GaussianFit< T >::NDF ( ) const
inlineoverridevirtual

Returns the degrees of freedom in the determination of the fit.

Returns
the degrees of freedom in the determination of the fit

The return value may be 0 or negative if insufficient points have been added.

Implements lar::util::details::SimpleFitterInterface< T, 3 >.

Definition at line 1170 of file SimpleFits.h.

Referenced by hit::CCHitFinderAlg::FastGaussianFit().

1170 { return fitter.NDF(); }
virtual int NDF() const override
Returns the degrees of freedom in the determination of the fit.
Definition: SimpleFits.h:731
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
Data_t lar::util::details::SimpleFitterInterface< T, N >::operator() ( Data_t  x) const
inlineinherited

Evaluates the fitted function; alias of Evaluate()

Definition at line 603 of file SimpleFits.h.

603 { return Evaluate(x); }
Float_t x
Definition: compare.C:6
virtual Data_t Evaluate(Data_t x) const =0
Evaluates the fitted function at the specified point.
template<typename T>
template<typename Stream >
void lar::util::GaussianFit< T >::PrintStats ( Stream &  out) const
inline

Prints the collected statistics into a stream.

Definition at line 1105 of file SimpleFits.h.

1105 { fitter.PrintStats(out); }
void PrintStats(Stream &out) const
Prints the collected statistics into a stream.
Definition: SimpleFits.h:436
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1242
static constexpr Data_t lar::util::details::SimpleFitterInterface< T, N >::sqr ( Data_t  v)
inlinestaticinherited

Returns the square of the specified data value.

Definition at line 607 of file SimpleFits.h.

607 { return v*v; }
template<typename T>
static void lar::util::GaussianFit< T >::ThrowNotImplemented ( std::string  method)
inlinestaticprotected

Definition at line 1425 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::add().

1426  { throw std::logic_error("Method " + method + "() not implemented"); }

Member Data Documentation

template<typename T>
Fitter_t lar::util::GaussianFit< T >::fitter
protected

the actual fitter and data holder

Definition at line 1242 of file SimpleFits.h.

template<typename T>
constexpr unsigned int lar::util::GaussianFit< T >::NParams = Base_t::NParams
static

Number of parameters in the fit.

Definition at line 1024 of file SimpleFits.h.


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