The Gaudi Framework  master (594c33fa)
Gaudi::Accumulators Namespace Reference

Namespaces

 details
 
 naming
 

Classes

class  AccumulatorSet
 AccumulatorSet is an Accumulator that holds a set of Accumulators templated by same Arithmetic and Atomicity and increase them altogether. More...
 
struct  Adder
 An Adder ValueHandler operator(a, b) means a += b. More...
 
struct  Adder< Arithmetic, atomicity::full >
 Adder specialization in the case of atomicity full. More...
 
struct  Adder< Arithmetic, atomicity::none >
 Adder specialization in the case of atomicity none. More...
 
struct  AveragingAccumulatorBase
 AveragingAccumulatorBase. More...
 
struct  AveragingCounter
 A counter aiming at computing sum and average. More...
 
struct  Axis
 Definition of an Histogram Axis. More...
 
struct  Axis< Gaudi::Tests::Histograms::CustomAxis::Category >
 
struct  BaseValueHandler
 Base type for all functors used as ValuesHandler. More...
 
struct  BaseValueHandler< Arithmetic, atomicity::full >
 BaseValueHandler specialization in the case of atomicity full. More...
 
struct  BaseValueHandler< Arithmetic, atomicity::none >
 BaseValueHandler specialization in the case of atomicity none. More...
 
struct  BinomialAccumulator
 BinomialAccumulator. More...
 
struct  BinomialCounter
 A counter dealing with binomial data. More...
 
class  Buffer
 Buffer is a non atomic Accumulator which, when it goes out-of-scope, updates the underlying thread-safe Accumulator for all previous updates in one go. More...
 
class  BufferableCounter
 An empty ancester of all counters that provides a buffer method that returns a buffer on itself Also registers the counter to its owner, with default type "counter" Due to this registration, move semantic is disabled. More...
 
struct  Constant
 A functor always returning the value N. More...
 
struct  construct_empty_t
 constant used to disambiguate construction of an empty Accumulator versus the copy constructor. More...
 
struct  CountAccumulator
 CountAccumulator. More...
 
struct  Counter
 A basic integral counter;. More...
 
struct  CounterArray
 generic class implementing an array of counters The only addition to a raw array is the constructor that allows to build names of the counters automatically from the index of the counter in the array There are 2 possibilities : More...
 
struct  ExtractWeight
 A functor to extract weight, take a pair (valueTuple, weight) as input. More...
 
struct  Extremum
 An Extremum ValueHandler, to be reused for Minimum and Maximum operator(a, b) means if (Compare(b,a)) a = b In case of full atomicity, compare_exchange_weak is used. More...
 
struct  Extremum< Arithmetic, atomicity::full, Compare, Initial >
 Extremum specialization in the case of atomicity full. More...
 
struct  Extremum< Arithmetic, atomicity::none, Compare, Initial >
 Extremum specialization in the case of atomicity none. More...
 
struct  FalseAccumulator
 FalseAccumulator. More...
 
struct  FalseTo1
 helper functor for the FalseAccumulator More...
 
class  GenericAccumulator
 Generic Accumulator, templated by. More...
 
struct  HistogramArrayBase
 generic class implementing an array of histograms The only addition to a raw array is the constructor that allows to build names and titles for the histograms automatically from the index of the histogram in the array There are 2 possibilities : More...
 
struct  HistogramArrayBase< Histo, N, std::index_sequence< NDs... > >
 
class  HistogramingAccumulatorInternal
 Internal Accumulator class dealing with Histograming. More...
 
class  HistogramingCounterBaseInternal
 A base counter dealing with Histograms. More...
 
class  HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence< NDs... > >
 
struct  HistoInputType
 small class used as InputType for regular Histograms More...
 
class  HistoInputType< Arithmetic, 1 >
 specialization of HistoInputType for ND == 1 in order to have simpler syntax that is, no tuple of one item More...
 
struct  Identity
 An Identity functor. More...
 
struct  IntegralAccumulator
 IntegralAccumulator. More...
 
struct  MaxAccumulator
 MaxAccumulator. More...
 
struct  MinAccumulator
 MinAccumulator. More...
 
