LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 36 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 77 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 80 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 83 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 1412 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 >::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(), and lar::util::details::FitDataCollector< T, D >::add_without_uncertainty().

1415 {
1417  if (!std::isnormal(w)) return false;
1418  // the x section has a 1/s^2 weight; we track that weight separately
1419  s2.add(w);
1420  x.add(x_value, w);
1421  // we treat the y section as if it were a x section with a y/s^2 weight;
1422  // we track that weight separately
1423  Data_t yw = y_value * w;
1424  y.add(yw);
1425  y2.add(sqr(y_value), w); // used only for chi^2
1426  xy.add(x_value, yw);
1427 
1428  return true; // we did add the value
1429 } // 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:319
WeightTracker< Data_t > y
accumulator for y
Definition: SimpleFits.h:327
static constexpr V sqr(V const &v)
Returns the square of the specified value.
Definition: SimpleFits.h:284
void add(Weight_t weight)
Adds the specified weight to the statistics.
Definition: StatCollector.h:49
DataTracker< 1, Data_t > y2
accumulator for y2
Definition: SimpleFits.h:328
WeightTracker< Data_t > s2
accumulator for uncertainty
Definition: SimpleFits.h:325
DataTracker< Degree *2, Data_t > x
accumulator for variable x^k
Definition: SimpleFits.h:326
DataTracker< Degree, Data_t > xy
accumulator for variable xy
Definition: SimpleFits.h:329
Float_t w
Definition: plot.C:20
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 109 of file SimpleFits.h.

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

110  {
111  return add(std::get<0>(value), std::get<1>(value), sy);
112  }
double value
Definition: spectrum.C:18
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:1412
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 121 of file SimpleFits.h.

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

122  {
123  return add(std::get<0>(value), std::get<1>(value), std::get<2>(value));
124  }
double value
Definition: spectrum.C:18
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:1412
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 1442 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().

1449 {
1450  unsigned int n = 0;
1451  while (begin_value != end_value) {
1452  if (add(value_extractor(*begin_value), uncertainty_extractor(*begin_uncertainty))) ++n;
1453  ++begin_value;
1454  ++begin_uncertainty;
1455  } // while
1456  return n;
1457 } // 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:1412
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 1461 of file SimpleFits.h.

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

1462 {
1463  unsigned int old_n = N();
1464  std::for_each(begin, end, [this](auto p) { this->add(p); });
1465  return N() - old_n;
1466 } // FitDataCollector<>::add_with_uncertainty(Iter, Iter)
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
int N() const
Returns the number of entries added.
Definition: SimpleFits.h:269
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
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:1412
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 255 of file SimpleFits.h.

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

256  {
257  return add_with_uncertainty(std::begin(cont), std::end(cont));
258  }
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:1442
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 , 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 136 of file SimpleFits.h.

References util::begin(), and util::end().

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

137  {
138  add_without_uncertainty(begin, end, identity());
139  }
void add_without_uncertainty(Iter begin, Iter end)
Adds measurements from a sequence, with no uncertainty.
Definition: SimpleFits.h:136
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 , 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 1433 of file SimpleFits.h.

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

1436 {
1437  std::for_each(begin, end, [this, extractor](auto item) { this->add(extractor(item)); });
1438 } // FitDataCollector<>::add_without_uncertainty(Iter, Pred)
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
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:1412
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 172 of file SimpleFits.h.

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

173  {
174  add_without_uncertainty(std::begin(cont), std::end(cont), extractor);
175  }
void add_without_uncertainty(Iter begin, Iter end)
Adds measurements from a sequence, with no uncertainty.
Definition: SimpleFits.h:136
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 , 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 188 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().

189  {
191  }
void add_without_uncertainty(Iter begin, Iter end)
Adds measurements from a sequence, with no uncertainty.
Definition: SimpleFits.h:136
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 , 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 280 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().

