StatEntity.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_STATENTITY_H
2 #define GAUDIKERNEL_STATENTITY_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <string>
9 #include <iostream>
10 // ============================================================================
11 // Gaudi
12 // ============================================================================
13 #include "GaudiKernel/Kernel.h"
14 // ============================================================================
64 class GAUDI_API StatEntity final
65 {
66 public:
67  // ==========================================================================
69  StatEntity () { reset() ; }
70  /* The full constructor from all important values:
71  * @attention it need to be coherent with
72  * the actual structure of the class
73  * and the format description
74  * @see StatEntity::format
75  * @param entries number of entries
76  * @param flag accumulated flag
77  * @param flag2 accumulated statistics: flag**2
78  * @param minFlag the minimum value for flag
79  * @param maxFlag the maximum value for flag
80  */
81  StatEntity ( const unsigned long entries ,
82  const double flag ,
83  const double flag2 ,
84  const double minFlag ,
85  const double maxFlag ) ;
87  ~StatEntity () = default;
88  // ==========================================================================
89 public: // the basic quantities
90  // ==========================================================================
92  const unsigned long& nEntries () const { return m_se_nEntries ; }
94  const double& sum () const { return m_se_accumulatedFlag ; }
96  const double& sum2 () const { return m_se_accumulatedFlag2 ; }
98  double mean () const ;
100  double rms () const ;
102  double meanErr () const ;
104  const double& min () const { return m_se_minimalFlag ; }
106  const double& max () const { return m_se_maximalFlag ; }
107  // ==========================================================================
108 public:
109  // ==========================================================================
142  double efficiency () const ;
179  double efficiencyErr () const ;
181  double eff () const { return efficiency () ; }
183  double effErr () const { return efficiencyErr () ; }
184  // ==========================================================================
185 public: // operators
186  // ==========================================================================
206  StatEntity& operator+= ( const double f )
207  {
208  addFlag ( f ) ;
209  return *this ;
210  }
228  StatEntity& operator++ () { return (*this)+= 1 ; }
247  StatEntity& operator++ (int) { return ++(*this) ; }
267  StatEntity& operator-= ( const double f )
268  {
269  addFlag ( -f ) ;
270  return *this ;
271  }
289  StatEntity& operator-- () { return (*this)-=1 ; }
307  StatEntity& operator-- (int) { return --(*this) ; }
325  StatEntity& operator= ( const double f )
326  {
327  // reset the statistics
328  reset() ;
329  // use the regular increment
330  return ((*this)+=f);
331  }
347  StatEntity& operator+= ( const StatEntity& other ) ;
348  // ==========================================================================
349 public:
350  // ==========================================================================
352  bool operator<( const StatEntity& se ) const ;
357  unsigned long add ( const double Flag ) ;
359  void reset () ;
361  void setnEntriesBeforeReset ( unsigned long nEntriesBeforeReset );
363  std::string toString () const;
367  std::ostream& print ( std::ostream& o = std::cout ) const ;
371  std::ostream& fillStream ( std::ostream& o ) const { return print ( o ) ; }
372  // ==========================================================================
373 public: // aliases (a'la ROOT)
374  // ==========================================================================
376  inline double Sum () const { return sum () ; } // get sum
378  inline double Mean () const { return mean () ; } // get mean
380  inline double MeanErr () const { return meanErr () ; } // get error in mean
382  inline double Rms () const { return rms () ; } // get rms
384  inline double RMS () const { return rms () ; } // get rms
386  inline double Eff () const { return eff () ; } // get efficiency
388  inline double Min () const { return min () ; } // get minimal value
390  inline double Max () const { return max () ; } // get maximal value
391  // ==========================================================================
392 public: // some legacy methods, to be removed ...
393  // ==========================================================================
395  inline double flag () const { return sum () ; }
397  inline double flag2 () const { return sum2 () ; }
399  inline double flagMean () const { return mean () ; }
401  inline double flagRMS () const { return rms () ; }
403  inline double flagMeanErr () const { return meanErr () ; }
405  inline double flagMin () const { return min () ; }
407  inline double flagMax () const { return max () ; }
412  inline unsigned long addFlag ( const double Flag ) { return add ( Flag ) ; }
413  // ==========================================================================
414 public:
415  // ==========================================================================
422  static const std::string& format () ;
429  static int size () ;
430  // ==========================================================================
431 private:
432  // ==========================================================================
434  unsigned long m_se_nEntries ;
440  // DR number of calls before reset
442  // ==========================================================================
443 };
444 // ============================================================================
446 GAUDI_API StatEntity operator+( const StatEntity& entity , const double value ) ;
448 GAUDI_API StatEntity operator+( const double value , const StatEntity& entity ) ;
450 GAUDI_API StatEntity operator+( const StatEntity& entity , const StatEntity& value ) ;
452 GAUDI_API StatEntity operator-( const StatEntity& entity , const double value ) ;
454 GAUDI_API std::ostream& operator<<( std::ostream& stream , const StatEntity& entity ) ;
455 // ============================================================================
456 namespace Gaudi
457 {
458  // ==========================================================================
459  namespace Utils
460  {
461  // ========================================================================
512  ( const StatEntity& counter ,
513  const bool flag ,
514  const std::string& format1 =
515  " |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |" ,
516  const std::string& format2 =
517  "*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |" );
518  // ========================================================================
580  ( const std::string& name ,
581  const StatEntity& counter ,
582  const bool flag = true ,
583  const std::string& format1 =
584  " %|-15.15s|%|17t||%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |" ,
585  const std::string& format2 =
586  "*%|-15.15s|%|17t||%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |" );
587  // ========================================================================
656  ( const std::string& name ,
657  const std::string& group ,
658  const StatEntity& entity ,
659  const bool flag = true ,
660  const std::string& format1 =
661  " %|15.15s|%|-15.15s|%|32t||%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |" ,
662  const std::string& format2 =
663  "*%|15.15s|%|-15.15s|%|32t||%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |" ) ;
664  // ========================================================================
665  } // end of namespace Gaudi::Utils
666  // ==========================================================================
667 } // end of namespace Gaudi
668 // ============================================================================
669 // The END
670 // ============================================================================
671 #endif // GAUDIKERNEL_STATENTITY_H
672 // ============================================================================
double effErr() const
shortcut,
Definition: StatEntity.h:183
const double & max() const
maximal value
Definition: StatEntity.h:106
unsigned long m_se_nEntries
number of calls
Definition: StatEntity.h:434
StatEntity()
the default constructor
Definition: StatEntity.h:69
double Min() const
get minimal value
Definition: StatEntity.h:388
const unsigned long & nEntries() const
getters
Definition: StatEntity.h:92
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
double Mean() const
get mean
Definition: StatEntity.h:378
double flagRMS() const
r.m.s of flag
Definition: StatEntity.h:401
std::ostream & fillStream(std::ostream &o) const
printout to std::ostream
Definition: StatEntity.h:371
double sum(double x, double y, double z)
double flagMin() const
minimal flag
Definition: StatEntity.h:405
double m_se_minimalFlag
Definition: StatEntity.h:438
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:403
long m_se_nEntriesBeforeReset
Definition: StatEntity.h:441
double Max() const
get maximal value
Definition: StatEntity.h:390
const double & sum2() const
accumulated value**2
Definition: StatEntity.h:96
double flagMax() const
maximal flag
Definition: StatEntity.h:407
GAUDI_API std::string formatAsTableRow(const std::string &name, const std::string &group, const StatEntity &entity, const bool flag=true, const std::string &format1=" %|15.15s|%|-15.15s|%|32t||%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |", const std::string &format2="*%|15.15s|%|-15.15s|%|32t||%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |")
print the counter in a form of the table row
Definition: StatEntity.cpp:381
PropertyMgr & operator=(const PropertyMgr &)=delete
const double & sum() const
accumulated value
Definition: StatEntity.h:94
STL class.
double eff() const
shortcut,
Definition: StatEntity.h:181
double MeanErr() const
get error in mean
Definition: StatEntity.h:380
double flagMean() const
mean value of flag
Definition: StatEntity.h:399
double Eff() const
get efficiency
Definition: StatEntity.h:386
double m_se_accumulatedFlag
accumulated flag
Definition: StatEntity.h:436
GAUDI_API StatEntity operator+(const StatEntity &entity, const double value)
external operator for addition of StatEntity and a number
Definition: StatEntity.cpp:244
const double & min() const
minimal value
Definition: StatEntity.h:104
double Sum() const
get sum
Definition: StatEntity.h:376
unsigned long addFlag(const double Flag)
add a flag
Definition: StatEntity.h:412
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:185
GAUDI_API std::ostream & operator<<(std::ostream &stream, const StatEntity &entity)
external printout operator to std::ostream
Definition: StatEntity.cpp:264
void print(string text)
Definition: mergesort.cpp:33
double Rms() const
get rms
Definition: StatEntity.h:382
double RMS() const
get rms
Definition: StatEntity.h:384
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:64
double m_se_maximalFlag
Definition: StatEntity.h:439
GAUDI_API StatEntity operator-(const StatEntity &entity, const double value)
external operator for subtraction of StatEntity and a number
Definition: StatEntity.cpp:254
double flag2() const
accumulated "flag squared"
Definition: StatEntity.h:397
#define GAUDI_API
Definition: Kernel.h:107
STL class.
Helper functions to set/get the application return code.
Definition: __init__.py:1
double flag() const
accumulated "flag"
Definition: StatEntity.h:395
double m_se_accumulatedFlag2
Definition: StatEntity.h:437