class  MsgCounter
 
struct  PrintableCounter
 An empty ancester of all counters that knows how to print themselves. More...
 
struct  RootHistogramingAccumulator
 Class implementing a root histogram accumulator. More...
 
struct  RootHistogramingAccumulator< Atomicity, Arithmetic, std::integral_constant< int, 1 > >
 
struct  RootHistogramingAccumulator< Atomicity, Arithmetic, std::integral_constant< int, 2 > >
 
struct  RootHistogramingAccumulator< Atomicity, Arithmetic, std::integral_constant< int, 3 > >
 
class  RootHistogramingAccumulatorInternal
 Internal Accumulator class dealing with RootHistograming. More...
 
class  RootHistogramingCounterBase
 Extension of the standard Gaudi histogram to provide similar functionnality as ROOT. More...
 
class  RootHistogramingCounterBase< 1, Atomicity, Arithmetic, Type >
 
class  RootHistogramingCounterBase< 2, Atomicity, Arithmetic, Type >
 
class  RootHistogramingCounterBase< 3, Atomicity, Arithmetic, Type >
 
struct  SigmaAccumulatorBase
 SigmaAccumulatorBase. More...
 
struct  SigmaCounter
 A counter aiming at computing average and sum2 / variance / standard deviation. More...
 
struct  SigmaNAccumulator
 
struct  SigmaNAccumulator< Arithmetic, Atomicity, 1 >
 specialization for ND=1 to allow for better syntax More...
 
struct  SigmasValueHandler
 
struct  Square
 A Square functor. More...
 
struct  SquareAccumulator
 SquareAccumulator. More...
 
struct  StatCounter
 A counter aiming at computing average and sum2 / variance / standard deviation. More...
 
struct  SumAccumulator
 SumAccumulator. More...
 
struct  TrueAccumulator
 TrueAccumulator. More...
 
struct  TrueTo1
 helper functor for the TrueAccumulator More...
 
struct  WeightedCountAccumulator
 WeightedCountAccumulator. More...
 
struct  WeightedHistoInputType
 small class used as InputType for weighted Histograms More...
 
struct  WeightedProduct
 A Product functor, take a pair (value, weight) as input. More...
 
struct  WeightedSquare
 A WeightedSquare functor, take a pair (value, weight) as input. More...
 
struct  WeightedSquareAccumulator
 WeightedSquareAccumulator. More...
 
struct  WeightedSumAccumulator
 WeightedSumAccumulator. More...
 

Typedefs

template<atomicity Atomicity, typename Arithmetic >
using WeightedAveragingAccumulator = AveragingAccumulatorBase< Atomicity, Arithmetic, WeightedCountAccumulator, WeightedSumAccumulator >
 WeightedAveragingAccumulator. More...
 
template<atomicity Atomicity, typename Arithmetic >
using WeightedSigmaAccumulator = SigmaAccumulatorBase< Atomicity, Arithmetic, WeightedAveragingAccumulator, WeightedSquareAccumulator >
 WeightedSigmaAccumulator. More...
 
template<atomicity Atomicity, typename Arithmetic , typename ND >
using HistogramingAccumulator = HistogramingAccumulatorInternal< Atomicity, HistoInputType< Arithmetic, ND::value >, unsigned long, ND, IntegralAccumulator >
 Class implementing a regular histogram accumulator. More...
 
template<atomicity Atomicity, typename Arithmetic , typename ND >
using WeightedHistogramingAccumulator = HistogramingAccumulatorInternal< Atomicity, WeightedHistoInputType< Arithmetic, ND::value >, Arithmetic, ND, WeightedCountAccumulator >
 Class implementing a weighted histogram accumulator. More...
 
template<atomicity Atomicity, typename Arithmetic , typename ND >
using ProfileHistogramingAccumulator = HistogramingAccumulatorInternal< Atomicity, HistoInputType< Arithmetic, ND::value+1, ND::value >, Arithmetic, ND, SigmaAccumulator >
 Class implementing a profile histogram accumulator. More...
 
