LArSoft
v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
|
"Fast" Gaussian fit More...
#include "SimpleFits.h"
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 ¶ms, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override |
Fills the specified parameters. More... | |
virtual bool | FillResults (FitParameters_t ¶ms, FitParameters_t ¶merrors, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override |
Fills the specified parameters. More... | |
virtual bool | FillResults (FitParameters_t ¶ms, FitParameters_t ¶merrors) 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 ¶ms, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const =0 |
Fills the specified parameters. More... | |
virtual bool | FillResults (FitParameters_t ¶ms, FitParameters_t ¶merrors, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const =0 |
Fills the specified parameters. More... | |
virtual bool | FillResults (FitParameters_t ¶ms, FitParameters_t ¶merrors) 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 | |
| |
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 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 ¶ms, FitParameters_t ¶merrors) |
Converts the specified quadratic fit parameters and errors. More... | |
static void | ConvertParametersAndVariances (FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t ¶ms, FitParameters_t ¶mvariances) |
Converts the specified quadratic fit parameters and errors. More... | |
static void | ConvertParametersAndErrorMatrix (FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t ¶ms, FitMatrix_t &Smat) |
Converts the specified quadratic fit parameters and errors. More... | |
static bool | isValid (FitParameters_t const ¶ms, 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... | |
"Fast" Gaussian fit
T | data 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.
|
private |
base class
Definition at line 1019 of file SimpleFits.h.
using lar::util::GaussianFit< T >::Data_t = typename Base_t::Data_t |
type of the data
Definition at line 1026 of file SimpleFits.h.
using lar::util::GaussianFit< T >::FitMatrix_t = typename Fitter_t::FitMatrix_t |
Definition at line 1036 of file SimpleFits.h.
using lar::util::GaussianFit< T >::FitParameters_t = typename Fitter_t::FitParameters_t |
Definition at line 1035 of file SimpleFits.h.
|
private |
base class
Definition at line 1020 of file SimpleFits.h.
|
inherited |
Definition at line 466 of file SimpleFits.h.
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.
using lar::util::GaussianFit< T >::MeasurementAndUncertainty_t = typename Fitter_t::MeasurementAndUncertainty_t |
type of measurement with uncertainty
Definition at line 1033 of file SimpleFits.h.
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().
|
inline |
Clears all the input statistics.
Definition at line 1050 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::add().
|
inline |
Clears all the input statistics.
Definition at line 1053 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::add().
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().
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().
|
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().
|
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().
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.
|
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().
|
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().
|
inlineoverridevirtual |
Returns the of the original fit.
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().
|
inline |
Clears all the input statistics.
Definition at line 1097 of file SimpleFits.h.
|
staticprotected |
Converts the specified quadratic fit parameters into Gaussian.
qpars | the quadratic fit parameters |
Definition at line 1920 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::sqr().
|
staticprotected |
Converts the specified quadratic fit parameters and errors.
qpars | the quadratic fit parameters |
qparerrmat | the quadratic fit parameter error matrix |
params | the Gaussian fit parameters |
Smat | the 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().
|
staticprotected |
Converts the specified quadratic fit parameters and errors.
qpars | the quadratic fit parameters |
qparerrmat | the quadratic fit parameter error matrix |
params | the Gaussian fit parameters |
paramerrors | the Gaussian fit parameter errors |
Definition at line 1974 of file SimpleFits.h.
|
staticprotected |
Converts the specified quadratic fit parameters and errors.
qpars | the quadratic fit parameters |
qparerrmat | the quadratic fit parameter error matrix |
params | the Gaussian fit parameters |
paramvariances | the Gaussian fit parameter variance |
Definition at line 1938 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::sqr().
|
inlinestaticinherited |
Returns the cube of the specified data value.
Definition at line 610 of file SimpleFits.h.
|
inlinestaticprotected |
Converts a value from the quadratic fit into a proper value.
Definition at line 1268 of file SimpleFits.h.
|
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().
|
inlineprotectedvirtualinherited |
Computes the determinant of a matrix.
Definition at line 615 of file SimpleFits.h.
|
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.
|
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.
|
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.
|
inlinestaticprotected |
Converts a value and error into a proper input for the quadratic fit.
Definition at line 1272 of file SimpleFits.h.
|
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().
|
inlinestaticprotected |
Converts a value and error into a proper input for the quadratic fit.
Definition at line 1289 of file SimpleFits.h.
|
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().
|
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().
|
pure virtualinherited |
Evaluates the fitted function at the specified point.
x | the point where to evaluate the fit function |
No check is performed whether the fit is valid.
|
inlineoverridevirtual |
Evaluates the fitted function at the specified point.
x | the point where to evaluate the fit function |
No check is performed whether the fit is valid.
Definition at line 1225 of file SimpleFits.h.
|
static |
Evaluates a Gaussian with given parameters at one point.
x | the point where to evaluate the fit function |
params | Gaussian parameters: amplitude, mean, sigma |
Definition at line 1911 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::sqr(), and z.
|
pure virtualinherited |
Fills the specified parameters.
params | the fitted values of the parameters |
Xmat | the matrix of the x^n/s^2 sums |
Smat | the covariance matrix |
det | the determinant of Xmat |
|
pure virtualinherited |
Fills the specified parameters.
params | the fitted values of the parameters |
paramerrors | the uncertainty on the fitted parameters |
Xmat | the matrix of the x^n/s^2 sums |
Smat | the covariance matrix |
det | the determinant of Xmat |
|
pure virtualinherited |
Fills the specified parameters.
params | the fitted values of the parameters |
paramerrors | the uncertainty on the fitted parameters |
|
overridevirtual |
Fills the specified parameters.
params | the fitted values of the parameters |
Xmat | the matrix of the x^n/s^2 sums |
Smat | the covariance matrix |
det | the determinant of Xmat |
Unsupported.
Definition at line 1888 of file SimpleFits.h.
Referenced by hit::CCHitFinderAlg::FastGaussianFit(), and lar::util::GaussianFit< T >::FitParameterCovariance().
|
overridevirtual |
Fills the specified parameters.
params | the fitted values of the parameters |
paramerrors | the uncertainty on the fitted parameters |
Xmat | the matrix of the x^n/s^2 sums |
Smat | the covariance matrix |
det | the determinant of Xmat |
Unsupported.
Definition at line 1900 of file SimpleFits.h.
|
overridevirtual |
Fills the specified parameters.
params | the fitted values of the parameters |
paramerrors | the uncertainty on the fitted parameters |
Only the version returning the parameters and errors is supported.
Definition at line 1875 of file SimpleFits.h.
|
inlinevirtualinherited |
Returns the parameter n of the fit result.
n | degree of the parameter; must be no larger than Degree |
std::runtime_error | if there is no unique solution |
Definition at line 524 of file SimpleFits.h.
|
overridevirtual |
Computes and returns all the covariance matrix of the fit result.
std::runtime_error | if 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().
|
inlinevirtualinherited |
Returns the error on parameter n of the fit result.
n | degree of the parameter; must be no larger than Degree |
std::runtime_error | if there is no unique solution |
Definition at line 533 of file SimpleFits.h.
|
overridevirtual |
Computes and returns all the parameter errors of the fit result.
std::runtime_error | if there is no unique solution |
Implements lar::util::details::SimpleFitterInterface< T, 3 >.
Definition at line 1847 of file SimpleFits.h.
|
overridevirtual |
Computes and returns all the parameters of the fit result.
std::runtime_error | if there is no unique solution |
Implements lar::util::details::SimpleFitterInterface< T, 3 >.
Definition at line 1841 of file SimpleFits.h.
|
inlinevirtual |
Returns the internal fitter (mostly for debugging)
Definition at line 1230 of file SimpleFits.h.
|
inlineprotectedvirtualinherited |
Computes the inverse of a matrix (using provided determinant)
Definition at line 620 of file SimpleFits.h.
|
inlineprotectedvirtualinherited |
Computes the inverse of a matrix.
Definition at line 624 of file SimpleFits.h.
|
inlineoverridevirtual |
Returns if the fit has valid results.
The fit has no valid results if:
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().
|
staticprotected |
Returns whether the specified parameters represent a valid fit.
params | Gaussian parameters |
qpars | quadratic fit parameters |
Definition at line 2040 of file SimpleFits.h.
|
inlineprotectedvirtualinherited |
Computes the product of a FitMatrix_t and a FitParameters_t.
Definition at line 629 of file SimpleFits.h.
|
inline |
Returns the number of (valid) points added.
Definition at line 1100 of file SimpleFits.h.
|
inlineoverridevirtual |
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().
|
inlineinherited |
Evaluates the fitted function; alias of Evaluate()
Definition at line 603 of file SimpleFits.h.
|
inline |
Prints the collected statistics into a stream.
Definition at line 1105 of file SimpleFits.h.
|
inlinestaticinherited |
Returns the square of the specified data value.
Definition at line 607 of file SimpleFits.h.
|
inlinestaticprotected |
Definition at line 1425 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::add().
|
protected |
the actual fitter and data holder
Definition at line 1242 of file SimpleFits.h.
|
static |
Number of parameters in the fit.
Definition at line 1024 of file SimpleFits.h.