LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar::util::details::FitDataCollector< T, D > Class Template Reference

Class providing data collection for the simple polynomial fitters. More...

#include "SimpleFits.h"

Classes

struct  SumExtractor
 
struct  SumExtractor< Power, 0U >
 

Public Types

using Data_t = T
 type of the data More...
 
using Measurement_t = std::tuple< Data_t, Data_t >
 type of measurement without uncertainty More...
 
using MeasurementAndUncertainty_t = std::tuple< Data_t, Data_t, Data_t >
 type of measurement with uncertainty More...
 

Public Member Functions

void clear ()
 Clears all the statistics. More...
 
template<typename Stream >
void Print (Stream &out) const
 Prints the statistics into a stream. More...
 
Add elements
bool add (Data_t x, Data_t y, Data_t sy=Data_t(1.0))
 Adds one entry with specified x, y and uncertainty. More...
 
bool add (Measurement_t value, Data_t sy=Data_t(1.0))
 Adds one entry with specified x, y and uncertainty. More...
 
bool add (MeasurementAndUncertainty_t value)
 Adds one entry with specified x, y and uncertainty. More...
 
template<typename Iter >
void add_without_uncertainty (Iter begin, Iter end)
 Adds measurements from a sequence, with no uncertainty. More...
 
template<typename Iter , typename Pred >
void add_without_uncertainty (Iter begin, Iter end, Pred extractor)
 Adds measurements from a sequence with no uncertainty. More...
 
template<typename Cont , typename Pred >
void add_without_uncertainty (Cont cont, Pred extractor)
 Adds all measurements from a container, with no uncertainty. More...
 
template<typename Cont >
void add_without_uncertainty (Cont cont)
 Adds all measurements from a container, with no uncertainty. 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())
 Adds measurements with uncertainties from a sequence. More...
 
template<typename Iter >
unsigned int add_with_uncertainty (Iter begin, Iter end)
 Adds measurements with uncertainties from a sequence. More...
 
template<typename Cont >
unsigned int add_with_uncertainty (Cont cont)
 Adds measurements with uncertainties from a container. More...
 

Static Public Member Functions

static Data_t UncertaintyToWeight (Data_t s)
 Transforms an uncertainty into a weight ( $ s^{-2} $) More...
 
static Data_t WeightToUncertainty (Data_t w)
 Transforms a weight back to an uncertainty ( $ s^{-1/2} $) More...
 

Static Public Attributes

static constexpr unsigned int Degree = D
 Degree of the fit. More...
 
static constexpr unsigned int NParams = Degree + 1
 

Protected Attributes

WeightTracker< Data_ts2
 accumulator for uncertainty More...
 
DataTracker< Degree *2, Data_tx
 accumulator for variable x^k More...
 
WeightTracker< Data_ty
 accumulator for y More...
 
DataTracker< 1, Data_ty2
 accumulator for y2 More...
 
DataTracker< Degree, Data_txy
 accumulator for variable xy More...
 

Statistic retrieval

int N () const
 Returns the number of entries added. More...
 
Data_t AverageUncertainty () const
 Returns an average of the uncertainties. More...
 
Data_t XN (unsigned int n) const
 Returns the weighted sum of x^n. More...
 
Data_t XNY (unsigned int n) const
 Returns the weighted sum of x^n y. More...
 
template<unsigned int N>
Data_t XN () const
 Returns the weighted sum of x^N. More...
 
template<unsigned int N>
Data_t XNY () const
 Returns the weighted sum of x^N y. More...
 
Data_t Y2 () const
 Returns the weighted sum of y^2. More...
 
template<typename V >
static constexpr V sqr (V const &v)
 Returns the square of the specified value. More...
 

Detailed Description

template<typename T, unsigned int D>
class lar::util::details::FitDataCollector< T, D >

Class providing data collection for the simple polynomial fitters.

Definition at line 37 of file SimpleFits.h.

Member Typedef Documentation

