| The Gaudi Framework v32r1 (f65d50dc)

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
555 std::string m_header;
556 // the table footer
557 std::string m_footer;
558 // the default format
559 std::string m_format;
560 //
561 };
562 } // namespace Histos
563 } // namespace Utils
564 } // end of namespace Gaudi
565 // ============================================================================
566 // The END
567 // ============================================================================
568 #endif // GAUDIUTILS_HISTOTABLEFORMAT_H
Histos
helper namespace to collect useful definitions, types, constants and functions, related to manipulati...
Gaudi::Utils::Histos::printMap
STREAM & printMap(HISTO begin, HISTO end, const std::string &fmt1, const std::string &fmt2, STREAM &stream, TERMINATOR term)
Print the "associative sequence" (e.g.
Definition: HistoTableFormat.h:355
Gaudi::Utils::Histos::Formats::Stat
Definition: HistoTableFormat.h:90
Kernel.h
std::string::empty
T empty(T... args)
Gaudi::Utils::Histos::Formats::Old
Definition: HistoTableFormat.h:87
Gaudi::Utils::Histos::Table::m_header
std::string m_header
the table header
Definition: HistoTableFormat.h:555
Gaudi::Utils::Histos::Table::footer
const std::string & footer() const
the table footer
Definition: HistoTableFormat.h:478
Gaudi::Utils::end
AttribStringParser::Iterator end(const AttribStringParser &)
Definition: AttribStringParser.h:123
Gaudi::Utils::Histos::Table::setHeader
void setHeader(std::string v)
set new header
Definition: HistoTableFormat.h:486
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:334
Gaudi::Utils::Histos::format
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.
Definition: HistoTableFormat.cpp:234
Gaudi::Utils::Histos::Formats::LineOnly
Definition: HistoTableFormat.h:96
Gaudi::Utils::Histos::Table::printMap
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::...
Definition: HistoTableFormat.h:464
Gaudi::Utils::Histos::Table::printList
STREAM & printList(HISTO first, HISTO last, STREAM &stream, TERMINATOR term) const
print the simple sequence of histograms as table
Definition: HistoTableFormat.h:443
Gaudi::Utils::Histos::Table::setFormat
void setFormat(std::string v)
set new format
Definition: HistoTableFormat.h:492
Gaudi::Utils::Histos::Formats::header
GAUDI_API std::string header(const int ID=Default)
get the recommended header by enum
Definition: HistoTableFormat.cpp:187
AIDA
GaudiKernel.
Definition: Fill.h:10
Gaudi::Utils::Histos::Formats::Full
Definition: HistoTableFormat.h:88
Gaudi::Utils::Histos::Formats::PathTitle
Definition: HistoTableFormat.h:97
std::string
STL class.
Gaudi::Utils::Histos::Formats::Shape
Definition: HistoTableFormat.h:94
Gaudi::Utils::Histos::Formats::format
GAUDI_API std::string format(const int ID=Default)
get the format by enum
Definition: HistoTableFormat.cpp:154
compareRootHistos.histos
list histos
Definition: compareRootHistos.py:13
Gaudi::Utils::Histos::Table::format
const std::string & format() const
the format
Definition: HistoTableFormat.h:481
Gaudi::Utils::Histos::Table::header
const std::string & header() const
the table header
Definition: HistoTableFormat.h:475
Gaudi::Utils::Histos::Table
Simple class for the customizeble printout of the histogram tables.
Definition: HistoTableFormat.h:427
Gaudi::Utils::Histos::Formats::Default
Definition: HistoTableFormat.h:86
Gaudi::Utils::Histos::Table::m_footer
std::string m_footer
the table footer
Definition: HistoTableFormat.h:557
std::move
T move(T... args)
Gaudi::Utils::Histos::path
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
Definition: HistoTableFormat.cpp:219
Gaudi::Utils::Histos::Formats::LineTitle
Definition: HistoTableFormat.h:95
Gaudi::Utils::Histos::Table::setFooter
void setFooter(std::string v)
set new footer
Definition: HistoTableFormat.h:489
Gaudi::Utils::Histos::Formats::ShapeOnly
Definition: HistoTableFormat.h:93
Gaudi::Utils::Histos::printList
STREAM & printList(HISTO first, HISTO last, const std::string &fmt, STREAM &stream, TERMINATOR term)
print the simple sequence (list-like) of histograms as table
Definition: HistoTableFormat.h:277
Gaudi::Utils::Histos::Formats::Stat1
Definition: HistoTableFormat.h:92
Gaudi::Utils::Histos::Formats::FullStat
Definition: HistoTableFormat.h:89
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:120
Gaudi::Utils::Histos::Formats::Format
Format
the ID for predefined formats
Definition: HistoTableFormat.h:85
Gaudi::Utils::Histos::Formats::StatOnly
Definition: HistoTableFormat.h:91
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
Gaudi::Utils::Histos::Table::m_format
std::string m_format
the defautl format
Definition: HistoTableFormat.h:559