All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HistoTableFormat.h
Go to the documentation of this file.
1 // $Id: HistoTableFormat.h,v 1.3 2007/11/16 15:29:02 hmd Exp $
2 // ============================================================================
3 #ifndef GAUDIUTILS_HISTOTABLEFORMAT_H
4 #define GAUDIUTILS_HISTOTABLEFORMAT_H 1
5 // ============================================================================
6 // Include files
7 // ============================================================================
8 #include "GaudiKernel/Kernel.h"
9 // ============================================================================
10 // forward declarations
11 // ============================================================================
12 namespace AIDA
13 {
14  class IHistogram1D ;
15  class IBaseHistogram ;
16 }
17 // ============================================================================
18 namespace Gaudi
19 {
20  namespace Utils
21  {
22  // ========================================================================
29  namespace Histos
30  {
31  // ======================================================================
73  namespace Formats
74  {
75  // ====================================================================
90  enum Format
91  {
92  Default = 0 , // default format
93  Old , // "OLD"-line format: title,integral,#ent,mean,rms
94  Full , // FULL format: the first 15 positions
95  FullStat , // Full statistical info (3-15)
96  Stat , // title,#ent,mean,rms,skewness&kurtosis
97  StatOnly , // #entries,mean,rms,skewness&kurtosis
98  Stat1 , // #entries,mean+-,rms+-,skewness+-&kurtosis+-
99  ShapeOnly , // mean,rms,skewness,kurtosis,underflow&overflow fractions
100  Shape , // as ShapeOnly but with errors
101  LineTitle , // line-format : title,mean,rms,skewness&kurtosis
102  LineOnly , // line-format : mean,rms,skewness&kurtosis
103  PathTitle // "PathTitle" : path & title
104  } ;
105  // ====================================================================
113  GAUDI_API std::string format ( const int ID = Default ) ;
114  // ====================================================================
122  GAUDI_API std::string header ( const int ID = Default ) ;
123  // ====================================================================
124  } // end of namespace Gaudi::Utils::Histos::Formats
125  // ======================================================================
130  GAUDI_API std::string path ( const AIDA::IBaseHistogram* aida ) ;
131  // ======================================================================
170  GAUDI_API std::string format
171  ( const AIDA::IHistogram1D* histo ,
172  const std::string& fmt ) ;
173  // ======================================================================
202  GAUDI_API std::string format
203  ( const AIDA::IHistogram1D* histo ,
204  const std::string& ID ,
205  const std::string& fmt1 ,
206  const std::string& fmt2 ) ;
207  // ========================================================================
231  template <class HISTO, class STREAM, class TERMINATOR>
232  inline STREAM& printList
233  ( HISTO first ,
234  HISTO last ,
235  const std::string& fmt ,
236  STREAM& stream ,
237  TERMINATOR term )
238  {
239  for ( ; first != last ; ++first )
240  { stream << format ( *first , fmt ) << term ; } // print table rows
241  return stream ; // RETURN
242  }
243  // ======================================================================
267  template <class LIST, class STREAM, class TERMINATOR>
268  inline STREAM& printList
269  ( const LIST& histos ,
270  const std::string& fmt ,
271  STREAM& stream ,
272  TERMINATOR term )
273  {
274  return printList
275  ( histos.begin () , histos.end () , fmt , stream , term ) ;
276  }
277  // ======================================================================
322  template <class HISTO, class STREAM, class TERMINATOR>
323  inline STREAM& printMap
324  ( HISTO begin ,
325  HISTO end ,
326  const std::string& fmt1 ,
327  const std::string& fmt2 ,
328  STREAM& stream ,
329  TERMINATOR term )
330  {
331  for ( ; begin != end ; ++begin )
332  {
333  stream << format
334  ( begin -> second , // the histogram
335  begin -> first , // the key
336  fmt1 , fmt2 ) << term ;
337  }
338  return stream ;
339  }
340  // ======================================================================
383  template <class MAP, class STREAM, class TERMINATOR>
384  inline STREAM& printMap
385  ( const MAP& histos ,
386  const std::string& fmt1 ,
387  const std::string& fmt2 ,
388  STREAM& stream ,
389  TERMINATOR term )
390  {
391  return printMap
392  ( histos.begin () , histos.end() , fmt1 , fmt2 , stream , term ) ;
393  }
394  // ======================================================================
399  GAUDI_API std::string format
400  ( const std::string& val1 ,
401  const std::string& val2 ,
402  const std::string& fmt ) ;
403  // ======================================================================
410  // ========================================================================
412  {
413  public:
415  Table ( const int ID = 0 ) ;
417  Table
418  ( const std::string& format ,
419  const std::string& header = "" ,
420  const std::string& footer = "" ) ;
421  public:
422  // ======================================================================
429  template <class HISTO, class STREAM, class TERMINATOR>
430  STREAM& printList
431  ( HISTO first ,
432  HISTO last ,
433  STREAM& stream ,
434  TERMINATOR term ) const
435  {
436  if ( !header().empty() ) { stream << header () << term ; }
437  Gaudi::Utils::Histos::printList ( first , last , format() , stream , term ) ;
438  if ( !footer().empty() ) { stream << footer () << term ; }
439  return stream ;
440  }
441  // ======================================================================
442  public:
455  template <class HISTO, class STREAM, class TERMINATOR>
456  STREAM& printMap
457  ( HISTO first ,
458  HISTO last ,
459  const std::string& fmt ,
460  const std::string& hval ,
461  STREAM& stream ,
462  TERMINATOR term ) const
463  {
464  if ( !hval.empty() || !header().empty() )
465  { stream << Gaudi::Utils::Histos::format ( hval , header() , fmt ) << term ; }
467  ( first , last , fmt , format() , stream , term ) ;
468  }
469  // ======================================================================
470  public:
471  // ======================================================================
473  const std::string& header () const { return m_header ; }
474  // ======================================================================
476  const std::string& footer () const { return m_footer ; }
477  // ======================================================================
479  const std::string& format () const { return m_format ; }
480  // ======================================================================
481  public:
482  // ======================================================================
484  void setHeader ( const std::string& v ) { m_header = v ; }
485  // ======================================================================
487  void setFooter ( const std::string& v ) { m_footer = v ; }
488  // ======================================================================
490  void setFormat ( const std::string& v ) { m_format = v ; }
491  // ======================================================================
492  public :
493  // ======================================================================
495  std::string toString ( const AIDA::IHistogram1D* histo ) const ;
496  // ======================================================================
497  public:
498  // ======================================================================
522  std::string toString
523  ( const AIDA::IHistogram1D* histo ,
524  const std::string& ID ,
525  const std::string& fmt ) const ;
526  // ======================================================================
527  public:
528  // the table header
529  std::string m_header ;
530  // the table footer
531  std::string m_footer ;
532  // the default format
533  std::string m_format ;
534  //
535  } ;
536  } // end of namespace Gaudi::Utils::Histos
537  } // end of namespace Gaudi::Utils
538 } // end of namespace Gaudi
539 // ============================================================================
540 // The END
541 // ============================================================================
542 #endif // GAUDIUTILS_HISTOTABLEFORMAT_H
543 // ============================================================================
STREAM & printMap(HISTO begin, HISTO end, const std::string &fmt1, const std::string &fmt2, STREAM &stream, TERMINATOR term)
Print the "associative sequence" (e.g.
void setFooter(const std::string &v)
set new footer
void setFormat(const std::string &v)
set new format
std::string m_header
the table header
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:367
GAUDI_API std::string format(const AIDA::IHistogram1D *histo, const std::string &fmt)
Make the string representation of the historgam according to the specified format.
GAUDI_API std::string header(const int ID=Default)
get the recommended header by enum
const std::string & header() const
the table header
void setHeader(const std::string &v)
set new header
GAUDI_API std::string format(const int ID=Default)
get the format by enum
const std::string & format() const
the format
Simple class for the customizeble printout of the histogram tables.
std::string m_footer
the table footer
tuple end
Definition: IOTest.py:101
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
STREAM & printList(HISTO first, HISTO last, const std::string &fmt, STREAM &stream, TERMINATOR term)
print the simple sequence (list-like) of histograms as table
Format
the ID for predefined formats
This is a number of static methods for bootstrapping the Gaudi framework.
Definition: Bootstrap.h:15
#define GAUDI_API
Definition: Kernel.h:108
std::string m_format
the defautl format
const std::string & footer() const
the table footer