template<typename T , unsigned int D>
using lar::util::details::FitDataCollector< T, D >::Data_t = T

type of the data

Definition at line 76 of file SimpleFits.h.

template<typename T , unsigned int D>
using lar::util::details::FitDataCollector< T, D >::Measurement_t = std::tuple<Data_t, Data_t>

type of measurement without uncertainty

Definition at line 79 of file SimpleFits.h.

template<typename T , unsigned int D>
using lar::util::details::FitDataCollector< T, D >::MeasurementAndUncertainty_t = std::tuple<Data_t, Data_t, Data_t>

type of measurement with uncertainty

Definition at line 82 of file SimpleFits.h.

Member Function Documentation

template<typename T , unsigned int D>
bool lar::util::details::FitDataCollector< T, D >::add ( Data_t  x,
Data_t  y,
Data_t  sy = Data_t(1.0) 
)

Adds one entry with specified x, y and uncertainty.

Parameters
xvalue of x
yvalue of y
syvalue of uncertainty on y (1 by default)
Returns
whether the point was added

If the uncertainty is exactly 0, the entry is ignored and not added.

Definition at line 1446 of file SimpleFits.h.

References lar::util::details::WeightTracker< W >::add(), lar::util::details::DataTracker< PWR, T, W >::add(), lar::util::details::FitDataCollector< T, D >::add_without_uncertainty(), lar::util::details::FitDataCollector< T, D >::s2, lar::util::details::FitDataCollector< T, D >::sqr(), lar::util::details::FitDataCollector< T, D >::UncertaintyToWeight(), w, lar::util::details::FitDataCollector< T, D >::xy, and lar::util::details::FitDataCollector< T, D >::y2.

Referenced by lar::util::details::FitDataCollector< T, D >::add(), lar::util::GaussianFit< T >::add(), lar::util::details::FitDataCollector< T, D >::add_with_uncertainty(), lar::util::GaussianFit< T >::add_with_uncertainty(), lar::util::details::FitDataCollector< T, D >::add_without_uncertainty(), and lar::util::GaussianFit< T >::ThrowNotImplemented().

1447 {
1449  if (!std::isnormal(w)) return false;
1450  // the x section has a 1/s^2 weight; we track that weight separately
1451  s2.add(w);
1452  x.add(x_value, w);
1453  // we treat the y section as if it were a x section with a y/s^2 weight;
1454  // we track that weight separately
1455  Data_t yw = y_value * w;
1456  y.add(yw);
1457  y2.add(sqr(y_value), w); // used only for chi^2
1458  xy.add(x_value, yw);
1459 
1460  return true; // we did add the value
1461 } // FitDataCollector<>::add()
void add(Data_t v, Weight_t w)
Adds the specified weight to the statistics.
static Data_t UncertaintyToWeight(Data_t s)
Transforms an uncertainty into a weight ( )
Definition: SimpleFits.h:317
WeightTracker< Data_t > y
accumulator for y
Definition: SimpleFits.h:329
static constexpr V sqr(V const &v)
Returns the square of the specified value.
Definition: SimpleFits.h:283
void add(Weight_t weight)
Adds the specified weight to the statistics.
Definition: StatCollector.h:53
DataTracker< 1, Data_t > y2
accumulator for y2
Definition: SimpleFits.h:330
WeightTracker< Data_t > s2
accumulator for uncertainty
Definition: SimpleFits.h:327
DataTracker< Degree *2, Data_t > x
accumulator for variable x^k
Definition: SimpleFits.h:328
DataTracker< Degree, Data_t > xy
accumulator for variable xy
Definition: SimpleFits.h:331
Float_t w
Definition: plot.C:23
template<typename T , unsigned int D>
bool lar::util::details::FitDataCollector< T, D >::add ( Measurement_t  value,
Data_t  sy = Data_t(1.0) 
)
inline

Adds one entry with specified x, y and uncertainty.

Parameters
valuethe ( x ; y ) pair
syvalue of uncertainty on y (1 by default)
Returns
whether the point was added

