Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HistoTableFormat.h
Go to the documentation of this file.
1 #ifndef GAUDIUTILS_HISTOTABLEFORMAT_H
2 #define GAUDIUTILS_HISTOTABLEFORMAT_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 #include "GaudiKernel/Kernel.h"
7 #include <string>
8 // ============================================================================
9 // forward declarations
10 // ============================================================================
11 namespace AIDA {
12  class IHistogram1D;
13  class IProfile1D;
14  class IBaseHistogram;
15 } // namespace AIDA
16 // ============================================================================
17 namespace Gaudi {
18  namespace Utils {
19  // ========================================================================
26  namespace Histos {
27  // ======================================================================
69  namespace Formats {
70  // ====================================================================
85  enum Format {
86  Default = 0, // default format
87  Old, // "OLD"-line format: title,integral,#ent,mean,rms
88  Full, // FULL format: the first 15 positions
89  FullStat, // Full statistical info (3-15)
90  Stat, // title,#ent,mean,rms,skewness&kurtosis
91  StatOnly, // #entries,mean,rms,skewness&kurtosis
92  Stat1, // #entries,mean+-,rms+-,skewness+-&kurtosis+-
93  ShapeOnly, // mean,rms,skewness,kurtosis,underflow&overflow fractions
94  Shape, // as ShapeOnly but with errors
95  LineTitle, // line-format : title,mean,rms,skewness&kurtosis
96  LineOnly, // line-format : mean,rms,skewness&kurtosis
97  PathTitle // "PathTitle" : path & title
98  };
99  // ====================================================================
107  GAUDI_API std::string format( const int ID = Default );
108  // ====================================================================
116  GAUDI_API std::string header( const int ID = Default );
117  // ====================================================================
118  } // namespace Formats
119  // ======================================================================
124  GAUDI_API std::string path( const AIDA::IBaseHistogram* aida );
125  // ======================================================================
164  GAUDI_API std::string format( const AIDA::IHistogram1D* histo, const std::string& fmt );
165  // ======================================================================
189  GAUDI_API std::string format( const AIDA::IProfile1D* histo, const std::string& fmt );
190  // ======================================================================
219  GAUDI_API std::string format( const AIDA::IHistogram1D* histo, const std::string& ID, const std::string& fmt1,
220  const std::string& fmt2 );
221  // ======================================================================
250  GAUDI_API std::string format( const AIDA::IProfile1D* histo, const std::string& ID, const std::string& fmt1,
251  const std::string& fmt2 );
252  // ========================================================================
276  template <class HISTO, class STREAM, class TERMINATOR>
277  inline STREAM& printList( HISTO first, HISTO last, const std::string& fmt, STREAM& stream, TERMINATOR term ) {
278  for ( ; first != last; ++first ) { stream << format( *first, fmt ) << term; } // print table rows
279  return stream; // RETURN
280  }
281  // ======================================================================
305  template <class LIST, class STREAM, class TERMINATOR>
306  inline STREAM& printList( const LIST& histos, const std::string& fmt, STREAM& stream, TERMINATOR term ) {
307  return printList( histos.begin(), histos.end(), fmt, stream, term );
308  }
309  // ======================================================================
354  template <class HISTO, class STREAM, class TERMINATOR>
355  inline STREAM& printMap( HISTO begin, HISTO end, const std::string& fmt1, const std::string& fmt2, STREAM& stream,
356  TERMINATOR term ) {
357  for ( ; begin != end; ++begin ) {
358  stream << format( begin->second, // the histogram
359  begin->first, // the key
360  fmt1, fmt2 )
361  << term;
362  }
363  return stream;
364  }
365  // ======================================================================
408  template <class MAP, class STREAM, class TERMINATOR>
409  inline STREAM& printMap( const MAP& histos, const std::string& fmt1, const std::string& fmt2, STREAM& stream,
410  TERMINATOR term ) {
411  return printMap( histos.begin(), histos.end(), fmt1, fmt2, stream, term );
412  }
413  // ======================================================================
418  GAUDI_API std::string format( const std::string& val1, const std::string& val2, const std::string& fmt );
419  // ======================================================================
426  // ========================================================================
427  class GAUDI_API Table {
428  public:
430  Table( const int ID = 0 );
432  Table( const std::string& format, const std::string& header = "", const std::string& footer = "" );
433 
434  public:
435  // ======================================================================
442  template <class HISTO, class STREAM, class TERMINATOR>
443  STREAM& printList( HISTO first, HISTO last, STREAM& stream, TERMINATOR term ) const {
444  if ( !header().empty() ) { stream << header() << term; }
445  Gaudi::Utils::Histos::printList( first, last, format(), stream, term );
446  if ( !footer().empty() ) { stream << footer() << term; }
447  return stream;
448  }
449  // ======================================================================
450  public:
463  template <class HISTO, class STREAM, class TERMINATOR>
464  STREAM& printMap( HISTO first, HISTO last, const std::string& fmt, const std::string& hval, STREAM& stream,
465  TERMINATOR term ) const {
466  if ( !hval.empty() || !header().empty() ) {
467  stream << Gaudi::Utils::Histos::format( hval, header(), fmt ) << term;
468  }
469  return Gaudi::Utils::Histos::printMap( first, last, fmt, format(), stream, term );
470  }
471  // ======================================================================
472  public:
473  // ======================================================================
475  const std::string& header() const { return m_header; }
476  // ======================================================================
478  const std::string& footer() const { return m_footer; }
479  // ======================================================================
481  const std::string& format() const { return m_format; }
482  // ======================================================================
483  public:
484  // ======================================================================
486  void setHeader( std::string v ) { m_header = std::move( v ); }
487  // ======================================================================
489  void setFooter( std::string v ) { m_footer = std::move( v ); }
490  // ======================================================================
492  void setFormat( std::string v ) { m_format = std::move( v ); }
493  // ======================================================================
494  public:
495  // ======================================================================
497  std::string toString( const AIDA::IHistogram1D* histo ) const;
498  // ======================================================================
500  std::string toString( const AIDA::IProfile1D* histo ) const;
501  // ======================================================================
502  public:
503  // ======================================================================
527  std::string toString( const AIDA::IHistogram1D* histo, const std::string& ID, const std::string& fmt ) const;
551  std::string toString( const AIDA::IProfile1D* histo, const std::string& ID, const std::string& fmt ) const;
552  // ======================================================================
553  public:
554  // the table header
556  // the table footer
558  // the default format
560  //
561  };
562  } // namespace Histos
563  } // namespace Utils
564 } // end of namespace Gaudi
565 // ============================================================================
566 // The END
567 // ============================================================================
568 #endif // GAUDIUTILS_HISTOTABLEFORMAT_H
helper namespace to collect useful definitions, types, constants and functions, related to manipulati...
STREAM & printMap(HISTO begin, HISTO end, const std::string &fmt1, const std::string &fmt2, STREAM &stream, TERMINATOR term)
Print the "associative sequence" (e.g.
T empty(T...args)
STREAM & printMap(const MAP &histos, const std::string &fmt1, const std::string &fmt2, STREAM &stream, TERMINATOR term)
Print the "associative sequence" (e.g.
std::string m_header
the table header
void setHeader(std::string v)
set new header
GAUDI_API std::string format(const AIDA::IHistogram1D *histo, const std::string &fmt)
Make the string representation of the histogram according to the specified format.
STREAM & printMap(HISTO first, HISTO last, const std::string &fmt, const std::string &hval, STREAM &stream, TERMINATOR term) const
print as table the content of the accociative map (key->histogram) with the key, convertible to std::...
void setFormat(std::string v)
set new format
GAUDI_API std::string header(const int ID=Default)
get the recommended header by enum
GaudiKernel.
Definition: Fill.h:10
const std::string & header() const
the table header
STL class.
GAUDI_API std::string format(const std::string &val1, const std::string &val2, const std::string &fmt)
helper method to merge the headers for short format table
STREAM & printList(HISTO first, HISTO last, STREAM &stream, TERMINATOR term) const
print the simple sequence of histograms as table
const std::string & format() const
the format
Simple class for the customizeble printout of the histogram tables.
std::string m_footer
the table footer
T move(T...args)
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
void setFooter(std::string v)
set new footer
STREAM & printList(HISTO first, HISTO last, const std::string &fmt, STREAM &stream, TERMINATOR term)
print the simple sequence (list-like) of histograms as table
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Format
the ID for predefined formats
#define GAUDI_API
Definition: Kernel.h:71
Helper functions to set/get the application return code.
Definition: __init__.py:1
std::string m_format
the defautl format
std::string toString(const Type &)
STREAM & printList(const LIST &histos, const std::string &fmt, STREAM &stream, TERMINATOR term)
print the simple container of histograms as table
const std::string & footer() const
the table footer