The Gaudi Framework  v28r3 (cc1cf868)
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 {
13  class IHistogram1D ;
14  class IBaseHistogram ;
15 }
16 // ============================================================================
17 namespace Gaudi
18 {
19  namespace Utils
20  {
21  // ========================================================================
28  namespace Histos
29  {
30  // ======================================================================
72  namespace Formats
73  {
74  // ====================================================================
89  enum Format
90  {
91  Default = 0 , // default format
92  Old , // "OLD"-line format: title,integral,#ent,mean,rms
93  Full , // FULL format: the first 15 positions
94  FullStat , // Full statistical info (3-15)
95  Stat , // title,#ent,mean,rms,skewness&kurtosis
96  StatOnly , // #entries,mean,rms,skewness&kurtosis
97  Stat1 , // #entries,mean+-,rms+-,skewness+-&kurtosis+-
98  ShapeOnly , // mean,rms,skewness,kurtosis,underflow&overflow fractions
99  Shape , // as ShapeOnly but with errors
100  LineTitle , // line-format : title,mean,rms,skewness&kurtosis
101  LineOnly , // line-format : mean,rms,skewness&kurtosis
102  PathTitle // "PathTitle" : path & title
103  } ;
104  // ====================================================================
112  GAUDI_API std::string format ( const int ID = Default ) ;
113  // ====================================================================
121  GAUDI_API std::string header ( const int ID = Default ) ;
122  // ====================================================================
123  } // end of namespace Gaudi::Utils::Histos::Formats
124  // ======================================================================
129  GAUDI_API std::string path ( const AIDA::IBaseHistogram* aida ) ;
130  // ======================================================================
170  ( const AIDA::IHistogram1D* histo ,
171  const std::string& fmt ) ;
172  // ======================================================================
202  ( const AIDA::IHistogram1D* histo ,
203  const std::string& ID ,
204  const std::string& fmt1 ,
205  const std::string& fmt2 ) ;
206  // ========================================================================
230  template <class HISTO, class STREAM, class TERMINATOR>
231  inline STREAM& printList
232  ( HISTO first ,
233  HISTO last ,
234  const std::string& fmt ,
235  STREAM& stream ,
236  TERMINATOR term )
237  {
238  for ( ; first != last ; ++first )
239  { stream << format ( *first , fmt ) << term ; } // print table rows
240  return stream ; // RETURN
241  }
242  // ======================================================================
266  template <class LIST, class STREAM, class TERMINATOR>
267  inline STREAM& printList
268  ( const LIST& histos ,
269  const std::string& fmt ,
270  STREAM& stream ,
271  TERMINATOR term )
272  {
273  return printList
274  ( histos.begin () , histos.end () , fmt , stream , term ) ;
275  }
276  // ======================================================================
321  template <class HISTO, class STREAM, class TERMINATOR>
322  inline STREAM& printMap
323  ( HISTO begin ,
324  HISTO end ,
325  const std::string& fmt1 ,
326  const std::string& fmt2 ,
327  STREAM& stream ,
328  TERMINATOR term )
329  {
330  for ( ; begin != end ; ++begin )
331  {
332  stream << format
333  ( begin -> second , // the histogram
334  begin -> first , // the key
335  fmt1 , fmt2 ) << term ;
336  }
337  return stream ;
338  }
339  // ======================================================================
382  template <class MAP, class STREAM, class TERMINATOR>
383  inline STREAM& printMap
384  ( const MAP& histos ,
385  const std::string& fmt1 ,
386  const std::string& fmt2 ,
387  STREAM& stream ,
388  TERMINATOR term )
389  {
390  return printMap
391  ( histos.begin () , histos.end() , fmt1 , fmt2 , stream , term ) ;
392  }
393  // ======================================================================
399  ( const std::string& val1 ,
400  const std::string& val2 ,
401  const std::string& fmt ) ;
402  // ======================================================================
409  // ========================================================================
411  {
412  public:
414  Table ( const int ID = 0 ) ;
416  Table
417  ( const std::string& format ,
418  const std::string& header = "" ,
419  const std::string& footer = "" ) ;
420  public:
421  // ======================================================================
428  template <class HISTO, class STREAM, class TERMINATOR>
429  STREAM& printList
430  ( HISTO first ,
431  HISTO last ,
432  STREAM& stream ,
433  TERMINATOR term ) const
434  {
435  if ( !header().empty() ) { stream << header () << term ; }
436  Gaudi::Utils::Histos::printList ( first , last , format() , stream , term ) ;
437  if ( !footer().empty() ) { stream << footer () << term ; }
438  return stream ;
439  }
440  // ======================================================================
441  public:
454  template <class HISTO, class STREAM, class TERMINATOR>
455  STREAM& printMap
456  ( HISTO first ,
457  HISTO last ,
458  const std::string& fmt ,
459  const std::string& hval ,
460  STREAM& stream ,
461  TERMINATOR term ) const
462  {
463  if ( !hval.empty() || !header().empty() )
464  { stream << Gaudi::Utils::Histos::format ( hval , header() , fmt ) << term ; }
466  ( first , last , fmt , format() , stream , term ) ;
467  }
468  // ======================================================================
469  public:
470  // ======================================================================
472  const std::string& header () const { return m_header ; }
473  // ======================================================================
475  const std::string& footer () const { return m_footer ; }
476  // ======================================================================
478  const std::string& format () const { return m_format ; }
479  // ======================================================================
480  public:
481  // ======================================================================
483  void setHeader ( std::string v ) { m_header = std::move(v) ; }
484  // ======================================================================
486  void setFooter ( std::string v ) { m_footer = std::move(v) ; }
487  // ======================================================================
489  void setFormat ( std::string v ) { m_format = std::move(v) ; }
490  // ======================================================================
491  public :
492  // ======================================================================
494  std::string toString ( const AIDA::IHistogram1D* histo ) const ;
495  // ======================================================================
496  public:
497  // ======================================================================
522  ( const AIDA::IHistogram1D* histo ,
523  const std::string& ID ,
524  const std::string& fmt ) const ;
525  // ======================================================================
526  public:
527  // the table header
529  // the table footer
531  // the default format
533  //
534  } ;
535  } // end of namespace Gaudi::Utils::Histos
536  } // end of namespace Gaudi::Utils
537 } // end of namespace Gaudi
538 // ============================================================================
539 // The END
540 // ============================================================================
541 #endif // GAUDIUTILS_HISTOTABLEFORMAT_H
542 // ============================================================================
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 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:10
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
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