Gaudi Framework, version v23r0 |
Home | Generated: Mon Jan 30 2012 |
The basic counter used for Monitoring purposes. More...
#include <GaudiKernel/StatEntity.h>
Public Member Functions | |
StatEntity () | |
the default constructor | |
StatEntity (const unsigned long entries, const double flag, const double flag2, const double minFlag, const double maxFlag) | |
~StatEntity () | |
destructor | |
const unsigned long & | nEntries () const |
getters | |
const double & | sum () const |
accumulated value | |
const double & | sum2 () const |
accumulated value**2 | |
double | mean () const |
mean value of counter | |
double | rms () const |
r.m.s of value | |
double | meanErr () const |
error in mean value of counter | |
const double & | min () const |
minimal value | |
const double & | max () const |
maximal value | |
double | efficiency () const |
Interpret the counter as some measure of efficiency The efficiency is calculated as the ratio of the weight over the number of entries One gets the correct interpretation in the case of filling the counters only with 0 and 1. | |
double | efficiencyErr () const |
Interpret the counter as some measure of efficiency and evaluate the uncertainty of this efficiency using binomial estimate. | |
double | eff () const |
shortcut, | |
double | effErr () const |
shortcut, | |
StatEntity & | operator+= (const double f) |
General increment operator for the flag Could be used for easy manipulation with StatEntity object: | |
StatEntity & | operator++ () |
Pre-increment operator for the flag Could be used for easy manipulation with StatEntity object: | |
StatEntity & | operator++ (int) |
Post-increment operator for the flag. | |
StatEntity & | operator-= (const double f) |
General decrement operator for the flag Could be used for easy manipulation with StatEntity object: | |
StatEntity & | operator-- () |
Pre-decrement operator for the flag Could be used for easy manipulation with StatEntity object: | |
StatEntity & | operator-- (int) |
Post-decrement operator for the flag Could be used for easy manipulation with StatEntity object: | |
StatEntity & | operator= (const double f) |
Assignment from the flag The action: reset and the general increment Such case could be useful for statistical monitoring. | |
StatEntity & | operator+= (const StatEntity &other) |
increment with other counter (useful for Monitoring/Adder ) | |
bool | operator< (const StatEntity &se) const |
comparison | |
unsigned long | add (const double Flag) |
add a value | |
void | reset () |
reset the counters | |
void | setnEntriesBeforeReset (unsigned long nEntriesBeforeReset) |
DR specify number of entry before reset. | |
std::string | toString () const |
representation as string | |
std::ostream & | print (std::ostream &o=std::cout) const |
printout to std::ostream | |
std::ostream & | fillStream (std::ostream &o) const |
printout to std::ostream | |
double | Sum () const |
get sum | |
double | Mean () const |
get mean | |
double | MeanErr () const |
get error in mean | |
double | Rms () const |
get rms | |
double | RMS () const |
get rms | |
double | Eff () const |
get efficiency | |
double | Min () const |
get minimal value | |
double | Max () const |
get maximal value | |
double | flag () const |
accumulated "flag" | |
double | flag2 () const |
accumulated "flag squared" | |
double | flagMean () const |
mean value of flag | |
double | flagRMS () const |
r.m.s of flag | |
double | flagMeanErr () const |
error in mean value of flag | |
double | flagMin () const |
minimal flag | |
double | flagMax () const |
maximal flag | |
unsigned long | addFlag (const double Flag) |
add a flag | |
Static Public Member Functions | |
static const std::string & | format () |
the internal format description | |
static int | size () |
the actual size of published data | |
Private Attributes | |
unsigned long | m_se_nEntries |
number of calls | |
double | m_se_accumulatedFlag |
accumulated flag | |
double | m_se_accumulatedFlag2 |
double | m_se_minimalFlag |
double | m_se_maximalFlag |
long | m_se_nEntriesBeforeReset |
The basic counter used for Monitoring purposes.
It is used as a small helper class for implementation of class ChronoStatSvc but it also could be used in stand-alone mode to perform trivial statistical evaluations. e.g.
Essentially the generic counter could be considered as the trivial 1-bin
// get all tracks const Tracks* tracks = ... ; // create the counter StatEntity chi2 ; // make a loop over all tracks: for ( Tracks::const_iterator itrack = tracks->begin() ; tracks->end() != itrack ; ++itrack ) { const Track* track = *itrack ; // use the counters to accumulate information: chi2 += track -> chi2 () ; } ; // Extract the information from the counter: // get number of entries (== number of tracks) int nEntries = chi2.nEntries() ; // get the minimal value of chi2 double chi2Min = chi2.flagMin() ; // get the average value of chi2: double meanChi2 = chi2.flagMean() ; // get R.M.S. for chi2-distribution: double rmsChi2 = chi2.flagRMS() ; .. etc...
Definition at line 68 of file StatEntity.h.
StatEntity::StatEntity | ( | ) | [inline] |
StatEntity::StatEntity | ( | const unsigned long | entries, |
const double | flag, | ||
const double | flag2, | ||
const double | minFlag, | ||
const double | maxFlag | ||
) |
Definition at line 48 of file StatEntity.cpp.
: m_se_nEntries ( entries ) , m_se_accumulatedFlag ( flag ) , m_se_accumulatedFlag2 ( flag2 ) , m_se_minimalFlag ( minFlag ) , m_se_maximalFlag ( maxFlag ) , m_se_nEntriesBeforeReset ( -1 ) {}
StatEntity::~StatEntity | ( | ) | [inline] |
unsigned long StatEntity::add | ( | const double | Flag ) |
add a value
Flag | value to be added |
accumulate the flag
evaluate min/max
Definition at line 189 of file StatEntity.cpp.
{ // if ( 0 < m_se_nEntriesBeforeReset ) { --m_se_nEntriesBeforeReset; } else if ( 0 == m_se_nEntriesBeforeReset ) { reset(); } m_se_accumulatedFlag += Flag ; // accumulate the flag m_se_minimalFlag = std::min ( m_se_minimalFlag , Flag ) ; // evaluate min/max m_se_maximalFlag = std::max ( m_se_maximalFlag , Flag ) ; // evaluate min/max // accumulate statistics, but avoid FPE for small flags... static const double s_min1 = 2 * ::sqrt ( std::numeric_limits<double>::min() ) ; if ( s_min1 < Flag || -s_min1 > Flag ) { m_se_accumulatedFlag2 += Flag * Flag ; }// accumulate statistics: // return ++m_se_nEntries ; }
unsigned long StatEntity::addFlag | ( | const double | Flag ) | [inline] |
add a flag
Flag | value to be added |
Definition at line 416 of file StatEntity.h.
{ return add ( Flag ) ; }
double StatEntity::Eff | ( | ) | const [inline] |
double StatEntity::eff | ( | ) | const [inline] |
shortcut,
Definition at line 185 of file StatEntity.h.
{ return efficiency () ; }
double StatEntity::effErr | ( | ) | const [inline] |
shortcut,
Definition at line 187 of file StatEntity.h.
{ return efficiencyErr () ; }
double StatEntity::efficiency | ( | ) | const |
Interpret the counter as some measure of efficiency The efficiency is calculated as the ratio of the weight over the number of entries One gets the correct interpretation in the case of filling the counters only with 0 and 1.
Some checks are performed:
If these conditions are not satisfied the method returns -1, otherwise it returns the value of "flagMean"
StatEntity& stat = ... ; for ( TRACKS::iterator itrack = tracks.begin() ; tracks.end() != itrack ; itrack ) { const bool good = PT( *itrack ) > 1 * Gaudi::Units::GeV ; stat += good ; } std::cout << " Efficiency of PT-cut is " << stat.efficiency() << std::endl ;
Definition at line 123 of file StatEntity.cpp.
double StatEntity::efficiencyErr | ( | ) | const |
Interpret the counter as some measure of efficiency and evaluate the uncertainty of this efficiency using binomial estimate.
The efficiency is calculated as the ratio of the weight over the number of entries One gets the correct interpretation in the case of filling the counters only with 0 and 1. Some checks are performed:
If these conditions are not satisfied the method returns -1.
StatEntity& stat = ... ; for ( TRACKS::iterator itrack = tracks.begin() ; tracks.end() != itrack ; itrack ) { const bool good = PT( *itrack ) > 1 * Gaudi::Units::GeV ; stat += good ; } std::cout << " Efficiency of PT-cut is " << stat.efficiency () << "+-" << stat.efficiencyErr () << std::endl ;
Definition at line 135 of file StatEntity.cpp.
{ if ( 0 > efficiency() ) { return -1 ; } // long double n1 = sum () ; // treat properly the bins with eff=0 if ( 0 == n1 ) { n1 = 1 ; } const long double n3 = nEntries () ; long double n2 = n3 - flag () ; // treat properly the bins with eff=100% if ( 1 > fabsl( n2 ) ) { n2 = 1 ; } // return ::sqrtl( n1 * n2 / n3 ) / n3 ; }
std::ostream& StatEntity::fillStream | ( | std::ostream & | o ) | const [inline] |
printout to std::ostream
s | the reference to the output stream |
Definition at line 375 of file StatEntity.h.
{ return print ( o ) ; }
double StatEntity::flag | ( | ) | const [inline] |
double StatEntity::flag2 | ( | ) | const [inline] |
double StatEntity::flagMax | ( | ) | const [inline] |
double StatEntity::flagMean | ( | ) | const [inline] |
double StatEntity::flagMeanErr | ( | ) | const [inline] |
double StatEntity::flagMin | ( | ) | const [inline] |
double StatEntity::flagRMS | ( | ) | const [inline] |
const std::string & StatEntity::format | ( | ) | [static] |
the internal format description
< check for "D"
Definition at line 63 of file StatEntity.cpp.
{ // check for "X" or "L" BOOST_STATIC_ASSERT(((sizeof(unsigned long)==4)||(sizeof(unsigned long)==8))); // check for "D" BOOST_STATIC_ASSERT((sizeof(double)==8)) ; // static const std::string s_fmt = ( ( 8 == sizeof(unsigned long) ) ?"X:1;" : "L:1;" ) + std::string("D:4") ; return s_fmt ; }
double StatEntity::Max | ( | ) | const [inline] |
get maximal value
Definition at line 394 of file StatEntity.h.
{ return max () ; } // get maximal value
const double& StatEntity::max | ( | ) | const [inline] |
double StatEntity::mean | ( | ) | const |
mean value of counter
Definition at line 85 of file StatEntity.cpp.
{ if ( 0 >= nEntries() ) { return 0 ;} const long double f1 = m_se_accumulatedFlag ; const long double f2 = m_se_nEntries ; return f1 / f2 ; }
double StatEntity::Mean | ( | ) | const [inline] |
double StatEntity::meanErr | ( | ) | const |
error in mean value of counter
Definition at line 108 of file StatEntity.cpp.
{ if ( 0 >= nEntries () ) { return 0 ; } const long double f1 = m_se_accumulatedFlag ; const long double f2 = f1 / nEntries () ; const long double f3 = m_se_accumulatedFlag2 ; const long double f4 = f3 / nEntries () ; const long double result = f4 - f2 * f2 ; if ( 0 > result ) { return 0 ; } // return ::sqrtl ( result / nEntries () ) ; }
double StatEntity::MeanErr | ( | ) | const [inline] |
get error in mean
Definition at line 384 of file StatEntity.h.
{ return meanErr () ; } // get error in mean
double StatEntity::Min | ( | ) | const [inline] |
get minimal value
Definition at line 392 of file StatEntity.h.
{ return min () ; } // get minimal value
const double& StatEntity::min | ( | ) | const [inline] |
const unsigned long& StatEntity::nEntries | ( | ) | const [inline] |
StatEntity& StatEntity::operator++ | ( | ) | [inline] |
Pre-increment operator for the flag Could be used for easy manipulation with StatEntity object:
StatEntity stat ; for ( int i = ... ) { double eTotal = .... ; // increment the counter if ( eTotal > 1 * TeV ) { ++stat ; } ; }
Definition at line 232 of file StatEntity.h.
{ return (*this)+= 1 ; }
StatEntity& StatEntity::operator++ | ( | int | ) | [inline] |
Post-increment operator for the flag.
Actually it is the same as pre-increment. Could be used for easy manipulation with StatEntity object:
StatEntity stat ; for ( int i = ... ) { double eTotal = .... ; // increment the counter if ( eTotal > 1 * TeV ) { stat++ ; } ; }
Definition at line 251 of file StatEntity.h.
{ return ++(*this) ; }
StatEntity & StatEntity::operator+= | ( | const StatEntity & | other ) |
increment with other counter (useful for Monitoring/Adder )
const StatEntity second = ... ; StatEntity first = ... ; first += second ;
other | counter to be added |
Definition at line 152 of file StatEntity.cpp.
{ m_se_nEntries += other.m_se_nEntries ; m_se_accumulatedFlag += other.m_se_accumulatedFlag ; m_se_accumulatedFlag2 += other.m_se_accumulatedFlag2 ; m_se_minimalFlag = std::min ( m_se_minimalFlag , other.m_se_minimalFlag ) ; m_se_maximalFlag = std::max ( m_se_maximalFlag , other.m_se_maximalFlag ) ; // return *this ; }
StatEntity& StatEntity::operator+= | ( | const double | f ) | [inline] |
General increment operator for the flag Could be used for easy manipulation with StatEntity object:
StatEntity stat ; for ( int i = ... ) { double eTotal = .... ; // increment the counter stat += eTotal ; }
f | counter increment |
Definition at line 210 of file StatEntity.h.
{ addFlag ( f ) ; return *this ; }
StatEntity& StatEntity::operator-- | ( | ) | [inline] |
Pre-decrement operator for the flag Could be used for easy manipulation with StatEntity object:
StatEntity stat ; for ( int i = ... ) { double eTotal = .... ; // increment the counter if ( eTotal > 1 * TeV ) { --stat ; } ; }
Definition at line 293 of file StatEntity.h.
{ return (*this)-=1 ; }
StatEntity& StatEntity::operator-- | ( | int | ) | [inline] |
Post-decrement operator for the flag Could be used for easy manipulation with StatEntity object:
StatEntity stat ; for ( int i = ... ) { double eTotal = .... ; // increment the counter if ( eTotal > 1 * TeV ) { stat-- ; } ; }
Definition at line 311 of file StatEntity.h.
{ return --(*this) ; }
StatEntity& StatEntity::operator-= | ( | const double | f ) | [inline] |
General decrement operator for the flag Could be used for easy manipulation with StatEntity object:
StatEntity stat ; for ( int i = ... ) { double eTotal = .... ; // decrement the counter stat -= eTotal ; }
f | counter increment |
Definition at line 271 of file StatEntity.h.
{ addFlag ( -f ) ; return *this ; }
bool StatEntity::operator< | ( | const StatEntity & | se ) | const |
comparison
Definition at line 165 of file StatEntity.cpp.
{ if ( &se == this ) { return false ; } else if ( nEntries () < se.nEntries () ) { return true ; } else if ( nEntries () == se.nEntries () && sum () < se.sum () ) { return true ; } else if ( nEntries () == se.nEntries () && sum () == se.sum () && min () < se.min () ) { return true ; } else if ( nEntries () == se.nEntries () && sum () == se.sum () && min () == se.min () && max () < se.max () ) { return true ; } else if ( nEntries () == se.nEntries () && sum () == se.flag () && min () == se.min () && max () == se.max () && sum2 () < se.sum2 () ) { return true ; } return false; }
StatEntity& StatEntity::operator= | ( | const double | f ) | [inline] |
Assignment from the flag The action: reset and the general increment Such case could be useful for statistical monitoring.
const long numberOfHits = ... ; StatEntity& stat = ... ; stat = numberOfHits ;
f | new value of the counter |
< reset the statistics
< use the regular increment
Definition at line 329 of file StatEntity.h.
{ // reset the statistics reset() ; // use the regular increment return ((*this)+=f); }
std::ostream & StatEntity::print | ( | std::ostream & | o = std::cout ) |
const |
printout to std::ostream
s | the reference to the output stream |
Definition at line 236 of file StatEntity.cpp.
{ boost::format fmt1 ("#=%|-7lu| Sum=%|-11.5g|" ) ; o << fmt1 % nEntries() % sum() ; boost::format fmt2 ( " Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|" ) ; o << fmt2 % mean() % rms() % min() % max() ; return o ; }
void StatEntity::reset | ( | ) |
reset the counters
Definition at line 209 of file StatEntity.cpp.
{ // m_se_nEntries = 0 ; m_se_accumulatedFlag = 0 ; m_se_minimalFlag = std::numeric_limits<double>::max() ; m_se_maximalFlag = -1 * std::numeric_limits<double>::max() ; m_se_accumulatedFlag2 = 0 ; m_se_nEntriesBeforeReset = -1 ; // ? }
double StatEntity::Rms | ( | ) | const [inline] |
double StatEntity::RMS | ( | ) | const [inline] |
double StatEntity::rms | ( | ) | const |
r.m.s of value
Definition at line 95 of file StatEntity.cpp.
{ if ( 0 >= nEntries() ) { return 0 ; } const long double f1 = m_se_accumulatedFlag ; const long double f2 = f1 / nEntries () ; const long double f3 = m_se_accumulatedFlag2 ; const long double f4 = f3 / nEntries () ; const long double result = f4 - f2 * f2 ; return ( 0 > result ) ? 0 : ::sqrtl ( result ) ; }
void StatEntity::setnEntriesBeforeReset | ( | unsigned long | nEntriesBeforeReset ) |
DR specify number of entry before reset.
Definition at line 222 of file StatEntity.cpp.
{ m_se_nEntriesBeforeReset = nEntriesBeforeReset; }
int StatEntity::size | ( | void | ) | [static] |
the actual size of published data
Definition at line 77 of file StatEntity.cpp.
{ static const int s_size = sizeof(unsigned long) + 4 * sizeof(double) ; return s_size ; }
const double& StatEntity::sum | ( | ) | const [inline] |
double StatEntity::Sum | ( | ) | const [inline] |
const double& StatEntity::sum2 | ( | ) | const [inline] |
accumulated value**2
Definition at line 100 of file StatEntity.h.
{ return m_se_accumulatedFlag2 ; }
std::string StatEntity::toString | ( | ) | const |
representation as string
Definition at line 227 of file StatEntity.cpp.
{ std::ostringstream ost ; print ( ost ) ; return ost.str () ; }
double StatEntity::m_se_accumulatedFlag [private] |
accumulated flag
Definition at line 440 of file StatEntity.h.
double StatEntity::m_se_accumulatedFlag2 [private] |
Definition at line 441 of file StatEntity.h.
double StatEntity::m_se_maximalFlag [private] |
Definition at line 443 of file StatEntity.h.
double StatEntity::m_se_minimalFlag [private] |
Definition at line 442 of file StatEntity.h.
unsigned long StatEntity::m_se_nEntries [private] |
number of calls
Definition at line 438 of file StatEntity.h.
long StatEntity::m_se_nEntriesBeforeReset [private] |
Definition at line 445 of file StatEntity.h.