Go to the documentation of this file.
13 #include <boost/algorithm/string/predicate.hpp>
14 #include <boost/format.hpp>
22 Gaudi::Accumulators::StatAccumulator,
23 Gaudi::Accumulators::BinomialAccumulator> {
35 const double maxFlag ) {
69 std::make_tuple( se.nEntries(), se.sum(), se.min(), se.max(), se.sum2() );
73 this->AccumulatorSet::operator+=( by );
80 unsigned long add(
const double v ) {
86 double Sum()
const {
return sum(); }
87 double Mean()
const {
return mean(); }
88 double MeanErr()
const {
return meanErr(); }
89 double rms()
const {
return standard_deviation(); }
90 double Rms()
const {
return standard_deviation(); }
91 double RMS()
const {
return standard_deviation(); }
92 double Eff()
const {
return eff(); }
93 double Min()
const {
return min(); }
94 double Max()
const {
return max(); }
96 double flag()
const {
return sum(); }
97 double flag2()
const {
return sum2(); }
99 double flagRMS()
const {
return standard_deviation(); }
104 using boost::algorithm::icontains;
105 return icontains(
name,
"eff" ) || icontains(
name,
"acc" ) || icontains(
name,
"filt" ) ||
106 icontains(
name,
"fltr" ) || icontains(
name,
"pass" );
108 template <
typename stream>
111 fmt % nEntries() % sum() % mean() % standard_deviation() % min() % max();
112 return o <<
fmt.str();
119 template <
typename stream>
121 if (
flag &&
effCounter(
name ) && 0 <= eff() && 0 <= effErr() && sum() <= nEntries() &&
126 if (
name.empty() ) {
127 constexpr
auto fmt =
"|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
129 ( efficiencyErr() * 100 );
132 "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |" );
137 constexpr
auto fmt =
"#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|";
139 ( efficiencyErr() * 100 );
144 if (
name.empty() ) {
145 constexpr
auto fmt =
"|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
146 return o <<
boost::format{
fmt } % nEntries() % sum() % mean() % standard_deviation() % min() % max();
150 "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" );
152 mean() % standard_deviation() % min() % max();
155 constexpr
auto fmt =
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|";
156 return o <<
boost::format{
fmt } % nEntries() % sum() % mean() % standard_deviation() % min() % max();
161 std::string_view fmtHead =
"%|-48.48s|%|27t|" )
const {
165 std::string_view fmtHead =
"%|-48.48s|%|27t|" )
const {
169 return print( o,
true, tag,
true );
174 return print( o, tableFormat, emptyName,
true );
178 return print( o, tableFormat, emptyName,
true );
192 j, { { { {
"nEntries",
"sum" },
"sum2" },
"min",
"max" }, {
"nTrueEntries",
"nFalseEntries" } } ) );
An empty ancester of all counters that knows how to print themselves.
static InternalType extractJSONData(const nlohmann::json &j, const JSONStringEntriesType &entries)
StatEntity & operator+=(double by)
void operator=(double by)
void mergeAndReset(AccumulatorSet< double, Ato, InputType, Gaudi::Accumulators::StatAccumulator ... > &other)
AccumulatorSet is an Accumulator that holds a set of Accumulators templated by same Arithmetic and At...
stream & printFormattedImpl(stream &o, const std::string &format) const
StatEntity(const unsigned long entries, const double flag, const double flag2, const double minFlag, const double maxFlag)
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
StatEntity & operator+=(StatEntity by)
stream & printImpl(stream &o, bool tableFormat, std::string_view name, bool flag, std::string_view fmtHead) const
backward compatible StatEntity class.
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
StatEntity operator--(int)
StatEntity & operator-=(double by)
MsgStream & printFormatted(MsgStream &o, const std::string &format) const
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
static StatEntity fromJSON(const nlohmann::json &j)
StatEntity & operator--()
static constexpr bool essentiallyEqual(double const a, double const b)
double flagMeanErr() const
MsgStream & print(MsgStream &o, bool tableFormat, std::string_view name, bool flag=true, std::string_view fmtHead="%|-48.48s|%|27t|") const
std::ostream & print(std::ostream &o, bool tableFormat, std::string_view name, bool flag=true, std::string_view fmtHead="%|-48.48s|%|27t|") const
std::ostream & printFormatted(std::ostream &o, const std::string &format) const
friend void to_json(nlohmann::json &j, StatEntity const &s)
Basic JSON export for Gaudi::Monitoring::Hub support.
AccumulatorSet< Arithmetic, Atomicity, Arithmetic, SigmaAccumulator, MinAccumulator, MaxAccumulator > StatAccumulator
StatAccumulator.
virtual 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
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
static const std::string typeString
std::string toString() const
unsigned long addFlag(const double v)
std::ostream & fillStream(std::ostream &o) const
unsigned long add(const double v)
virtual MsgStream & print(MsgStream &o, std::string_view tag) const override
bool operator<(const StatEntity &se) const
friend void reset(StatEntity &s)
StatEntity & operator++()
static bool effCounter(std::string_view name)
unsigned long nEntries() const
virtual std::ostream & print(std::ostream &, bool tableFormat=false) const =0
prints the counter to a stream
StatEntity()=default
the constructor with automatic registration in the owner's counter map
MsgStream & fillStream(MsgStream &o) const
StatEntity operator++(int)