LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 993 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 994 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 1001 of file SimpleFits.h.

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

Definition at line 1010 of file SimpleFits.h.

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

Definition at line 1009 of file SimpleFits.h.

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

base class

Definition at line 995 of file SimpleFits.h.

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

Definition at line 465 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 1004 of file SimpleFits.h.

type of measurement with uncertainty

Definition at line 1007 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 1719 of file SimpleFits.h.

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

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

1720 {
1721  if (y <= Data_t(0)) return false; // ignore the non-positive values
1722  Value_t value = EncodeValue(Value_t(y, sy));
1723  return fitter.add(x, value.value(), value.error());
1724 } // 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:1001
Float_t y
Definition: compare.C:6
double value
Definition: spectrum.C:18
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1215
static Data_t EncodeValue(Data_t value)
Definition: SimpleFits.h:1237
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Definition: SimpleFits.h:363
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 1023 of file SimpleFits.h.

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

1024  {
1025  return add(std::get<0>(value), std::get<1>(value), sy);
1026  }
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Clears all the input statistics.
Definition: SimpleFits.h:1719
double value
Definition: spectrum.C:18
template<typename T>
bool lar::util::GaussianFit< T >::add ( MeasurementAndUncertainty_t  value)
inline

Clears all the input statistics.

Definition at line 1028 of file SimpleFits.h.

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

1029  {
1030  return add(std::get<0>(value), std::get<1>(value), std::get<2>(value));
1031  }
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Clears all the input statistics.
Definition: SimpleFits.h:1719
double value
Definition: spectrum.C:18
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 1735 of file SimpleFits.h.

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

1742 {
1743  return add_with_uncertainty(
1744  begin_value, end_value, begin_uncertainty, Encoder(value_extractor, uncertainty_extractor));
1745 } // 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:1735
static EncodeExtractor< Pred > Encoder(Pred &pred)
Definition: SimpleFits.h:1329
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 1749 of file SimpleFits.h.

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

1750 {
1751  unsigned int old_n = N();
1752  std::for_each(begin, end, [this](auto p) { this->add(p); });
1753  return N() - old_n;
1754 } // 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:1719
int N() const
Returns the number of (valid) points added.
Definition: SimpleFits.h:1074
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
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 1065 of file SimpleFits.h.

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

1066  {
1067  return add_with_uncertainty(std::begin(cont), std::end(cont));
1068  }
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:1735
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
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 1034 of file SimpleFits.h.

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