template<atomicity Atomicity, typename Arithmetic , typename ND >
using WeightedProfileHistogramingAccumulator = HistogramingAccumulatorInternal< Atomicity, WeightedHistoInputType< Arithmetic, ND::value+1, ND::value >, Arithmetic, ND, WeightedSigmaAccumulator >
 Class implementing a weighted profile histogram accumulator. More...
 
template<unsigned int ND, atomicity Atomicity, typename Arithmetic , const char * Type, template< atomicity, typename, typename > typename Accumulator>
using HistogramingCounterBase = HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::make_index_sequence< ND > >
 
template<unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
using Histogram = HistogramingCounterBase< ND, Atomicity, Arithmetic, naming::histogramString, HistogramingAccumulator >
 standard histograming counter. See HistogramingCounterBase for details More...
 
template<unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
using WeightedHistogram = HistogramingCounterBase< ND, Atomicity, Arithmetic, naming::weightedHistogramString, WeightedHistogramingAccumulator >
 standard histograming counter with weight. See HistogramingCounterBase for details More...
 
template<unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
using ProfileHistogram = HistogramingCounterBase< ND, Atomicity, Arithmetic, naming::profilehistogramString, ProfileHistogramingAccumulator >
 profile histograming counter. See HistogramingCounterBase for details More...
 
template<unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
using WeightedProfileHistogram = HistogramingCounterBase< ND, Atomicity, Arithmetic, naming::weightedProfilehistogramString, WeightedProfileHistogramingAccumulator >
 weighted profile histograming counter. See HistogramingCounterBase for details More...
 
template<typename Histo , std::size_t N>
using HistogramArray = HistogramArrayBase< Histo, N, std::make_index_sequence< Histo::NumberDimensions::value > >
 
template<unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
using RootHistogram = RootHistogramingCounterBase< ND, Atomicity, Arithmetic, naming::histogramString >
 Root histograming counter. See RootHistogramingCounterBase for details. More...
 
template<typename T , typename = int>
using has_fetch_add_ = decltype(std::declval< T & >().fetch_add(0))
 type_traits for checking the presence of fetch_add More...
 
template<typename Arithmetic , typename Result = double>
using fp_result_type = std::conditional_t< std::is_integral_v< Arithmetic >, Result, Arithmetic >
 type_trait for the result type of a floating point operation on the type Arithmetic More...
 
template<typename Arithmetic , atomicity Atomicity = atomicity::full>
using Minimum = Extremum< Arithmetic, Atomicity, std::less< Arithmetic >, std::numeric_limits< Arithmetic >::max >
 A Minimun ValueHandler operator(a, b) means a = min(a, b) In case of full atomicity, compare_exchange_weak is used. More...
 
template<typename Arithmetic , atomicity Atomicity = atomicity::full>
using Maximum = Extremum< Arithmetic, Atomicity, std::greater< Arithmetic >, std::numeric_limits< Arithmetic >::lowest >
 An Maximum ValueHandler operator(a, b) means a = max(a, b) In case of full atomicity, compare_exchange_weak is used. More...
 
template<atomicity Atomicity, typename Arithmetic >
using AveragingAccumulator = AveragingAccumulatorBase< Atomicity, Arithmetic, CountAccumulator, SumAccumulator >
 AveragingAccumulator. More...
 
template<atomicity Atomicity, typename Arithmetic >
using SigmaAccumulator = SigmaAccumulatorBase< Atomicity, Arithmetic, AveragingAccumulator, SquareAccumulator >
 SigmaAccumulator. More...
 
template<atomicity Atomicity, typename Arithmetic >
using StatAccumulator = AccumulatorSet< Arithmetic, Atomicity, Arithmetic, SigmaAccumulator, MinAccumulator, MaxAccumulator >
 StatAccumulator. More...
 
template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
using SummingCounter = AveragingCounter< Arithmetic, Atomicity >
 

Enumerations

enum  atomicity { atomicity::none, atomicity::full }
 Defines atomicity of the accumulators. More...
 

Functions

template<typename Arithmetic >
void to_json (nlohmann::json &j, const Axis< Arithmetic > &axis)
 automatic conversion of the Axis type to json More...
 
constexpr unsigned int NSUMS (unsigned int ND)
 number of items in sums for a given dimension = 1 (nb items) + ND (sums of each dimension) + ND*(ND+1)/2 (square sums) More...
 
template<class Rep , class Period >
auto sqrt (std::chrono::duration< Rep, Period > d)
 sqrt for std::chrono::duration More...
 
template<class Rep1 , class Rep2 , class Period >
auto operator* (const std::chrono::duration< Rep1, Period > &lhs, const std::chrono::duration< Rep2, Period > &rhs)
 Multiplication of two std::chrono::duration objects with same Period. More...
 
template<class T >
auto sqrt (T d)
 forward declaration of sqrt for custom types More...
 
template<typename AtomicType , typename Arithmetic >
void fetch_add (AtomicType &atVar, Arithmetic value)
 generic fetch_add, also dealing with atomic types with no fetch_add member method More...
 
std::ostreamoperator<< (std::ostream &s, const PrintableCounter &counter)
 external printout operator to a stream type More...
 
MsgStreamoperator<< (MsgStream &s, const PrintableCounter &counter)
 
template<typename Counter , typename Container , typename Fun >
void accumulate (Counter &counter, const Container &container, Fun f=Identity{})
 A helper function for accumulating data from a container into a counter This is internally using buffers so that the original counter is only updated once. More...
 

Variables

template<typename T >
constexpr bool has_fetch_add_v = Gaudi::cpp17::is_detected_v<has_fetch_add_, T>
 
constexpr construct_empty_t construct_empty {}
 

Detailed Description

Efficient counter implementations for Gaudi.

A number of concepts and templated classes are defined:

Concepts

  • Accumulator : object accumulating some data in some way. examples : counters, sum of squares accumulator, minimum accumulator (keeps minimum of all values)
  • Atomicity : the atomicity of an accumulator. Can be none or full. "none" means that the accumulator is not thread safe and should only be used locally within a thread. "full" means that the accumulator is thread safe, but that you pay the price of atomics inside. Note that this price may be reduced by the usage of the Buffer class, see below.
  • InputTransform : a transformation to be applied to the input of an Accumulator. for example "elevation to power 2" for a sum of squares Accumulator, "identity" for a sum Accumulator or a minimum Accumulator, "constant 1" for a pure counter
  • OutputTransform : a transformation to be applied to the value of an Accumulator when reading it. Usually identity. You can think of square root for an RMS Accumulator (accumulating squares internally)
  • ValueHandler : the class handling the internal value of an Accumulator, and responsible for updating it with a new input. It defines the initial default value, the storage type used (depending on atomicity) and the actual update operation (sum, keep min or max typically).
  • AccumulatorSet : an Accumulator defined as a set of Accumulators with same InputType and Atomicity. Updating it means updating all Accumulators of the set with the same value. E.g. a set with Counter and Sum will be able to compute some average
  • Buffer : a wrapper around a thread safe Accumulator that allows to accumulate locally (in a non thread safe Accumulator) data before merging into the original one when Buffer is destructed. To be use when accumulators are updated in tight loops
  • Counter : a higher level object that is an Accumulator and provides extra methods, most notably a way to print itself via operator<<, a print method and a buffer method to retrieve a Buffer on top of it.

Classes and helper functions

(De)Serialization

All counters are serialized into JSON strings using nlohmann's json library (pure header) See https://github.com/nlohmann/json for details, but here are few notes :

  • all Arithmetic types used in Counters need to be serializable with this library
  • standard types (STL included) already are
  • for custom types, one needs to implement a to_json method along these lines :
    void to_json(json& j, const Person& p) {
    j = nlohmann::json{{"name", p.name}, {"type", "person:basic"}, {"address", p.address}, {"age", p.age}};
    }
    This method must be declared in your type namespace
  • for third-party type, it's slightly more complicated and one has to specialize a class called adl_serializer for the given type. Just follow the example given in this file for std::chrono::duration

Symetrically to serialization, all counters objects can be constructed from json objects using the same nlohmann's json library via a the fromJSON static method;

The serialized json needs to contain a 'type' entry defining the rest of the json structure. If the type value contains a ':' character, then the part preceding it will be considered as a namespace. The rest is free text.

