2 #define GAUDIKERNEL_STATENTITY_CPP 1
16 #include "GaudiKernel/StatEntity.h"
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 )
63 BOOST_STATIC_ASSERT(((
sizeof(
unsigned long)==4)||(
sizeof(
unsigned long)==8)));
65 BOOST_STATIC_ASSERT((
sizeof(
double)==8)) ;
67 static const std::string s_fmt =
68 ( ( 8 ==
sizeof(
unsigned long) ) ?
"X:1;" :
"L:1;" ) + std::string(
"D:4") ;
76 static const int s_size =
sizeof(
unsigned long) + 4 *
sizeof(
double) ;
94 if ( 0 >=
nEntries() ) {
return 0 ; }
96 const long double f2 = f1 /
nEntries () ;
98 const long double f4 = f3 /
nEntries () ;
99 const long double result = f4 - f2 * f2 ;
100 return ( 0 > result ) ? 0 : ::sqrtl ( result ) ;
107 if ( 0 >=
nEntries () ) {
return 0 ; }
109 const long double f2 = f1 /
nEntries () ;
111 const long double f4 = f3 /
nEntries () ;
112 const long double result = f4 - f2 * f2 ;
113 if ( 0 > result ) {
return 0 ; }
115 return ::sqrtl ( result /
nEntries () ) ;
123 const long double fMin =
min () ;
124 if ( 0 != fMin && 1 != fMin ) {
return -1 ; }
125 const long double fMax =
max () ;
126 if ( 0 != fMax && 1 != fMax ) {
return -1 ; }
136 long double n1 =
sum () ;
138 if ( 0 == n1 ) { n1 = 1 ; }
139 const long double n3 =
nEntries () ;
140 long double n2 = n3 -
flag () ;
142 if ( 1 > fabsl( n2 ) ) { n2 = 1 ; }
144 return ::sqrtl( n1 * n2 / n3 ) / n3 ;
164 if ( &se ==
this ) {
return false ; }
167 sum () < se.
sum () ) {
return true ; }
170 min () < se.
min () ) {
return true ; }
174 max () < se.
max () ) {
return true ; }
179 sum2 () < se.
sum2 () ) {
return true ; }
197 static const double s_min1 = 2 * ::sqrt ( std::numeric_limits<double>::min() ) ;
198 if ( s_min1 < Flag || -s_min1 > Flag )
226 std::ostringstream ost ;
237 boost::format fmt2 (
" Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|" ) ;
250 {
return entity +
value ; }
265 {
return entity.
print ( stream ) ; }
277 inline bool effCounter (
const std::string&
name )
279 const std::string lower = boost::algorithm::to_lower_copy( name ) ;
281 std::string::npos != lower.find (
"eff" ) ||
282 std::string::npos != lower.find (
"acc" ) ||
283 std::string::npos != lower.find (
"filt" ) ||
284 std::string::npos != lower.find (
"fltr" ) ||
285 std::string::npos != lower.find (
"pass" ) ;
301 const std::string& format1 ,
302 const std::string& format2 )
304 using namespace boost::io ;
305 if ( flag && 0 <= counter.
eff() && 0 <= counter.
effErr() )
308 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
312 % ( counter.
eff () * 100 )
313 % ( counter.
effErr () * 100 ) ;
317 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
338 (
const std::string& name ,
341 const std::string& format1 ,
342 const std::string& format2 )
344 using namespace boost::io ;
345 if ( flag && effCounter ( name ) && 0 <= counter.
eff() && 0 <= counter.
effErr() )
348 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
350 % (
"\"" + name +
"\"" )
353 % ( counter.
eff () * 100 )
354 % ( counter.
effErr () * 100 ) ;
358 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
360 % (
"\"" + name +
"\"" )
381 (
const std::string& name ,
382 const std::string& group ,
385 const std::string& format1 ,
386 const std::string& format2 )
388 using namespace boost::io ;
389 if ( flag && ( effCounter ( name ) || effCounter ( group ) )
390 && 0 <= counter.
eff() && 0 <= counter.
effErr() )
393 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
395 % (
"\"" + name +
":" )
396 % (
":" + group +
"\"" )
399 % ( counter.
eff () * 100 )
400 % ( counter.
effErr () * 100 ) ;
404 fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
406 % (
"\"" + name +
":" )
407 % (
":" + 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
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
const double & sum() const
accumulated value
void setnEntriesBeforeReset(unsigned long nEntriesBeforeReset)
DR specify number of entry before reset.
double eff() const
shortcut,
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
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: ...
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
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