Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v28r2p1 (f1a77ff4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 #include <mutex>
11 // ============================================================================
12 // Gaudi
13 // ============================================================================
14 #include "GaudiKernel/Kernel.h"
15 // ============================================================================
65 class GAUDI_API StatEntity final
66 {
67 public:
68  // ==========================================================================
70  StatEntity () { reset() ; }
71  /* The full constructor from all important values:
72  * @attention it need to be coherent with
73  * the actual structure of the class
74  * and the format description
75  * @see StatEntity::format
76  * @param entries number of entries
77  * @param flag accumulated flag
78  * @param flag2 accumulated statistics: flag**2
79  * @param minFlag the minimum value for flag
80  * @param maxFlag the maximum value for flag
81  */
82  StatEntity ( const unsigned long entries ,
83  const double flag ,
84  const double flag2 ,
85  const double minFlag ,
86  const double maxFlag ) ;
88  StatEntity ( const StatEntity& );
90  StatEntity& operator= ( const StatEntity& );
92  ~StatEntity () = default;
93  // ==========================================================================
94 public: // the basic quantities
95  // ==========================================================================
97  const unsigned long& nEntries () const { return m_se_nEntries ; }
99  const double& sum () const { return m_se_accumulatedFlag ; }
101  const double& sum2 () const { return m_se_accumulatedFlag2 ; }
103  double mean () const ;
105  double rms () const ;
107  double meanErr () const ;
109  const double& min () const { return m_se_minimalFlag ; }
111  const double& max () const { return m_se_maximalFlag ; }
112  // ==========================================================================
113 public:
114  // ==========================================================================
147  double efficiency () const ;
184  double efficiencyErr () const ;
186  double eff () const { return efficiency () ; }
188  double effErr () const { return efficiencyErr () ; }
189  // ==========================================================================
190 public: // operators
191  // ==========================================================================
211  StatEntity& operator+= ( const double f )
212  {
213  addFlag ( f ) ;
214  return *this ;
215  }
233  StatEntity& operator++ () { return (*this)+= 1 ; }
252  StatEntity& operator++ (int) { return ++(*this) ; }
272  StatEntity& operator-= ( const double f )
273  {
274  addFlag ( -f ) ;
275  return *this ;
276  }
294  StatEntity& operator-- () { return (*this)-=1 ; }
312  StatEntity& operator-- (int) { return --(*this) ; }
330  StatEntity& operator= ( const double f )
331  {
332  // reset the statistics
333  reset() ;
334  // use the regular increment
335  return ((*this)+=f);
336  }
352  StatEntity& operator+= ( const StatEntity& other ) ;
353  // ==========================================================================
354 public:
355  // ==========================================================================
357  bool operator<( const StatEntity& se ) const ;
362  unsigned long add ( const double Flag ) ;
364  void reset () ;
366  void setnEntriesBeforeReset ( unsigned long nEntriesBeforeReset );
368  std::string toString () const;
372  std::ostream& print ( std::ostream& o = std::cout ) const ;
376  std::ostream& fillStream ( std::ostream& o ) const { return print ( o ) ; }
377  // ==========================================================================
378 public: // aliases (a'la ROOT)
379  // ==========================================================================
381  inline double Sum () const { return sum () ; } // get sum
383  inline double Mean () const { return mean () ; } // get mean
385  inline double MeanErr () const { return meanErr () ; } // get error in mean
387  inline double Rms () const { return rms () ; } // get rms
389  inline double RMS () const { return rms () ; } // get rms
391  inline double Eff () const { return eff () ; } // get efficiency
393  inline double Min () const { return min () ; } // get minimal value
395  inline double Max () const { return max () ; } // get maximal value
396  // ==========================================================================
397 public: // some legacy methods, to be removed ...
398  // ==========================================================================
400  inline double flag () const { return sum () ; }
402  inline double flag2 () const { return sum2 () ; }
404  inline double flagMean () const { return mean () ; }
406  inline double flagRMS () const { return rms () ; }
408  inline double flagMeanErr () const { return meanErr () ; }
410  inline double flagMin () const { return min () ; }
412  inline double flagMax () const { return max () ; }
417  inline unsigned long addFlag ( const double Flag ) { return add ( Flag ) ; }
418  // ==========================================================================
419 public:
420  // ==========================================================================
427  static const std::string& format () ;
434  static int size () ;
435  // ==========================================================================
436 private:
437  // ==========================================================================
439  unsigned long m_se_nEntries ;
445  // DR number of calls before reset
447  // Mutex to protect calls of add/reset/operator++
449  // ==========================================================================
450 };
451 // ============================================================================
453 GAUDI_API StatEntity operator+( const StatEntity& entity , const double value ) ;
455 GAUDI_API StatEntity operator+( const double value , const StatEntity& entity ) ;
457 GAUDI_API StatEntity operator+( const StatEntity& entity , const StatEntity& value ) ;
459 GAUDI_API StatEntity operator-( const StatEntity& entity , const double value ) ;
461 GAUDI_API std::ostream& operator<<( std::ostream& stream , const StatEntity& entity ) ;
462 // ============================================================================
463 namespace Gaudi
464 {
465  // ==========================================================================
466  namespace Utils
467  {
468  // ========================================================================
519  ( const StatEntity& counter ,
520  const bool flag ,
521  const std::string& format1 =
522  " |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |" ,
523  const std::string& format2 =
524  "*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |" );
525  // ========================================================================
587  ( const std::string& name ,
588  const StatEntity& counter ,
589  const bool flag = true ,
590  const std::string& format1 =
591  " %|-15.15s|%|17t||%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |" ,
592  const std::string& format2 =
593  "*%|-15.15s|%|17t||%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |" );
594  // ========================================================================
663  ( const std::string& name ,
664  const std::string& group ,
665  const StatEntity& entity ,
666  const bool flag = true ,
667  const std::string& format1 =
668  " %|15.15s|%|-15.15s|%|32t||%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |" ,
669  const std::string& format2 =
670  "*%|15.15s|%|-15.15s|%|32t||%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |" ) ;
671  // ========================================================================
672  } // end of namespace Gaudi::Utils
673  // ==========================================================================
674 } // end of namespace Gaudi
675 // ============================================================================
676 // The END
677 // ============================================================================
678 #endif // GAUDIKERNEL_STATENTITY_H
679 // ============================================================================
double effErr() const
shortcut,
Definition: StatEntity.h:188
const double & max() const
maximal value
Definition: StatEntity.h:111
unsigned long m_se_nEntries
number of calls
Definition: StatEntity.h:439
StatEntity()
the default constructor
Definition: StatEntity.h:70
double Min() const
get minimal value
Definition: StatEntity.h:393
const unsigned long & nEntries() const
getters
Definition: StatEntity.h:97
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:383
double flagRMS() const
r.m.s of flag
Definition: StatEntity.h:406
std::ostream & fillStream(std::ostream &o) const
printout to std::ostream
Definition: StatEntity.h:376
std::mutex m_mutex
Definition: StatEntity.h:448
double sum(double x, double y, double z)
double flagMin() const
minimal flag
Definition: StatEntity.h:410
double m_se_minimalFlag
Definition: StatEntity.h:443
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:408
long m_se_nEntriesBeforeReset
Definition: StatEntity.h:446
double Max() const
get maximal value
Definition: StatEntity.h:395
const double & sum2() const
accumulated value**2
Definition: StatEntity.h:101
double flagMax() const
maximal flag
Definition: StatEntity.h:412
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:408
PropertyMgr & operator=(const PropertyMgr &)=delete
const double & sum() const
accumulated value
Definition: StatEntity.h:99
STL class.
double eff() const
shortcut,
Definition: StatEntity.h:186
double MeanErr() const
get error in mean
Definition: StatEntity.h:385
double flagMean() const
mean value of flag
Definition: StatEntity.h:404
double Eff() const
get efficiency
Definition: StatEntity.h:391
double m_se_accumulatedFlag
accumulated flag
Definition: StatEntity.h:441
GAUDI_API StatEntity operator+(const StatEntity &entity, const double value)
external operator for addition of StatEntity and a number
Definition: StatEntity.cpp:271
const double & min() const
minimal value
Definition: StatEntity.h:109
double Sum() const
get sum
Definition: StatEntity.h:381
unsigned long addFlag(const double Flag)
add a flag
Definition: StatEntity.h:417
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:291
void print(string text)
Definition: mergesort.cpp:33
double Rms() const
get rms
Definition: StatEntity.h:387
double RMS() const
get rms
Definition: StatEntity.h:389
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
double m_se_maximalFlag
Definition: StatEntity.h:444
GAUDI_API StatEntity operator-(const StatEntity &entity, const double value)
external operator for subtraction of StatEntity and a number
Definition: StatEntity.cpp:281
double flag2() const
accumulated "flag squared"
Definition: StatEntity.h:402
#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:400
double m_se_accumulatedFlag2
Definition: StatEntity.h:442