Here is a list of types defined in this header and their corresponding fields. Note that there are 2 kinds of fields : raw ones and derived ones, built on top of raw ones. Note also that <prec> when present is a string defining the precision of the data when numerical. It is described at the end of the list for each dependent field, the computation formula is given

  • counter:Counter:<prec> : empty(bool), nEntries(integer)
  • counter:AveragingCounter:<prec> : same as counter:Counter, sum(number), mean(number) = sum/nEntries
  • counter:SigmaCounter:<prec> : same as counter:AveragingCounter, sum2(number), standard_deviation(number) = sqrt((sum2-sum*sum/nEntries)/(nEntries-1))
  • counter:StatCounter:<prec> : same as counter:SigmaCounter, min(number), max(number)
  • counter:BinomialCounter:<prec> : nTrueEntries(integer), nFalseEntries(integer), nEntries(integer) = nTrueEntries+nFalseEntries efficiency(number) = nTrueEntries/nEntries, efficiencyErr(number) = (nTrueEntries*nFalseEntries)/(nEntries*nEntries)
  • counter:MsgCounter : same as counter:Counter, level(number), max(number), msg(string)
  • statentity : union of fields of counter:StatCounter and counter:BinomialCounter. DEPRECATED
  • timer:<prec> : same fields as counter:StatCounter
  • <prec> is a string defining the type of data in the counter. It is the typeid representation of the type that should be used by a customer to use the data and not lose precision. In other terms, it's usually one char of chstijlmxyfde for respectively char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double Note that it does not have to match the original type, just to be the same precision. E.g. an std::chrono::nanoseconds type can and should be mapped to its internal representation that happens to be long so <prec> will be l.

Notes

All Accumulators and Counters defined above are provided in their atomic and non atomic versions

Here is an example of the typical usage of these classes :

AveragingCounter<> avg;
avg += 3;
avg += 5;
avg += 6;
std::cout << avg << std::endl;
SigmaCounter<> sig;
sig += 3;
sig += 5;
sig += 6;
std::cout << sig << std::endl;
AveragingCounter<float, atomicity::full> avg2;
{
auto buf = avg2.buffer();
for ( int i = 0; i < 1000; i++ ) buf += i;
// single update of original counter when buf is destroyed
}
std::cout << avg2 << std::endl;
BinomialCounter<> bin;
bin += false;
bin += true;
bin += true;
bin += false;
bin += false;
std::cout << bin << std::endl;
se += 3;
se += 5;
se += 6;

Typedef Documentation

◆ AveragingAccumulator

template<atomicity Atomicity, typename Arithmetic >
using Gaudi::Accumulators::AveragingAccumulator = typedef AveragingAccumulatorBase<Atomicity, Arithmetic, CountAccumulator, SumAccumulator>

AveragingAccumulator.

An AveragingAccumulator is an Accumulator able to compute an average

See also
Gaudi::Accumulators for detailed documentation

Definition at line 771 of file Accumulators.h.

◆ fp_result_type

template<typename Arithmetic , typename Result = double>
using Gaudi::Accumulators::fp_result_type = typedef std::conditional_t<std::is_integral_v<Arithmetic>, Result, Arithmetic>

type_trait for the result type of a floating point operation on the type Arithmetic

Definition at line 312 of file Accumulators.h.

◆ has_fetch_add_

template<typename T , typename = int>
using Gaudi::Accumulators::has_fetch_add_ = typedef decltype( std::declval<T&>().fetch_add( 0 ) )

type_traits for checking the presence of fetch_add

Definition at line 304 of file Accumulators.h.

◆ Histogram

template<unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
using Gaudi::Accumulators::Histogram = typedef HistogramingCounterBase<ND, Atomicity, Arithmetic, naming::histogramString, HistogramingAccumulator>

standard histograming counter. See HistogramingCounterBase for details

Definition at line 538 of file Histogram.h.

◆ HistogramArray

template<typename Histo , std::size_t N>
using Gaudi::Accumulators::HistogramArray = typedef HistogramArrayBase<Histo, N, std::make_index_sequence<Histo::NumberDimensions::value> >

Definition at line 104 of file HistogramArray.h.

