The Gaudi Framework  v29r0 (ff2e7097)
StatEntity Class Referencefinal

The basic counter used for Monitoring purposes. More...

#include <GaudiKernel/StatEntity.h>

Collaboration diagram for StatEntity:

Classes

struct  se
 

Public Member Functions

 StatEntity ()=default
 the default constructor More...
 
 StatEntity (const unsigned long entries, const double flag, const double flag2, const double minFlag, const double maxFlag)
 
 StatEntity (const StatEntity &)
 copy constructor More...
 
StatEntityoperator= (const StatEntity &)
 assignment operator More...
 
const unsigned long & nEntries () const
 getters – no synchronization! More...
 
const double & sum () const
 accumulated value More...
 
const double & sum2 () const
 accumulated value**2 More...
 
double mean () const
 mean value of counter More...
 
double rms () const
 r.m.s of value More...
 
double meanErr () const
 error in mean value of counter More...
 
const double & min () const
 minimal value More...
 
const double & max () const
 maximal value More...
 
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. More...
 
double efficiencyErr () const
 Interpret the counter as some measure of efficiency and evaluate the uncertainty of this efficiency using binomial estimate. More...
 
double eff () const
 shortcut, More...
 
double effErr () const
 shortcut, More...
 
StatEntityoperator+= (const double f)
 General increment operator for the flag Could be used for easy manipulation with StatEntity object: More...
 
StatEntityoperator++ ()
 Pre-increment operator for the flag Could be used for easy manipulation with StatEntity object: More...
 
StatEntityoperator++ (int)
 Post-increment operator for the flag. More...
 
StatEntityoperator-= (const double f)
 General decrement operator for the flag Could be used for easy manipulation with StatEntity object: More...
 
StatEntityoperator-- ()
 Pre-decrement operator for the flag Could be used for easy manipulation with StatEntity object: More...
 
StatEntityoperator-- (int)
 Post-decrement operator for the flag Could be used for easy manipulation with StatEntity object: More...
 
StatEntityoperator= (const double f)
 Assignment from the flag The action: reset and the general increment Such case could be useful for statistical monitoring. More...
 
StatEntityoperator+= (const StatEntity &other)
 increment with other counter (useful for Monitoring/Adder ) More...
 
unsigned long add (const double Flag)
 add a value More...
 
void reset ()
 reset the counters More...
 
void setnEntriesBeforeReset (unsigned long nEntriesBeforeReset)
 DR specify number of entry before reset. More...
 
std::string toString () const
 representation as string More...
 
std::ostreamprint (std::ostream &o=std::cout) const
 printout to std::ostream More...
 
std::ostreamfillStream (std::ostream &o) const
 printout to std::ostream More...
 
double Sum () const
 get sum More...
 
double Mean () const
 get mean More...
 
double MeanErr () const
 get error in mean More...
 
double Rms () const
 get rms More...
 
double RMS () const
 get rms More...
 
double Eff () const
 get efficiency More...
 
double Min () const
 get minimal value More...
 
double Max () const
 get maximal value More...
 
double flag () const
 accumulated "flag" More...
 
double flag2 () const
 accumulated "flag squared" More...
 
double flagMean () const
 mean value of flag More...
 
double flagRMS () const
 r.m.s of flag More...
 
double flagMeanErr () const
 error in mean value of flag More...
 
double flagMin () const
 minimal flag More...
 
double flagMax () const
 maximal flag More...
 
unsigned long addFlag (const double Flag)
 add a flag More...
 

Static Public Member Functions

static const std::stringformat ()
 the internal format description More...
 
static int size ()
 the actual size of published data More...
 

Private Attributes

struct StatEntity::se m_se = {}
 
std::mutex m_mutex
 

Friends

GAUDI_API friend bool operator< (const StatEntity &lhs, const StatEntity &rhs)
 comparison More...
 
GAUDI_API friend StatEntity operator+ (const StatEntity &entity, const double value)
 external operator for addition of StatEntity and a number More...
 
GAUDI_API friend StatEntity operator+ (const double value, const StatEntity &entity)
 external operator for addition of StatEntity and a number More...
 
