Go to the documentation of this file.
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__ )
27 namespace 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(); }
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> ) {
377 if ( DefaultValue() == b )
return;
387 template <
typename Arithmetic, atomicity Atomicity,
typename Compare, Arithmetic ( *Initial )()>
393 template <
typename Arithmetic,
typename Compare, Arithmetic ( *Initial )()>
399 if ( Compare{}( b, a ) ) a = b;
406 template <
typename Arithmetic,
typename Compare, Arithmetic ( *Initial )()>
413 while ( Compare{}( b, prev_value ) && !a.compare_exchange_weak( prev_value, b ) )
422 template <
typename Arithmetic, atomicity Atomicity = atomicity::full>
429 template <
typename Arithmetic, atomicity Atomicity = atomicity::full>
460 typename InputTransform = Identity,
typename OutputTransform = Identity,
461 typename ValueHandler = Adder<InnerType, Atomicity>>
463 template <
typename,
typename, atomicity,
typename,
typename,
typename>
468 using OutputType = std::decay_t<std::invoke_result_t<OutputTransform, InnerType>>;
477 template <atomicity ato,
typename VH>
481 template <
typename... Args>
490 template <atomicity ato,
typename VH>
494 template <atomicity ato,
typename VH>
504 return j.at( entries ).get<InnerType>();
508 typename ValueHandler::InternalType
m_value{ ValueHandler::DefaultValue() };
516 template <
typename Arithmetic,
atomicity Atomicity,
typename InputTypeT = Arithmetic,
517 template <atomicity,
typename>
class... Bases>
521 using OutputType = std::tuple<typename Bases<Atomicity, Arithmetic>::OutputType...>;
522 using InternalType = std::tuple<typename Bases<Atomicity, Arithmetic>::InternalType...>;
526 template <atomicity ato>
530 ( Bases<Atomicity, Arithmetic>::operator+=( by ), ... );
533 OutputType value()
const {
return std::make_tuple( Bases<Atomicity, Arithmetic>::value()... ); }
534 void reset() { ( Bases<Atomicity, Arithmetic>::reset(), ... ); }
535 template <atomicity Ato>
537 ( Bases<Atomicity, Arithmetic>::mergeAndReset(
static_cast<Bases<Ato, Arithmetic>&
>( other ) ), ... );
539 template <atomicity Ato>
547 std::apply( [
this](
const auto&... i ) { ( this->Bases<Atomicity, Arithmetic>::reset( i ), ... ); },
t );
554 template <
size_t... Is>
556 std::index_sequence<Is...> ) {
561 typename Bases<Atomicity, Arithmetic>::JSONStringEntriesType... entries ) {
562 return { Bases<Atomicity, Arithmetic>::extractJSONData(
j, entries )... };
570 template <atomicity Atomicity,
typename Arithmetic =
double>
572 :
GenericAccumulator<Arithmetic, Arithmetic, Atomicity, Identity, Identity, Maximum<Arithmetic, Atomicity>> {
582 template <atomicity Atomicity,
typename Arithmetic =
double>
584 :
GenericAccumulator<Arithmetic, Arithmetic, Atomicity, Identity, Identity, Minimum<Arithmetic, Atomicity>> {
596 template <atomicity Atomicity,
typename Arithmetic =
double>
600 ( *this ) += Arithmetic{};
615 template <atomicity Atomicity,
typename Arithmetic =
double>
626 template <atomicity Atomicity,
typename Arithmetic =
unsigned long>
628 static_assert( std::is_integral_v<Arithmetic>,
629 "Invalid Arithmetic type for IntegralAccumulator. It must be an integral type" );
649 template <atomicity Atomicity,
typename Arithmetic =
double>
665 template <atomicity Atomicity,
typename Arithmetic>
681 template <atomicity Atomicity,
typename Arithmetic>
692 template <atomicity Atomicity,
typename Arithmetic>
697 template <
typename Result = fp_result_type<Arithmetic>>
700 if ( 1 > nbEntries )
return Result{ -1 };
701 return static_cast<Result
>( this->
nTrueEntries() ) / nbEntries;
705 template <
typename Result = fp_result_type<Arithmetic>>
712 if ( 1 > nbEntries )
return Result{ -1 };
713 return sqrt(
static_cast<Result
>( this->
nTrueEntries() * this->nFalseEntries() ) / nbEntries ) / nbEntries;
722 assert( b.nPass <= b.nTotal );
736 template <atomicity Atomicity,
typename Arithmetic,
template <atomicity,
typename>
typename CountAcc,
737 template <atomicity,
typename>
typename SumAcc>
739 :
AccumulatorSet<Arithmetic, Atomicity, typename CountAcc<Atomicity, Arithmetic>::InputType, CountAcc, SumAcc> {
740 static_assert( std::is_same_v<
typename CountAcc<Atomicity, Arithmetic>::InputType,
741 typename SumAcc<Atomicity, Arithmetic>::InputType>,
742 "Incompatible Counters in definition of AveragingAccumulator. Both should have identical Input" );
745 template <
typename Result = fp_result_type<Arithmetic>>
747 auto n = this->nEntries();
748 Result sum = this->sum();
749 return (
n > 0 ) ?
static_cast<Result
>( sum /
n ) : Result{};
757 template <atomicity Atomicity,
typename Arithmetic>
765 template <atomicity Atomicity,
typename Arithmetic,
template <atomicity,
typename>
typename AvgAcc,
766 template <atomicity,
typename>
typename SquareAcc>
768 :
AccumulatorSet<Arithmetic, Atomicity, typename AvgAcc<Atomicity, Arithmetic>::InputType, AvgAcc, SquareAcc> {
769 static_assert( std::is_same_v<
typename AvgAcc<Atomicity, Arithmetic>::InputType,
770 typename SquareAcc<Atomicity, Arithmetic>::InputType>,
771 "Incompatible Counters in definition of SigmaAccumulator. Both should have identical Input" );
774 template <
typename Result = fp_result_type<Arithmetic>>
776 auto n = this->nEntries();
777 Result sum = this->sum();
778 return (
n > 0 ) ?
static_cast<Result
>( ( this->sum2() - sum * ( sum /
n ) ) /
n ) : Result{};
781 template <
typename Result = fp_result_type<Arithmetic>>
783 auto n = this->nEntries();
784 Result sum = this->sum();
785 return (
n > 1 ) ?
static_cast<Result
>( ( this->sum2() - sum * ( sum /
n ) ) / (
n - 1 ) ) : Result{};
788 template <
typename Result = fp_result_type<Arithmetic>>
795 return ( Result{ 0 } >
v ) ? Result{} :
static_cast<Result
>(
sqrt(
v ) );
797 [[deprecated(
"The name 'rms' has changed to standard_deviation" )]] Arithmetic
rms()
const {
801 template <
typename Result = fp_result_type<Arithmetic>>
803 auto n = this->nEntries();
804 if ( 0 ==
n )
return Result{};
810 return ( Result{ 0 } >
v ) ? Result{} :
static_cast<Result
>(
sqrt(
v /
n ) );
818 template <atomicity Atomicity,
typename Arithmetic>
825 template <atomicity Atomicity,
typename Arithmetic>
835 template <
template <
atomicity Ato,
typename...
Int>
class ContainedAccumulator,
atomicity Atomicity, typename... Args>
836 class Buffer :
public ContainedAccumulator<atomicity::none, Args...> {
847 if ( m_prime ) { m_prime->mergeAndReset(
static_cast<base_type&
>( *
this ) ); }
864 template <
typename stream>
866 s <<
boost::format{
" | %|-48.48s|%|50t|" } % ( std::string{
'\"' }.append( tag ).append(
"\"" ) );
870 virtual std::ostream&
print( std::ostream&,
bool tableFormat =
false )
const = 0;
873 virtual std::ostream&
print( std::ostream& o, std::string_view tag )
const {
return printImpl( o, tag ); }
880 std::ostringstream ost;
897 template <
atomicity Atomicity,
template <
atomicity Ato,
typename...
Int>
class Accumulator, typename... Args>
900 using Accumulator<Atomicity, Args...>::Accumulator;
903 template <
typename OWNER>
909 if ( m_monitoringHub ) { m_monitoringHub->removeEntity( *
this ); }
912 inline static const std::string typeString{
"counter" };
915 template <
typename OWNER,
typename SELF,
typename... CARGS>
917 : Accumulator<Atomicity, Args...>(
args... ), m_monitoringHub( &o->serviceLocator()->monitoringHub() ) {
918 m_monitoringHub->registerEntity( o->name(),
name,
self.typeString,
self );
929 template <atomicity Atomicity = atomicity::full,
typename Arithmetic =
unsigned long>
931 inline static const std::string
typeString{ std::string{
"counter:Counter:" } +
typeid( Arithmetic ).
name() };
933 template <
typename OWNER>
943 template <
typename stream>
946 auto fmt = ( tableFormat ?
"|%|10d| |" :
"#=%|-7lu|" );
950 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
958 j = { {
"type",
c.typeString }, {
"empty",
c.nEntries() == 0 }, {
"nEntries",
c.nEntries() } };
969 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
971 inline static const std::string
typeString{ std::string{
"counter:AveragingCounter:" } +
972 typeid( Arithmetic ).
name() };
974 template <
typename OWNER>
979 template <
typename stream>
981 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |" :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g|" );
985 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
990 bool toBePrinted()
const override {
return this->nEntries() > 0; }
994 j = { {
"type",
c.typeString },
995 {
"empty",
c.nEntries() == 0 },
996 {
"nEntries",
c.nEntries() },
998 {
"mean",
c.mean() } };
1004 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1011 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1013 inline static const std::string
typeString{ std::string{
"counter:SigmaCounter:" } +
typeid( Arithmetic ).
name() };
1015 template <
typename OWNER>
1020 template <
typename stream>
1022 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |"
1023 :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g|" );
1027 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1035 j = { {
"type",
c.typeString },
1036 {
"empty",
c.nEntries() == 0 },
1037 {
"nEntries",
c.nEntries() },
1039 {
"mean",
c.mean() },
1040 {
"sum2",
c.sum2() },
1041 {
"standard_deviation",
c.standard_deviation() } };
1052 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1054 inline static const std::string
typeString{ std::string{
"counter:StatCounter:" } +
typeid( Arithmetic ).
name() };
1056 template <
typename OWNER>
1061 template <
typename stream>
1063 auto fmt = ( tableFormat ?
"|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |"
1064 :
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|" );
1065 return o <<
boost::format{
fmt } % this->nEntries() % this->sum() % this->mean() % this->standard_deviation() %
1066 this->min() % this->max();
1069 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1077 j = { {
"type",
c.typeString },
1078 {
"empty",
c.nEntries() == 0 },
1079 {
"nEntries",
c.nEntries() },
1081 {
"mean",
c.mean() },
1082 {
"sum2",
c.sum2() },
1083 {
"standard_deviation",
c.standard_deviation() },
1085 {
"max",
c.max() } };
1089 j, { { {
"nEntries",
"sum" },
"sum2" },
"min",
"max" } );
1097 template <
typename Arithmetic =
double, atomicity Atomicity = atomicity::full>
1099 inline static const std::string
typeString{ std::string{
"counter:BinomialCounter:" } +
1100 typeid( Arithmetic ).
name() };
1102 template <
typename OWNER>
1106 template <
typename stream>
1108 auto fmt = ( tableFormat ?
"|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%% |"
1109 :
"#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|" );
1114 std::ostream&
print( std::ostream& o,
bool tableFormat =
false )
const override {
1119 template <
typename stream>
1122 o <<
boost::format{
" |*%|-48.48s|%|50t|" } % ( std::string{
"\"" }.append( tag ).append(
"\"" ) );
1123 return print( o,
true );
1126 std::ostream&
print( std::ostream& o, std::string_view tag )
const override {
return printImpl( o, tag ); }
1132 j = { {
"type",
c.typeString },
1133 {
"empty",
c.nEntries() == 0 },
1134 {
"nEntries",
c.nTrueEntries() +
c.nFalseEntries() },
1135 {
"nTrueEntries",
c.nTrueEntries() },
1136 {
"nFalseEntries",
c.nFalseEntries() },
1137 {
"efficiency",
c.efficiency() },
1138 {
"efficiencyErr",
c.efficiencyErr() } };
1145 namespace details::MsgCounter {
1146 template <atomicity Atomicity>
1149 static void merge(
typename Base::InternalType& orig,
bool b ) {
1155 template <atomicity Atomicity,
typename Arithmetic =
double>
1159 template <MSG::Level level, atomicity Atomicity = atomicity::full>
1162 inline static const std::string
typeString{
"counter:MsgCounter" };
1163 template <
typename OWNER>
1168 template <
typename OWNER>
1184 template <
typename stream>
1186 return o <<
boost::format{ tableFormat ?
"|%|10d| |" :
"#=%|-7lu|" } % this->
value();
1189 std::ostream&
print( std::ostream& os,
bool tableFormat )
const override {
return printImpl( os, tableFormat ); }
1195 j = { {
"type",
c.typeString }, {
"empty",
c.value() == 0 },
1196 {
"nEntries",
c.value() }, {
"level",
level },
1197 {
"max",
c.max }, {
"msg",
c.msg } };
1200 return {
j.at(
"msg" ).get<std::string>(),
j.at(
"max" ).get<
unsigned long>(),
1201 j.at(
"nEntries" ).get<
unsigned long>() };
1205 MsgCounter( std::string
const&
ms,
unsigned long nMax,
unsigned long count )
1214 if ( this->
value() == max ) {
1228 template <
typename Counter,
typename Container,
typename Fun>
1231 for (
const auto& elem : container ) b += f( elem );
MsgCounter(std::string const &ms, unsigned long nMax, unsigned long count)
An empty ancester of all counters that knows how to print themselves.
stream & printImpl(stream &s, std::string_view tag) const
auto sqrt(std::chrono::duration< Rep, Period > d)
sqrt for std::chrono::duration
unsigned long InternalType
static const std::string typeString
static InternalType extractJSONData(const nlohmann::json &j, const JSONStringEntriesType &entries)
std::tuple< typename CountAcc< Atomicity, Arithmetic >::OutputType... > OutputType
const CommonMessagingBase * logger
friend void mergeAndReset(MsgCounter &c, MsgCounter &o)
stream & printImpl(stream &o, bool tableFormat) const
CountAccumulator & operator++()
ContainedAccumulator< Atomicity, Args... > prime_type
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
Base type for all functors used as ValuesHandler.
BufferableCounter(BufferableCounter const &)=delete
AccumulatorSet & operator+=(const InputType by)
friend void reset(SigmaCounter &c)
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.
ValueHandler::InternalType m_value
MsgCounter(MsgCounter const &)=delete
Monitoring::Hub * m_monitoringHub
A counter aiming at computing average and sum2 / variance / standard deviation.
static constexpr OutputType DefaultValue()
void mergeAndReset(AccumulatorSet< Arithmetic, Ato, InputType, Bases... > &other)
static constexpr OutputType getValue(const InternalType &v) noexcept
virtual bool toBePrinted() const
hint whether we should print that counter or not.
BufferableCounter & operator=(BufferableCounter const &)=delete
GenericAccumulator(InnerType in)
friend void mergeAndReset(StatCounter &c, StatCounter &o)
AccumulatorSet is an Accumulator that holds a set of Accumulators templated by same Arithmetic and At...
A basic integral counter;.
MsgCounter(OWNER *o, std::string const &ms, unsigned long nMax=10)
AveragingCounter(OWNER *o, std::string const &name)
std::string JSONStringEntriesType
static Arithmetic exchange(InternalType &v, Arithmetic newv) noexcept
static StatCounter fromJSON(const nlohmann::json &j)
MsgStream & print(MsgStream &os, bool tableFormat) const override
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
virtual ~PrintableCounter()=default
destructor
static constexpr OutputType getValue(const InternalType &v) noexcept
std::string toString() const
get a string representation
BufferableCounter()=default
friend void to_json(nlohmann::json &j, BinomialCounter const &c)
bool toBePrinted() const override
hint whether we should print that counter or not.
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
static void merge(InternalType &a, Arithmetic b) noexcept
GenericAccumulator(std::in_place_t, Args &&... args)
friend void reset(MsgCounter &c)
static Counter fromJSON(const nlohmann::json &j)
virtual MsgStream & print(MsgStream &, bool tableFormat=true) const =0
MsgCounter & operator++()
A counter aiming at computing sum and average.
PrintableCounter()=default
Buffer(const Buffer &)=delete
friend void mergeAndReset(Counter &c, Counter &o)
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
AccumulatorSet(construct_empty_t, const AccumulatorSet< Arithmetic, ato, InputType, Bases... > &)
constructor of an empty AccumulatorSet, copying the (non existent) config from another GenericAccumul...
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
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
BinomialAccumulator & operator+=(binomial_t b)
BinomialCounter(OWNER *o, std::string const &name)
void operator+(AccumulatorSet< Arithmetic, Ato, InputType, Bases... > &&other)
MsgCounter & operator=(MsgCounter const &)=delete
stream & printImpl(stream &o, bool tableFormat) const
helper functor for the TrueAccumulator
MsgCounter(OWNER *o, std::string const &ms, int nMax)
AveragingAccumulatorBase.
static Arithmetic exchange(InternalType &v, Arithmetic newv) noexcept
ContainedAccumulator< atomicity::none, Args... > base_type
SigmaCounter(OWNER *o, std::string const &name)
Counter & operator+=(const Arithmetic v)
BufferableCounter(OWNER *o, std::string const &name)
static InternalType extractJSONDataHelper(const nlohmann::json &j, typename Bases< Atomicity, Arithmetic >::JSONStringEntriesType... entries)
MsgCounter & operator+=(const bool by)
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
GenericAccumulator operator+=(const InputType by)
StatCounter(OWNER *o, std::string const &name)
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
MsgStream & operator<<(MsgStream &s, const PrintableCounter &counter)
Arithmetic nEntries() const
An Extremum ValueHandler, to be reused for Minimum and Maximum operator(a, b) means if (Compare(b,...
IntegralAccumulator & operator++()
stream & printImpl(stream &o, bool tableFormat) const
An Adder ValueHandler operator(a, b) means a += b.
CountAccumulator operator++(int)
auto unbiased_sample_variance() const
auto efficiencyErr() const
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
static void from_json(const json &j, std::chrono::duration< Rep, Period > &d)
friend void reset(Counter &c)
static constexpr OutputType DefaultValue()
stream & printImpl(stream &o, std::string_view tag) const
std::tuple< typename CountAcc< Atomicity, Arithmetic >::InternalType... > InternalType
static constexpr OutputType DefaultValue()
friend void reset(StatCounter &c)
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...
friend class GenericAccumulator
std::decay_t< std::invoke_result_t< Identity, unsigned long > > OutputType
static const std::string typeString
GenericAccumulator & operator=(const GenericAccumulator &other)
GenericAccumulator< bool, unsigned long, Atomicity, Identity, Identity, Handler< Atomicity > > MsgAccumulator
A counter dealing with binomial data.
static void merge(typename Base::InternalType &orig, bool b)
void registerEntity(std::string c, std::string n, std::string t, T &ent)
static void merge(InternalType &a, Arithmetic b) noexcept
static InternalType extractJSONDataHelper(const nlohmann::json &j, const JSONStringEntriesType &entries, std::index_sequence< Is... >)
void operator=(const Buffer &)=delete
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
void mergeAndReset(GenericAccumulator< InputType, InnerType, ato, InputTransform, OutputTransform, VH > &other)
std::ostream & print(std::ostream &os, bool tableFormat) const override
prints the counter to a stream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
void removeEntity(T &ent)
CountAcc< Atomicity, Arithmetic >::InputType InputType
unsigned long nFalseEntries() const
std::atomic< Arithmetic > InternalType
constexpr AccumulatorSet()=default
Generic Accumulator, templated by.
BufferableCounter(OWNER *o, std::string const &name, SELF &self, CARGS... args)
A functor always returning the value N.
friend void mergeAndReset(BinomialCounter &c, BinomialCounter &o)
static void to_json(json &j, const std::chrono::duration< Rep, Period > &d)
MsgStream & msgStream() const
Return an uninitialized MsgStream.
bool toBePrinted() const override
hint whether we should print that counter or not.
An empty ancester of all counters that provides a buffer method that returns a buffer on itself Also ...
static const std::string typeString
friend void to_json(nlohmann::json &j, SigmaCounter const &c)
auto sqrt(T d)
forward declaration of sqrt for custom types
GenericAccumulator()=default
int merge(const char *target, const char *source, bool fixup=false, bool dbg=true)
stream & printImpl(stream &o, bool tableFormat) const
static const std::string typeString
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(const InternalType &t)
friend void to_json(nlohmann::json &j, AveragingCounter const &c)
virtual MsgStream & print(MsgStream &o, std::string_view tag) const
static InnerType extractJSONData(const nlohmann::json &j, const JSONStringEntriesType &entries)
bool toBePrinted() const override
hint whether we should print that counter or not.
auto standard_deviation() const
construct_empty_t()=default
constexpr construct_empty_t construct_empty
helper functor for the FalseAccumulator
static BinomialCounter fromJSON(const nlohmann::json &j)
void reset(const InternalType &t)
Buffer is a non atomic Accumulator which, when it goes out-of-scope, updates the underlying thread-sa...
unsigned long nEntries() const
void operator+(GenericAccumulator< InputType, InnerType, ato, InputTransform, OutputTransform, VH > &&other)
stream & printImpl(stream &o, bool tableFormat) const
bool toBePrinted() const override
hint whether we should print that counter or not.
atomicity
Defines atomicity of the accumulators.
void fetch_add(AtomicType &atVar, Arithmetic value)
generic fetch_add, also dealing with atomic types with no fetch_add member method
static void merge(InternalType &a, Arithmetic b) noexcept
GenericAccumulator(const GenericAccumulator &other)
static constexpr OutputType DefaultValue()
A counter aiming at computing average and sum2 / variance / standard deviation.
constant used to disambiguate construction of an empty Accumulator versus the copy constructor.
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
unsigned long nEntries() const
stream & printImpl(stream &o, bool tableFormat) const
static SigmaCounter fromJSON(const nlohmann::json &j)
auto biased_sample_variance() const
unsigned long nTrueEntries() const
friend void reset(BinomialCounter &c)
virtual std::ostream & print(std::ostream &, bool tableFormat=false) const =0
prints the counter to a stream
Central entity in a Gaudi application that manages monitoring objects (i.e.
unsigned int operator()(bool v) const
Counter(OWNER *o, std::string const &name)
IntegralAccumulator operator++(int)
static void merge(InternalType &a, Arithmetic b) noexcept
unsigned int operator()(bool v) const
static const std::string typeString
MsgStream & print(MsgStream &o, std::string_view tag) const override
friend void mergeAndReset(AveragingCounter &c, AveragingCounter &o)
bool toBePrinted() const override
hint whether we should print that counter or not.
friend void to_json(nlohmann::json &j, StatCounter const &c)
static MsgCounter fromJSON(const nlohmann::json &j)
static AveragingCounter fromJSON(const nlohmann::json &j)
bool toBePrinted() const override
hint whether we should print that counter or not.
constexpr T operator()(U &&) const noexcept
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...
decltype(auto) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
std::tuple< typename CountAcc< Atomicity, Arithmetic >::JSONStringEntriesType... > JSONStringEntriesType
static const std::string typeString
friend void to_json(nlohmann::json &j, Counter const &c)
std::ostream & operator<<(std::ostream &s, const PrintableCounter &counter)
external printout operator to a stream type
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
friend void to_json(nlohmann::json &j, MsgCounter const &c)
friend void mergeAndReset(SigmaCounter &c, SigmaCounter &o)
friend void reset(AveragingCounter &c)
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream