19 template <
class Rep,
class Period>
20 auto sqrt( std::chrono::duration<Rep, Period> d );
21 template <
class Rep1,
class Rep2,
class Period>
22 auto operator*(
const std::chrono::duration<Rep1, Period>& lhs,
const std::chrono::duration<Rep2, Period>& rhs );
26#if defined( __GNUC__ ) && ( __GNUC__ == 11 ) && !defined( __clang__ )
27namespace std::chrono {
28 template <
typename Ratio>
29 static constexpr const char* suffix(
const Ratio& ) {
30 if constexpr ( std::ratio_equal_v<Ratio, std::ratio<1>> ) {
32 }
else if constexpr ( std::ratio_equal_v<Ratio, std::milli> ) {
34 }
else if constexpr ( std::ratio_equal_v<Ratio, std::micro> ) {
36 }
else if constexpr ( std::ratio_equal_v<Ratio, std::nano> ) {
38 }
else if constexpr ( std::ratio_equal_v<Ratio, std::ratio<60>> ) {
40 }
else if constexpr ( std::ratio_equal_v<Ratio, std::ratio<3600>> ) {
45 template <
class Rep,
class Period>
46 std::ostream&
operator<<( std::ostream& os,
const std::chrono::duration<Rep, Period>& d ) {
47 return os << d.count() << suffix( Period{} );
235#include <boost/format.hpp>
239#include <nlohmann/json.hpp>
242#include <type_traits>
250 template <
class Rep,
class Period>
251 struct adl_serializer<
std::chrono::duration<Rep, Period>> {
252 static void to_json( json& j,
const std::chrono::duration<Rep, Period>& d ) { j = d.count(); }
253 static void from_json(
const json& j, std::chrono::duration<Rep, Period>& d ) {
254 d = std::chrono::duration<Rep, Period>{ j.get<Rep>() };
271 template <
typename T, T N>
273 template <
typename U>
283 template <
typename U>
284 constexpr decltype( auto )
operator()( U&& v )
const noexcept {
285 return std::forward<U>( v );
293 template <
typename U>
294 constexpr decltype( auto )
operator()( U&& v )
const noexcept {
302 template <
typename Arithmetic,
typename Result =
double>
303 using fp_result_type = std::conditional_t<std::is_integral_v<Arithmetic>, Result, Arithmetic>;
308 template <
typename Arithmetic, atomicity Atomicity>
314 template <
typename Arithmetic>
325 template <
typename Arithmetic>
330 return v.load( std::memory_order_relaxed );
339 template <
typename Arithmetic, atomicity Atomicity>
345 template <
typename Arithmetic>
356 template <
typename AtomicType,
typename Arithmetic>
358 if constexpr (
requires { atVar.fetch_add( value, std::memory_order_relaxed ); } ) {
359 atVar.fetch_add( value, std::memory_order_relaxed );
362 while ( !atVar.compare_exchange_weak( current, current + value ) )
370 template <
typename Arithmetic>
376 if constexpr ( !std::is_floating_point_v<Arithmetic> ) {
387 template <
typename Arithmetic>
389 static constexpr Arithmetic
value() {
return std::numeric_limits<Arithmetic>::lowest(); }
395 template <
typename Arithmetic>
397 static constexpr Arithmetic
value() {
return std::numeric_limits<Arithmetic>::max(); }
405 template <
typename Arithmetic, atomicity Atomicity,
typename Compare,
typename Initial>
411 template <
typename Arithmetic,
typename Compare,
typename Initial>
417 if ( Compare{}( b, a ) ) a = b;
424 template <
typename Arithmetic,
typename Compare,
typename Initial>
431 while ( Compare{}( b, prev_value ) && !a.compare_exchange_weak( prev_value, b ) )
440 template <
typename Arithmetic, atomicity Atomicity = atomicity::full>
447 template <
typename Arithmetic, atomicity Atomicity = atomicity::full>
478 typename InputTransform = Identity,
typename OutputTransform = Identity,
479 typename ValueHandler = Adder<InnerType, Atomicity>>
481 template <
typename,
typename, atomicity,
typename,
typename,
typename>
486 using OutputType = std::decay_t<std::invoke_result_t<OutputTransform, InnerType>>;
490 ValueHandler::merge(
m_value, InputTransform{}( by ) );
495 template <atomicity ato,
typename VH>
499 template <
typename... Args>
508 template <atomicity ato,
typename VH>
510 ValueHandler::merge(
m_value, VH::exchange( other.
m_value, VH::DefaultValue() ) );
512 template <atomicity ato,
typename VH>
514 ValueHandler::merge(
m_value, other.m_value );
522 return j.at( entries ).get<InnerType>();
526 typename ValueHandler::InternalType
m_value{ ValueHandler::DefaultValue() };
534 template <
typename Arithmetic,
atomicity Atomicity,
typename InputTypeT = Arithmetic,
535 template <atomicity,
typename>
class... Bases>
539 using OutputType = std::tuple<typename Bases<Atomicity, Arithmetic>::OutputType...>;
540 using InternalType = std::tuple<typename Bases<Atomicity, Arithmetic>::InternalType...>;
544 template <atomicity ato>
548 ( Bases<Atomicity, Arithmetic>::operator+=( by ), ... );
551 OutputType value()
const {
return std::make_tuple( Bases<Atomicity, Arithmetic>::value()... ); }
552 void reset() { ( Bases<Atomicity, Arithmetic>::reset(), ... ); }
553 template <atomicity Ato>
555 ( Bases<Atomicity, Arithmetic>::mergeAndReset(
static_cast<Bases<Ato, Arithmetic>&
>( other ) ), ... );
557 template <atomicity Ato>
559 ( Bases<Atomicity, Arithmetic>::operator+(
static_cast<Bases<Ato, Arithmetic>&&
>( other ) ), ... );
569 std::apply( [
this](
const auto&... i ) { ( this->Bases<Atomicity, Arithmetic>::reset( i ), ... ); }, t );
572 return extractJSONDataHelper( j, entries, std::index_sequence_for<Bases<Atomicity, Arithmetic>...>{} );
576 template <
size_t... Is>
578 std::index_sequence<Is...> ) {
583 typename Bases<Atomicity, Arithmetic>::JSONStringEntriesType... entries ) {
584 return { Bases<Atomicity, Arithmetic>::extractJSONData( j, entries )... };
592 template <atomicity Atomicity,
typename Arithmetic =
double>
594 :
GenericAccumulator<Arithmetic, Arithmetic, Atomicity, Identity, Identity, Maximum<Arithmetic, Atomicity>> {
604 template <atomicity Atomicity,
typename Arithmetic =
double>
606 :
GenericAccumulator<Arithmetic, Arithmetic, Atomicity, Identity, Identity, Minimum<Arithmetic, Atomicity>> {
618 template <atomicity Atomicity,
typename Arithmetic =
double>
622 ( *this ) += Arithmetic{};
637 template <atomicity Atomicity,
typename Arithmetic =
double>
648 template <atomicity Atomicity,
typename Arithmetic =
unsigned long>
650 static_assert( std::is_integral_v<Arithmetic>,
651 "Invalid Arithmetic type for IntegralAccumulator. It must be an integral type" );
671 template <atomicity Atomicity,
typename Arithmetic =
double>
687 template <atomicity Atomicity,
typename Arithmetic>
703 template <atomicity Atomicity,
typename Arithmetic>
714 template <atomicity Atomicity,
typename Arithmetic>
719 template <
typename Result = fp_result_type<Arithmetic>>
722 if ( 1 > nbEntries )
return Result{ -1 };
723 return static_cast<Result
>( this->
nTrueEntries() ) / nbEntries;
727 template <
typename Result = fp_result_type<Arithmetic>>
734 if ( 1 > nbEntries )
return Result{ -1 };
735 return sqrt(
static_cast<Result
>( this->
nTrueEntries() * this->nFalseEntries() ) / nbEntries ) / nbEntries;
744 assert( b.nPass <= b.nTotal );
758 template <atomicity Atomicity,
typename Arithmetic,
template <atomicity,
typename>
typename CountAcc,
759 template <atomicity,
typename>
typename SumAcc>
761 :
AccumulatorSet<Arithmetic, Atomicity, typename CountAcc<Atomicity, Arithmetic>::InputType, CountAcc, SumAcc> {
762 static_assert( std::is_same_v<typename CountAcc<Atomicity, Arithmetic>::InputType,
763 typename SumAcc<Atomicity, Arithmetic>::InputType>,
764 "Incompatible Counters in definition of AveragingAccumulator. Both should have identical Input" );
765 using AccumulatorSet<Arithmetic, Atomicity,
typename CountAcc<Atomicity, Arithmetic>::InputType, CountAcc,
767 template <
typename Result = fp_result_type<Arithmetic>>
769 auto n = this->nEntries();
770 Result sum = this->sum();
771 return ( n > 0 ) ?
static_cast<Result
>( sum / n ) : Result{};
779 template <atomicity Atomicity,
typename Arithmetic>
787 template <atomicity Atomicity,
typename Arithmetic,
template <atomicity,
typename>
typename AvgAcc,
788 template <atomicity,
typename>
typename SquareAcc>
790 :
AccumulatorSet<Arithmetic, Atomicity, typename AvgAcc<Atomicity, Arithmetic>::InputType, AvgAcc, SquareAcc> {
791 static_assert( std::is_same_v<typename AvgAcc<Atomicity, Arithmetic>::InputType,
792 typename SquareAcc<Atomicity, Arithmetic>::InputType>,
793 "Incompatible Counters in definition of SigmaAccumulator. Both should have identical Input" );
794 using AccumulatorSet<Arithmetic, Atomicity,
typename SquareAcc<Atomicity, Arithmetic>::InputType, AvgAcc,
796 template <
typename Result = fp_result_type<Arithmetic>>
798 auto n = this->nEntries();
799 Result sum = this->sum();
800 return ( n > 0 ) ?
static_cast<Result
>( ( this->sum2() - sum * ( sum / n ) ) / n ) : Result{};
803 template <
typename Result = fp_result_type<Arithmetic>>
805 auto n = this->nEntries();
806 Result sum = this->sum();
807 return ( n > 1 ) ?
static_cast<Result
>( ( this->sum2() - sum * ( sum / n ) ) / ( n - 1 ) ) : Result{};
810 template <
typename Result = fp_result_type<Arithmetic>>
817 return ( Result{ 0 } > v ) ? Result{} :
static_cast<Result
>(
sqrt( v ) );
819 [[deprecated(
"The name 'rms' has changed to standard_deviation" )]] Arithmetic
rms()
const {
823 template <
typename Result = fp_result_type<Arithmetic>>
825 auto n = this->nEntries();
826 if ( 0 == n )
return Result{};
832 return ( Result{ 0 } > v ) ? Result{} :
static_cast<Result
>(
sqrt( v / n ) );
840 template <atomicity Atomicity,
typename Arithmetic>
847 template <atomicity Atomicity,
typename Arithmetic>
857 template <
template <
atomicity Ato,
typename... Int>
class ContainedAccumulator,
atomicity Atomicity, typename... Args>
858 class Buffer :
public ContainedAccumulator<atomicity::none, Args...> {
886 template <
typename stream>
887 stream&
printImpl( stream& s, std::string_view tag )
const {
888 s << boost::format{
" | %|-48.48s|%|50t|" } % ( std::string{
'\"' }.append( tag ).append(
"\"" ) );
889 return print( s,
true );
892 virtual std::ostream&
print( std::ostream&,
bool tableFormat =
false )
const = 0;
895 virtual std::ostream&
print( std::ostream& o, std::string_view tag )
const {
return printImpl( o, tag ); }
902 std::ostringstream ost;
919 template <
atomicity Atomicity,
template <
atomicity Ato,
typename... Int>
class Accumulator, typename... Args>
922 using Accumulator<Atomicity, Args...>::Accumulator;
925 template <
typename OWNER>
937 template <
typename OWNER,
typename SELF,
typename... CARGS>
939 : Accumulator<Atomicity, Args...>( args... ),
m_monitoringHub( &o->serviceLocator()->monitoringHub() ) {
940 m_monitoringHub->registerEntity( o->name(), name, self.typeString, self );
951 template <atomicity Atomicity = atomicity::full,
typename Arithmetic =
unsigned long>
953 inline static const std::string
typeString{ std::string{
"counter:Counter:" } +
typeid( Arithmetic ).name() };
955 template <
typename OWNER>
965 template <
typename stream>
966 stream&
printImpl( stream& o,
bool tableFormat )
const {
968 auto fmt = ( tableFormat ?
"|%|10d| |" :
"#=%|-7lu|" );
969 return o << boost::format{ fmt } % this->
nEntries();
972 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
980 j = { {
"type", c.typeString }, {
"empty", c.nEntries() == 0 }, {
"nEntries", c.nEntries() } };
991 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
993 inline static const std::string
typeString{ std::string{
"counter:AveragingCounter:" } +
994 typeid( Arithmetic ).name() };
996 template <
typename OWNER>
1001 template <
typename stream>
1003 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |" :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g|" );
1004 return o << boost::format{ fmt } % this->nEntries() % this->sum() % this->
mean();
1007 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1016 j = { {
"type", c.typeString },
1017 {
"empty", c.nEntries() == 0 },
1018 {
"nEntries", c.nEntries() },
1020 {
"mean", c.mean() } };
1026 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1033 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1035 inline static const std::string
typeString{ std::string{
"counter:SigmaCounter:" } +
typeid( Arithmetic ).name() };
1037 template <
typename OWNER>
1042 template <
typename stream>
1044 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |"
1045 :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g|" );
1046 return o << boost::format{ fmt } % this->nEntries() % this->sum() % this->mean() % this->
standard_deviation();
1049 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1057 j = { {
"type", c.typeString },
1058 {
"empty", c.nEntries() == 0 },
1059 {
"nEntries", c.nEntries() },
1061 {
"mean", c.mean() },
1062 {
"sum2", c.sum2() },
1063 {
"standard_deviation", c.standard_deviation() } };
1074 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1076 inline static const std::string
typeString{ std::string{
"counter:StatCounter:" } +
typeid( Arithmetic ).name() };
1078 template <
typename OWNER>
1083 template <
typename stream>
1085 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |"
1086 :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|" );
1087 return o << boost::format{ fmt } % this->nEntries() % this->sum() % this->mean() % this->
standard_deviation() %
1088 this->min() % this->max();
1091 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1099 j = { {
"type", c.typeString },
1100 {
"empty", c.nEntries() == 0 },
1101 {
"nEntries", c.nEntries() },
1103 {
"mean", c.mean() },
1104 {
"sum2", c.sum2() },
1105 {
"standard_deviation", c.standard_deviation() },
1107 {
"max", c.max() } };
1111 j, { { {
"nEntries",
"sum" },
"sum2" },
"min",
"max" } );
1119 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1121 inline static const std::string
typeString{ std::string{
"counter:BinomialCounter:" } +
1122 typeid( Arithmetic ).name() };
1124 template <
typename OWNER>
1128 template <
typename stream>
1130 auto fmt = ( tableFormat ?
"|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%% |"
1131 :
"#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|" );
1136 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1141 template <
typename stream>
1142 stream&
printImpl( stream& o, std::string_view tag )
const {
1144 o << boost::format{
" |*%|-48.48s|%|50t|" } % ( std::string{
"\"" }.append( tag ).append(
"\"" ) );
1145 return print( o,
true );
1148 std::ostream&
print( std::ostream& o, std::string_view tag )
const override {
return printImpl( o, tag ); }
1154 j = { {
"type", c.typeString },
1155 {
"empty", c.nEntries() == 0 },
1156 {
"nEntries", c.nTrueEntries() + c.nFalseEntries() },
1157 {
"nTrueEntries", c.nTrueEntries() },
1158 {
"nFalseEntries", c.nFalseEntries() },
1159 {
"efficiency", c.efficiency() },
1160 {
"efficiencyErr", c.efficiencyErr() } };
1168 template <atomicity Atomicity>
1171 static void merge(
typename Base::InternalType& orig,
bool b ) {
1172 if ( b ) Base::merge( orig, 1 );
1177 template <atomicity Atomicity,
typename Arithmetic =
double>
1181 template <MSG::Level level, atomicity Atomicity = atomicity::full>
1184 inline static const std::string
typeString{
"counter:MsgCounter" };
1185 template <
typename OWNER>
1186 MsgCounter( OWNER* o, std::string
const& ms,
unsigned long nMax = 10 )
1204 template <
typename stream>
1206 return o << boost::format{ tableFormat ?
"|%|10d| |" :
"#=%|-7lu|" } % this->
value();
1209 std::ostream&
print( std::ostream& os,
bool tableFormat )
const override {
return printImpl( os, tableFormat ); }
1215 j = { {
"type", c.typeString }, {
"empty", c.value() == 0 },
1216 {
"nEntries", c.value() }, {
"level", level },
1217 {
"max", c.max }, {
"msg", c.msg } };
1220 return { j.at(
"msg" ).get<std::string>(), j.at(
"max" ).get<
unsigned long>(),
1221 j.at(
"nEntries" ).get<
unsigned long>() };
1225 MsgCounter( std::string
const& ms,
unsigned long nMax,
unsigned long count )
1234 if ( this->
value() == max ) {
1235 logger->msgStream( level ) <<
"Suppressing message: " << std::quoted(
msg,
'\'' ) <<
endmsg;
1248 template <
typename Counter,
typename Container,
typename Fun>
1250 auto b = counter.buffer();
1251 for (
const auto& elem : container ) b += f( elem );
std::ostream & operator<<(std::ostream &s, AlgsExecutionStates::State x)
Streaming of State values.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
AccumulatorSet is an Accumulator that holds a set of Accumulators templated by same Arithmetic and At...
void operator++(int)=delete
static InternalType extractJSONData(const nlohmann::json &j, const JSONStringEntriesType &entries)
static InternalType extractJSONDataHelper(const nlohmann::json &j, const JSONStringEntriesType &entries, std::index_sequence< Is... >)
void operator+(AccumulatorSet< Arithmetic, Ato, InputType, Bases... > &&other)
std::tuple< typename Bases< Atomicity, Arithmetic >::InternalType... > InternalType
std::tuple< typename Bases< Atomicity, Arithmetic >::OutputType... > OutputType
AccumulatorSet(const InternalType &t)
static InternalType extractJSONDataHelper(const nlohmann::json &j, typename Bases< Atomicity, Arithmetic >::JSONStringEntriesType... entries)
constexpr AccumulatorSet()=default
void mergeAndReset(AccumulatorSet< Arithmetic, Ato, InputType, Bases... > &other)
void reset(const InternalType &t)
AccumulatorSet & operator+=(const InputType by)
AccumulatorSet(construct_empty_t, const AccumulatorSet< Arithmetic, ato, InputType, Bases... > &)
constructor of an empty AccumulatorSet, copying the (non existent) config from another GenericAccumul...
std::tuple< typename Bases< Atomicity, Arithmetic >::JSONStringEntriesType... > JSONStringEntriesType
Buffer is a non atomic Accumulator which, when it goes out-of-scope, updates the underlying thread-sa...
ContainedAccumulator< Atomicity, Args... > prime_type
ContainedAccumulator< atomicity::none, Args... > base_type
void operator=(const Buffer &)=delete
Buffer(const Buffer &)=delete
An empty ancester of all counters that provides a buffer method that returns a buffer on itself Also ...
Monitoring::Hub * m_monitoringHub
BufferableCounter()=default
static const std::string typeString
BufferableCounter(OWNER *o, std::string const &name, SELF &self, CARGS... args)
Buffer< Accumulator, Atomicity, Args... > BufferType
BufferableCounter & operator=(BufferableCounter const &)=delete
BufferableCounter(BufferableCounter const &)=delete
BufferableCounter(OWNER *o, std::string const &name)
Generic Accumulator, templated by.
GenericAccumulator & operator=(const GenericAccumulator &other)
GenericAccumulator(const GenericAccumulator &other)
GenericAccumulator(InnerType in)
GenericAccumulator(std::in_place_t, Args &&... args)
Handler< Atomicity >::InternalType m_value
std::decay_t< std::invoke_result_t< OutputTransform, InnerType > > OutputType
static InnerType extractJSONData(const nlohmann::json &j, const JSONStringEntriesType &entries)
GenericAccumulator(construct_empty_t, const GenericAccumulator< InputType, InnerType, ato, InputTransform, OutputTransform, VH > &)
constructor of an empty GenericAccumulator, copying the (non existent) config from another GenericAcc...
void mergeAndReset(GenericAccumulator< InputType, InnerType, ato, InputTransform, OutputTransform, VH > &other)
void operator+(GenericAccumulator< InputType, InnerType, ato, InputTransform, OutputTransform, VH > &&other)
std::string JSONStringEntriesType
GenericAccumulator()=default
GenericAccumulator operator+=(const InputType by)
friend class GenericAccumulator
std::ostream & print(std::ostream &os, bool tableFormat) const override
prints the counter to a stream
friend void to_json(nlohmann::json &j, MsgCounter const &c)
friend void reset(MsgCounter &c)
MsgCounter & operator++()
MsgCounter(OWNER *o, std::string const &ms, unsigned long nMax=10)
bool toBePrinted() const override
hint whether we should print that counter or not.
stream & printImpl(stream &o, bool tableFormat) const
friend void mergeAndReset(MsgCounter &c, MsgCounter &o)
Monitoring::Hub * m_monitoringHub
static MsgCounter fromJSON(const nlohmann::json &j)
static const std::string typeString
const CommonMessagingBase * logger
MsgCounter & operator+=(const bool by)
MsgStream & print(MsgStream &os, bool tableFormat) const override
MsgCounter(MsgCounter const &)=delete
MsgCounter & operator=(MsgCounter const &)=delete
MsgCounter(std::string const &ms, unsigned long nMax, unsigned long count)
Definition of the MsgStream class used to transmit messages.
GenericAccumulator< bool, unsigned long, Atomicity, Identity, Identity, Handler< Atomicity > > MsgAccumulator
Efficient counter implementations for Gaudi.
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.
std::ostream & operator<<(std::ostream &s, const PrintableCounter &counter)
external printout operator to a stream type
AccumulatorSet< Arithmetic, Atomicity, Arithmetic, SigmaAccumulator, MinAccumulator, MaxAccumulator > StatAccumulator
StatAccumulator.
Extremum< Arithmetic, Atomicity, std::less< Arithmetic >, detail::Max< Arithmetic > > Minimum
A Minimun ValueHandler operator(a, b) means a = min(a, b) In case of full atomicity,...
auto sqrt(std::chrono::duration< Rep, Period > d)
sqrt for std::chrono::duration
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 buff...
Extremum< Arithmetic, Atomicity, std::greater< Arithmetic >, detail::Min< Arithmetic > > Maximum
An Maximum ValueHandler operator(a, b) means a = max(a, b) In case of full atomicity,...
AveragingCounter< Arithmetic, Atomicity > SummingCounter
atomicity
Defines atomicity of the accumulators.
std::conditional_t< std::is_integral_v< Arithmetic >, Result, Arithmetic > fp_result_type
type_trait for the result type of a floating point operation on the type Arithmetic
constexpr construct_empty_t construct_empty
AveragingAccumulatorBase< Atomicity, Arithmetic, CountAccumulator, SumAccumulator > AveragingAccumulator
AveragingAccumulator.
void fetch_add(AtomicType &atVar, Arithmetic value)
generic fetch_add, also dealing with atomic types with no fetch_add member method
SigmaAccumulatorBase< Atomicity, Arithmetic, AveragingAccumulator, SquareAccumulator > SigmaAccumulator
SigmaAccumulator.
An Adder ValueHandler operator(a, b) means a += b.
static constexpr OutputType DefaultValue()
static void merge(InternalType &a, Arithmetic b) noexcept
static constexpr OutputType DefaultValue()
static void merge(InternalType &a, Arithmetic b) noexcept
AveragingAccumulatorBase.
A counter aiming at computing sum and average.
stream & printImpl(stream &o, bool tableFormat) const
friend void mergeAndReset(AveragingCounter &c, AveragingCounter &o)
bool toBePrinted() const override
hint whether we should print that counter or not.
AveragingCounter(OWNER *o, std::string const &name)
static const std::string typeString
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
friend void to_json(nlohmann::json &j, AveragingCounter const &c)
static AveragingCounter fromJSON(const nlohmann::json &j)
friend void reset(AveragingCounter &c)
Base type for all functors used as ValuesHandler.
static constexpr OutputType getValue(const InternalType &v) noexcept
std::atomic< Arithmetic > InternalType
static Arithmetic exchange(InternalType &v, Arithmetic newv) noexcept
static constexpr OutputType getValue(const InternalType &v) noexcept
static Arithmetic exchange(InternalType &v, Arithmetic newv) noexcept
BinomialAccumulator & operator+=(binomial_t b)
auto efficiencyErr() const
unsigned long nEntries() const
friend void to_json(nlohmann::json &j, BinomialCounter const &c)
BinomialCounter(OWNER *o, std::string const &name)
stream & printImpl(stream &o, bool tableFormat) const
friend void mergeAndReset(BinomialCounter &c, BinomialCounter &o)
std::ostream & print(std::ostream &o, std::string_view tag) const override
prints the counter to a stream in table format, with the given tag
MsgStream & print(MsgStream &o, std::string_view tag) const override
static BinomialCounter fromJSON(const nlohmann::json &j)
static const std::string typeString
friend void reset(BinomialCounter &c)
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
bool toBePrinted() const override
hint whether we should print that counter or not.
stream & printImpl(stream &o, std::string_view tag) const
A functor always returning the value N.
constexpr T operator()(U &&) const noexcept
CountAccumulator operator++(int)
unsigned long nEntries() const
CountAccumulator & operator++()
A basic integral counter;.
friend void mergeAndReset(Counter &c, Counter &o)
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
Counter(OWNER *o, std::string const &name)
static Counter fromJSON(const nlohmann::json &j)
Counter & operator+=(const Arithmetic v)
friend void reset(Counter &c)
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
bool toBePrinted() const override
hint whether we should print that counter or not.
stream & printImpl(stream &o, bool tableFormat) const
friend void to_json(nlohmann::json &j, Counter const &c)
static const std::string typeString
An Extremum ValueHandler, to be reused for Minimum and Maximum operator(a, b) means if (Compare(b,...
static void merge(InternalType &a, Arithmetic b) noexcept
static constexpr OutputType DefaultValue()
static void merge(InternalType &a, Arithmetic b) noexcept
static constexpr OutputType DefaultValue()
unsigned long nFalseEntries() const
helper functor for the FalseAccumulator
unsigned int operator()(bool v) const
IntegralAccumulator operator++(int)
Arithmetic nEntries() const
IntegralAccumulator & operator++()
An empty ancester of all counters that knows how to print themselves.
virtual ~PrintableCounter()=default
destructor
std::string toString() const
get a string representation
virtual std::ostream & print(std::ostream &, bool tableFormat=false) const =0
prints the counter to a stream
stream & printImpl(stream &s, std::string_view tag) const
virtual MsgStream & print(MsgStream &, bool tableFormat=true) const =0
PrintableCounter()=default
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 bool toBePrinted() const
hint whether we should print that counter or not.
virtual MsgStream & print(MsgStream &o, std::string_view tag) const
auto biased_sample_variance() const
auto unbiased_sample_variance() const
auto standard_deviation() const
stream & printImpl(stream &o, bool tableFormat) const
bool toBePrinted() const override
hint whether we should print that counter or not.
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
friend void to_json(nlohmann::json &j, SigmaCounter const &c)
SigmaCounter(OWNER *o, std::string const &name)
friend void reset(SigmaCounter &c)
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
friend void mergeAndReset(SigmaCounter &c, SigmaCounter &o)
static const std::string typeString
static SigmaCounter fromJSON(const nlohmann::json &j)
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
friend void mergeAndReset(StatCounter &c, StatCounter &o)
stream & printImpl(stream &o, bool tableFormat) const
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
friend void reset(StatCounter &c)
friend void to_json(nlohmann::json &j, StatCounter const &c)
static StatCounter fromJSON(const nlohmann::json &j)
bool toBePrinted() const override
hint whether we should print that counter or not.
StatCounter(OWNER *o, std::string const &name)
static const std::string typeString
unsigned long nTrueEntries() const
helper functor for the TrueAccumulator
unsigned int operator()(bool v) const
constant used to disambiguate construction of an empty Accumulator versus the copy constructor.
construct_empty_t()=default
Type trait providing the highest possible value (to be used as initial value for Minimum)
static constexpr Arithmetic value()
Type trait providing the lowest possible value (to be used as initial value for Maximum)
static constexpr Arithmetic value()
static void merge(typename Base::InternalType &orig, bool b)
Adder< unsigned long, Atomicity > Base
Central entity in a Gaudi application that manages monitoring objects (i.e.
static void from_json(const json &j, std::chrono::duration< Rep, Period > &d)
static void to_json(json &j, const std::chrono::duration< Rep, Period > &d)