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 // ============================================================================
8 // forward declarations
9 // ============================================================================
10 namespace AIDA
11 {
12  class IHistogram1D ;
13  class IBaseHistogram ;
14 }
15 // ============================================================================
16 namespace Gaudi
17 {
18  namespace Utils
19  {
20  // ========================================================================
27  namespace Histos
28  {
29  // ======================================================================
71  namespace Formats
72  {
73  // ====================================================================
88  enum Format
89  {
90  Default = 0 , // default format
91  Old , // "OLD"-line format: title,integral,#ent,mean,rms
92  Full , // FULL format: the first 15 positions
93  FullStat , // Full statistical info (3-15)
94  Stat , // title,#ent,mean,rms,skewness&kurtosis
95  StatOnly , // #entries,mean,rms,skewness&kurtosis
96  Stat1 , // #entries,mean+-,rms+-,skewness+-&kurtosis+-
97  ShapeOnly , // mean,rms,skewness,kurtosis,underflow&overflow fractions
98  Shape , // as ShapeOnly but with errors
99  LineTitle , // line-format : title,mean,rms,skewness&kurtosis
100  LineOnly , // line-format : mean,rms,skewness&kurtosis
101  PathTitle // "PathTitle" : path & title
102  } ;
103  // ====================================================================
111  GAUDI_API std::string format ( const int ID = Default ) ;
112  // ====================================================================
120  GAUDI_API std::string header ( const int ID = Default ) ;
121  // ====================================================================
122  } // end of namespace Gaudi::Utils::Histos::Formats
123  // ======================================================================
128  GAUDI_API std::string path ( const AIDA::IBaseHistogram* aida ) ;
129  // ======================================================================
169  ( const AIDA::IHistogram1D* histo ,
170  const std::string& fmt ) ;
171  // ======================================================================
201  ( const AIDA::IHistogram1D* histo ,
202  const std::string& ID ,
203  const std::string& fmt1 ,
204  const std::string& fmt2 ) ;
205  // ========================================================================
229  template <class HISTO, class STREAM, class TERMINATOR>
230  inline STREAM& printList
231  ( HISTO first ,
232  HISTO last ,
233  const std::string& fmt ,
234  STREAM& stream ,
235  TERMINATOR term )
236  {
237  for ( ; first != last ; ++first )
238  { stream << format ( *first , fmt ) << term ; } // print table rows
239  return stream ; // RETURN
240  }
241  // ======================================================================
265  template <class LIST, class STREAM, class TERMINATOR>
266  inline STREAM& printList
267  ( const LIST& histos ,
268  const std::string& fmt ,
269  STREAM& stream ,
270  TERMINATOR term )
271  {
272  return printList
273  ( histos.begin () , histos.end () , fmt , stream , term ) ;
274  }
275  // ======================================================================
320  template <class HISTO, class STREAM, class TERMINATOR>
321  inline STREAM& printMap
322  ( HISTO begin ,
323  HISTO end ,
324  const std::string& fmt1 ,
325  const std::string& fmt2 ,
326  STREAM& stream ,
327  TERMINATOR term )
328  {
329  for ( ; begin != end ; ++begin )
330  {
331  stream << format
332  ( begin -> second , // the histogram
333  begin -> first , // the key
334  fmt1 , fmt2 ) << term ;
335  }
336  return stream ;
337  }
338  // ======================================================================
381  template <class MAP, class STREAM, class TERMINATOR>
382  inline STREAM& printMap
383  ( const MAP& histos ,
384  const std::string& fmt1 ,
385  const std::string& fmt2 ,
386  STREAM& stream ,
387  TERMINATOR term )
388  {
389  return printMap
390  ( histos.begin () , histos.end() , fmt1 , fmt2 , stream , term ) ;
391  }
392  // ======================================================================
398  ( const std::string& val1 ,
399  const std::string& val2 ,
400  const std::string& fmt ) ;
401  // ======================================================================
408  // ========================================================================
410  {
411  public:
413  Table ( const int ID = 0 ) ;
415  Table
416  ( const std::string& format ,
417  const std::string& header = "" ,
418  const std::string& footer = "" ) ;
419  public:
420  // ======================================================================
427  template <class HISTO, class STREAM, class TERMINATOR>
428  STREAM& printList
429  ( HISTO first ,
430  HISTO last ,
431  STREAM& stream ,
432  TERMINATOR term ) const
433  {
434  if ( !header().empty() ) { stream << header () << term ; }
435  Gaudi::Utils::Histos::printList ( first , last , format() , stream , term ) ;
436  if ( !footer().empty() ) { stream << footer () << term ; }
437  return stream ;
438  }
439  // ======================================================================
440  public:
453  template <class HISTO, class STREAM, class TERMINATOR>
454  STREAM& printMap
455  ( HISTO first ,
456  HISTO last ,
457  const std::string& fmt ,
458  const std::string& hval ,
459  STREAM& stream ,
460  TERMINATOR term ) const
461  {
462  if ( !hval.empty() || !header().empty() )
463  { stream << Gaudi::Utils::Histos::format ( hval , header() , fmt ) << term ; }
465  ( first , last , fmt , format() , stream , term ) ;
466  }
467  // ======================================================================
468  public:
469  // ======================================================================
471  const std::string& header () const { return m_header ; }
472  // ======================================================================
474  const std::string& footer () const { return m_footer ; }
475  // ======================================================================
477  const std::string& format () const { return m_format ; }
478  // ======================================================================
479  public:
480  // ======================================================================
482  void setHeader ( std::string v ) { m_header = std::move(v) ; }
483  // ======================================================================
485  void setFooter ( std::string v ) { m_footer = std::move(v) ; }
486  // ======================================================================
488  void setFormat ( std::string v ) { m_format = std::move(v) ; }
489  // ======================================================================
490  public :
491  // ======================================================================
493  std::string toString ( const AIDA::IHistogram1D* histo ) const ;
494  // ======================================================================
495  public:
496  // ======================================================================
521  ( const AIDA::IHistogram1D* histo ,
522  const std::string& ID ,
523  const std::string& fmt ) const ;
524  // ======================================================================
525  public:
526  // the table header
528  // the table footer
530  // the default format
532  //
533  } ;
534  } // end of namespace Gaudi::Utils::Histos
535  } // end of namespace Gaudi::Utils
536 } // end of namespace Gaudi
537 // ============================================================================
538 // The END
539 // ============================================================================
540 #endif // GAUDIUTILS_HISTOTABLEFORMAT_H
541 // ============================================================================
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
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.
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:8
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:48
constexpr double second
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
const std::string & format() const
the format
Simple class for the customizeble printout of the histogram tables.
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
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
Format
the ID for predefined formats
#define GAUDI_API
Definition: Kernel.h:107
Helper functions to set/get the application return code.
Definition: __init__.py:1
std::string m_format
the defautl format
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