1035  {
1036  add_without_uncertainty(begin, end, identity());
1037  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
void add_without_uncertainty(Iter begin, Iter end)
Clears all the input statistics.
Definition: SimpleFits.h:1034
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
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 1728 of file SimpleFits.h.

1729 {
1730  return fitter.add_without_uncertainty(begin, end, Encoder(extractor));
1731 } // GaussianFit<>::add_without_uncertainty(Iter, Iter, Pred)
void add_without_uncertainty(Iter begin, Iter end)
Definition: SimpleFits.h:370
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1215
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
static EncodeExtractor< Pred > Encoder(Pred &pred)
Definition: SimpleFits.h:1329
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 1043 of file SimpleFits.h.

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

1044  {
1045  add_without_uncertainty(std::begin(cont), std::end(cont), extractor);
1046  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
void add_without_uncertainty(Iter begin, Iter end)
Clears all the input statistics.
Definition: SimpleFits.h:1034
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
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 1049 of file SimpleFits.h.

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

1050  {
1052  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
void add_without_uncertainty(Iter begin, Iter end)
Clears all the input statistics.
Definition: SimpleFits.h:1034
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
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 1135 of file SimpleFits.h.

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

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

Clears all the input statistics.

Definition at line 1071 of file SimpleFits.h.

1071 { fitter.clear(); }
void clear()
Clears all the statistics.
Definition: SimpleFits.h:419
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1215
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 1835 of file SimpleFits.h.

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

1836 {
1837  FitParameters_t params;
1838 
1839  Data_t sigma2 = -0.5 / qpars[2]; // sigma^2 = -1 / (2 a2)
1840  params[2] = std::sqrt(sigma2); // sigma
1841 
1842  params[1] = sigma2 * qpars[1]; // mean = sigma2 a1
1843 
1844  params[0] = std::exp(qpars[0] - 0.25 * sqr(qpars[1]) / qpars[2]);
1845 
1846  return params;
1847 } // GaussianFit<>::ConvertParameters()
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1001
static constexpr Data_t sqr(Data_t v)
Returns the square of the specified data value.
Definition: SimpleFits.h:600
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1009
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 1891 of file SimpleFits.h.

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

1895 {
1896  FitParameters_t paramvariances;
1897  ConvertParametersAndVariances(qpars, qparerrmat, params, paramvariances);
1898 
1899  // let's call things with their names
1900  FitParameters_t const& a = qpars;
1901  Data_t const& A = params[0];
1902  Data_t const& mu = params[1];
1903  Data_t const& sigma = params[2];
1904 
1905  // variance on sigma
1906  Smat[3 * 2 + 2] = paramvariances[2];
1907 
1908  // variance on mu
1909  Smat[3 * 1 + 1] = paramvariances[1];
1910 
1911  // variance on A
1912  Smat[3 * 0 + 0] = paramvariances[0];
1913 
1914  // covariance on sigma and mu
1915  Smat[3 * 1 + 2] = Smat[3 * 2 + 1] =
1916  (qparerrmat[3 * 1 + 2] + 2 * mu * qparerrmat[3 * 2 + 2]) / sigma;
1917 
1918  // this is the sum of the derivatives of A vs. all a parameters, each one
1919  // multiplied by the covariance of that parameter with a2
1920  const Data_t dA_dak_cov_aka2 =
1921  A * (qparerrmat[3 * 0 + 2] + qparerrmat[3 * 1 + 2] * mu + qparerrmat[3 * 2 + 2] * sqr(mu));
1922  // covariance on A and sigma
1923  Smat[3 * 0 + 2] = Smat[3 * 2 + 0] = dA_dak_cov_aka2 / cube(sigma);
1924 
1925  // this other is the same as dA_dak_cov_aka2, but for a1
1926  const Data_t dA_dak_cov_aka1 =
1927  A * (qparerrmat[3 * 0 + 1] + qparerrmat[3 * 1 + 1] * mu + qparerrmat[3 * 2 + 1] * sqr(mu));
1928 
1929  // covariance on A and mu
1930  Smat[3 * 0 + 1] = Smat[3 * 1 + 0] = mu * (dA_dak_cov_aka1 / a[1] - dA_dak_cov_aka2 / a[2]);
1931 
1932 } // GaussianFit<>::ConvertParametersAndErrors()
static constexpr Data_t cube(Data_t v)
Returns the cube of the specified data value.
Definition: SimpleFits.h:603
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1001
static constexpr Data_t sqr(Data_t v)
Returns the square of the specified data value.
Definition: SimpleFits.h:600
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:1850
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1009
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 1879 of file SimpleFits.h.

1883 {
1884  ConvertParametersAndVariances(qpars, qparerrmat, params, paramerrors);
1885  // paramerrors actually stores the square of the error; fix it:
1886  for (Data_t& paramerror : paramerrors)
1887  paramerror = std::sqrt(paramerror);
1888 } // GaussianFit<>::ConvertParametersAndErrors()
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1001
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:1850
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 1850 of file SimpleFits.h.

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

1854 {
1855  params = ConvertParameters(qpars);
1856 
1857  FitParameters_t const& a = qpars;
1858  Data_t const& A = params[0];
1859  Data_t const& mu = params[1];
1860  Data_t const& sigma = params[2];
1861 
1862  // error on sigma
1863  paramvariances[2] = qparerrmat[3 * 2 + 2] / sqr(cube(sigma));
1864 
1865  // error on mu
1866  paramvariances[1] =
1867  sqr(mu * (+qparerrmat[3 * 1 + 1] / sqr(a[1]) - 2. * qparerrmat[3 * 2 + 1] / (a[1] * a[2]) +
1868  qparerrmat[3 * 2 + 2] / sqr(a[2])));
1869 
1870  // error on A
1871  paramvariances[0] =
1872  sqr(A * (+qparerrmat[3 * 0 + 0] + 2. * qparerrmat[3 * 0 + 1] * mu +
1873  (qparerrmat[3 * 1 + 1] + 2. * qparerrmat[3 * 0 + 2]) * sqr(mu) +
1874  2. * qparerrmat[3 * 1 + 2] * cube(mu) + qparerrmat[3 * 2 + 2] * sqr(sqr(mu))));
1875 
1876 } // GaussianFit<>::ConvertParametersAndVariances()
static constexpr Data_t cube(Data_t v)
Returns the cube of the specified data value.
Definition: SimpleFits.h:603
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1001
static constexpr Data_t sqr(Data_t v)
Returns the square of the specified data value.
Definition: SimpleFits.h:600
static FitParameters_t ConvertParameters(FitParameters_t const &qpars)
Converts the specified quadratic fit parameters into Gaussian.
Definition: SimpleFits.h:1835
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1009
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 603 of file SimpleFits.h.

603 { 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 1240 of file SimpleFits.h.

1240 { return std::exp(value); }
double value
Definition: spectrum.C:18
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 1255 of file SimpleFits.h.

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

1256  {
1257  const Data_t v = std::exp(value.value());
1258  return {v, v * value.error()};
1259  } // DecodeValue()
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1001
double value
Definition: spectrum.C:18
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 607 of file SimpleFits.h.

608  {
609  return MatrixOps::Determinant(mat);
610  }
Float_t mat
Definition: plot.C:38
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 1329 of file SimpleFits.h.

1330  {
1331  return {pred};
1332  }
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 1335 of file SimpleFits.h.

1336  {
1337  return {vpred, upred};
1338  }
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 1237 of file SimpleFits.h.

1237 { return std::log(value); }
double value
Definition: spectrum.C:18
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 1243 of file SimpleFits.h.

References util::abs().

1244  {
1245  return {std::log(value), error / std::abs(value)};
1246  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
double value
Definition: spectrum.C:18
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 1249 of file SimpleFits.h.

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

1250  {
1251  return EncodeValue(value.value(), value.error());
1252  }
double value
Definition: spectrum.C:18
static Data_t EncodeValue(Data_t value)
Definition: SimpleFits.h:1237
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 1262 of file SimpleFits.h.

1263  {
1264  return Measurement_t(std::get<0>(meas), EncodeValue(std::get<1>(meas)));
1265  }
typename Fitter_t::Measurement_t Measurement_t
type of measurement without uncertainty
Definition: SimpleFits.h:1004
static Data_t EncodeValue(Data_t value)
Definition: SimpleFits.h:1237
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 1268 of file SimpleFits.h.

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

1269  {
1270  Value_t value = EncodeValue(Value_t(meas));
1271  return {std::get<0>(meas), value.value(), value.error()};
1272  } // EncodeValue(MeasurementAndUncertainty_t)
double value
Definition: spectrum.C:18
static Data_t EncodeValue(Data_t value)
Definition: SimpleFits.h:1237
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 1275 of file SimpleFits.h.

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

1276  {
1277  Value_t value = EncodeValue(Value_t(std::get<1>(meas), error));
1278  return {std::get<0>(meas), value.value(), value.error()};
1279  } // EncodeValue(Measurement_t, Data_t)
double value
Definition: spectrum.C:18
static Data_t EncodeValue(Data_t value)
Definition: SimpleFits.h:1237
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 1198 of file SimpleFits.h.

1199  {
1200  return Evaluate(x, FitParameters().data());
1201  }
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:1198
virtual FitParameters_t FitParameters() const override
Computes and returns all the parameters of the fit result.
Definition: SimpleFits.h:1760
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 1828 of file SimpleFits.h.

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

1829 {
1830  Data_t z = (x - params[1]) / params[2];
1831  return params[0] * std::exp(-0.5 * sqr(z));
1832 } // GaussianFit<>::Evaluate()
Float_t x
Definition: compare.C:6
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1001
Double_t z
Definition: plot.C:276
static constexpr Data_t sqr(Data_t v)
Returns the square of the specified data value.
Definition: SimpleFits.h:600
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 1803 of file SimpleFits.h.

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

1807 {
1808  FitParameters_t qpars;
1809  FitMatrix_t qparerrmat;
1810  if (!fitter.FillResults(qpars, Xmat, det, qparerrmat)) return false;
1811  ConvertParametersAndErrorMatrix(qpars, qparerrmat, params, Smat);
1812  return isValid(params, qpars);
1813 } // GaussianFit::FillResults()
typename Fitter_t::FitMatrix_t FitMatrix_t
Definition: SimpleFits.h:1010
bool FillResults(FitParameters_t &params, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override
Fills the specified parameters.
Definition: SimpleFits.h:1546
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1215
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:1891
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1009
virtual bool isValid() const override
Returns if the fit has valid results.
Definition: SimpleFits.h:1097
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 1816 of file SimpleFits.h.

1821 {
1822  if (!FillResults(params, Xmat, det, Smat)) return false;
1823  paramerrors = fitter.ExtractParameterErrors(Smat);
1824  return true;
1825 } // 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:1803
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1215
static FitParameters_t ExtractParameterErrors(FitMatrix_t const &Smat)
Extracts parameter errors from diagonal of the covarriance matrix.
Definition: SimpleFits.h:1653
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 1790 of file SimpleFits.h.

1792 {
1793  FitParameters_t qpars;
1794  FitMatrix_t qparerrmat;
1795  FitMatrix_t Xmat; // not used
1796  Data_t det; // not used
1797  if (!fitter.FillResults(qpars, Xmat, det, qparerrmat)) return false;
1798  ConvertParametersAndErrors(qpars, qparerrmat, params, paramerrors);
1799  return isValid(params, qpars);
1800 } // GaussianFit<>::FillResults()
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1001
typename Fitter_t::FitMatrix_t FitMatrix_t
Definition: SimpleFits.h:1010
bool FillResults(FitParameters_t &params, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override
Fills the specified parameters.
Definition: SimpleFits.h:1546
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:1879
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1215
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1009
virtual bool isValid() const override
Returns if the fit has valid results.
Definition: SimpleFits.h:1097
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 521 of file SimpleFits.h.

521 { 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 1776 of file SimpleFits.h.

1777 {
1778  // we need to go through the whole chain to get the error matrix
1779  FitParameters_t params;
1780  FitMatrix_t Xmat;
1781  Data_t det;
1782  FitMatrix_t Smat;
1783  if (!FillResults(params, Xmat, det, Smat)) {
1784  throw std::runtime_error("GaussianFit::FitParameterCovariance() yielded invalid results");
1785  }
1786  return Smat;
1787 } // SimplePolyFitterBase<>::FitParameterCovariance()
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1001
typename Fitter_t::FitMatrix_t FitMatrix_t
Definition: SimpleFits.h:1010
virtual bool FillResults(FitParameters_t &params, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override
Fills the specified parameters.
Definition: SimpleFits.h:1803
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1009
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 529 of file SimpleFits.h.

530  {
531  return std::sqrt(FitParameterCovariance()[n * (NParams + 1)]);
532  }
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:461
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 1766 of file SimpleFits.h.

1767 {
1768  FitParameters_t qpars, qparerrors;
1769  if (!FillResults(qpars, qparerrors)) {
1770  throw std::runtime_error("GaussianFit::FitParameterErrors() yielded invalid results");
1771  }
1772  return qparerrors;
1773 } // 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:1803
typename Fitter_t::FitParameters_t FitParameters_t
Definition: SimpleFits.h:1009
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 1760 of file SimpleFits.h.

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

Returns the internal fitter (mostly for debugging)

Definition at line 1204 of file SimpleFits.h.

1204 { return fitter; }
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1215
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 613 of file SimpleFits.h.

614  {
615  return MatrixOps::InvertSymmetricMatrix(mat, det);
616  }
Float_t mat
Definition: plot.C:38
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 619 of file SimpleFits.h.

620  {
621  return MatrixOps::InvertSymmetricMatrix(mat);
622  }
Float_t mat
Definition: plot.C:38
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 1097 of file SimpleFits.h.

1097 { return fitter.isValid(); }
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1215
virtual bool isValid() const override
Returns if the fit has valid results.
Definition: SimpleFits.h:1497
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 1935 of file SimpleFits.h.

1936 {
1937  return (qpars[2] < Data_t(0)) && (params[0] >= Data_t(0));
1938 } // GaussianFit<>::isValid(FitParameters_t)
typename Base_t::Data_t Data_t
type of the data
Definition: SimpleFits.h:1001
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 625 of file SimpleFits.h.

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

Returns the number of (valid) points added.

Definition at line 1074 of file SimpleFits.h.

1074 { return fitter.N(); }
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1215
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 1144 of file SimpleFits.h.

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

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

Evaluates the fitted function; alias of Evaluate()

Definition at line 597 of file SimpleFits.h.

597 { 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 1078 of file SimpleFits.h.

1079  {
1080  fitter.PrintStats(out);
1081  }
void PrintStats(Stream &out) const
Prints the collected statistics into a stream.
Definition: SimpleFits.h:433
Fitter_t fitter
the actual fitter and data holder
Definition: SimpleFits.h:1215
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 600 of file SimpleFits.h.

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

Definition at line 1393 of file SimpleFits.h.

1394  {
1395  throw std::logic_error("Method " + method + "() not implemented");
1396  }

Member Data Documentation

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

the actual fitter and data holder

Definition at line 1215 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 999 of file SimpleFits.h.


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