280 { 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:325
static Data_t WeightToUncertainty(Data_t w)
Transforms a weight back to an uncertainty ( )
Definition: SimpleFits.h:322
template<typename T , unsigned int D>
void lar::util::details::FitDataCollector< T, D >::clear ( )
inline

Clears all the statistics.

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

1470 {
1471  s2.clear();
1472  x.clear();
1473  y.clear();
1474  y2.clear();
1475  xy.clear();
1476 } // FitDataCollector<>::clear()
WeightTracker< Data_t > y
accumulator for y
Definition: SimpleFits.h:327
DataTracker< 1, Data_t > y2
accumulator for y2
Definition: SimpleFits.h:328
void clear()
Resets the count.
Definition: StatCollector.h:56
WeightTracker< Data_t > s2
accumulator for uncertainty
Definition: SimpleFits.h:325
DataTracker< Degree *2, Data_t > x
accumulator for variable x^k
Definition: SimpleFits.h:326
void clear()
Resets the count.
DataTracker< Degree, Data_t > xy
accumulator for variable xy
Definition: SimpleFits.h:329
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 269 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().

269 { return s2.N(); }
int N() const
Returns the number of entries added.
Definition: StatCollector.h:63
WeightTracker< Data_t > s2
accumulator for uncertainty
Definition: SimpleFits.h:325
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 1480 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().

1481 {
1482 
1483  out << "Sums 1/s^2=" << s2.Weights() << "\n x/s^2=" << x.template SumN<1>();
1484  for (unsigned int degree = 2; degree <= x.Power; ++degree)
1485  out << "\n x^" << degree << "/s^2=" << x.Sum(degree);
1486  out << "\n y/s^2=" << y.Weights() << "\n y^2/s^2=" << y2.Sum();
1487  if (xy.Power >= 1) out << "\n xy/s^2=" << xy.template SumN<1>();
1488  for (unsigned int degree = 2; degree <= xy.Power; ++degree)
1489  out << "\n x^" << degree << "y/s^2=" << xy.Sum(degree);
1490  out << std::endl;
1491 } // FitDataCollector<>::Print()
Weight_t Weights() const
Returns the sum of the weights.
Definition: StatCollector.h:66
WeightTracker< Data_t > y
accumulator for y
Definition: SimpleFits.h:327
DataTracker< 1, Data_t > y2
accumulator for y2
Definition: SimpleFits.h:328
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:325
DataTracker< Degree *2, Data_t > x
accumulator for variable x^k
Definition: SimpleFits.h:326
static constexpr unsigned int Power
DataTracker< Degree, Data_t > xy
accumulator for variable xy
Definition: SimpleFits.h:329
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 319 of file SimpleFits.h.

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

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

319 { return Data_t(1.) / sqr(s); }
static constexpr V sqr(V const &v)
Returns the square of the specified value.
Definition: SimpleFits.h:284
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 322 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:20
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 290 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().

290 { return (n == 0) ? s2.Weights() : x.Sum(n); }
Weight_t Weights() const
Returns the sum of the weights.
Definition: StatCollector.h:66
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:325
DataTracker< Degree *2, Data_t > x
accumulator for variable x^k
Definition: SimpleFits.h:326
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.

298  {
300  }
WeightTracker< Data_t > s2
accumulator for uncertainty
Definition: SimpleFits.h:325
DataTracker< Degree *2, Data_t > x
accumulator for variable x^k
Definition: SimpleFits.h:326
static T Sum(WeightTracker< T > const &, DataTracker< Power, T > const &sums)
Definition: SimpleFits.h:57
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 293 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().

293 { return (n == 0) ? y.Weights() : xy.Sum(n); }
Weight_t Weights() const
Returns the sum of the weights.
Definition: StatCollector.h:66
WeightTracker< Data_t > y
accumulator for y
Definition: SimpleFits.h:327
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:329
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 304 of file SimpleFits.h.

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

305  {
307  }
WeightTracker< Data_t > y
accumulator for y
Definition: SimpleFits.h:327
static T Sum(WeightTracker< T > const &, DataTracker< Power, T > const &sums)
Definition: SimpleFits.h:57
DataTracker< Degree, Data_t > xy
accumulator for variable xy
Definition: SimpleFits.h:329
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 310 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().

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

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 74 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 326 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 327 of file SimpleFits.h.

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


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