If the uncertainty is exactly 0, the entry is ignored and not added.

Definition at line 108 of file SimpleFits.h.

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

109  { return add(std::get<0>(value), std::get<1>(value), sy); }
std::string value(boost::any const &)
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Adds one entry with specified x, y and uncertainty.
Definition: SimpleFits.h:1446
template<typename T , unsigned int D>
bool lar::util::details::FitDataCollector< T, D >::add ( MeasurementAndUncertainty_t  value)
inline

Adds one entry with specified x, y and uncertainty.

Parameters
value( x ; y ; sy ), sy being the uncertainty on y
Returns
whether the point was added

If the uncertainty is exactly 0, the entry is ignored and not added.

Definition at line 118 of file SimpleFits.h.

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

119  {
120  return
121  add(std::get<0>(value), std::get<1>(value), std::get<2>(value));
122  }
std::string value(boost::any const &)
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Adds one entry with specified x, y and uncertainty.
Definition: SimpleFits.h:1446
template<typename T , unsigned int D>
template<typename VIter , typename UIter , typename VPred , typename UPred >
unsigned int lar::util::details::FitDataCollector< T, D >::add_with_uncertainty ( VIter  begin_value,
VIter  end_value,
UIter  begin_uncertainty,
VPred  value_extractor,
UPred  uncertainty_extractor = UPred() 
)

Adds measurements with uncertainties from a sequence.

Template Parameters
VIterforward iterator to the elements to be added
UIterforward iterator to the uncertainties
VPredpredicate to extract the measurement from iterator value
UPredpredicate to extract the uncertainty from iterator value
Parameters
begin_valueiterator to the first measurement to be added
end_valueiterator after the last measurement to be added
begin_uncertaintyiterator to the uncertainty of first measurement
value_extractorpredicate extracting the measurement to be inserted
uncertainty_extractorpredicate extracting the uncertainty
Returns
number of points added

Each element is added with the uncertainty pointed by the matching element in the list pointed by begin_weight: the $ y $ measurement of *(begin_value) will have uncertainty *(begin_uncertainty), the next measurement *(begin_value + 1) will have uncertainty *(begin_uncertainty + 1), etc.

The predicates are required to react to a call like with:

Measurement_t VPred::operator() (typename VIter::value_type);
Data_t UPred::operator() (typename UIter::value_type);

Points with zero or infinite uncertainty are ignored and not added.

Definition at line 1477 of file SimpleFits.h.

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

Referenced by lar::util::details::FitDataCollector< T, D >::add_with_uncertainty(), lar::util::GaussianFit< T >::add_with_uncertainty(), lar::util::details::FitDataCollector< T, D >::add_without_uncertainty(), and lar::util::GaussianFit< T >::add_without_uncertainty().

1482  {
1483  unsigned int n = 0;
1484  while (begin_value != end_value) {
1485  if (add
1486  (value_extractor(*begin_value), uncertainty_extractor(*begin_uncertainty))
1487  )
1488  ++n;
1489  ++begin_value;
1490  ++begin_uncertainty;
1491  } // while
1492  return n;
1493 } // FitDataCollector<>::add_with_uncertainty(VIter, VIter, UIter, VPred, UPred)
Char_t n[5]
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Adds one entry with specified x, y and uncertainty.
Definition: SimpleFits.h:1446
template<typename T , unsigned int D>
template<typename Iter >
unsigned int lar::util::details::FitDataCollector< T, D >::add_with_uncertainty ( Iter  begin,
Iter  end 
)

Adds measurements with uncertainties from a sequence.

Template Parameters
Iterforward iterator to MeasurementAndUncertainty_t to be added
Parameters
beginiterator pointing to the first measurement to be added
enditerator pointing after the last measurement to be added
Returns
number of points added

The value pointed by the iterator must be a MeasurementAndUncertainty_t or something with elements convertible to its own (Data_t triplet). For more complicate structures, use the version with two predicates (using the uncertainty iterator the same as the measurement iterator).