GAUDI_API friend StatEntity operator+ (const StatEntity &entity, const StatEntity &value)
 external operator for addition of StatEntity and a number More...
 
GAUDI_API friend StatEntity operator- (const StatEntity &entity, const double value)
 external operator for subtraction of StatEntity and a number More...
 
GAUDI_API friend std::ostreamoperator<< (std::ostream &stream, const StatEntity &entity)
 external printout operator to std::ostream More...
 

Detailed Description

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...
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@l.nosp@m.app..nosp@m.in2p3.nosp@m..fr
Date
26/11/1999
2005-08-02

Definition at line 65 of file StatEntity.h.

Constructor & Destructor Documentation

StatEntity::StatEntity ( )
default

the default constructor

StatEntity::StatEntity ( const unsigned long  entries,
const double  flag,
const double  flag2,
const double  minFlag,
const double  maxFlag 
)

Definition at line 42 of file StatEntity.cpp.

44  : m_se{entries, flag, flag2, minFlag, maxFlag}
45 {
46 }
struct StatEntity::se m_se
double flag2() const
accumulated "flag squared"
Definition: StatEntity.h:398
double flag() const
accumulated "flag"
Definition: StatEntity.h:396
StatEntity::StatEntity ( const StatEntity other)

copy constructor

Definition at line 50 of file StatEntity.cpp.

50 : m_se{other.m_se} {}
struct StatEntity::se m_se

Member Function Documentation

unsigned long StatEntity::add ( const double  Flag)

add a value

Parameters
Flagvalue to be added
Returns
number of entries

Definition at line 199 of file StatEntity.cpp.

200 {
202  return m_se.add( flag );
203 }
unsigned long add(double Flag)
Definition: StatEntity.cpp:83
std::mutex m_mutex
Definition: StatEntity.h:483
struct StatEntity::se m_se
double flag() const
accumulated "flag"
Definition: StatEntity.h:396
unsigned long StatEntity::addFlag ( const double  Flag)
inline

add a flag

Parameters
Flagvalue to be added
Returns
number of entries

Definition at line 413 of file StatEntity.h.

413 { return add( Flag ); }
unsigned long add(const double Flag)
add a value
Definition: StatEntity.cpp:199
double StatEntity::eff ( ) const
inline

shortcut,

See also
StatEntity::efficiency

Definition at line 181 of file StatEntity.h.

181 { return efficiency(); }
double efficiency() const
Interpret the counter as some measure of efficiency The efficiency is calculated as the ratio of the ...
Definition: StatEntity.h:142
double StatEntity::Eff ( ) const
inline

get efficiency

Definition at line 387 of file StatEntity.h.

387 { return eff(); } // get efficiency
double eff() const
shortcut,
Definition: StatEntity.h:181
double StatEntity::effErr ( ) const
inline

shortcut,

See also
StatEntity::efficiencyErr

Definition at line 183 of file StatEntity.h.

183 { return efficiencyErr(); }
double efficiencyErr() const
Interpret the counter as some measure of efficiency and evaluate the uncertainty of this efficiency u...
Definition: StatEntity.h:179
double StatEntity::efficiency ( ) const
inline

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:

  • number of counts must be positive
  • "flag" must be non-negative
  • "flag" does not exceed the overall number of counts

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 ;
See also
StatEntity::flagMean
StatEntity::eff
StatEntity::efficiencyErr

Definition at line 142 of file StatEntity.h.

142 { return m_se.efficiency(); }
double efficiency() const
Definition: StatEntity.cpp:149
struct StatEntity::se m_se
double StatEntity::efficiencyErr ( ) const
inline

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:

  • number of counts must be positive
  • "flag" must be non-negative
  • "flag" does not exceed the overall number of counts

If these conditions are not satisfied the method returns -1.

Attention
The action of this method is DIFFERENT from the action of the method StatEntity::flagMeanErr
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 ;
See also
StatEntity::efficiency
StatEntity::effErr
StatEntity::flagMeanErr

Definition at line 179 of file StatEntity.h.

179 { return m_se.efficiencyErr(); }
double efficiencyErr() const
Definition: StatEntity.cpp:167
struct StatEntity::se m_se
std::ostream& StatEntity::fillStream ( std::ostream o) const
inline

printout to std::ostream

Parameters
sthe reference to the output stream

Definition at line 372 of file StatEntity.h.

372 { return print( o ); }
std::ostream & print(std::ostream &o=std::cout) const
printout to std::ostream
Definition: StatEntity.cpp:232
double StatEntity::flag ( ) const
inline

accumulated "flag"

Definition at line 396 of file StatEntity.h.

396 { return sum(); }
const double & sum() const
accumulated value
Definition: StatEntity.h:94
double StatEntity::flag2 ( ) const
inline

accumulated "flag squared"

Definition at line 398 of file StatEntity.h.

398 { return sum2(); }
const double & sum2() const
accumulated value**2
Definition: StatEntity.h:96
double StatEntity::flagMax ( ) const
inline

maximal flag

Definition at line 408 of file StatEntity.h.

408 { return max(); }
const double & max() const
maximal value
Definition: StatEntity.h:106
double StatEntity::flagMean ( ) const
inline

mean value of flag

Definition at line 400 of file StatEntity.h.

400 { return mean(); }
double mean() const
mean value of counter
Definition: StatEntity.h:98
double StatEntity::flagMeanErr ( ) const
inline

error in mean value of flag

Definition at line 404 of file StatEntity.h.

404 { return meanErr(); }
double meanErr() const
error in mean value of counter
Definition: StatEntity.h:102
double StatEntity::flagMin ( ) const
inline

minimal flag

Definition at line 406 of file StatEntity.h.

406 { return min(); }
const double & min() const
minimal value
Definition: StatEntity.h:104
double StatEntity::flagRMS ( ) const
inline

r.m.s of flag

Definition at line 402 of file StatEntity.h.

402 { return rms(); }
double rms() const
r.m.s of value
Definition: StatEntity.h:100
const std::string & StatEntity::format ( )
static

the internal format description

Attention
: it needs to be coherent with the actual class structure! It is useful for DIM publishing
See also
StatEntity::size

< check for "D"

Definition at line 62 of file StatEntity.cpp.

63 {
64  // check for "X" or "L"
65  static_assert( ( ( sizeof( unsigned long ) == 4 ) || ( sizeof( unsigned long ) == 8 ) ), "check for X or L" );
66  // check for "D"
67  static_assert( ( sizeof( double ) == 8 ), "check for D" );
68  //
69  static const std::string s_fmt = ( ( 8 == sizeof( unsigned long ) ) ? "X:1;" : "L:1;" ) + std::string( "D:4" );
70  return s_fmt;
71 }
STL class.
const double& StatEntity::max ( ) const
inline

maximal value

Definition at line 106 of file StatEntity.h.

106 { return m_se.maximalFlag; }
double maximalFlag
Definition: StatEntity.h:453
struct StatEntity::se m_se
double StatEntity::Max ( ) const
inline

get maximal value

Definition at line 391 of file StatEntity.h.

391 { return max(); } // get maximal value
const double & max() const
maximal value
Definition: StatEntity.h:106
double StatEntity::mean ( ) const
inline

mean value of counter

Definition at line 98 of file StatEntity.h.

98 { return m_se.mean(); }
double mean() const
Definition: StatEntity.cpp:106
struct StatEntity::se m_se
double StatEntity::Mean ( ) const
inline

get mean

Definition at line 379 of file StatEntity.h.

379 { return mean(); } // get mean
double mean() const
mean value of counter
Definition: StatEntity.h:98
double StatEntity::meanErr ( ) const
inline

error in mean value of counter

Definition at line 102 of file StatEntity.h.

102 { return m_se.meanErr(); }
double meanErr() const
Definition: StatEntity.cpp:130
struct StatEntity::se m_se
double StatEntity::MeanErr ( ) const
inline

get error in mean

Definition at line 381 of file StatEntity.h.

381 { return meanErr(); } // get error in mean
double meanErr() const
error in mean value of counter
Definition: StatEntity.h:102
const double& StatEntity::min ( ) const
inline

