2 #define GAUDIKERNEL_STATENTITY_CPP 1 20 #include "boost/format.hpp" 21 #include "boost/static_assert.hpp" 22 #include "boost/algorithm/string/case_conv.hpp" 28 #pragma warning(disable:1572) 32 #pragma warning(disable:2259) 45 (
const unsigned long entries ,
48 const double minFlag ,
49 const double maxFlag )
50 : m_se_nEntries ( entries )
51 , m_se_accumulatedFlag ( flag )
52 , m_se_accumulatedFlag2 ( flag2 )
53 , m_se_minimalFlag ( minFlag )
54 , m_se_maximalFlag ( maxFlag )
55 , m_se_nEntriesBeforeReset ( -1 )
87 BOOST_STATIC_ASSERT(((
sizeof(
unsigned long)==4)||(
sizeof(
unsigned long)==8)));
89 BOOST_STATIC_ASSERT((
sizeof(
double)==8)) ;
92 ( ( 8 ==
sizeof(
unsigned long) ) ?
"X:1;" :
"L:1;" ) +
std::string(
"D:4") ;
100 static const int s_size =
sizeof(
unsigned long) + 4 *
sizeof(
double) ;
108 if ( 0 >=
nEntries() ) {
return 0 ;}
118 if ( 0 >=
nEntries() ) {
return 0 ; }
120 const long double f2 = f1 /
nEntries () ;
122 const long double f4 = f3 /
nEntries () ;
123 const long double result = f4 - f2 * f2 ;
124 return ( 0 > result ) ? 0 : ::sqrtl ( result ) ;
131 if ( 0 >=
nEntries () ) {
return 0 ; }
133 const long double f2 = f1 /
nEntries () ;
135 const long double f4 = f3 /
nEntries () ;
136 const long double result = f4 - f2 * f2 ;
137 if ( 0 > result ) {
return 0 ; }
139 return ::sqrtl ( result /
nEntries () ) ;
147 const long double fMin =
min () ;
148 if ( 0 != fMin && 1 != fMin ) {
return -1 ; }
149 const long double fMax =
max () ;
150 if ( 0 != fMax && 1 != fMax ) {
return -1 ; }
160 long double n1 =
sum () ;
162 if ( 0 == n1 ) { n1 = 1 ; }
163 const long double n3 =
nEntries () ;
164 long double n2 = n3 -
flag () ;
166 if ( 1 > fabsl( n2 ) ) { n2 = 1 ; }
168 return ::sqrtl( n1 * n2 / n3 ) / n3 ;
189 if ( &se ==
this ) {
return false ; }
192 sum () < se.
sum () ) {
return true ; }
195 min () < se.
min () ) {
return true ; }
199 max () < se.
max () ) {
return true ; }
204 sum2 () < se.
sum2 () ) {
return true ; }
224 if ( s_min1 < Flag || -s_min1 > Flag )
264 boost::format fmt2 (
" Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|" ) ;
272 {
StatEntity aux ( entity ) ;
return aux+=value ; }
277 {
return entity + value ; }
282 {
StatEntity aux ( entity ) ;
return aux-=value ; }
287 {
StatEntity aux ( entity ) ;
return aux+=value ; }
292 {
return entity.
print ( stream ) ; }
306 const std::string lower = boost::algorithm::to_lower_copy( name ) ;
308 std::string::npos != lower.
find (
"eff" ) ||
309 std::string::npos != lower.
find (
"acc" ) ||
310 std::string::npos != lower.
find (
"filt" ) ||
311 std::string::npos != lower.
find (
"fltr" ) ||
312 std::string::npos != lower.
find (
"pass" ) ;
331 using namespace boost::io ;
332 if ( flag && 0 <= counter.
eff() && 0 <= counter.
effErr() )
335 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
339 % ( counter.
eff () * 100 )
340 % ( counter.
effErr () * 100 ) ;
344 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
371 using namespace boost::io ;
372 if ( flag && effCounter ( name ) && 0 <= counter.
eff() && 0 <= counter.
effErr() )
375 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
377 % (
"\"" + name +
"\"" )
380 % ( counter.
eff () * 100 )
381 % ( counter.
effErr () * 100 ) ;
385 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
387 % (
"\"" + name +
"\"" )
415 using namespace boost::io ;
416 if ( flag && ( effCounter ( name ) || effCounter ( group ) )
417 && 0 <= counter.
eff() && 0 <= counter.
effErr() )
420 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
422 % (
"\"" + name +
":" )
423 % (
":" + group +
"\"" )
426 % ( counter.
eff () * 100 )
427 % ( counter.
effErr () * 100 ) ;
431 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
433 % (
"\"" + name +
":" )
434 % (
":" + group +
"\"" )
std::string toString() const
representation as string
double effErr() const
shortcut,
const double & max() const
maximal value
unsigned long m_se_nEntries
number of calls
StatEntity()
the default constructor
const unsigned long & nEntries() const
getters
StatEntity operator+(const StatEntity &entity, const double value)
external operator for addition of StatEntity and a number
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 ...
std::ostream & operator<<(std::ostream &stream, const StatEntity &entity)
external printout operator to std::ostream
double meanErr() const
error in mean value of counter
void reset()
reset the counters
long m_se_nEntriesBeforeReset
unsigned long add(const double Flag)
add a value
bool operator<(const StatEntity &se) const
comparison
std::ostream & print(std::ostream &o=std::cout) const
printout to std::ostream
const double & sum2() const
accumulated value**2
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
const double & sum() const
accumulated value
void setnEntriesBeforeReset(unsigned long nEntriesBeforeReset)
DR specify number of entry before reset.
double eff() const
shortcut,
double mean() const
mean value of counter
double m_se_accumulatedFlag
accumulated flag
StatEntity operator-(const StatEntity &entity, const double value)
external operator for subtraction of StatEntity and a number
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: ...
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 flag() const
accumulated "flag"
double efficiencyErr() const
Interpret the counter as some measure of efficiency and evaluate the uncertainty of this efficiency u...
double m_se_accumulatedFlag2