Gaudi Framework, version v23r2

Home   Generated: Thu Jun 28 2012

StatEntity.h

Go to the documentation of this file.
00001 // $Id: StatEntity.h,v 1.7 2007/08/06 08:39:40 marcocle Exp $
00002 // ============================================================================
00003 // CVS tag $Name:  $, version $Revision: 1.7 $
00004 // ============================================================================
00005 #ifndef   GAUDIKERNEL_STATENTITY_H
00006 #define   GAUDIKERNEL_STATENTITY_H 1
00007 // ============================================================================
00008 // Include files
00009 // ============================================================================
00010 // STD & STL
00011 // ============================================================================
00012 #include <string>
00013 #include <iostream>
00014 // ============================================================================
00015 // Gaudi
00016 // ============================================================================
00017 #include "GaudiKernel/Kernel.h"
00018 // ============================================================================
00068 class GAUDI_API StatEntity
00069 {
00070 public:
00071   // ==========================================================================
00073   StatEntity  () { reset() ; }
00074   /* The full constructor from all important values:
00075    * @attention it need to be coherent with
00076    *            the actual structure of the class
00077    *            and the format description
00078    *  @see StatEntity::format
00079    *  @param entries number of entries
00080    *  @param flag  accumulated flag
00081    *  @param flag2 accumulated statistics: flag**2
00082    *  @param minFlag the minimum value for flag
00083    *  @param maxFlag the maximum value for flag
00084    */
00085   StatEntity ( const unsigned long entries ,
00086                const double        flag    ,
00087                const double        flag2   ,
00088                const double        minFlag ,
00089                const double        maxFlag ) ;
00091   ~StatEntity () {}
00092   // ==========================================================================
00093 public: // the basic quantities
00094   // ==========================================================================
00096   const unsigned long& nEntries () const { return m_se_nEntries         ; }
00098   const double&        sum      () const { return m_se_accumulatedFlag  ; }
00100   const double&        sum2     () const { return m_se_accumulatedFlag2 ; }
00102   double               mean     () const ;
00104   double               rms      () const ;
00106   double               meanErr  () const ;
00108   const double&        min      () const { return m_se_minimalFlag ; }
00110   const double&        max      () const { return m_se_maximalFlag ; }
00111   // ==========================================================================
00112 public:
00113   // ==========================================================================
00146   double efficiency () const ;
00183   double efficiencyErr () const ;
00185   double eff           () const { return efficiency    () ; }
00187   double effErr        () const { return efficiencyErr () ; }
00188   // ==========================================================================
00189 public: // operators
00190   // ==========================================================================
00210   StatEntity& operator+= ( const double f )
00211   {
00212     addFlag ( f ) ;
00213     return *this ;
00214   }
00232   StatEntity& operator++ ()    { return   (*this)+= 1  ; }
00251   StatEntity& operator++ (int) { return ++(*this)      ; }
00271   StatEntity& operator-= ( const double   f )
00272   {
00273     addFlag ( -f ) ;
00274     return *this ;
00275   }
00293   StatEntity& operator-- () { return (*this)-=1  ; }
00311   StatEntity& operator-- (int) { return --(*this) ; }
00329   StatEntity& operator= ( const double   f )
00330   {
00331     // reset the statistics
00332     reset() ;            
00333     // use the regular increment
00334     return ((*this)+=f); 
00335   }
00351   StatEntity& operator+= ( const StatEntity& other ) ;
00352   // ==========================================================================
00353 public:
00354   // ==========================================================================
00356   bool operator<( const StatEntity& se ) const ;
00361   unsigned long add ( const double Flag ) ;
00363   void reset () ;
00365   void setnEntriesBeforeReset ( unsigned long nEntriesBeforeReset );
00367   std::string   toString () const;
00371   std::ostream& print      ( std::ostream& o = std::cout ) const ;
00375   std::ostream& fillStream ( std::ostream& o ) const { return print ( o ) ; }
00376   // ==========================================================================
00377 public: // aliases (a'la ROOT)
00378   // ==========================================================================
00380   inline double Sum     () const { return sum     () ; } // get sum
00382   inline double Mean    () const { return mean    () ; } // get mean
00384   inline double MeanErr () const { return meanErr () ; } // get error in mean
00386   inline double Rms     () const { return rms     () ; } // get rms
00388   inline double RMS     () const { return rms     () ; } // get rms
00390   inline double Eff     () const { return eff     () ; } // get efficiency
00392   inline double Min     () const { return min     () ; } // get minimal value
00394   inline double Max     () const { return max     () ; } // get maximal value
00395   // ==========================================================================
00396 public: // some legacy methods, to be removed ...
00397   // ==========================================================================
00399   inline double   flag               () const { return sum     () ; }
00401   inline double   flag2              () const { return sum2    () ; }
00403   inline double   flagMean           () const { return mean    () ; }
00405   inline double   flagRMS            () const { return rms     () ; }
00407   inline double   flagMeanErr        () const { return meanErr () ; }
00409   inline double   flagMin            () const { return min     () ; }
00411   inline double   flagMax            () const { return max     () ; }
00416   inline unsigned long addFlag ( const double Flag ) { return add ( Flag ) ; }
00417   // ==========================================================================
00418 public:
00419   // ==========================================================================
00426   static const std::string& format () ;
00433   static int                size  () ;
00434   // ==========================================================================
00435 private:
00436   // ==========================================================================
00438   unsigned long                m_se_nEntries          ;
00440   double                       m_se_accumulatedFlag   ;
00441   double                       m_se_accumulatedFlag2  ;
00442   double                       m_se_minimalFlag       ;
00443   double                       m_se_maximalFlag       ;
00444   // DR number of calls before reset
00445   long                         m_se_nEntriesBeforeReset ;
00446   // ==========================================================================
00447 };
00448 // ============================================================================
00450 GAUDI_API StatEntity operator+( const StatEntity& entity , const double      value  ) ;
00452 GAUDI_API StatEntity operator+( const double      value  , const StatEntity& entity ) ;
00454 GAUDI_API StatEntity operator+( const StatEntity& entity , const StatEntity& value  ) ;
00456 GAUDI_API StatEntity operator-( const StatEntity& entity , const double      value  ) ;
00458 GAUDI_API std::ostream& operator<<( std::ostream& stream , const StatEntity& entity ) ;
00459 // ============================================================================
00460 namespace Gaudi
00461 {
00462   // ==========================================================================
00463   namespace Utils
00464   {
00465     // ========================================================================
00515     GAUDI_API std::string formatAsTableRow
00516     ( const StatEntity&  counter ,
00517       const bool         flag    ,
00518       const std::string& format1 =
00519       " |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |"        ,
00520       const std::string& format2 =
00521       "*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%|   -----   |   -----   |" );
00522     // ========================================================================
00583     GAUDI_API std::string formatAsTableRow
00584     ( const std::string& name           ,
00585       const StatEntity&  counter        ,
00586       const bool         flag    = true ,
00587       const std::string& format1 =
00588       " %|-15.15s|%|17t||%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |"       ,
00589       const std::string& format2 =
00590       "*%|-15.15s|%|17t||%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%|   -----   |   -----   |" );
00591     // ========================================================================
00659     GAUDI_API std::string formatAsTableRow
00660     ( const std::string& name           ,
00661       const std::string& group          ,
00662       const StatEntity&  entity         ,
00663       const bool         flag    = true ,
00664       const std::string& format1 =
00665       " %|15.15s|%|-15.15s|%|32t||%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |"         ,
00666       const std::string& format2 =
00667       "*%|15.15s|%|-15.15s|%|32t||%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%|    -----    |   -----   |" ) ;
00668     // ========================================================================
00669   } //                                            end of namespace Gaudi::Utils
00670   // ==========================================================================
00671 } //                                                     end of namespace Gaudi
00672 // ============================================================================
00673 // The END
00674 // ============================================================================
00675 #endif // GAUDIKERNEL_STATENTITY_H
00676 // ============================================================================
00677 
00678 
00679 
00680 
00681 
00682 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Thu Jun 28 2012 23:27:23 for Gaudi Framework, version v23r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004