minimal value

Definition at line 104 of file StatEntity.h.

104 { return m_se.minimalFlag; }
double minimalFlag
Definition: StatEntity.h:452
struct StatEntity::se m_se
double StatEntity::Min ( ) const
inline

get minimal value

Definition at line 389 of file StatEntity.h.

389 { return min(); } // get minimal value
const double & min() const
minimal value
Definition: StatEntity.h:104
const unsigned long& StatEntity::nEntries ( ) const
inline

getters – no synchronization!

Definition at line 92 of file StatEntity.h.

92 { return m_se.nEntries; }
struct StatEntity::se m_se
unsigned long nEntries
number of calls
Definition: StatEntity.h:448
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 229 of file StatEntity.h.

229 { 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 248 of file StatEntity.h.

248 { 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 ;
}
Parameters
fcounter increment

Definition at line 207 of file StatEntity.h.

208  {
209  addFlag( f );
210  return *this;
211  }
unsigned long addFlag(const double Flag)
add a flag
Definition: StatEntity.h:413
StatEntity & StatEntity::operator+= ( const StatEntity other)

increment with other counter (useful for Monitoring/Adder )

const StatEntity second = ... ;
StatEntity first = ... ;
first += second ;
Parameters
othercounter to be added
Returns
self-reference

Definition at line 190 of file StatEntity.cpp.

191 {
193  m_se += other.m_se;
194  return *this;
195 }
std::mutex m_mutex
Definition: StatEntity.h:483
struct StatEntity::se m_se
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 290 of file StatEntity.h.

290 { 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 308 of file StatEntity.h.

308 { 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 ;
}
Parameters
fcounter increment

Definition at line 268 of file StatEntity.h.

269  {
270  addFlag( -f );
271  return *this;
272  }
unsigned long addFlag(const double Flag)
add a flag
Definition: StatEntity.h:413
StatEntity & StatEntity::operator= ( const StatEntity other)

assignment operator

Definition at line 54 of file StatEntity.cpp.

55 {
57  m_se = other.m_se;
58  return *this;
59 } // ============================================================================
std::mutex m_mutex
Definition: StatEntity.h:483
struct StatEntity::se m_se
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 ;
Parameters
fnew value of the counter
Returns
self-reference

< reset the statistics

< use the regular increment

Definition at line 326 of file StatEntity.h.

327  {
328  // reset the statistics
329  reset();
330  // use the regular increment
331  return ( ( *this ) += f );
332  }
void reset()
reset the counters
Definition: StatEntity.cpp:207
std::ostream & StatEntity::print ( std::ostream o = std::cout) const

printout to std::ostream

Parameters
sthe reference to the output stream

Definition at line 232 of file StatEntity.cpp.

233 {
234  boost::format fmt1( "#=%|-7lu| Sum=%|-11.5g|" );
235  o << fmt1 % nEntries() % sum();
236  boost::format fmt2( " Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|" );
237  o << fmt2 % mean() % rms() % min() % max();
238  return o;
239 }
const double & max() const
maximal value
Definition: StatEntity.h:106
const unsigned long & nEntries() const
getters – no synchronization!
Definition: StatEntity.h:92
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
const double & sum() const
accumulated value
Definition: StatEntity.h:94
double mean() const
mean value of counter
Definition: StatEntity.h:98
const double & min() const
minimal value
Definition: StatEntity.h:104
double rms() const
r.m.s of value
Definition: StatEntity.h:100
void StatEntity::reset ( )

reset the counters

Definition at line 207 of file StatEntity.cpp.

208 {
210  m_se = {};
211 }
std::mutex m_mutex
Definition: StatEntity.h:483
struct StatEntity::se m_se
double StatEntity::rms ( ) const
inline

r.m.s of value

Definition at line 100 of file StatEntity.h.

100 { return m_se.rms(); }
double rms() const
Definition: StatEntity.cpp:115
struct StatEntity::se m_se
double StatEntity::Rms ( ) const
inline

get rms

Definition at line 383 of file StatEntity.h.

383 { return rms(); } // get rms
double rms() const
r.m.s of value
Definition: StatEntity.h:100
double StatEntity::RMS ( ) const
inline

get rms

Definition at line 385 of file StatEntity.h.

385 { return rms(); } // get rms
double rms() const
r.m.s of value
Definition: StatEntity.h:100
void StatEntity::setnEntriesBeforeReset ( unsigned long  nEntriesBeforeReset)

DR specify number of entry before reset.

Definition at line 215 of file StatEntity.cpp.

216 {
218  m_se.nEntriesBeforeReset = nEntriesBeforeReset;
219 }
long nEntriesBeforeReset
Definition: StatEntity.h:455
std::mutex m_mutex
Definition: StatEntity.h:483
struct StatEntity::se m_se
int StatEntity::size ( )
static

the actual size of published data

Attention
: it needs to be coherent with the actual class structure! It is useful for DIM publishing
See also
StatEntity::format

Definition at line 75 of file StatEntity.cpp.

76 {
77  static const int s_size = sizeof( unsigned long ) + 4 * sizeof( double );
78  return s_size;
79 }
const double& StatEntity::sum ( ) const
inline

accumulated value

Definition at line 94 of file StatEntity.h.

94 { return m_se.accumulatedFlag; }
double accumulatedFlag
accumulated flag
Definition: StatEntity.h:450
struct StatEntity::se m_se
double StatEntity::Sum ( ) const
inline

get sum

Definition at line 377 of file StatEntity.h.

377 { return sum(); } // get sum
const double & sum() const
accumulated value
Definition: StatEntity.h:94
const double& StatEntity::sum2 ( ) const
inline

accumulated value**2

Definition at line 96 of file StatEntity.h.

96 { return m_se.accumulatedFlag2; }
double accumulatedFlag2
Definition: StatEntity.h:451
struct StatEntity::se m_se
std::string StatEntity::toString ( ) const

representation as string

Definition at line 223 of file StatEntity.cpp.

224 {
225  std::ostringstream ost;
226  print( ost );
227  return ost.str();
228 }
std::ostream & print(std::ostream &o=std::cout) const
printout to std::ostream
Definition: StatEntity.cpp:232

Friends And Related Function Documentation

GAUDI_API friend StatEntity operator+ ( const StatEntity entity,
const double  value 
)
friend

external operator for addition of StatEntity and a number

Definition at line 247 of file StatEntity.cpp.

248 {
249  StatEntity aux( entity );
250  return aux += value;
251 }
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
GAUDI_API friend StatEntity operator+ ( const double  value,
const StatEntity entity 
)
friend

external operator for addition of StatEntity and a number

Definition at line 255 of file StatEntity.cpp.

255 { return entity + value; }
GAUDI_API friend StatEntity operator+ ( const StatEntity entity,
const StatEntity value 
)
friend

external operator for addition of StatEntity and a number

Definition at line 267 of file StatEntity.cpp.

268 {
269  StatEntity aux( entity );
270  return aux += value;
271 }
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
GAUDI_API friend StatEntity operator- ( const StatEntity entity,
const double  value 
)
friend

external operator for subtraction of StatEntity and a number

Definition at line 259 of file StatEntity.cpp.

260 {
261  StatEntity aux( entity );
262  return aux -= value;
263 }
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
GAUDI_API friend bool operator< ( const StatEntity lhs,
const StatEntity rhs 
)
friend

comparison

Definition at line 243 of file StatEntity.cpp.

243 { return lhs.m_se < rhs.m_se; }
struct StatEntity::se m_se
GAUDI_API friend std::ostream& operator<< ( std::ostream stream,
const StatEntity entity 
)
friend

external printout operator to std::ostream

Definition at line 275 of file StatEntity.cpp.

275 { return entity.print( stream ); }
std::ostream & print(std::ostream &o=std::cout) const
printout to std::ostream
Definition: StatEntity.cpp:232

Member Data Documentation

std::mutex StatEntity::m_mutex
private

Definition at line 483 of file StatEntity.h.

struct StatEntity::se StatEntity::m_se = {}
private

The documentation for this class was generated from the following files: