Gaudi Framework, version v23r4

Home   Generated: Mon Sep 17 2012

HistoTableFormat.h

Go to the documentation of this file.
00001 // $Id: HistoTableFormat.h,v 1.3 2007/11/16 15:29:02 hmd Exp $
00002 // ============================================================================
00003 #ifndef GAUDIUTILS_HISTOTABLEFORMAT_H
00004 #define GAUDIUTILS_HISTOTABLEFORMAT_H 1
00005 // ============================================================================
00006 // Include files
00007 // ============================================================================
00008 #include "GaudiKernel/Kernel.h"
00009 // ============================================================================
00010 // forward declarations
00011 // ============================================================================
00012 namespace AIDA
00013 {
00014   class IHistogram1D   ;
00015   class IBaseHistogram ;
00016 }
00017 // ============================================================================
00018 namespace Gaudi
00019 {
00020   namespace Utils
00021   {
00022     // ========================================================================
00029     namespace Histos
00030     {
00031       // ======================================================================
00073       namespace Formats
00074       {
00075         // ====================================================================
00090         enum Format
00091           {
00092             Default = 0 , // default format
00093             Old         , // "OLD"-line format: title,integral,#ent,mean,rms
00094             Full        , // FULL format: the first 15 positions
00095             FullStat    , // Full statistical info (3-15)
00096             Stat        , // title,#ent,mean,rms,skewness&kurtosis
00097             StatOnly    , // #entries,mean,rms,skewness&kurtosis
00098             Stat1       , // #entries,mean+-,rms+-,skewness+-&kurtosis+-
00099             ShapeOnly   , // mean,rms,skewness,kurtosis,underflow&overflow fractions
00100             Shape       , // as ShapeOnly but with errors 
00101             LineTitle   , // line-format : title,mean,rms,skewness&kurtosis
00102             LineOnly    , // line-format : mean,rms,skewness&kurtosis
00103             PathTitle     // "PathTitle" : path & title
00104           } ;
00105         // ====================================================================
00113         GAUDI_API std::string format ( const int ID = Default ) ;
00114         // ====================================================================
00122         GAUDI_API std::string header ( const int ID = Default ) ;
00123         // ====================================================================
00124       } // end of namespace Gaudi::Utils::Histos::Formats
00125       // ======================================================================
00130       GAUDI_API std::string path ( const AIDA::IBaseHistogram* aida ) ;
00131       // ======================================================================
00170       GAUDI_API std::string format
00171       ( const AIDA::IHistogram1D* histo  ,
00172         const std::string&        fmt    ) ;
00173       // ======================================================================
00202       GAUDI_API std::string format
00203       ( const AIDA::IHistogram1D* histo  ,
00204         const std::string&        ID     ,
00205         const std::string&        fmt1   ,
00206         const std::string&        fmt2   ) ;
00207       // ========================================================================
00231       template <class HISTO, class STREAM, class TERMINATOR>
00232       inline STREAM& printList
00233       ( HISTO              first  ,
00234         HISTO              last   ,
00235         const std::string& fmt    ,
00236         STREAM&            stream ,
00237         TERMINATOR         term   )
00238       {
00239         for ( ; first != last ; ++first )
00240         { stream << format   ( *first , fmt ) << term ; }  // print table rows
00241         return stream ;                                    // RETURN
00242       }
00243       // ======================================================================
00267       template <class LIST, class STREAM, class TERMINATOR>
00268       inline STREAM& printList
00269       ( const LIST&        histos ,
00270         const std::string& fmt    ,
00271         STREAM&            stream ,
00272         TERMINATOR         term   )
00273       {
00274         return printList
00275           ( histos.begin () , histos.end  () , fmt , stream , term ) ;
00276       }
00277       // ======================================================================
00322       template <class HISTO, class STREAM, class TERMINATOR>
00323       inline STREAM& printMap
00324       ( HISTO              begin  ,
00325         HISTO              end    ,
00326         const std::string& fmt1   ,
00327         const std::string& fmt2   ,
00328         STREAM&            stream ,
00329         TERMINATOR         term   )
00330       {
00331         for ( ; begin != end ; ++begin )
00332         {
00333           stream << format
00334             ( begin -> second , // the histogram
00335               begin -> first  , // the key
00336               fmt1  ,  fmt2   ) << term ;
00337         }
00338         return stream ;
00339       }
00340       // ======================================================================
00383       template <class MAP, class STREAM, class TERMINATOR>
00384       inline STREAM& printMap
00385       ( const MAP&         histos ,
00386         const std::string& fmt1   ,
00387         const std::string& fmt2   ,
00388         STREAM&            stream ,
00389         TERMINATOR         term   )
00390       {
00391         return printMap
00392           ( histos.begin () , histos.end() , fmt1 , fmt2 , stream , term ) ;
00393       }
00394       // ======================================================================
00399       GAUDI_API std::string format
00400       ( const std::string& val1 ,
00401         const std::string& val2 ,
00402         const std::string& fmt  ) ;
00403       // ======================================================================
00410       // ========================================================================
00411       class GAUDI_API Table
00412       {
00413       public:
00415         Table  ( const int ID  = 0 ) ;
00417         Table
00418         ( const std::string& format      ,
00419           const std::string& header = "" ,
00420           const std::string& footer = "" ) ;
00421       public:
00422         // ======================================================================
00429         template <class HISTO, class STREAM, class TERMINATOR>
00430         STREAM& printList
00431         ( HISTO              first  ,
00432           HISTO              last   ,
00433           STREAM&            stream ,
00434           TERMINATOR         term   ) const
00435         {
00436           if ( !header().empty() ) { stream << header () << term ; }
00437           Gaudi::Utils::Histos::printList ( first , last , format() , stream , term ) ;
00438           if ( !footer().empty() ) { stream << footer () << term ; }
00439           return stream ;
00440         }
00441         // ======================================================================
00442       public:
00455         template <class HISTO, class STREAM, class TERMINATOR>
00456         STREAM& printMap
00457         ( HISTO              first  ,
00458           HISTO              last   ,
00459           const std::string& fmt    ,
00460           const std::string& hval   ,
00461           STREAM&            stream ,
00462           TERMINATOR         term   ) const
00463         {
00464           if ( !hval.empty() || !header().empty() )
00465           { stream << Gaudi::Utils::Histos::format ( hval , header() , fmt ) << term ; }
00466           return Gaudi::Utils::Histos::printMap
00467             ( first , last , fmt , format() , stream , term ) ;
00468         }
00469         // ======================================================================
00470       public:
00471         // ======================================================================
00473         const std::string& header () const { return m_header ; }
00474         // ======================================================================
00476         const std::string& footer () const { return m_footer ; }
00477         // ======================================================================
00479         const std::string& format () const { return m_format ; }
00480         // ======================================================================
00481       public:
00482         // ======================================================================
00484         void setHeader ( const std::string& v ) { m_header = v ; }
00485         // ======================================================================
00487         void setFooter ( const std::string& v ) { m_footer = v ; }
00488         // ======================================================================
00490         void setFormat ( const std::string& v ) { m_format = v ; }
00491         // ======================================================================
00492       public :
00493         // ======================================================================
00495         std::string toString ( const AIDA::IHistogram1D* histo  ) const ;
00496         // ======================================================================
00497       public:
00498         // ======================================================================
00522         std::string toString
00523         ( const AIDA::IHistogram1D* histo  ,
00524           const std::string&        ID     ,
00525           const std::string&        fmt    ) const ;
00526         // ======================================================================
00527       public:
00528         // the table header
00529         std::string m_header ; 
00530         // the table footer
00531         std::string m_footer ; 
00532         // the default format
00533         std::string m_format ; 
00534         //
00535       } ;
00536     } // end of namespace Gaudi::Utils::Histos
00537   } // end of namespace Gaudi::Utils
00538 } // end of namespace Gaudi
00539 // ============================================================================
00540 // The END
00541 // ============================================================================
00542 #endif // GAUDIUTILS_HISTOTABLEFORMAT_H
00543 // ============================================================================
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Sep 17 2012 13:49:37 for Gaudi Framework, version v23r4 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004