The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
Gaudi::Accumulators::SigmaCounter< Arithmetic, Atomicity > Struct Template Reference

A counter aiming at computing average and sum2 / variance / standard deviation. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/Gaudi/Accumulators.h>

Inheritance diagram for Gaudi::Accumulators::SigmaCounter< Arithmetic, Atomicity >:
Collaboration diagram for Gaudi::Accumulators::SigmaCounter< Arithmetic, Atomicity >:

Public Member Functions

template<typename OWNER>
 SigmaCounter (OWNER *o, std::string const &name)
 
template<typename stream>
stream & printImpl (stream &o, bool tableFormat) const
 
std::ostream & print (std::ostream &o, bool tableFormat=false) const override
 prints the counter to a stream
 
MsgStreamprint (MsgStream &o, bool tableFormat=false) const override
 
bool toBePrinted () const override
 hint whether we should print that counter or not.
 
- Public Member Functions inherited from Gaudi::Accumulators::BufferableCounter< atomicity::full, SigmaAccumulator, double >
 BufferableCounter ()=default
 
 BufferableCounter (OWNER *o, std::string const &name)
 
 BufferableCounter (BufferableCounter const &)=delete
 
BufferType buffer ()
 
BufferableCounteroperator= (BufferableCounter const &)=delete
 
 ~BufferableCounter ()
 
- Public Member Functions inherited from Gaudi::Accumulators::PrintableCounter
 PrintableCounter ()=default
 
virtual ~PrintableCounter ()=default
 destructor
 
template<typename stream>
stream & printImpl (stream &s, std::string_view tag) const
 
virtual std::ostream & print (std::ostream &o, std::string_view tag) const
 prints the counter to a stream in table format, with the given tag
 
virtual MsgStreamprint (MsgStream &o, std::string_view tag) const
 
std::string toString () const
 get a string representation
 
- Public Member Functions inherited from Gaudi::Accumulators::SigmaAccumulatorBase< Atomicity, Arithmetic, AveragingAccumulator, SquareAccumulator >
auto biased_sample_variance () const
 
auto unbiased_sample_variance () const
 
auto standard_deviation () const
 
Arithmetic rms () const
 
auto meanErr () const
 
auto biased_sample_variance () const
 
auto unbiased_sample_variance () const
 
auto standard_deviation () const
 
Arithmetic rms () const
 
auto meanErr () const
 
- Public Member Functions inherited from Gaudi::Accumulators::AccumulatorSet< Arithmetic, Atomicity, InputTypeT, Bases >
constexpr AccumulatorSet ()=default
 
template<atomicity ato>
 AccumulatorSet (construct_empty_t, const AccumulatorSet< Arithmetic, ato, InputType, Bases... > &)
 constructor of an empty AccumulatorSet, copying the (non existent) config from another GenericAccumulator
 
AccumulatorSetoperator+= (const InputType by)
 
OutputType value () const
 
void reset ()
 
template<atomicity Ato>
void mergeAndReset (AccumulatorSet< Arithmetic, Ato, InputType, Bases... > &other)
 
template<atomicity Ato>
void operator+ (AccumulatorSet< Arithmetic, Ato, InputType, Bases... > &&other)
 

Static Public Member Functions

static SigmaCounter fromJSON (const nlohmann::json &j)
 

Static Public Attributes

static const std::string typeString { std::string{ "counter:SigmaCounter:" } + typeid( Arithmetic ).name() }
 
- Static Public Attributes inherited from Gaudi::Accumulators::BufferableCounter< atomicity::full, SigmaAccumulator, double >
static const std::string typeString
 

Friends

void reset (SigmaCounter &c)
 
void mergeAndReset (SigmaCounter &c, SigmaCounter &o)
 
void to_json (nlohmann::json &j, SigmaCounter const &c)
 

Additional Inherited Members

- Public Types inherited from Gaudi::Accumulators::BufferableCounter< atomicity::full, SigmaAccumulator, double >
using BufferType
 
- Public Types inherited from Gaudi::Accumulators::AccumulatorSet< Arithmetic, Atomicity, InputTypeT, Bases >
using InputType = InputTypeT
 
using OutputType = std::tuple<typename Bases<Atomicity, Arithmetic>::OutputType...>
 
using InternalType = std::tuple<typename Bases<Atomicity, Arithmetic>::InternalType...>
 
using JSONStringEntriesType = std::tuple<typename Bases<Atomicity, Arithmetic>::JSONStringEntriesType...>
 
- Protected Member Functions inherited from Gaudi::Accumulators::BufferableCounter< atomicity::full, SigmaAccumulator, double >
 BufferableCounter (OWNER *o, std::string const &name, SELF &self, CARGS... args)
 
- Protected Member Functions inherited from Gaudi::Accumulators::AccumulatorSet< Arithmetic, Atomicity, InputTypeT, Bases >
 AccumulatorSet (const InternalType &t)
 
void reset (const InternalType &t)
 
- Static Protected Member Functions inherited from Gaudi::Accumulators::AccumulatorSet< Arithmetic, Atomicity, InputTypeT, Bases >
static InternalType extractJSONData (const nlohmann::json &j, const JSONStringEntriesType &entries)
 

Detailed Description

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
struct Gaudi::Accumulators::SigmaCounter< Arithmetic, Atomicity >

A counter aiming at computing average and sum2 / variance / standard deviation.

See also
Gaudi::Accumulators for detailed documentation

Definition at line 1012 of file Accumulators.h.

Constructor & Destructor Documentation

◆ SigmaCounter()

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
template<typename OWNER>
Gaudi::Accumulators::SigmaCounter< Arithmetic, Atomicity >::SigmaCounter ( OWNER * o,
std::string const & name )
inline

Definition at line 1016 of file Accumulators.h.

Member Function Documentation

◆ fromJSON()

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
static SigmaCounter Gaudi::Accumulators::SigmaCounter< Arithmetic, Atomicity >::fromJSON ( const nlohmann::json & j)
inlinestatic

Definition at line 1043 of file Accumulators.h.

1043 {
1044 return SigmaAccumulator<Atomicity, Arithmetic>::extractJSONData( j, { { "nEntries", "sum" }, "sum2" } );
1045 }
static InternalType extractJSONData(const nlohmann::json &j, const JSONStringEntriesType &entries)

◆ print() [1/2]

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
MsgStream & Gaudi::Accumulators::SigmaCounter< Arithmetic, Atomicity >::print ( MsgStream & o,
bool tableFormat = false ) const
inlineoverridevirtual

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 1030 of file Accumulators.h.

1030{ return printImpl( o, tableFormat ); }
stream & printImpl(stream &o, bool tableFormat) const

◆ print() [2/2]

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
std::ostream & Gaudi::Accumulators::SigmaCounter< Arithmetic, Atomicity >::print ( std::ostream & ,
bool tableFormat = false ) const
inlineoverridevirtual

prints the counter to a stream

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 1027 of file Accumulators.h.

1027 {
1028 return printImpl( o, tableFormat );
1029 }

◆ printImpl()

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
template<typename stream>
stream & Gaudi::Accumulators::SigmaCounter< Arithmetic, Atomicity >::printImpl ( stream & o,
bool tableFormat ) const
inline

Definition at line 1021 of file Accumulators.h.

1021 {
1022 auto fmt = ( tableFormat ? "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |"
1023 : "#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g|" );
1024 return o << boost::format{ fmt } % this->nEntries() % this->sum() % this->mean() % this->standard_deviation();
1025 }

◆ toBePrinted()

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
bool Gaudi::Accumulators::SigmaCounter< Arithmetic, Atomicity >::toBePrinted ( ) const
inlineoverridevirtual

hint whether we should print that counter or not.

Typically empty counters may not be printed

Reimplemented from Gaudi::Accumulators::PrintableCounter.

Definition at line 1031 of file Accumulators.h.

1031{ return this->nEntries() > 0; }

Friends And Related Symbol Documentation

◆ mergeAndReset

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
void mergeAndReset ( SigmaCounter< Arithmetic, Atomicity > & c,
SigmaCounter< Arithmetic, Atomicity > & o )
friend

Definition at line 1033 of file Accumulators.h.

1033{ c.mergeAndReset( o ); }
friend void mergeAndReset(SigmaCounter &c, SigmaCounter &o)

◆ reset

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
void reset ( SigmaCounter< Arithmetic, Atomicity > & c)
friend

Definition at line 1032 of file Accumulators.h.

1032{ c.reset(); }
friend void reset(SigmaCounter &c)

◆ to_json

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
void to_json ( nlohmann::json & j,
SigmaCounter< Arithmetic, Atomicity > const & c )
friend

Definition at line 1034 of file Accumulators.h.

1034 {
1035 j = { { "type", c.typeString },
1036 { "empty", c.nEntries() == 0 },
1037 { "nEntries", c.nEntries() },
1038 { "sum", c.sum() },
1039 { "mean", c.mean() },
1040 { "sum2", c.sum2() },
1041 { "standard_deviation", c.standard_deviation() } };
1042 }
static const std::string typeString

Member Data Documentation

◆ typeString

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
const std::string Gaudi::Accumulators::SigmaCounter< Arithmetic, Atomicity >::typeString { std::string{ "counter:SigmaCounter:" } + typeid( Arithmetic ).name() }
inlinestatic

Definition at line 1013 of file Accumulators.h.

1013{ std::string{ "counter:SigmaCounter:" } + typeid( Arithmetic ).name() };

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