| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 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 // ======================================================================
168 GAUDI_API std::string format( const AIDA::IHistogram1D* histo, const std::string& fmt );
169 // ======================================================================
198 GAUDI_API std::string format( const AIDA::IHistogram1D* histo, const std::string& ID, const std::string& fmt1,
199 const std::string& fmt2 );
200 // ========================================================================
224 template <class HISTO, class STREAM, class TERMINATOR>
225 inline STREAM& printList( HISTO first, HISTO last, const std::string& fmt, STREAM& stream, TERMINATOR term )
226 {
227 for ( ; first != last; ++first ) {
228 stream << format( *first, fmt ) << term;
229 } // print table rows
230 return stream; // RETURN
231 }
232 // ======================================================================
256 template <class LIST, class STREAM, class TERMINATOR>
257 inline STREAM& printList( const LIST& histos, const std::string& fmt, STREAM& stream, TERMINATOR term )
258 {
259 return printList( histos.begin(), histos.end(), fmt, stream, term );
260 }
261 // ======================================================================
306 template <class HISTO, class STREAM, class TERMINATOR>
307 inline STREAM& printMap( HISTO begin, HISTO end, const std::string& fmt1, const std::string& fmt2, STREAM& stream,
308 TERMINATOR term )
309 {
310 for ( ; begin != end; ++begin ) {
311 stream << format( begin->second, // the histogram
312 begin->first, // the key
313 fmt1, fmt2 )
314 << term;
315 }
316 return stream;
317 }
318 // ======================================================================
361 template <class MAP, class STREAM, class TERMINATOR>
362 inline STREAM& printMap( const MAP& histos, const std::string& fmt1, const std::string& fmt2, STREAM& stream,
363 TERMINATOR term )
364 {
365 return printMap( histos.begin(), histos.end(), fmt1, fmt2, stream, term );
366 }
367 // ======================================================================
372 GAUDI_API std::string format( const std::string& val1, const std::string& val2, const std::string& fmt );
373 // ======================================================================
380 // ========================================================================
381 class GAUDI_API Table
382 {
383 public:
385 Table( const int ID = 0 );
387 Table( const std::string& format, const std::string& header = "", const std::string& footer = "" );
388
389 public:
390 // ======================================================================
397 template <class HISTO, class STREAM, class TERMINATOR>
398 STREAM& printList( HISTO first, HISTO last, STREAM& stream, TERMINATOR term ) const
399 {
400 if ( !header().empty() ) {
401 stream << header() << term;
402 }
403 Gaudi::Utils::Histos::printList( first, last, format(), stream, term );
404 if ( !footer().empty() ) {
405 stream << footer() << term;
406 }
407 return stream;
408 }
409 // ======================================================================
410 public:
423 template <class HISTO, class STREAM, class TERMINATOR>
424 STREAM& printMap( HISTO first, HISTO last, const std::string& fmt, const std::string& hval, STREAM& stream,
425 TERMINATOR term ) const
426 {
427 if ( !hval.empty() || !header().empty() ) {
428 stream << Gaudi::Utils::Histos::format( hval, header(), fmt ) << term;
429 }
430 return Gaudi::Utils::Histos::printMap( first, last, fmt, format(), stream, term );
431 }
432 // ======================================================================
433 public:
434 // ======================================================================
436 const std::string& header() const { return m_header; }
437 // ======================================================================
439 const std::string& footer() const { return m_footer; }
440 // ======================================================================
442 const std::string& format() const { return m_format; }
443 // ======================================================================
444 public:
445 // ======================================================================
447 void setHeader( std::string v ) { m_header = std::move( v ); }
448 // ======================================================================
450 void setFooter( std::string v ) { m_footer = std::move( v ); }
451 // ======================================================================
453 void setFormat( std::string v ) { m_format = std::move( v ); }
454 // ======================================================================
455 public:
456 // ======================================================================
458 std::string toString( const AIDA::IHistogram1D* histo ) const;
459 // ======================================================================
460 public:
461 // ======================================================================
485 std::string toString( const AIDA::IHistogram1D* histo, const std::string& ID, const std::string& fmt ) const;
486 // ======================================================================
487 public:
488 // the table header
489 std::string m_header;
490 // the table footer
491 std::string m_footer;
492 // the default format
493 std::string m_format;
494 //
495 };
496 } // end of namespace Gaudi::Utils::Histos
497 } // end of namespace Gaudi::Utils
498 } // end of namespace Gaudi
499 // ============================================================================
500 // The END
501 // ============================================================================
502 #endif // GAUDIUTILS_HISTOTABLEFORMAT_H
503 // ============================================================================
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:307
Gaudi::Utils::Histos::Formats::Stat
Definition: HistoTableFormat.h:94
Kernel.h
std::string::empty
T empty(T...args)
Gaudi::Utils::Histos::Formats::Old
Definition: HistoTableFormat.h:91
Gaudi::Utils::Histos::printMap
STREAM & printMap(const MAP &histos, const std::string &fmt1, const std::string &fmt2, STREAM &stream, TERMINATOR term)
Print the "associative sequence" (e.g.
Definition: HistoTableFormat.h:362
Gaudi::Utils::Histos::Table::m_header
std::string m_header
the table header
Definition: HistoTableFormat.h:489
Gaudi::Utils::Histos::Table::setHeader
void setHeader(std::string v)
set new header
Definition: HistoTableFormat.h:447
Gaudi::Utils::Histos::format
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.
Definition: HistoTableFormat.cpp:234
Gaudi::Utils::Histos::Formats::LineOnly
Definition: HistoTableFormat.h:100
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:424
Gaudi::Utils::Histos::Table::setFormat
void setFormat(std::string v)
set new format
Definition: HistoTableFormat.h:453
Gaudi::Utils::Histos::Formats::header
GAUDI_API std::string header(const int ID=Default)
get the recommended header by enum
Definition: HistoTableFormat.cpp:176
AIDA
GaudiKernel.
Definition: Fill.h:10
Gaudi::Utils::Histos::Formats::Full
Definition: HistoTableFormat.h:92
Gaudi::Utils::Histos::Formats::PathTitle
Definition: HistoTableFormat.h:101
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:58
Gaudi::Utils::Histos::Table::header
const std::string & header() const
the table header
Definition: HistoTableFormat.h:436
std::string
STL class.
Gaudi::Utils::Histos::format
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
Definition: HistoTableFormat.cpp:298
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:398
Gaudi::Utils::Histos::Formats::Shape
Definition: HistoTableFormat.h:98
Gaudi::Utils::Histos::Table::format
const std::string & format() const
the format
Definition: HistoTableFormat.h:442
compareRootHistos.histos
list histos
Definition: compareRootHistos.py:13
Gaudi::Utils::Histos::Table
Simple class for the customizeble printout of the histogram tables.
Definition: HistoTableFormat.h:381
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
Gaudi::Utils::Histos::Formats::Default
Definition: HistoTableFormat.h:90
Gaudi::Utils::Histos::Table::m_footer
std::string m_footer
the table footer
Definition: HistoTableFormat.h:491
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:209
Gaudi::Utils::Histos::Formats::LineTitle
Definition: HistoTableFormat.h:99
Gaudi::Utils::Histos::Table::setFooter
void setFooter(std::string v)
set new footer
Definition: HistoTableFormat.h:450
Gaudi::Utils::Histos::Formats::ShapeOnly
Definition: HistoTableFormat.h:97
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:225
Gaudi::Utils::Histos::Formats::Stat1
Definition: HistoTableFormat.h:96
Gaudi::Utils::Histos::Formats::FullStat
Definition: HistoTableFormat.h:93
Gaudi::Utils::Histos::Formats::Format
Format
the ID for predefined formats
Definition: HistoTableFormat.h:89
Gaudi::Utils::Histos::Formats::StatOnly
Definition: HistoTableFormat.h:95
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::Utils::Histos::Table::m_format
std::string m_format
the defautl format
Definition: HistoTableFormat.h:493
GaudiMath::Interpolation::toString
std::string toString(const Type &)
Definition: Interpolation.cpp:42
Gaudi::Utils::Histos::printList
STREAM & printList(const LIST &histos, const std::string &fmt, STREAM &stream, TERMINATOR term)
print the simple container of histograms as table
Definition: HistoTableFormat.h:257
Gaudi::Utils::Histos::Table::footer
const std::string & footer() const
the table footer
Definition: HistoTableFormat.h:439