LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar::util::MinMaxCollector< T > Class Template Reference

Keeps track of the minimum and maximum value we observed. More...

#include "StatCollector.h"

Public Types

using Data_t = T
 type of data we collect More...
 
using This_t = MinMaxCollector< T >
 this type More...
 

Public Member Functions

bool has_data () const
 Returns whether at least one datum has been added. More...
 
Data_t min () const
 Returns the accumulated minimum, or a very large number if no values. More...
 
Data_t max () const
 Returns the accumulated maximum, or a very small number if no values. More...
 
void clear ()
 Removes all statistics and reinitializes the object. More...
 
template<typename Iter >
lar::util::MinMaxCollector< T > & add (Iter begin, Iter end)
 
 MinMaxCollector ()=default
 Default constructor: no data collected so far. More...
 
 MinMaxCollector (std::initializer_list< Data_t > init)
 Constructor: starts with parsing the specified data. More...
 
template<typename Iter >
 MinMaxCollector (Iter begin, Iter end)
 Include a sequence of values in the statistics. More...
 
Inserters
This_tadd (Data_t value)
 Include a single value in the statistics. More...
 
This_tadd (std::initializer_list< Data_t > values)
 Include a sequence of values in the statistics. More...
 
template<typename Iter >
This_tadd (Iter begin, Iter end)
 Include a sequence of values in the statistics. More...
 

Protected Attributes

Data_t minimum = std::numeric_limits<Data_t>::max()
 the accumulated minimum More...
 
Data_t maximum = std::numeric_limits<Data_t>::min()
 the accumulated maximum More...
 

Detailed Description

template<typename T>
class lar::util::MinMaxCollector< T >

Keeps track of the minimum and maximum value we observed.


Template Parameters
Ttype of datum

Implementation note: a similar class with an arbitrary comparison rule would require a careful choice of initial values for minimum and maximum, or a entry count that should be checked at each insertion. We save that slight overhead here.

Definition at line 751 of file StatCollector.h.

Member Typedef Documentation

template<typename T>
using lar::util::MinMaxCollector< T >::Data_t = T

type of data we collect

Definition at line 753 of file StatCollector.h.

template<typename T>
using lar::util::MinMaxCollector< T >::This_t = MinMaxCollector<T>

this type

Definition at line 754 of file StatCollector.h.

Constructor & Destructor Documentation

template<typename T>
lar::util::MinMaxCollector< T >::MinMaxCollector ( )
default

Default constructor: no data collected so far.

template<typename T>
lar::util::MinMaxCollector< T >::MinMaxCollector ( std::initializer_list< Data_t init)
inline

Constructor: starts with parsing the specified data.

Definition at line 761 of file StatCollector.h.

761 { add(init); }
This_t & add(Data_t value)
Include a single value in the statistics.
template<typename T>
template<typename Iter >
lar::util::MinMaxCollector< T >::MinMaxCollector ( Iter  begin,
Iter  end 
)
inline

Include a sequence of values in the statistics.

Template Parameters
Itertype of an iterator on values
Parameters
beginiterator pointing to the first value to be included
enditerator pointing to the last value to be included

Definition at line 770 of file StatCollector.h.

771  {
772  add(begin, end);
773  }
This_t & add(Data_t value)
Include a single value in the statistics.
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

Member Function Documentation

template<typename T >
lar::util::MinMaxCollector< T > & lar::util::MinMaxCollector< T >::add ( Data_t  value)

Include a single value in the statistics.

Parameters
valuethe value to be added
Returns
this object

Definition at line 1056 of file StatCollector.h.

References value.

Referenced by dump::raw::OpDetWaveformDumper::dump(), detsim::DumpRawDigits::PrintRawDigit(), and caldata::DumpWires::PrintWire().

1057 {
1058  if (value < minimum) minimum = value;
1059  if (value > maximum) maximum = value;
1060  return *this;
1061 } // lar::util::MinMaxCollector<T>::add
Data_t minimum
the accumulated minimum
Data_t maximum
the accumulated maximum
double value
Definition: spectrum.C:18
template<typename T >
lar::util::MinMaxCollector< T > & lar::util::MinMaxCollector< T >::add ( std::initializer_list< Data_t values)
inline

Include a sequence of values in the statistics.

Parameters
valuesthe values to be added
Returns
this object

Definition at line 1064 of file StatCollector.h.

1066 {
1067  return add(values.begin(), values.end());
1068 }
This_t & add(Data_t value)
Include a single value in the statistics.
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
template<typename T>
template<typename Iter >
This_t& lar::util::MinMaxCollector< T >::add ( Iter  begin,
Iter  end 
)

Include a sequence of values in the statistics.

Template Parameters
Itertype of an iterator on values
Parameters
beginiterator pointing to the first value to be included
enditerator pointing to the last value to be included
Returns
this object
template<typename T>
template<typename Iter >
lar::util::MinMaxCollector<T>& lar::util::MinMaxCollector< T >::add ( Iter  begin,
Iter  end 
)
inline

Definition at line 1072 of file StatCollector.h.

References value.

1073 {
1074  std::for_each(begin, end, [this](Data_t value) { this->add(value); });
1075  return *this;
1076 } // lar::util::MinMaxCollector<T>::add(Iter)
This_t & add(Data_t value)
Include a single value in the statistics.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
T Data_t
type of data we collect
double value
Definition: spectrum.C:18
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
template<typename T >
void lar::util::MinMaxCollector< T >::clear ( )
inline

Removes all statistics and reinitializes the object.

Definition at line 1079 of file StatCollector.h.

1080 {
1081  minimum = std::numeric_limits<Data_t>::max();
1082  maximum = std::numeric_limits<Data_t>::min();
1083 } // lar::util::MinMaxCollector<T>::clear()
Data_t minimum
the accumulated minimum
Data_t maximum
the accumulated maximum
template<typename T>
bool lar::util::MinMaxCollector< T >::has_data ( ) const
inline

Returns whether at least one datum has been added.

Definition at line 806 of file StatCollector.h.

806 { return minimum <= maximum; }
Data_t minimum
the accumulated minimum
Data_t maximum
the accumulated maximum
template<typename T>
Data_t lar::util::MinMaxCollector< T >::max ( ) const
inline

Returns the accumulated maximum, or a very small number if no values.

Definition at line 812 of file StatCollector.h.

Referenced by dump::raw::OpDetWaveformDumper::dump(), detsim::DumpRawDigits::PrintRawDigit(), and caldata::DumpWires::PrintWire().

812 { return maximum; }
Data_t maximum
the accumulated maximum
template<typename T>
Data_t lar::util::MinMaxCollector< T >::min ( ) const
inline

Returns the accumulated minimum, or a very large number if no values.

Definition at line 809 of file StatCollector.h.

Referenced by evd::details::RawDigitInfo_t::CollectSampleInfo(), dump::raw::OpDetWaveformDumper::dump(), detsim::DumpRawDigits::PrintRawDigit(), and caldata::DumpWires::PrintWire().

809 { return minimum; }
Data_t minimum
the accumulated minimum

Member Data Documentation

template<typename T>
Data_t lar::util::MinMaxCollector< T >::maximum = std::numeric_limits<Data_t>::min()
protected

the accumulated maximum

Definition at line 822 of file StatCollector.h.

template<typename T>
Data_t lar::util::MinMaxCollector< T >::minimum = std::numeric_limits<Data_t>::max()
protected

the accumulated minimum

Definition at line 819 of file StatCollector.h.


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