◆ HistogramingAccumulator

template<atomicity Atomicity, typename Arithmetic , typename ND >
using Gaudi::Accumulators::HistogramingAccumulator = typedef HistogramingAccumulatorInternal<Atomicity, HistoInputType<Arithmetic, ND::value>, unsigned long, ND, IntegralAccumulator>

Class implementing a regular histogram accumulator.

Actually only an alias to HistogramingAccumulatorInternal with proper template parameters

Definition at line 374 of file Histogram.h.

◆ HistogramingCounterBase

template<unsigned int ND, atomicity Atomicity, typename Arithmetic , const char * Type, template< atomicity, typename, typename > typename Accumulator>
using Gaudi::Accumulators::HistogramingCounterBase = typedef HistogramingCounterBaseInternal<ND, Atomicity, Arithmetic, Type, Accumulator, std::make_index_sequence<ND> >

Definition at line 527 of file Histogram.h.

◆ Maximum

template<typename Arithmetic , atomicity Atomicity = atomicity::full>
using Gaudi::Accumulators::Maximum = typedef Extremum<Arithmetic, Atomicity, std::greater<Arithmetic>, std::numeric_limits<Arithmetic>::lowest>

An Maximum ValueHandler operator(a, b) means a = max(a, b) In case of full atomicity, compare_exchange_weak is used.

Definition at line 439 of file Accumulators.h.

◆ Minimum

template<typename Arithmetic , atomicity Atomicity = atomicity::full>
using Gaudi::Accumulators::Minimum = typedef Extremum<Arithmetic, Atomicity, std::less<Arithmetic>, std::numeric_limits<Arithmetic>::max>

A Minimun ValueHandler operator(a, b) means a = min(a, b) In case of full atomicity, compare_exchange_weak is used.

Definition at line 432 of file Accumulators.h.

◆ ProfileHistogram

template<unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
using Gaudi::Accumulators::ProfileHistogram = typedef HistogramingCounterBase<ND, Atomicity, Arithmetic, naming::profilehistogramString, ProfileHistogramingAccumulator>

profile histograming counter. See HistogramingCounterBase for details

Definition at line 548 of file Histogram.h.

◆ ProfileHistogramingAccumulator

template<atomicity Atomicity, typename Arithmetic , typename ND >
using Gaudi::Accumulators::ProfileHistogramingAccumulator = typedef HistogramingAccumulatorInternal<Atomicity, HistoInputType<Arithmetic, ND::value + 1, ND::value>, Arithmetic, ND, SigmaAccumulator>

Class implementing a profile histogram accumulator.

Actually only an alias to HistogramingAccumulatorInternal with proper template parameters

Definition at line 393 of file Histogram.h.

◆ RootHistogram

template<unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
using Gaudi::Accumulators::RootHistogram = typedef RootHistogramingCounterBase<ND, Atomicity, Arithmetic, naming::histogramString>

Root histograming counter. See RootHistogramingCounterBase for details.

Definition at line 343 of file RootHistogram.h.

◆ SigmaAccumulator

template<atomicity Atomicity, typename Arithmetic >
using Gaudi::Accumulators::SigmaAccumulator = typedef SigmaAccumulatorBase<Atomicity, Arithmetic, AveragingAccumulator, SquareAccumulator>

SigmaAccumulator.

A SigmaAccumulator is an Accumulator able to compute an average and variance/rms

See also
Gaudi::Accumulators for detailed documentation

Definition at line 832 of file Accumulators.h.

◆ StatAccumulator

template<atomicity Atomicity, typename Arithmetic >
using Gaudi::Accumulators::StatAccumulator = typedef AccumulatorSet<Arithmetic, Atomicity, Arithmetic, SigmaAccumulator, MinAccumulator, MaxAccumulator>

StatAccumulator.

A StatAccumulator is an Accumulator able to compute an average, variance/rms and min/max

See also
Gaudi::Accumulators for detailed documentation

Definition at line 839 of file Accumulators.h.

◆ SummingCounter

template<typename Arithmetic = double, atomicity Atomicity = atomicity::full>
using Gaudi::Accumulators::SummingCounter = typedef AveragingCounter<Arithmetic, Atomicity>