Points with zero or infinite uncertainty are ignored and not added.

Definition at line 1499 of file SimpleFits.h.

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

1500 {
1501  unsigned int old_n = N();
1502  std::for_each(begin, end, [this](auto p) { this->add(p); });
1503  return N() - old_n;
1504 } // FitDataCollector<>::add_with_uncertainty(Iter, Iter)
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
int N() const
Returns the number of entries added.
Definition: SimpleFits.h:266
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Adds one entry with specified x, y and uncertainty.
Definition: SimpleFits.h:1446
template<typename T , unsigned int D>
template<typename Cont >
unsigned int lar::util::details::FitDataCollector< T, D >::add_with_uncertainty ( Cont  cont)
inline

Adds measurements with uncertainties from a container.

Template Parameters
Conttype of container of MeasurementAndUncertainty_t elements
Parameters
contcontainer of MeasurementAndUncertainty_t to be added
Returns
number of points added

The values in the container must be tuples with each element convertible to Data_t.

Points with zero or infinite uncertainty are ignored and not added.

Definition at line 254 of file SimpleFits.h.

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

255  { 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())
Adds measurements with uncertainties from a sequence.
Definition: SimpleFits.h:1477
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 , unsigned int D>
template<typename Iter >
void lar::util::details::FitDataCollector< T, D >::add_without_uncertainty ( Iter  begin,
Iter  end 
)
inline

Adds measurements from a sequence, with no uncertainty.

Template Parameters
Iterforward iterator to the pairs to be added
Parameters
beginiterator pointing to the first element to be added
enditerator pointing after the last element to be added

The value pointed by the iterator must be a tuple with types compatible with Measurement_t.

Definition at line 135 of file SimpleFits.h.

References evd::details::begin(), and evd::details::end().

Referenced by lar::util::details::FitDataCollector< T, D >::add(), lar::util::details::FitDataCollector< T, D >::add_without_uncertainty(), and lar::util::GaussianFit< T >::add_without_uncertainty().

136  { add_without_uncertainty(begin, end, identity()); }
void add_without_uncertainty(Iter begin, Iter end)
Adds measurements from a sequence, with no uncertainty.
Definition: SimpleFits.h:135
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 , unsigned int D>
template<typename Iter , typename Pred >
void lar::util::details::FitDataCollector< T, D >::add_without_uncertainty ( Iter  begin,
Iter  end,
Pred  extractor 
)

Adds measurements from a sequence with no uncertainty.

Template Parameters
Iterforward iterator to the elements to be added
Preda predicate to extract the element from iterator value
Parameters
beginiterator pointing to the first element to be added
enditerator pointing after the last element to be added
extractorthe predicate extracting the value to be inserted

The predicate is required to react to a call like with:

Measurement_t Pred::operator() (typename Iter::value_type);

Definition at line 1467 of file SimpleFits.h.

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

1468 {
1469  std::for_each
1470  (begin, end, [this, extractor](auto item) { this->add(extractor(item)); });
1471 } // FitDataCollector<>::add_without_uncertainty(Iter, Pred)
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
bool add(Data_t x, Data_t y, Data_t sy=Data_t(1.0))
Adds one entry with specified x, y and uncertainty.
Definition: SimpleFits.h:1446
template<typename T , unsigned int D>
template<typename Cont , typename Pred >
void lar::util::details::FitDataCollector< T, D >::add_without_uncertainty ( Cont  cont,
Pred  extractor 
)
inline

Adds all measurements from a container, with no uncertainty.

Template Parameters
Conttype of container of the elements to be added
Preda predicate to extract the element from iterator value
Parameters
contcontainer of the elements to be added
extractorthe predicate extracting the value to be inserted

The predicate is required to react to a call like with:

Measurement_t Pred::operator() (typename Cont::value_type);

The container must support the range-based for loop syntax, that is is must have std::begin<Cont>() and std::end<Cont>() defined.

