Gaudi Framework, version v21r6

Home   Generated: 11 Nov 2009

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 // ============================================================================
00069 class GAUDI_API StatEntity
00070 {
00071 public:
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 () {}
00093 public:
00100   static const std::string& format () ;
00107   static int                size  () ;
00108 public:
00110   unsigned long nEntries           () const { return m_se_nEntries         ; }
00111   // "flag" statistics:
00113   double   flag               () const { return m_se_accumulatedFlag  ; }
00115   double   flag2              () const { return m_se_accumulatedFlag2 ; }
00117   double   flagMean           () const ;
00119   double   flagRMS            () const ;
00121   double   flagMeanErr        () const ;
00123   double   flagMin            () const { return m_se_minimalFlag      ; }
00125   double   flagMax            () const { return m_se_maximalFlag      ; }
00158   double efficiency () const ;
00195   double efficiencyErr () const ;
00197   double eff           () const { return efficiency    () ; }
00199   double effErr        () const { return efficiencyErr () ; }
00219   StatEntity& operator+= ( const double f )
00220   {
00221     addFlag ( f ) ;
00222     return *this ;
00223   }
00241   StatEntity& operator++ ()    { return   (*this)+= 1  ; }
00260   StatEntity& operator++ (int) { return ++(*this)      ; }
00280   StatEntity& operator-= ( const double   f )
00281   {
00282     addFlag ( -f ) ;
00283     return *this ;
00284   }
00302   StatEntity& operator-- () { return (*this)-=1  ; }
00320   StatEntity& operator-- (int) { return --(*this) ; }
00338   StatEntity& operator= ( const double   f )
00339   {
00340     // reset the statistics
00341     reset() ;            
00342     // use the regular inrement
00343     return ((*this)+=f); 
00344   }
00360   StatEntity& operator+= ( const StatEntity& other ) ;
00361 public:
00363   bool operator<( const StatEntity& se ) const ;
00368   unsigned long addFlag ( const double Flag    ) ;
00370   void reset() ;
00372   void setnEntriesBeforeReset ( unsigned long nEntriesBeforeReset );
00374   std::string   toString () const;
00378   std::ostream& print      ( std::ostream& o = std::cout ) const ;
00382   std::ostream& fillStream ( std::ostream& o ) const { return print ( o ) ; }
00383 private:
00385   unsigned long                m_se_nEntries          ;
00387   double                       m_se_accumulatedFlag   ;
00388   double                       m_se_accumulatedFlag2  ;
00389   double                       m_se_minimalFlag       ;
00390   double                       m_se_maximalFlag       ;
00391   // DR number of calls before reset
00392   long                         m_se_nEntriesBeforeReset ;
00393 };
00394 // ============================================================================
00396 GAUDI_API StatEntity operator+( const StatEntity& entity , const double      value  ) ;
00398 GAUDI_API StatEntity operator+( const double      value  , const StatEntity& entity ) ;
00400 GAUDI_API StatEntity operator+( const StatEntity& entity , const StatEntity& value  ) ;
00402 GAUDI_API StatEntity operator-( const StatEntity& entity , const double      value  ) ;
00404 GAUDI_API std::ostream& operator<<( std::ostream& stream , const StatEntity& entity ) ;
00405 // ============================================================================
00406 namespace Gaudi
00407 {
00408   namespace Utils
00409   {
00410     // ========================================================================
00460     GAUDI_API std::string formatAsTableRow
00461     ( const StatEntity&  counter ,
00462       const bool         flag    ,
00463       const std::string& format1 =
00464       " |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |"        ,
00465       const std::string& format2 =
00466       "*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%|   -----   |   -----   |" );
00467     // ========================================================================
00528     GAUDI_API std::string formatAsTableRow
00529     ( const std::string& name           ,
00530       const StatEntity&  counter        ,
00531       const bool         flag    = true ,
00532       const std::string& format1 =
00533       " %|-15.15s|%|17t||%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |"       ,
00534       const std::string& format2 =
00535       "*%|-15.15s|%|17t||%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%|   -----   |   -----   |" );
00536     // ========================================================================
00604     GAUDI_API std::string formatAsTableRow
00605     ( const std::string& name           ,
00606       const std::string& group          ,
00607       const StatEntity&  entity         ,
00608       const bool         flag    = true ,
00609       const std::string& format1 =
00610       " %|15.15s|%|-15.15s|%|32t||%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |"         ,
00611       const std::string& format2 =
00612       "*%|15.15s|%|-15.15s|%|32t||%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%|    -----    |   -----   |" ) ;
00613     // ========================================================================
00614   } // end of namespace Gaudi::Utils
00615 } // end of namespace Gaudi
00616 // ============================================================================
00617 // The END
00618 // ============================================================================
00619 #endif // GAUDIKERNEL_STATENTITY_H
00620 // ============================================================================
00621 
00622 
00623 
00624 
00625 
00626 

Generated at Wed Nov 11 16:23:04 2009 for Gaudi Framework, version v21r6 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004