| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 ;
441 double m_se_accumulatedFlag ;
442 double m_se_accumulatedFlag2 ;
443 double m_se_minimalFlag ;
444 double m_se_maximalFlag ;
445 // DR number of calls before reset
446 long m_se_nEntriesBeforeReset ;
447 // Mutex to protect calls of add/reset/operator++
448 std::mutex m_mutex;
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 // ========================================================================
518 GAUDI_API std::string formatAsTableRow
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 // ========================================================================
586 GAUDI_API std::string formatAsTableRow
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 // ========================================================================
662 GAUDI_API std::string formatAsTableRow
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 // ============================================================================
StatEntity::effErr
double effErr() const
shortcut,
Definition: StatEntity.h:188
StatEntity::max
const double & max() const
maximal value
Definition: StatEntity.h:111
StatEntity::m_se_nEntries
unsigned long m_se_nEntries
number of calls
Definition: StatEntity.h:439
Kernel.h
StatEntity::StatEntity
StatEntity()
the default constructor
Definition: StatEntity.h:70
StatEntity::Min
double Min() const
get minimal value
Definition: StatEntity.h:393
StatEntity::nEntries
const unsigned long & nEntries() const
getters
Definition: StatEntity.h:97
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
StatEntity::Mean
double Mean() const
get mean
Definition: StatEntity.h:383
StatEntity::flagRMS
double flagRMS() const
r.m.s of flag
Definition: StatEntity.h:406
StatEntity::fillStream
std::ostream & fillStream(std::ostream &o) const
printout to std::ostream
Definition: StatEntity.h:376
StatEntity::m_mutex
std::mutex m_mutex
Definition: StatEntity.h:448
sum
double sum(double x, double y, double z)
Definition: 3DoubleFuncTest.cpp:25
GaudiPython.HistoUtils.meanErr
meanErr
Definition: HistoUtils.py:738
StatEntity::flagMin
double flagMin() const
minimal flag
Definition: StatEntity.h:410
StatEntity::m_se_minimalFlag
double m_se_minimalFlag
Definition: StatEntity.h:443
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:367
StatEntity::flagMeanErr
double flagMeanErr() const
error in mean value of flag
Definition: StatEntity.h:408
StatEntity::m_se_nEntriesBeforeReset
long m_se_nEntriesBeforeReset
Definition: StatEntity.h:446
std::mutex
StatEntity::Max
double Max() const
get maximal value
Definition: StatEntity.h:395
StatEntity::sum2
const double & sum2() const
accumulated value**2
Definition: StatEntity.h:101
StatEntity::flagMax
double flagMax() const
maximal flag
Definition: StatEntity.h:412
Gaudi::Utils::formatAsTableRow
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
operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
StatEntity::sum
const double & sum() const
accumulated value
Definition: StatEntity.h:99
std::string
STL class.
StatEntity::eff
double eff() const
shortcut,
Definition: StatEntity.h:186
GaudiPython.Persistency.add
def add(instance)
Definition: Persistency.py:32
GaudiPython.HistoUtils.mean
mean
Definition: HistoUtils.py:737
StatEntity::MeanErr
double MeanErr() const
get error in mean
Definition: StatEntity.h:385
StatEntity::flagMean
double flagMean() const
mean value of flag
Definition: StatEntity.h:404
StatEntity::Eff
double Eff() const
get efficiency
Definition: StatEntity.h:391
StatEntity::m_se_accumulatedFlag
double m_se_accumulatedFlag
accumulated flag
Definition: StatEntity.h:441
operator+
GAUDI_API StatEntity operator+(const StatEntity &entity, const double value)
external operator for addition of StatEntity and a number
Definition: StatEntity.cpp:271
StatEntity::min
const double & min() const
minimal value
Definition: StatEntity.h:109
StatEntity::Sum
double Sum() const
get sum
Definition: StatEntity.h:381
StatEntity::addFlag
unsigned long addFlag(const double Flag)
add a flag
Definition: StatEntity.h:417
operator<
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:185
plotSpeedupsPyRoot.counter
int counter
Definition: plotSpeedupsPyRoot.py:141
operator<<
GAUDI_API std::ostream & operator<<(std::ostream &stream, const StatEntity &entity)
external printout operator to std::ostream
Definition: StatEntity.cpp:291
print
void print(string text)
Definition: mergesort.cpp:33
StatEntity::Rms
double Rms() const
get rms
Definition: StatEntity.h:387
StatEntity::RMS
double RMS() const
get rms
Definition: StatEntity.h:389
StatEntity
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
StatEntity::m_se_maximalFlag
double m_se_maximalFlag
Definition: StatEntity.h:444
operator-
GAUDI_API StatEntity operator-(const StatEntity &entity, const double value)
external operator for subtraction of StatEntity and a number
Definition: StatEntity.cpp:281
StatEntity::flag2
double flag2() const
accumulated "flag squared"
Definition: StatEntity.h:402
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
std::ostream
STL class.
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
StatEntity::flag
double flag() const
accumulated "flag"
Definition: StatEntity.h:400
StatEntity::m_se_accumulatedFlag2
double m_se_accumulatedFlag2
Definition: StatEntity.h:442
GaudiPython.HistoUtils.rms
rms
Definition: HistoUtils.py:739