Definition at line 169 of file SimpleFits.h.

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

170  { add_without_uncertainty(std::begin(cont), std::end(cont), extractor); }
void add_without_uncertainty(Iter begin, Iter end)
Adds measurements from a sequence, with no uncertainty.
Definition: SimpleFits.h:135
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 , unsigned int D>
template<typename Cont >
void lar::util::details::FitDataCollector< T, D >::add_without_uncertainty ( Cont  cont)
inline

Adds all measurements from a container, with no uncertainty.

Template Parameters
Conttype of container of the elements to be added
Parameters
contcontainer of the elements to be added

The container must support the range-based for loop syntax, that is is must have std::begin<Cont>() and std::end<Cont>() defined. The value in the container must be convertible to the Measurement_t type.

Definition at line 183 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().

184  { add_without_uncertainty(std::begin(cont), std::end(cont)); }
void add_without_uncertainty(Iter begin, Iter end)
Adds measurements from a sequence, with no uncertainty.
Definition: SimpleFits.h:135
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 , unsigned int D>
Data_t lar::util::details::FitDataCollector< T, D >::AverageUncertainty ( ) const
inline

Returns an average of the uncertainties.

Returns
the uncertainty average
Exceptions
std::range_errorif no entry was added

The average is the square root of the harmonic average of the variances (that is, the errors squared): $ \bar{s}^{-2} = \frac{1}{N} \sum_{i=1}^{N} s_{y}^{-2} $

Definition at line 277 of file SimpleFits.h.

References lar::util::details::WeightTracker< W >::AverageWeight(), lar::util::details::FitDataCollector< T, D >::s2, and lar::util::details::FitDataCollector< T, D >::WeightToUncertainty().

278  { return WeightToUncertainty(s2.AverageWeight()); }
Weight_t AverageWeight() const
Returns the arithmetic average of the weights.
WeightTracker< Data_t > s2
accumulator for uncertainty
Definition: SimpleFits.h:327
static Data_t WeightToUncertainty(Data_t w)
Transforms a weight back to an uncertainty ( )
Definition: SimpleFits.h:321
template<typename T , unsigned int D>
void lar::util::details::FitDataCollector< T, D >::clear ( )
inline

Clears all the statistics.

Definition at line 1509 of file SimpleFits.h.

References lar::util::details::WeightTracker< W >::clear(), lar::util::details::DataTracker< PWR, T, W >::clear(), lar::util::details::FitDataCollector< T, D >::s2, lar::util::details::FitDataCollector< T, D >::xy, and lar::util::details::FitDataCollector< T, D >::y2.

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

1509  {
1510  s2.clear();
1511  x.clear();
1512  y.clear();
1513  y2.clear();
1514  xy.clear();
1515 } // FitDataCollector<>::clear()
WeightTracker< Data_t > y
accumulator for y
Definition: SimpleFits.h:329
DataTracker< 1, Data_t > y2
accumulator for y2
Definition: SimpleFits.h:330
void clear()
Resets the count.
Definition: StatCollector.h:56
WeightTracker< Data_t > s2
accumulator for uncertainty
Definition: SimpleFits.h:327
DataTracker< Degree *2, Data_t > x
accumulator for variable x^k
Definition: SimpleFits.h:328
void clear()
Resets the count.
DataTracker< Degree, Data_t > xy
accumulator for variable xy
Definition: SimpleFits.h:331
template<typename T , unsigned int D>
int lar::util::details::FitDataCollector< T, D >::N ( ) const
inline

Returns the number of entries added.

Definition at line 266 of file SimpleFits.h.

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

Referenced by lar::util::details::FitDataCollector< T, D >::add_with_uncertainty(), and lar::util::GaussianFit< T >::add_with_uncertainty().

266 { return s2.N(); }
int N() const
Returns the number of entries added.
Definition: StatCollector.h:59
WeightTracker< Data_t > s2
accumulator for uncertainty
Definition: SimpleFits.h:327
template<typename T , unsigned int D>
template<typename Stream >
void lar::util::details::FitDataCollector< T, D >::Print ( Stream &  out) const

Prints the statistics into a stream.

Definition at line 1519 of file SimpleFits.h.

References lar::util::details::DataTracker< PWR, T, W >::Power, lar::util::details::FitDataCollector< T, D >::s2, lar::util::details::DataTracker< PWR, T, W >::Sum(), lar::util::details::WeightTracker< W >::Weights(), lar::util::details::FitDataCollector< T, D >::xy, and lar::util::details::FitDataCollector< T, D >::y2.

Referenced by lar::util::details::FitDataCollector< T, D >::Y2().

1519  {
1520 
1521  out << "Sums 1/s^2=" << s2.Weights()
1522  << "\n x/s^2=" << x.template SumN<1>();
1523  for (unsigned int degree = 2; degree <= x.Power; ++degree)
1524  out << "\n x^" << degree << "/s^2=" << x.Sum(degree);
1525  out
1526  << "\n y/s^2=" << y.Weights()
1527  << "\n y^2/s^2=" << y2.Sum();
1528  if (xy.Power >= 1)
1529  out << "\n xy/s^2=" << xy.template SumN<1>();
1530  for (unsigned int degree = 2; degree <= xy.Power; ++degree)
1531  out << "\n x^" << degree << "y/s^2=" << xy.Sum(degree);
1532  out << std::endl;
1533 } // FitDataCollector<>::Print()
Weight_t Weights() const
Returns the sum of the weights.
Definition: StatCollector.h:62
WeightTracker< Data_t > y
accumulator for y
Definition: SimpleFits.h:329
DataTracker< 1, Data_t > y2
accumulator for y2
Definition: SimpleFits.h:330
Weight_t Sum(unsigned int n) const
Returns the sum of the values to the power n (1 <= n <= 2, no check)
WeightTracker< Data_t > s2
accumulator for uncertainty
Definition: SimpleFits.h:327
DataTracker< Degree *2, Data_t > x
accumulator for variable x^k
Definition: SimpleFits.h:328
static constexpr unsigned int Power
Definition: StatCollector.h:95
DataTracker< Degree, Data_t > xy
accumulator for variable xy
Definition: SimpleFits.h:331
template<typename T , unsigned int D>
static Data_t lar::util::details::FitDataCollector< T, D >::UncertaintyToWeight ( Data_t  s)
inlinestatic

Transforms an uncertainty into a weight ( $ s^{-2} $)

Definition at line 317 of file SimpleFits.h.

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

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

318  { return Data_t(1.)/sqr(s); }
Float_t s
Definition: plot.C:23
static constexpr V sqr(V const &v)
Returns the square of the specified value.
Definition: SimpleFits.h:283
template<typename T , unsigned int D>
static Data_t lar::util::details::FitDataCollector< T, D >::WeightToUncertainty ( Data_t  w)
inlinestatic

Transforms a weight back to an uncertainty ( $ s^{-1/2} $)

Definition at line 321 of file SimpleFits.h.

Referenced by lar::util::details::FitDataCollector< T, D >::AverageUncertainty().

322  { return Data_t(1.)/std::sqrt(w); }
Float_t w
Definition: plot.C:23
template<typename T , unsigned int D>
Data_t lar::util::details::FitDataCollector< T, D >::XN ( unsigned int  n) const
inline

Returns the weighted sum of x^n.

Definition at line 287 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::s2, and lar::util::details::WeightTracker< W >::Weights().

Referenced by lar::util::details::SimplePolyFitterDataBase< T, D >::XN().

