LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar::util::details::DataTracker3< T, W, PWR > Class Template Reference

Class tracking sums of variables up to power 2. More...

#include "StatCollector.h"

Inheritance diagram for lar::util::details::DataTracker3< T, W, PWR >:
lar::util::details::DataTracker2< T, W, PWR > lar::util::details::DataTracker< PWR, T, W >

Public Types

using Weight_t = typename Base_t::Weight_t
 
using Data_t = T
 type of data More...
 

Public Member Functions

Weight_t SumCube () const
 Returns the weighted sum of the square of the entries. More...
 
Weight_t SumSq () const
 Returns the weighted sum of the square of the entries. More...
 
void add (Data_t v, Weight_t w)
 Adds the specified weight to the statistics. More...
 
void clear ()
 Resets the count. More...
 
template<unsigned int N>
Weight_t SumN () const
 Returns the sum of the values to the power N (1 <= N <= 2) More...
 
Weight_t Sum (unsigned int n) const
 Returns the sum of the values to the power n (1 <= n <= 2, no check) More...
 
Weight_t Sum () const
 Returns the weighted sum of the entries. More...
 

Static Public Attributes

static constexpr unsigned int Power = PWR
 

Protected Attributes

std::array< Weight_t, Powersums
 

Private Types

using Base_t = DataTracker2< T, W, PWR >
 base class type More...
 

Detailed Description

template<typename T, typename W = T, unsigned int PWR = 3>
class lar::util::details::DataTracker3< T, W, PWR >

Class tracking sums of variables up to power 2.

Template Parameters
Ttype of the quantity
Wtype of the weight (as T by default)

Definition at line 164 of file StatCollector.h.

Member Typedef Documentation

template<typename T , typename W = T, unsigned int PWR = 3>
using lar::util::details::DataTracker3< T, W, PWR >::Base_t = DataTracker2<T, W, PWR>
private

base class type

Definition at line 165 of file StatCollector.h.

template<unsigned int PWR, typename T, typename W = T>
using lar::util::details::DataTracker< PWR, T, W >::Data_t = T
inherited

type of data

Definition at line 103 of file StatCollector.h.

template<typename T , typename W = T, unsigned int PWR = 3>
using lar::util::details::DataTracker3< T, W, PWR >::Weight_t = typename Base_t::Weight_t

Definition at line 169 of file StatCollector.h.

Member Function Documentation

template<unsigned int PWR, typename T, typename W = T>
void lar::util::details::DataTracker< PWR, T, W >::add ( Data_t  v,
Weight_t  w 
)
inlineinherited

Adds the specified weight to the statistics.

Definition at line 110 of file StatCollector.h.

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

111  {
112  Weight_t x = w;
113  for (size_t i = 0; i < Power; ++i)
114  sums[i] += (x *= v);
115  }
Float_t x
Definition: compare.C:6
static constexpr unsigned int Power
Float_t w
Definition: plot.C:20
std::array< Weight_t, Power > sums
template<unsigned int PWR, typename T, typename W = T>
void lar::util::details::DataTracker< PWR, T, W >::clear ( )
inlineinherited

Resets the count.

Definition at line 118 of file StatCollector.h.

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

118 { sums.fill(Data_t(0)); }
std::array< Weight_t, Power > sums
template<unsigned int PWR, typename T, typename W = T>
Weight_t lar::util::details::DataTracker< PWR, T, W >::Sum ( unsigned int  n) const
inlineinherited

Returns the sum of the values to the power n (1 <= n <= 2, no check)

Definition at line 129 of file StatCollector.h.

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

129 { return sums[n - 1]; }
Char_t n[5]
std::array< Weight_t, Power > sums
template<unsigned int PWR, typename T, typename W = T>
Weight_t lar::util::details::DataTracker< PWR, T, W >::Sum ( ) const
inlineinherited

Returns the weighted sum of the entries.

Definition at line 132 of file StatCollector.h.

132 { return SumN<1>(); }
template<typename T , typename W = T, unsigned int PWR = 3>
Weight_t lar::util::details::DataTracker3< T, W, PWR >::SumCube ( ) const
inline

Returns the weighted sum of the square of the entries.

Definition at line 172 of file StatCollector.h.

172 { return Base_t::sums[2]; }
std::array< Weight_t, Power > sums
template<unsigned int PWR, typename T, typename W = T>
template<unsigned int N>
Weight_t lar::util::details::DataTracker< PWR, T, W >::SumN ( ) const
inlineinherited

Returns the sum of the values to the power N (1 <= N <= 2)

Definition at line 122 of file StatCollector.h.

123  {
124  static_assert((N > 0) && (N <= Power), "Invalid sum of power requested");
125  return sums[N - 1];
126  } // SumN()
static constexpr unsigned int Power
std::array< Weight_t, Power > sums
template<typename T, typename W = T, unsigned int PWR = 2>
Weight_t lar::util::details::DataTracker2< T, W, PWR >::SumSq ( ) const
inlineinherited

Returns the weighted sum of the square of the entries.

Definition at line 153 of file StatCollector.h.

153 { return Base_t::sums[1]; }
std::array< Weight_t, Power > sums

Member Data Documentation

template<unsigned int PWR, typename T, typename W = T>
constexpr unsigned int lar::util::details::DataTracker< PWR, T, W >::Power = PWR
staticinherited
template<unsigned int PWR, typename T, typename W = T>
std::array<Weight_t, Power> lar::util::details::DataTracker< PWR, T, W >::sums
protectedinherited

Definition at line 135 of file StatCollector.h.


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