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 ) ), ... );
565 std::apply( [
this](
const auto&... i ) { ( this->Bases<Atomicity, Arithmetic>::reset( i ), ... ); }, t );
568 return extractJSONDataHelper( j, entries, std::index_sequence_for<Bases<Atomicity, Arithmetic>...>{} );
572 template <
size_t... Is>
574 std::index_sequence<Is...> ) {
579 typename Bases<Atomicity, Arithmetic>::JSONStringEntriesType... entries ) {
580 return { Bases<Atomicity, Arithmetic>::extractJSONData( j, entries )... };
588 template <atomicity Atomicity,
typename Arithmetic =
double>
590 :
GenericAccumulator<Arithmetic, Arithmetic, Atomicity, Identity, Identity, Maximum<Arithmetic, Atomicity>> {
600 template <atomicity Atomicity,
typename Arithmetic =
double>
602 :
GenericAccumulator<Arithmetic, Arithmetic, Atomicity, Identity, Identity, Minimum<Arithmetic, Atomicity>> {
614 template <atomicity Atomicity,
typename Arithmetic =
double>
618 ( *this ) += Arithmetic{};
633 template <atomicity Atomicity,
typename Arithmetic =
double>
644 template <atomicity Atomicity,
typename Arithmetic =
unsigned long>
646 static_assert( std::is_integral_v<Arithmetic>,
647 "Invalid Arithmetic type for IntegralAccumulator. It must be an integral type" );
667 template <atomicity Atomicity,
typename Arithmetic =
double>
683 template <atomicity Atomicity,
typename Arithmetic>
699 template <atomicity Atomicity,
typename Arithmetic>
710 template <atomicity Atomicity,
typename Arithmetic>
715 template <
typename Result = fp_result_type<Arithmetic>>
718 if ( 1 > nbEntries )
return Result{ -1 };
719 return static_cast<Result
>( this->
nTrueEntries() ) / nbEntries;
723 template <
typename Result = fp_result_type<Arithmetic>>
730 if ( 1 > nbEntries )
return Result{ -1 };
731 return sqrt(
static_cast<Result
>( this->
nTrueEntries() * this->nFalseEntries() ) / nbEntries ) / nbEntries;
740 assert( b.nPass <= b.nTotal );
754 template <atomicity Atomicity,
typename Arithmetic,
template <atomicity,
typename>
typename CountAcc,
755 template <atomicity,
typename>
typename SumAcc>
757 :
AccumulatorSet<Arithmetic, Atomicity, typename CountAcc<Atomicity, Arithmetic>::InputType, CountAcc, SumAcc> {
758 static_assert( std::is_same_v<typename CountAcc<Atomicity, Arithmetic>::InputType,
759 typename SumAcc<Atomicity, Arithmetic>::InputType>,
760 "Incompatible Counters in definition of AveragingAccumulator. Both should have identical Input" );
761 using AccumulatorSet<Arithmetic, Atomicity,
typename CountAcc<Atomicity, Arithmetic>::InputType, CountAcc,
763 template <
typename Result = fp_result_type<Arithmetic>>
765 auto n = this->nEntries();
766 Result sum = this->sum();
767 return ( n > 0 ) ?
static_cast<Result
>( sum / n ) : Result{};
775 template <atomicity Atomicity,
typename Arithmetic>
783 template <atomicity Atomicity,
typename Arithmetic,
template <atomicity,
typename>
typename AvgAcc,
784 template <atomicity,
typename>
typename SquareAcc>
786 :
AccumulatorSet<Arithmetic, Atomicity, typename AvgAcc<Atomicity, Arithmetic>::InputType, AvgAcc, SquareAcc> {
787 static_assert( std::is_same_v<typename AvgAcc<Atomicity, Arithmetic>::InputType,
788 typename SquareAcc<Atomicity, Arithmetic>::InputType>,
789 "Incompatible Counters in definition of SigmaAccumulator. Both should have identical Input" );
790 using AccumulatorSet<Arithmetic, Atomicity,
typename SquareAcc<Atomicity, Arithmetic>::InputType, AvgAcc,
792 template <
typename Result = fp_result_type<Arithmetic>>
794 auto n = this->nEntries();
795 Result sum = this->sum();
796 return ( n > 0 ) ?
static_cast<Result
>( ( this->sum2() - sum * ( sum / n ) ) / n ) : Result{};
799 template <
typename Result = fp_result_type<Arithmetic>>
801 auto n = this->nEntries();
802 Result sum = this->sum();
803 return ( n > 1 ) ?
static_cast<Result
>( ( this->sum2() - sum * ( sum / n ) ) / ( n - 1 ) ) : Result{};
806 template <
typename Result = fp_result_type<Arithmetic>>
813 return ( Result{ 0 } > v ) ? Result{} :
static_cast<Result
>(
sqrt( v ) );
815 [[deprecated(
"The name 'rms' has changed to standard_deviation" )]] Arithmetic
rms()
const {
819 template <
typename Result = fp_result_type<Arithmetic>>
821 auto n = this->nEntries();
822 if ( 0 == n )
return Result{};
828 return ( Result{ 0 } > v ) ? Result{} :
static_cast<Result
>(
sqrt( v / n ) );
836 template <atomicity Atomicity,
typename Arithmetic>
843 template <atomicity Atomicity,
typename Arithmetic>
853 template <
template <
atomicity Ato,
typename... Int>
class ContainedAccumulator,
atomicity Atomicity, typename... Args>
854 class Buffer :
public ContainedAccumulator<atomicity::none, Args...> {
882 template <
typename stream>
883 stream&
printImpl( stream& s, std::string_view tag )
const {
884 s << boost::format{
" | %|-48.48s|%|50t|" } % ( std::string{
'\"' }.append( tag ).append(
"\"" ) );
885 return print( s,
true );
888 virtual std::ostream&
print( std::ostream&,
bool tableFormat =
false )
const = 0;
891 virtual std::ostream&
print( std::ostream& o, std::string_view tag )
const {
return printImpl( o, tag ); }
898 std::ostringstream ost;
915 template <
atomicity Atomicity,
template <
atomicity Ato,
typename... Int>
class Accumulator, typename... Args>
918 using Accumulator<Atomicity, Args...>::Accumulator;
921 template <
typename OWNER>
933 template <
typename OWNER,
typename SELF,
typename... CARGS>
935 : Accumulator<Atomicity, Args...>( args... ),
m_monitoringHub( &o->serviceLocator()->monitoringHub() ) {
936 m_monitoringHub->registerEntity( o->name(), name, self.typeString, self );
947 template <atomicity Atomicity = atomicity::full,
typename Arithmetic =
unsigned long>
949 inline static const std::string
typeString{ std::string{
"counter:Counter:" } +
typeid( Arithmetic ).name() };
951 template <
typename OWNER>
961 template <
typename stream>
962 stream&
printImpl( stream& o,
bool tableFormat )
const {
964 auto fmt = ( tableFormat ?
"|%|10d| |" :
"#=%|-7lu|" );
965 return o << boost::format{ fmt } % this->
nEntries();
968 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
976 j = { {
"type", c.typeString }, {
"empty", c.nEntries() == 0 }, {
"nEntries", c.nEntries() } };
987 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
989 inline static const std::string
typeString{ std::string{
"counter:AveragingCounter:" } +
990 typeid( Arithmetic ).name() };
992 template <
typename OWNER>
997 template <
typename stream>
998 stream&
printImpl( stream& o,
bool tableFormat )
const {
999 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |" :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g|" );
1000 return o << boost::format{ fmt } % this->nEntries() % this->sum() % this->
mean();
1003 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1012 j = { {
"type", c.typeString },
1013 {
"empty", c.nEntries() == 0 },
1014 {
"nEntries", c.nEntries() },
1016 {
"mean", c.mean() } };
1022 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1029 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1031 inline static const std::string
typeString{ std::string{
"counter:SigmaCounter:" } +
typeid( Arithmetic ).name() };
1033 template <
typename OWNER>
1038 template <
typename stream>
1040 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |"
1041 :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g|" );
1042 return o << boost::format{ fmt } % this->nEntries() % this->sum() % this->mean() % this->
standard_deviation();
1045 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1053 j = { {
"type", c.typeString },
1054 {
"empty", c.nEntries() == 0 },
1055 {
"nEntries", c.nEntries() },
1057 {
"mean", c.mean() },
1058 {
"sum2", c.sum2() },
1059 {
"standard_deviation", c.standard_deviation() } };
1070 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1072 inline static const std::string
typeString{ std::string{
"counter:StatCounter:" } +
typeid( Arithmetic ).name() };
1074 template <
typename OWNER>
1079 template <
typename stream>
1081 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |"
1082 :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|" );
1083 return o << boost::format{ fmt } % this->nEntries() % this->sum() % this->mean() % this->
standard_deviation() %
1084 this->min() % this->max();
1087 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1095 j = { {
"type", c.typeString },
1096 {
"empty", c.nEntries() == 0 },
1097 {
"nEntries", c.nEntries() },
1099 {
"mean", c.mean() },
1100 {
"sum2", c.sum2() },
1101 {
"standard_deviation", c.standard_deviation() },
1103 {
"max", c.max() } };
1107 j, { { {
"nEntries",
"sum" },
"sum2" },
"min",
"max" } );
1115 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1117 inline static const std::string
typeString{ std::string{
"counter:BinomialCounter:" } +
1118 typeid( Arithmetic ).name() };
1120 template <
typename OWNER>
1124 template <
typename stream>
1126 auto fmt = ( tableFormat ?
"|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%% |"
1127 :
"#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|" );
1132 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1137 template <
typename stream>
1138 stream&
printImpl( stream& o, std::string_view tag )
const {
1140 o << boost::format{
" |*%|-48.48s|%|50t|" } % ( std::string{
"\"" }.append( tag ).append(
"\"" ) );
1141 return print( o,
true );
1144 std::ostream&
print( std::ostream& o, std::string_view tag )
const override {
return printImpl( o, tag ); }
1150 j = { {
"type", c.typeString },
1151 {
"empty", c.nEntries() == 0 },
1152 {
"nEntries", c.nTrueEntries() + c.nFalseEntries() },
1153 {
"nTrueEntries", c.nTrueEntries() },
1154 {
"nFalseEntries", c.nFalseEntries() },
1155 {
"efficiency", c.efficiency() },
1156 {
"efficiencyErr", c.efficiencyErr() } };
1164 template <atomicity Atomicity>
1167 static void merge(
typename Base::InternalType& orig,
bool b ) {
1168 if ( b ) Base::merge( orig, 1 );
1173 template <atomicity Atomicity,
typename Arithmetic =
double>
1177 template <MSG::Level level, atomicity Atomicity = atomicity::full>
1180 inline static const std::string
typeString{
"counter:MsgCounter" };
1181 template <
typename OWNER>
1182 MsgCounter( OWNER* o, std::string
const& ms,
unsigned long nMax = 10 )
1200 template <
typename stream>
1202 return o << boost::format{ tableFormat ?
"|%|10d| |" :
"#=%|-7lu|" } % this->
value();
1205 std::ostream&
print( std::ostream& os,
bool tableFormat )
const override {
return printImpl( os, tableFormat ); }
1211 j = { {
"type", c.typeString }, {
"empty", c.value() == 0 },
1212 {
"nEntries", c.value() }, {
"level", level },
1213 {
"max", c.max }, {
"msg", c.msg } };
1216 return { j.at(
"msg" ).get<std::string>(), j.at(
"max" ).get<
unsigned long>(),
1217 j.at(
"nEntries" ).get<
unsigned long>() };
1221 MsgCounter( std::string
const& ms,
unsigned long nMax,
unsigned long count )
1230 if ( this->
value() == max ) {
1231 logger->msgStream( level ) <<
"Suppressing message: " << std::quoted(
msg,
'\'' ) <<
endmsg;
1244 template <
typename Counter,
typename Container,
typename Fun>
1246 auto b = counter.buffer();
1247 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...
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)