288  { return (n == 0)? s2.Weights(): x.Sum(n); }
Weight_t Weights() const
Returns the sum of the weights.
Definition: StatCollector.h:62
Weight_t Sum(unsigned int n) const
Returns the sum of the values to the power n (1 <= n <= 2, no check)
WeightTracker< Data_t > s2
accumulator for uncertainty
Definition: SimpleFits.h:327
DataTracker< Degree *2, Data_t > x
accumulator for variable x^k
Definition: SimpleFits.h:328
Char_t n[5]
template<typename T , unsigned int D>
template<unsigned int N>
Data_t lar::util::details::FitDataCollector< T, D >::XN ( ) const
inline

Returns the weighted sum of x^N.

Definition at line 297 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::s2, and lar::util::details::FitDataCollector< T, D >::x.

WeightTracker< Data_t > s2
accumulator for uncertainty
Definition: SimpleFits.h:327
DataTracker< Degree *2, Data_t > x
accumulator for variable x^k
Definition: SimpleFits.h:328
static T Sum(WeightTracker< T > const &, DataTracker< Power, T > const &sums)
Definition: SimpleFits.h:59
template<typename T , unsigned int D>
Data_t lar::util::details::FitDataCollector< T, D >::XNY ( unsigned int  n) const
inline

Returns the weighted sum of x^n y.

Definition at line 291 of file SimpleFits.h.

References lar::util::details::DataTracker< PWR, T, W >::Sum(), and lar::util::details::FitDataCollector< T, D >::xy.

Referenced by lar::util::details::SimplePolyFitterDataBase< T, D >::XNY().

292  { return (n == 0)? y.Weights(): xy.Sum(n); }
Weight_t Weights() const
Returns the sum of the weights.
Definition: StatCollector.h:62
WeightTracker< Data_t > y
accumulator for y
Definition: SimpleFits.h:329
Weight_t Sum(unsigned int n) const
Returns the sum of the values to the power n (1 <= n <= 2, no check)
DataTracker< Degree, Data_t > xy
accumulator for variable xy
Definition: SimpleFits.h:331
Char_t n[5]
template<typename T , unsigned int D>
template<unsigned int N>
Data_t lar::util::details::FitDataCollector< T, D >::XNY ( ) const
inline

Returns the weighted sum of x^N y.

Definition at line 302 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::xy, and lar::util::details::FitDataCollector< T, D >::y.

WeightTracker< Data_t > y
accumulator for y
Definition: SimpleFits.h:329
static T Sum(WeightTracker< T > const &, DataTracker< Power, T > const &sums)
Definition: SimpleFits.h:59
DataTracker< Degree, Data_t > xy
accumulator for variable xy
Definition: SimpleFits.h:331
template<typename T , unsigned int D>
Data_t lar::util::details::FitDataCollector< T, D >::Y2 ( ) const
inline

Returns the weighted sum of y^2.

Definition at line 307 of file SimpleFits.h.

References lar::util::details::FitDataCollector< T, D >::Print(), and lar::util::details::FitDataCollector< T, D >::y2.

Referenced by lar::util::LinearFit< T >::ChiSquare(), and lar::util::QuadraticFit< T >::ChiSquare().

307 { return y2.template SumN<1>(); }
DataTracker< 1, Data_t > y2
accumulator for y2
Definition: SimpleFits.h:330

Member Data Documentation

template<typename T , unsigned int D>
constexpr unsigned int lar::util::details::FitDataCollector< T, D >::Degree = D
static

Degree of the fit.

Definition at line 73 of file SimpleFits.h.

Referenced by lar::util::details::SimplePolyFitterBase< T, D >::ExtractParameterErrors().

template<typename T , unsigned int D>
DataTracker<Degree*2, Data_t> lar::util::details::FitDataCollector< T, D >::x
protected

accumulator for variable x^k

Definition at line 328 of file SimpleFits.h.

Referenced by lar::util::details::FitDataCollector< T, D >::XN().

template<typename T , unsigned int D>
WeightTracker<Data_t> lar::util::details::FitDataCollector< T, D >::y
protected

accumulator for y

Definition at line 329 of file SimpleFits.h.

Referenced by lar::util::details::FitDataCollector< T, D >::XNY().


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