| The Gaudi Framework v29r0 (ff2e7097)

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

- File List
- File Members

HistoDef.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // ST D& STL
5 // ============================================================================
6 #include <ostream>
7 // ============================================================================
8 // GaudiKernel
9 // ============================================================================
10 #include "GaudiKernel/HistoDef.h"
11 #include "GaudiKernel/IHistogramSvc.h"
12 #include "GaudiKernel/ToStream.h"
13 // ============================================================================
19 // ============================================================================
20 /* full constructor from edges, #bins and the title
21 * @param low the low edge of the histogram
22 * @param high the high edge of the histogram
23 * @param bins number of bins
24 * @param title the histogram title
25 */
26 // ============================================================================
27 Gaudi::Histo1DDef::Histo1DDef( const double low, const double high, const int bins, std::string title )
28 : m_title( std::move( title ) ), m_low( low ), m_high( high ), m_bins( bins )
29 {
30 }
31 // ============================================================================
32 /* full constructor from edges, #bins and the title
33 * @param title the histogram title
34 * @param low the low edge of the histogram
35 * @param high the high edge of the histogram
36 * @param bins number of bins
37 */
38 // ============================================================================
39 Gaudi::Histo1DDef::Histo1DDef( std::string title, const double low, const double high, const int bins )
40 : m_title( std::move( title ) ), m_low( low ), m_high( high ), m_bins( bins )
41 {
42 }
43 // ============================================================================
44 // printout of the histogram definition
45 // ============================================================================
46 std::ostream& Gaudi::Histo1DDef::fillStream( std::ostream& o ) const
47 {
48 return o << "(" << Gaudi::Utils::toString( title() ) << "," << lowEdge() << "," << highEdge() << "," << bins() << ")";
49 }
50 // ============================================================================
51 // ordering operator (to please BoundedVerifier)
52 // ============================================================================
53 bool Gaudi::Histo1DDef::operator<( const Gaudi::Histo1DDef& right ) const
54 {
55 return this == &right ? false
56 : title() < right.title()
57 ? true
58 : title() > right.title()
59 ? false
60 : lowEdge() < right.lowEdge()
61 ? true
62 : lowEdge() > right.lowEdge()
63 ? false
64 : highEdge() < right.highEdge()
65 ? true
66 : highEdge() > right.highEdge() ? false : bins() < right.bins();
67 }
68 // ============================================================================
69 // equality operator
70 // ============================================================================
71 #ifdef __ICC
72 // disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
73 #pragma warning( push )
74 #pragma warning( disable : 1572 )
75 #endif
76 bool Gaudi::Histo1DDef::operator==( const Gaudi::Histo1DDef& right ) const
77 {
78 return ( this == &right ) || ( title() == right.title() && lowEdge() == right.lowEdge() &&
79 highEdge() == right.highEdge() && bins() == right.bins() );
80 }
81 #ifdef __ICC
82 // re-enable icc remark #1572
83 #pragma warning( pop )
84 #endif
85 // ============================================================================
86 // non-equality
87 // ============================================================================
88 bool Gaudi::Histo1DDef::operator!=( const Gaudi::Histo1DDef& right ) const { return !( *this == right ); }
89 // ============================================================================
90 // the streamer operator for class Gaudi::Histo1DDef
91 // ============================================================================
92 namespace Gaudi
93 {
94 std::ostream& operator<<( std::ostream& o, const Gaudi::Histo1DDef& histo ) { return histo.fillStream( o ); }
95 }
96 // ============================================================================
97
98 // ============================================================================
99 /* helper function to book 1D-histogram
100 * @param svc pointer to Histogram Service
101 * @param path full path in Histogram Data Store
102 * @param hist histogram desctriprion
103 */
104 // ============================================================================
105 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& path, const Gaudi::Histo1DDef& hist )
106 {
107 return svc ? svc->book( path, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
108 }
109 // ============================================================================
110 /* helper function to book 1D-histogram
111 * @param svc pointer to Histogram Service
112 * @param dir directory path in Histogram Data Store
113 * @param id histogram identifier
114 * @param hist histogram desctriprion
115 */
116 // ============================================================================
117 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& dir, const std::string& id,
118 const Gaudi::Histo1DDef& hist )
119 {
120 return svc ? svc->book( dir, id, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
121 }
122 // ============================================================================
123 /* helper function to book 1D-histogram
124 * @param svc pointer to Histogram Service
125 * @param dir directory path in Histogram Data Store
126 * @param id histogram identifier
127 * @param hist histogram desctriprion
128 */
129 // ============================================================================
130 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& dir, const int id,
131 const Gaudi::Histo1DDef& hist )
132 {
133 return svc ? svc->book( dir, id, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
134 }
135 // ============================================================================
136
137 // ============================================================================
138 // The END
139 // ============================================================================
Gaudi::operator<<
GAUDI_API std::ostream & operator<<(std::ostream &o, const Gaudi::Histo1DDef &histo)
the streamer operator for class Gaudi::Histo1DDef
Definition: HistoDef.cpp:94
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:895
Gaudi::Histos::book
GAUDI_API AIDA::IHistogram1D * book(IHistogramSvc *svc, const std::string &path, const Gaudi::Histo1DDef &hist)
helper function to book 1D-histogram
Definition: HistoDef.cpp:105
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:346
std
STL namespace.
Gaudi::Histo1DDef::highEdge
double highEdge() const
get the high edge
Definition: HistoDef.h:61
Gaudi::Histo1DDef::lowEdge
double lowEdge() const
get the low edge
Definition: HistoDef.h:59
Gaudi::Histo1DDef::operator<
bool operator<(const Histo1DDef &right) const
ordering operator (to please BoundedVerifier)
Definition: HistoDef.cpp:53
Gaudi::Histo1DDef::title
const std::string & title() const
get the title
Definition: HistoDef.h:65
std::string
STL class.
Gaudi::Histo1DDef::operator==
bool operator==(const Histo1DDef &right) const
equality operator
Definition: HistoDef.cpp:76
Gaudi::Histo1DDef::m_high
double m_high
High Edge.
Definition: HistoDef.h:104
Gaudi::Histo1DDef
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
Definition: HistoDef.h:33
Gaudi::Histo1DDef::m_title
std::string m_title
Histogram title.
Definition: HistoDef.h:100
IHistogramSvc
Definition of the IHistogramSvc interface class.
Definition: IHistogramSvc.h:47
Gaudi::Histo1DDef::bins
int bins() const
get the number of bins
Definition: HistoDef.h:63
IHistogramSvc::book
virtual AIDA::IHistogram1D * book(const std::string &fullPath, const std::string &title, int binsX, double lowX, double highX)=0
Book histogram and register it with the histogram data store.
Gaudi::Histo1DDef::Histo1DDef
Histo1DDef(double low, double high, int bins=100, std::string title="")
full constructor from edges, bins and the title
Definition: HistoDef.cpp:27
ToStream.h
implementation of various functions for streaming.
Gaudi::Histo1DDef::fillStream
std::ostream & fillStream(std::ostream &o) const
printout of the histogram definition
Definition: HistoDef.cpp:46
Gaudi::Histo1DDef::m_bins
int m_bins
Number of bins.
Definition: HistoDef.h:106
std::ostream
STL class.
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::Histo1DDef::operator!=
bool operator!=(const Histo1DDef &right) const
non-equality
Definition: HistoDef.cpp:88
Gaudi::Histo1DDef::m_low
double m_low
Low Edge.
Definition: HistoDef.h:102
HistoDef.h
IHistogramSvc.h