All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StatEntity.h
Go to the documentation of this file.
1 // $Id: StatEntity.h,v 1.7 2007/08/06 08:39:40 marcocle Exp $
2 // ============================================================================
3 // CVS tag $Name: $, version $Revision: 1.7 $
4 // ============================================================================
5 #ifndef GAUDIKERNEL_STATENTITY_H
6 #define GAUDIKERNEL_STATENTITY_H 1
7 // ============================================================================
8 // Include files
9 // ============================================================================
10 // STD & STL
11 // ============================================================================
12 #include <string>
13 #include <iostream>
14 // ============================================================================
15 // Gaudi
16 // ============================================================================
17 #include "GaudiKernel/Kernel.h"
18 // ============================================================================
69 {
70 public:
71  // ==========================================================================
73  StatEntity () { reset() ; }
74  /* The full constructor from all important values:
75  * @attention it need to be coherent with
76  * the actual structure of the class
77  * and the format description
78  * @see StatEntity::format
79  * @param entries number of entries
80  * @param flag accumulated flag
81  * @param flag2 accumulated statistics: flag**2
82  * @param minFlag the minimum value for flag
83  * @param maxFlag the maximum value for flag
84  */
85  StatEntity ( const unsigned long entries ,
86  const double flag ,
87  const double flag2 ,
88  const double minFlag ,
89  const double maxFlag ) ;
92  // ==========================================================================
93 public: // the basic quantities
94  // ==========================================================================
96  const unsigned long& nEntries () const { return m_se_nEntries ; }
98  const double& sum () const { return m_se_accumulatedFlag ; }
100  const double& sum2 () const { return m_se_accumulatedFlag2 ; }
102  double mean () const ;
104  double rms () const ;
106  double meanErr () const ;
108  const double& min () const { return m_se_minimalFlag ; }
110  const double& max () const { return m_se_maximalFlag ; }
111  // ==========================================================================
112 public:
113  // ==========================================================================
146  double efficiency () const ;
183  double efficiencyErr () const ;
185  double eff () const { return efficiency () ; }
187  double effErr () const { return efficiencyErr () ; }
188  // ==========================================================================
189 public: // operators
190  // ==========================================================================
210  StatEntity& operator+= ( const double f )
211  {
212  addFlag ( f ) ;
213  return *this ;
214  }
232  StatEntity& operator++ () { return (*this)+= 1 ; }
251  StatEntity& operator++ (int) { return ++(*this) ; }
271  StatEntity& operator-= ( const double f )
272  {
273  addFlag ( -f ) ;
274  return *this ;
275  }
293  StatEntity& operator-- () { return (*this)-=1 ; }
311  StatEntity& operator-- (int) { return --(*this) ; }
329  StatEntity& operator= ( const double f )
330  {
331  // reset the statistics
332  reset() ;
333  // use the regular increment
334  return ((*this)+=f);
335  }
351  StatEntity& operator+= ( const StatEntity& other ) ;
352  // ==========================================================================
353 public:
354  // ==========================================================================
356  bool operator<( const StatEntity& se ) const ;
361  unsigned long add ( const double Flag ) ;
363  void reset () ;
365  void setnEntriesBeforeReset ( unsigned long nEntriesBeforeReset );
367  std::string toString () const;
371  std::ostream& print ( std::ostream& o = std::cout ) const ;
375  std::ostream& fillStream ( std::ostream& o ) const { return print ( o ) ; }
376  // ==========================================================================
377 public: // aliases (a'la ROOT)
378  // ==========================================================================
380  inline double Sum () const { return sum () ; } // get sum
382  inline double Mean () const { return mean () ; } // get mean
384  inline double MeanErr () const { return meanErr () ; } // get error in mean
386  inline double Rms () const { return rms () ; } // get rms
388  inline double RMS () const { return rms () ; } // get rms
390  inline double Eff () const { return eff () ; } // get efficiency
392  inline double Min () const { return min () ; } // get minimal value
394  inline double Max () const { return max () ; } // get maximal value
395  // ==========================================================================
396 public: // some legacy methods, to be removed ...
397  // ==========================================================================
399  inline double flag () const { return sum () ; }
401  inline double flag2 () const { return sum2 () ; }
403  inline double flagMean () const { return mean () ; }
405  inline double flagRMS () const { return rms () ; }
407  inline double flagMeanErr () const { return meanErr () ; }
409  inline double flagMin () const { return min () ; }
411  inline double flagMax () const { return max () ; }
416  inline unsigned long addFlag ( const double Flag ) { return add ( Flag ) ; }
417  // ==========================================================================
418 public:
419  // ==========================================================================
426  static const std::string& format () ;
433  static int size () ;
434  // ==========================================================================
435 private:
436  // ==========================================================================
438  unsigned long m_se_nEntries ;
444  // DR number of calls before reset
446  // ==========================================================================
447 };
448 // ============================================================================
450 GAUDI_API StatEntity operator+( const StatEntity& entity , const double value ) ;
452 GAUDI_API StatEntity operator+( const double value , const StatEntity& entity ) ;
454 GAUDI_API StatEntity operator+( const StatEntity& entity , const StatEntity& value ) ;
456 GAUDI_API StatEntity operator-( const StatEntity& entity , const double value ) ;
458 GAUDI_API std::ostream& operator<<( std::ostream& stream , const StatEntity& entity ) ;
459 // ============================================================================
460 namespace Gaudi
461 {
462  // ==========================================================================
463  namespace Utils
464  {
465  // ========================================================================
515  GAUDI_API std::string formatAsTableRow
516  ( const StatEntity& counter ,
517  const bool flag ,
518  const std::string& format1 =
519  " |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |" ,
520  const std::string& format2 =
521  "*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |" );
522  // ========================================================================
583  GAUDI_API std::string formatAsTableRow
584  ( const std::string& name ,
585  const StatEntity& counter ,
586  const bool flag = true ,
587  const std::string& format1 =
588  " %|-15.15s|%|17t||%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |" ,
589  const std::string& format2 =
590  "*%|-15.15s|%|17t||%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |" );
591  // ========================================================================
659  GAUDI_API std::string formatAsTableRow
660  ( const std::string& name ,
661  const std::string& group ,
662  const StatEntity& entity ,
663  const bool flag = true ,
664  const std::string& format1 =
665  " %|15.15s|%|-15.15s|%|32t||%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |" ,
666  const std::string& format2 =
667  "*%|15.15s|%|-15.15s|%|32t||%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |" ) ;
668  // ========================================================================
669  } // end of namespace Gaudi::Utils
670  // ==========================================================================
671 } // end of namespace Gaudi
672 // ============================================================================
673 // The END
674 // ============================================================================
675 #endif // GAUDIKERNEL_STATENTITY_H
676 // ============================================================================
677 
678 
679 
680 
681 
682 
double effErr() const
shortcut,
Definition: StatEntity.h:187
const double & max() const
maximal value
Definition: StatEntity.h:110
unsigned long m_se_nEntries
number of calls
Definition: StatEntity.h:438
StatEntity()
the default constructor
Definition: StatEntity.h:73
double Min() const
get minimal value
Definition: StatEntity.h:392
const unsigned long & nEntries() const
getters
Definition: StatEntity.h:96
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:133
double Mean() const
get mean
Definition: StatEntity.h:382
double flagRMS() const
r.m.s of flag
Definition: StatEntity.h:405
std::ostream & fillStream(std::ostream &o) const
printout to std::ostream
Definition: StatEntity.h:375
double sum(double x, double y, double z)
double flagMin() const
minimal flag
Definition: StatEntity.h:409
~StatEntity()
destructor
Definition: StatEntity.h:91
double m_se_minimalFlag
Definition: StatEntity.h:442
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:367
double flagMeanErr() const
error in mean value of flag
Definition: StatEntity.h:407
long m_se_nEntriesBeforeReset
Definition: StatEntity.h:445
double Max() const
get maximal value
Definition: StatEntity.h:394
const double & sum2() const
accumulated value**2
Definition: StatEntity.h:100
double flagMax() const
maximal flag
Definition: StatEntity.h:411
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
Definition: StatEntity.cpp:302
const double & sum() const
accumulated value
Definition: StatEntity.h:98
double eff() const
shortcut,
Definition: StatEntity.h:185
double MeanErr() const
get error in mean
Definition: StatEntity.h:384
double flagMean() const
mean value of flag
Definition: StatEntity.h:403
double Eff() const
get efficiency
Definition: StatEntity.h:390
double m_se_accumulatedFlag
accumulated flag
Definition: StatEntity.h:440
GAUDI_API StatEntity operator+(const StatEntity &entity, const double value)
external operator for addition of StatEntity and a number
Definition: StatEntity.cpp:247
const double & min() const
minimal value
Definition: StatEntity.h:108
double Sum() const
get sum
Definition: StatEntity.h:380
unsigned long addFlag(const double Flag)
add a flag
Definition: StatEntity.h:416
#define min(a, b)
GAUDI_API std::ostream & operator<<(std::ostream &stream, const StatEntity &entity)
external printout operator to std::ostream
Definition: StatEntity.cpp:267
double Rms() const
get rms
Definition: StatEntity.h:386
double RMS() const
get rms
Definition: StatEntity.h:388
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:68
This is a number of static methods for bootstrapping the Gaudi framework.
Definition: Bootstrap.h:15
double m_se_maximalFlag
Definition: StatEntity.h:443
GAUDI_API StatEntity operator-(const StatEntity &entity, const double value)
external operator for subtraction of StatEntity and a number
Definition: StatEntity.cpp:257
double flag2() const
accumulated "flag squared"
Definition: StatEntity.h:401
bool operator<(const Gaudi::Time &t1, const Gaudi::Time &t2)
Definition: Time.icpp:233
#define GAUDI_API
Definition: Kernel.h:108
double flag() const
accumulated "flag"
Definition: StatEntity.h:399
double m_se_accumulatedFlag2
Definition: StatEntity.h:441