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>
553#pragma GCC diagnostic push
554#pragma GCC diagnostic ignored "-Wfloat-equal"
556 ( Bases<Atomicity, Arithmetic>::operator+=( by ), ... );
559#pragma GCC diagnostic pop
561 OutputType value()
const {
return std::make_tuple( Bases<Atomicity, Arithmetic>::value()... ); }
562 void reset() { ( Bases<Atomicity, Arithmetic>::reset(), ... ); }
563 template <atomicity Ato>
565 ( Bases<Atomicity, Arithmetic>::mergeAndReset(
static_cast<Bases<Ato, Arithmetic>&
>( other ) ), ... );
567 template <atomicity Ato>
569 ( Bases<Atomicity, Arithmetic>::operator+(
static_cast<Bases<Ato, Arithmetic>&&
>( other ) ), ... );
579 std::apply( [
this](
const auto&... i ) { ( this->Bases<Atomicity, Arithmetic>::reset( i ), ... ); }, t );
582 return extractJSONDataHelper( j, entries, std::index_sequence_for<Bases<Atomicity, Arithmetic>...>{} );
586 template <
size_t... Is>
588 std::index_sequence<Is...> ) {
593 typename Bases<Atomicity, Arithmetic>::JSONStringEntriesType... entries ) {
594 return { Bases<Atomicity, Arithmetic>::extractJSONData( j, entries )... };
602 template <atomicity Atomicity,
typename Arithmetic =
double>
604 :
GenericAccumulator<Arithmetic, Arithmetic, Atomicity, Identity, Identity, Maximum<Arithmetic, Atomicity>> {
614 template <atomicity Atomicity,
typename Arithmetic =
double>
616 :
GenericAccumulator<Arithmetic, Arithmetic, Atomicity, Identity, Identity, Minimum<Arithmetic, Atomicity>> {
628 template <atomicity Atomicity,
typename Arithmetic =
double>
632 ( *this ) += Arithmetic{};
647 template <atomicity Atomicity,
typename Arithmetic =
double>
658 template <atomicity Atomicity,
typename Arithmetic =
unsigned long>
660 static_assert( std::is_integral_v<Arithmetic>,
661 "Invalid Arithmetic type for IntegralAccumulator. It must be an integral type" );
681 template <atomicity Atomicity,
typename Arithmetic =
double>
697 template <atomicity Atomicity,
typename Arithmetic>
713 template <atomicity Atomicity,
typename Arithmetic>
724 template <atomicity Atomicity,
typename Arithmetic>
729 template <
typename Result = fp_result_type<Arithmetic>>
732 if ( 1 > nbEntries )
return Result{ -1 };
733 return static_cast<Result
>( this->
nTrueEntries() ) / nbEntries;
737 template <
typename Result = fp_result_type<Arithmetic>>
744 if ( 1 > nbEntries )
return Result{ -1 };
745 return sqrt(
static_cast<Result
>( this->
nTrueEntries() * this->nFalseEntries() ) / nbEntries ) / nbEntries;
754 assert( b.nPass <= b.nTotal );
768 template <atomicity Atomicity,
typename Arithmetic,
template <atomicity,
typename>
typename CountAcc,
769 template <atomicity,
typename>
typename SumAcc>
771 :
AccumulatorSet<Arithmetic, Atomicity, typename CountAcc<Atomicity, Arithmetic>::InputType, CountAcc, SumAcc> {
772 static_assert( std::is_same_v<typename CountAcc<Atomicity, Arithmetic>::InputType,
773 typename SumAcc<Atomicity, Arithmetic>::InputType>,
774 "Incompatible Counters in definition of AveragingAccumulator. Both should have identical Input" );
775 using AccumulatorSet<Arithmetic, Atomicity,
typename CountAcc<Atomicity, Arithmetic>::InputType, CountAcc,
777 template <
typename Result = fp_result_type<Arithmetic>>
779 auto n = this->nEntries();
780 Result sum = this->sum();
781 return ( n > 0 ) ?
static_cast<Result
>( sum / n ) : Result{};
789 template <atomicity Atomicity,
typename Arithmetic>
797 template <atomicity Atomicity,
typename Arithmetic,
template <atomicity,
typename>
typename AvgAcc,
798 template <atomicity,
typename>
typename SquareAcc>
800 :
AccumulatorSet<Arithmetic, Atomicity, typename AvgAcc<Atomicity, Arithmetic>::InputType, AvgAcc, SquareAcc> {
801 static_assert( std::is_same_v<typename AvgAcc<Atomicity, Arithmetic>::InputType,
802 typename SquareAcc<Atomicity, Arithmetic>::InputType>,
803 "Incompatible Counters in definition of SigmaAccumulator. Both should have identical Input" );
804 using AccumulatorSet<Arithmetic, Atomicity,
typename SquareAcc<Atomicity, Arithmetic>::InputType, AvgAcc,
806 template <
typename Result = fp_result_type<Arithmetic>>
808 auto n = this->nEntries();
809 Result sum = this->sum();
810 return ( n > 0 ) ?
static_cast<Result
>( ( this->sum2() - sum * ( sum / n ) ) / n ) : Result{};
813 template <
typename Result = fp_result_type<Arithmetic>>
815 auto n = this->nEntries();
816 Result sum = this->sum();
817 return ( n > 1 ) ?
static_cast<Result
>( ( this->sum2() - sum * ( sum / n ) ) / ( n - 1 ) ) : Result{};
820 template <
typename Result = fp_result_type<Arithmetic>>
827 return ( Result{ 0 } > v ) ? Result{} :
static_cast<Result
>(
sqrt( v ) );
829 [[deprecated(
"The name 'rms' has changed to standard_deviation" )]] Arithmetic
rms()
const {
833 template <
typename Result = fp_result_type<Arithmetic>>
835 auto n = this->nEntries();
836 if ( 0 == n )
return Result{};
842 return ( Result{ 0 } > v ) ? Result{} :
static_cast<Result
>(
sqrt( v / n ) );
850 template <atomicity Atomicity,
typename Arithmetic>
857 template <atomicity Atomicity,
typename Arithmetic>
867 template <
template <
atomicity Ato,
typename... Int>
class ContainedAccumulator,
atomicity Atomicity, typename... Args>
868 class Buffer :
public ContainedAccumulator<atomicity::none, Args...> {
896 template <
typename stream>
897 stream&
printImpl( stream& s, std::string_view tag )
const {
898 s << boost::format{
" | %|-48.48s|%|50t|" } % ( std::string{
'\"' }.append( tag ).append(
"\"" ) );
899 return print( s,
true );
902 virtual std::ostream&
print( std::ostream&,
bool tableFormat =
false )
const = 0;
905 virtual std::ostream&
print( std::ostream& o, std::string_view tag )
const {
return printImpl( o, tag ); }
912 std::ostringstream ost;
929 template <
atomicity Atomicity,
template <
atomicity Ato,
typename... Int>
class Accumulator, typename... Args>
932 using Accumulator<Atomicity, Args...>::Accumulator;
935 template <
typename OWNER>
947 template <
typename OWNER,
typename SELF,
typename... CARGS>
949 : Accumulator<Atomicity, Args...>( args... ),
m_monitoringHub( &o->serviceLocator()->monitoringHub() ) {
950 m_monitoringHub->registerEntity( o->name(), name, self.typeString, self );
961 template <atomicity Atomicity = atomicity::full,
typename Arithmetic =
unsigned long>
963 inline static const std::string
typeString{ std::string{
"counter:Counter:" } +
typeid( Arithmetic ).name() };
965 template <
typename OWNER>
975 template <
typename stream>
976 stream&
printImpl( stream& o,
bool tableFormat )
const {
978 auto fmt = ( tableFormat ?
"|%|10d| |" :
"#=%|-7lu|" );
979 return o << boost::format{ fmt } % this->
nEntries();
982 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
990 j = { {
"type", c.typeString }, {
"empty", c.nEntries() == 0 }, {
"nEntries", c.nEntries() } };
1001 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1003 inline static const std::string
typeString{ std::string{
"counter:AveragingCounter:" } +
1004 typeid( Arithmetic ).name() };
1006 template <
typename OWNER>
1011 template <
typename stream>
1013 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |" :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g|" );
1014 return o << boost::format{ fmt } % this->nEntries() % this->sum() % this->
mean();
1017 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1026 j = { {
"type", c.typeString },
1027 {
"empty", c.nEntries() == 0 },
1028 {
"nEntries", c.nEntries() },
1030 {
"mean", c.mean() } };
1036 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1043 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1045 inline static const std::string
typeString{ std::string{
"counter:SigmaCounter:" } +
typeid( Arithmetic ).name() };
1047 template <
typename OWNER>
1052 template <
typename stream>
1054 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |"
1055 :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g|" );
1056 return o << boost::format{ fmt } % this->nEntries() % this->sum() % this->mean() % this->
standard_deviation();
1059 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1067 j = { {
"type", c.typeString },
1068 {
"empty", c.nEntries() == 0 },
1069 {
"nEntries", c.nEntries() },
1071 {
"mean", c.mean() },
1072 {
"sum2", c.sum2() },
1073 {
"standard_deviation", c.standard_deviation() } };
1084 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1086 inline static const std::string
typeString{ std::string{
"counter:StatCounter:" } +
typeid( Arithmetic ).name() };
1088 template <
typename OWNER>
1093 template <
typename stream>
1095 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |"
1096 :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|" );
1097 return o << boost::format{ fmt } % this->nEntries() % this->sum() % this->mean() % this->
standard_deviation() %
1098 this->min() % this->max();
1101 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1109 j = { {
"type", c.typeString },
1110 {
"empty", c.nEntries() == 0 },
1111 {
"nEntries", c.nEntries() },
1113 {
"mean", c.mean() },
1114 {
"sum2", c.sum2() },
1115 {
"standard_deviation", c.standard_deviation() },
1117 {
"max", c.max() } };
1121 j, { { {
"nEntries",
"sum" },
"sum2" },
"min",
"max" } );
1129 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1131 inline static const std::string
typeString{ std::string{
"counter:BinomialCounter:" } +
1132 typeid( Arithmetic ).name() };
1134 template <
typename OWNER>
1138 template <
typename stream>
1140 auto fmt = ( tableFormat ?
"|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%% |"
1141 :
"#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|" );
1146 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1151 template <
typename stream>
1152 stream&
printImpl( stream& o, std::string_view tag )
const {
1154 o << boost::format{
" |*%|-48.48s|%|50t|" } % ( std::string{
"\"" }.append( tag ).append(
"\"" ) );
1155 return print( o,
true );
1158 std::ostream&
print( std::ostream& o, std::string_view tag )
const override {
return printImpl( o, tag ); }
1164 j = { {
"type", c.typeString },
1165 {
"empty", c.nEntries() == 0 },
1166 {
"nEntries", c.nTrueEntries() + c.nFalseEntries() },
1167 {
"nTrueEntries", c.nTrueEntries() },
1168 {
"nFalseEntries", c.nFalseEntries() },
1169 {
"efficiency", c.efficiency() },
1170 {
"efficiencyErr", c.efficiencyErr() } };
1178 template <atomicity Atomicity>
1181 static void merge(
typename Base::InternalType& orig,
bool b ) {
1182 if ( b ) Base::merge( orig, 1 );
1187 template <atomicity Atomicity,
typename Arithmetic =
double>
1191 template <MSG::Level level, atomicity Atomicity = atomicity::full>
1194 inline static const std::string
typeString{
"counter:MsgCounter" };
1195 template <
typename OWNER>
1196 MsgCounter( OWNER* o, std::string
const& ms,
unsigned long nMax = 10 )
1214 template <
typename stream>
1216 return o << boost::format{ tableFormat ?
"|%|10d| |" :
"#=%|-7lu|" } % this->
value();
1219 std::ostream&
print( std::ostream& os,
bool tableFormat )
const override {
return printImpl( os, tableFormat ); }
1225 j = { {
"type", c.typeString }, {
"empty", c.value() == 0 },
1226 {
"nEntries", c.value() }, {
"level", level },
1227 {
"max", c.max }, {
"msg", c.msg } };
1230 return { j.at(
"msg" ).get<std::string>(), j.at(
"max" ).get<
unsigned long>(),
1231 j.at(
"nEntries" ).get<
unsigned long>() };
1235 MsgCounter( std::string
const& ms,
unsigned long nMax,
unsigned long count )
1244 if ( this->
value() == max ) {
1245 logger->msgStream( level ) <<
"Suppressing message: " << std::quoted(
msg,
'\'' ) <<
endmsg;
1258 template <
typename Counter,
typename Container,
typename Fun>
1260 auto b = counter.buffer();
1261 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
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
AccumulatorSet< Arithmetic, Atomicity, Arithmetic, SigmaAccumulator, MinAccumulator, MaxAccumulator > StatAccumulator
StatAccumulator.
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.
static constexpr OutputType DefaultValue()
static void merge(InternalType &a, Arithmetic b) noexcept
static constexpr OutputType DefaultValue()
static void merge(InternalType &a, Arithmetic b) noexcept
An Adder ValueHandler operator(a, b) means a += b.
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)
static constexpr OutputType getValue(const InternalType &v) noexcept
std::atomic< Arithmetic > InternalType
static Arithmetic exchange(InternalType &v, Arithmetic newv) noexcept
static Arithmetic exchange(InternalType &v, Arithmetic newv) noexcept
static constexpr OutputType getValue(const InternalType &v) noexcept
Base type for all functors used as ValuesHandler.
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
static void merge(InternalType &a, Arithmetic b) noexcept
static constexpr OutputType DefaultValue()
static void merge(InternalType &a, Arithmetic b) noexcept
static constexpr OutputType DefaultValue()
An Extremum ValueHandler, to be reused for Minimum and Maximum operator(a, b) means if (Compare(b,...
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)