2 #define GAUDIKERNEL_STATENTITY_CPP 1 20 #include "boost/algorithm/string/case_conv.hpp" 21 #include "boost/format.hpp" 27 #pragma warning( disable : 1572 ) 31 #pragma warning( disable : 2259 ) 43 const double maxFlag )
44 : m_se{entries,
flag,
flag2, minFlag, maxFlag}
65 static_assert( ( (
sizeof(
unsigned long ) == 4 ) || (
sizeof(
unsigned long ) == 8 ) ),
"check for X or L" );
67 static_assert( (
sizeof(
double ) == 8 ),
"check for D" );
69 static const std::string s_fmt = ( ( 8 ==
sizeof(
unsigned long ) ) ?
"X:1;" :
"L:1;" ) +
std::string(
"D:4" );
77 static const int s_size =
sizeof(
unsigned long ) + 4 *
sizeof(
double );
85 if ( 0 < nEntriesBeforeReset ) {
86 --nEntriesBeforeReset;
87 }
else if ( 0 == nEntriesBeforeReset ) {
90 accumulatedFlag += Flag;
93 minimalFlag =
std::min( minimalFlag, Flag );
94 maximalFlag =
std::max( maximalFlag, Flag );
97 if ( s_min1 < Flag || -s_min1 > Flag ) {
98 accumulatedFlag2 += Flag * Flag;
108 const long double f1 = accumulatedFlag;
120 const long double f1 = accumulatedFlag;
121 const long double f2 = f1 /
nEntries;
122 const long double f3 = accumulatedFlag2;
123 const long double f4 = f3 /
nEntries;
124 const long double result = f4 - f2 * f2;
125 return ( 0 > result ) ? 0 : ::sqrtl( result );
135 const long double f1 = accumulatedFlag;
136 const long double f2 = f1 /
nEntries;
137 const long double f3 = accumulatedFlag2;
138 const long double f4 = f3 /
nEntries;
139 const long double result = f4 - f2 * f2;
144 return ::sqrtl( result /
nEntries );
154 const long double fMin = minimalFlag;
155 if ( 0 != fMin && 1 != fMin ) {
158 const long double fMax = maximalFlag;
159 if ( 0 != fMax && 1 != fMax ) {
173 long double n1 = accumulatedFlag;
179 long double n2 = n3 - accumulatedFlag;
181 if ( 1 > fabsl( n2 ) ) {
185 return ::sqrtl( n1 * n2 / n3 ) / n3;
236 boost::format fmt2(
" Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|" );
289 const std::string lower = boost::algorithm::to_lower_copy( name );
290 return std::string::npos != lower.
find(
"eff" ) || std::string::npos != lower.
find(
"acc" ) ||
291 std::string::npos != lower.
find(
"filt" ) || std::string::npos != lower.
find(
"fltr" ) ||
292 std::string::npos != lower.
find(
"pass" );
308 using namespace boost::io;
309 if ( flag && 0 <= counter.
eff() && 0 <= counter.
effErr() ) {
311 fmt.exceptions( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) );
312 fmt % counter.
nEntries() % counter.
sum() % ( counter.
eff() * 100 ) % ( counter.
effErr() * 100 );
316 fmt.exceptions( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) );
333 using namespace boost::io;
334 if ( flag && effCounter( name ) && 0 <= counter.
eff() && 0 <= counter.
effErr() ) {
336 fmt.exceptions( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) );
337 fmt % (
"\"" + name +
"\"" ) % counter.
nEntries() % counter.
sum() % ( counter.
eff() * 100 ) %
338 ( counter.
effErr() * 100 );
342 fmt.exceptions( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) );
343 fmt % (
"\"" + name +
"\"" ) % counter.
nEntries() % counter.
sum() % counter.
mean() % counter.
rms() % counter.
min() %
362 using namespace boost::io;
363 if ( flag && ( effCounter( name ) || effCounter( group ) ) && 0 <= counter.
eff() && 0 <= counter.
effErr() ) {
365 fmt.exceptions( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) );
366 fmt % (
"\"" + name +
":" ) % (
":" + group +
"\"" ) % counter.
nEntries() % counter.
sum() %
367 ( counter.
eff() * 100 ) % ( counter.
effErr() * 100 );
371 fmt.exceptions( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) );
372 fmt % (
"\"" + name +
":" ) % (
":" + group +
"\"" ) % counter.
nEntries() % counter.
sum() % counter.
mean() %
373 counter.
rms() % counter.
min() % counter.
max();
std::string toString() const
representation as string
StatEntity()=default
the default constructor
double effErr() const
shortcut,
const double & max() const
maximal value
GAUDI_API friend std::ostream & operator<<(std::ostream &stream, const StatEntity &entity)
external printout operator to std::ostream
const unsigned long & nEntries() const
getters – no synchronization!
unsigned long add(double Flag)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
double efficiency() const
Interpret the counter as some measure of efficiency The efficiency is calculated as the ratio of the ...
void reset()
reset the counters
unsigned long add(const double Flag)
add a value
std::ostream & print(std::ostream &o=std::cout) const
printout to std::ostream
GAUDI_API std::string formatAsTableRow(const StatEntity &counter, const bool flag, const std::string &format1=" |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |", const std::string &format2="*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |")
print the counter in a form of the table row
GAUDI_API friend StatEntity operator+(const StatEntity &entity, const double value)
external operator for addition of StatEntity and a number
const double & sum() const
accumulated value
void setnEntriesBeforeReset(unsigned long nEntriesBeforeReset)
DR specify number of entry before reset.
double eff() const
shortcut,
GAUDI_API friend StatEntity operator-(const StatEntity &entity, const double value)
external operator for subtraction of StatEntity and a number
double mean() const
mean value of counter
const double & min() const
minimal value
static const std::string & format()
the internal format description
StatEntity & operator+=(const double f)
General increment operator for the flag Could be used for easy manipulation with StatEntity object: ...
double efficiency() const
double efficiencyErr() const
struct StatEntity::se m_se
static int size()
the actual size of published data
double rms() const
r.m.s of value
The basic counter used for Monitoring purposes.
double flag2() const
accumulated "flag squared"
double flag() const
accumulated "flag"
GAUDI_API friend bool operator<(const StatEntity &lhs, const StatEntity &rhs)
comparison
StatEntity & operator=(const StatEntity &)
assignment operator