Definition at line 1015 of file Accumulators.h.

◆ WeightedAveragingAccumulator

template<atomicity Atomicity, typename Arithmetic >
using Gaudi::Accumulators::WeightedAveragingAccumulator = typedef AveragingAccumulatorBase<Atomicity, Arithmetic, WeightedCountAccumulator, WeightedSumAccumulator>

WeightedAveragingAccumulator.

An AveragingAccumulator is an Accumulator able to compute an average This implementation takes a pair (value, weight) as input

See also
Gaudi::Accumulators for detailed documentation

Definition at line 138 of file Histogram.h.

◆ WeightedHistogram

template<unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
using Gaudi::Accumulators::WeightedHistogram = typedef HistogramingCounterBase<ND, Atomicity, Arithmetic, naming::weightedHistogramString, WeightedHistogramingAccumulator>

standard histograming counter with weight. See HistogramingCounterBase for details

Definition at line 543 of file Histogram.h.

◆ WeightedHistogramingAccumulator

template<atomicity Atomicity, typename Arithmetic , typename ND >
using Gaudi::Accumulators::WeightedHistogramingAccumulator = typedef HistogramingAccumulatorInternal<Atomicity, WeightedHistoInputType<Arithmetic, ND::value>, Arithmetic, ND, WeightedCountAccumulator>

Class implementing a weighted histogram accumulator.

Actually only an alias to HistogramingAccumulatorInternal with proper template parameters

Definition at line 383 of file Histogram.h.

◆ WeightedProfileHistogram

template<unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
using Gaudi::Accumulators::WeightedProfileHistogram = typedef HistogramingCounterBase<ND, Atomicity, Arithmetic, naming::weightedProfilehistogramString, WeightedProfileHistogramingAccumulator>

weighted profile histograming counter. See HistogramingCounterBase for details

Definition at line 553 of file Histogram.h.

◆ WeightedProfileHistogramingAccumulator

template<atomicity Atomicity, typename Arithmetic , typename ND >
using Gaudi::Accumulators::WeightedProfileHistogramingAccumulator = typedef HistogramingAccumulatorInternal<Atomicity, WeightedHistoInputType<Arithmetic, ND::value + 1, ND::value>, Arithmetic, ND, WeightedSigmaAccumulator>

Class implementing a weighted profile histogram accumulator.

Actually only an alias to HistogramingAccumulatorInternal with proper template parameters

Definition at line 403 of file Histogram.h.

◆ WeightedSigmaAccumulator

template<atomicity Atomicity, typename Arithmetic >
using Gaudi::Accumulators::WeightedSigmaAccumulator = typedef SigmaAccumulatorBase<Atomicity, Arithmetic, WeightedAveragingAccumulator, WeightedSquareAccumulator>

WeightedSigmaAccumulator.

A SigmaAccumulator is an Accumulator able to compute an average and variance/rms This implementation takes a pair (value, weight) as input

See also
Gaudi::Accumulators for detailed documentation

Definition at line 147 of file Histogram.h.

Enumeration Type Documentation

◆ atomicity

Defines atomicity of the accumulators.

Enumerator
none 
full 

Definition at line 263 of file Accumulators.h.

263 { none, full };

Function Documentation

◆ accumulate()

template<typename Counter , typename Container , typename Fun >
void Gaudi::Accumulators::accumulate ( Counter counter,
const Container &  container,
Fun  f = Identity{} 
)

A helper function for accumulating data from a container into a counter This is internally using buffers so that the original counter is only updated once.

Definition at line 1239 of file Accumulators.h.

1239  {} ) {
1240  auto b = counter.buffer();
1241  for ( const auto& elem : container ) b += f( elem );
1242  }

◆ fetch_add()

template<typename AtomicType , typename Arithmetic >
void Gaudi::Accumulators::fetch_add ( AtomicType &  atVar,
Arithmetic  value 
)

generic fetch_add, also dealing with atomic types with no fetch_add member method

Definition at line 366 of file Accumulators.h.

366  {
367  if constexpr ( has_fetch_add_v<AtomicType> ) {
368  atVar.fetch_add( value, std::memory_order_relaxed );
369  } else {
370  auto current = BaseValueHandler<Arithmetic, atomicity::full>::getValue( atVar );
371  while ( !atVar.compare_exchange_weak( current, current + value ) )
372  ;
373  }
374  }

◆ NSUMS()

constexpr unsigned int Gaudi::Accumulators::NSUMS ( unsigned int  ND)
constexpr

number of items in sums for a given dimension = 1 (nb items) + ND (sums of each dimension) + ND*(ND+1)/2 (square sums)

Definition at line 21 of file RootHistogram.h.

21 { return 1 + ND + ND * ( ND + 1 ) / 2; }

◆ operator*()

template<class Rep1 , class Rep2 , class Period >
auto Gaudi::Accumulators::operator* ( const std::chrono::duration< Rep1, Period > &  lhs,
const std::chrono::duration< Rep2, Period > &  rhs 
)

Multiplication of two std::chrono::duration objects with same Period.

Definition at line 40 of file Counters.h.

40  {
41  return std::chrono::duration<std::common_type_t<Rep1, Rep2>, Period>( lhs.count() * rhs.count() );
42  }

◆ operator<<() [1/2]

MsgStream& Gaudi::Accumulators::operator<< ( MsgStream s,
const PrintableCounter counter 
)
inline

Definition at line 901 of file Accumulators.h.

901 { return counter.print( s ); }

◆ operator<<() [2/2]

std::ostream& Gaudi::Accumulators::operator<< ( std::ostream s,
const PrintableCounter counter 
)
inline

external printout operator to a stream type

Definition at line 900 of file Accumulators.h.

900 { return counter.print( s ); }

◆ sqrt() [1/2]

template<class Rep , class Period >
auto Gaudi::Accumulators::sqrt ( std::chrono::duration< Rep, Period >  d)

sqrt for std::chrono::duration

Definition at line 34 of file Counters.h.

34  {
35  return std::chrono::duration<Rep, Period>( static_cast<Rep>( std::round( std::sqrt( d.count() ) ) ) );
36  }

◆ sqrt() [2/2]

template<class T >
auto Gaudi::Accumulators::sqrt ( d)

forward declaration of sqrt for custom types

◆ to_json()

template<typename Arithmetic >
void Gaudi::Accumulators::to_json ( nlohmann::json &  j,
const Axis< Arithmetic > &  axis 
)

automatic conversion of the Axis type to json

Definition at line 200 of file Histogram.h.

200  {
201  j = nlohmann::json{ { "nBins", axis.nBins },
202  { "minValue", axis.minValue },
203  { "maxValue", axis.maxValue },
204  { "title", axis.title } };
205  if ( !axis.labels.empty() ) { j["labels"] = axis.labels; }
206  }

Variable Documentation

◆ construct_empty

constexpr construct_empty_t Gaudi::Accumulators::construct_empty {}
constexpr

Definition at line 449 of file Accumulators.h.

◆ has_fetch_add_v

template<typename T >
constexpr bool Gaudi::Accumulators::has_fetch_add_v = Gaudi::cpp17::is_detected_v<has_fetch_add_, T>
inlineconstexpr

Definition at line 306 of file Accumulators.h.

Gaudi::Accumulators::atomicity::full
@ full
gaudirun.s
string s
Definition: gaudirun.py:346
StatEntity
backward compatible StatEntity class.
Definition: StatEntity.h:23
jsonFromLHCbLog.json
json
Definition: jsonFromLHCbLog.py:86
std::chrono::duration
std::sqrt
T sqrt(T... args)
ProduceConsume.j
j
Definition: ProduceConsume.py:101
std::cout
Gaudi::Accumulators::to_json
void to_json(nlohmann::json &j, const Axis< Arithmetic > &axis)
automatic conversion of the Axis type to json
Definition: Histogram.h:200
std::round
T round(T... args)
std::endl
T endl(T... args)
std::chrono::duration::count
T count(T... args)
plotSpeedupsPyRoot.counter
counter
Definition: plotSpeedupsPyRoot.py:175
Gaudi::Accumulators::atomicity::none
@ none