| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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/IHistogramSvc.h"
11 #include "GaudiKernel/HistoDef.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
28 ( const double low ,
29 const double high ,
30 const int bins ,
31 std::string title )
32 : m_title ( std::move(title) )
33 , m_low ( low )
34 , m_high ( high )
35 , m_bins ( bins )
36 {}
37 // ============================================================================
38 /* full constructor from edges, #bins and the title
39 * @param title the histogram title
40 * @param low the low edge of the histogram
41 * @param high the high edge of the histogram
42 * @param bins number of bins
43 */
44 // ============================================================================
45 Gaudi::Histo1DDef::Histo1DDef
46 ( std::string title ,
47 const double low ,
48 const double high ,
49 const int bins )
50 : m_title ( std::move(title) )
51 , m_low ( low )
52 , m_high ( high )
53 , m_bins ( bins )
54 {}
55 // ============================================================================
56 // printout of the histogram definition
57 // ============================================================================
58 std::ostream& Gaudi::Histo1DDef::fillStream( std::ostream& o ) const
59 {
60 return o << "(" << Gaudi::Utils::toString ( title () )
61 << "," << lowEdge ()
62 << "," << highEdge ()
63 << "," << bins () << ")" ;
64 }
65 // ============================================================================
66 // ordering operator (to please BoundedVerifier)
67 // ============================================================================
68 bool Gaudi::Histo1DDef::operator< ( const Gaudi::Histo1DDef& right ) const
69 {
70 return
71 this == &right ? false :
72 title () < right.title () ? true :
73 title () > right.title () ? false :
74 lowEdge () < right.lowEdge () ? true :
75 lowEdge () > right.lowEdge () ? false :
76 highEdge () < right.highEdge () ? true :
77 highEdge () > right.highEdge () ? false : bins () < right.bins () ;
78 }
79 // ============================================================================
80 // equality operator
81 // ============================================================================
82 #ifdef __ICC
83 // disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
84 #pragma warning(push)
85 #pragma warning(disable:1572)
86 #endif
87 bool Gaudi::Histo1DDef::operator==( const Gaudi::Histo1DDef& right ) const
88 {
89 return ( this == &right ) ||
90 ( title () == right.title () &&
91 lowEdge () == right.lowEdge () &&
92 highEdge () == right.highEdge () &&
93 bins () == right.bins () );
94 }
95 #ifdef __ICC
96 // re-enable icc remark #1572
97 #pragma warning(pop)
98 #endif
99 // ============================================================================
100 // non-equality
101 // ============================================================================
102 bool Gaudi::Histo1DDef::operator!=( const Gaudi::Histo1DDef& right ) const
103 { return !( *this == right ) ; }
104 // ============================================================================
105 // the streamer operator for class Gaudi::Histo1DDef
106 // ============================================================================
107 namespace Gaudi
108 {
109 std::ostream& operator<<( std::ostream& o , const Gaudi::Histo1DDef& histo )
110 { return histo.fillStream ( o ) ; }
111 }
112 // ============================================================================
113
114
115 // ============================================================================
116 /* helper function to book 1D-histogram
117 * @param svc pointer to Histogram Service
118 * @param path full path in Histogram Data Store
119 * @param hist histogram desctriprion
120 */
121 // ============================================================================
122 AIDA::IHistogram1D*
123 Gaudi::Histos::book
124 ( IHistogramSvc* svc ,
125 const std::string& path ,
126 const Gaudi::Histo1DDef& hist )
127 {
128 return svc ? svc -> book( path , hist.title() , hist.bins() ,
129 hist.lowEdge() , hist.lowEdge() )
130 : nullptr;
131 }
132 // ============================================================================
133 /* helper function to book 1D-histogram
134 * @param svc pointer to Histogram Service
135 * @param dir directory path in Histogram Data Store
136 * @param id histogram identifier
137 * @param hist histogram desctriprion
138 */
139 // ============================================================================
140 AIDA::IHistogram1D*
141 Gaudi::Histos::book
142 ( IHistogramSvc* svc ,
143 const std::string& dir ,
144 const std::string& id ,
145 const Gaudi::Histo1DDef& hist )
146 {
147 return svc ? svc -> book ( dir , id , hist.title() , hist.bins() ,
148 hist.lowEdge() , hist.lowEdge() )
149 : nullptr;
150 }
151 // ============================================================================
152 /* helper function to book 1D-histogram
153 * @param svc pointer to Histogram Service
154 * @param dir directory path in Histogram Data Store
155 * @param id histogram identifier
156 * @param hist histogram desctriprion
157 */
158 // ============================================================================
159 AIDA::IHistogram1D*
160 Gaudi::Histos::book
161 ( IHistogramSvc* svc ,
162 const std::string& dir ,
163 const int id ,
164 const Gaudi::Histo1DDef& hist )
165 {
166 return svc ? svc -> book ( dir , id , hist.title() , hist.bins() ,
167 hist.lowEdge() , hist.lowEdge() )
168 : nullptr;
169 }
170 // ============================================================================
171
172
173 // ============================================================================
174 // The END
175 // ============================================================================
Gaudi::operator<<
GAUDI_API std::ostream & operator<<(std::ostream &o, const Gaudi::Histo1DDef &histo)
the streamer operator for class Gaudi::Histo1DDef
Definition: HistoDef.cpp:109
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:772
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:124
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:367
Gaudi::Histo1DDef::highEdge
double highEdge() const
get the high edge
Definition: HistoDef.h:66
Gaudi::Histo1DDef::lowEdge
double lowEdge() const
get the low edge
Definition: HistoDef.h:64
Gaudi::Histo1DDef::operator<
bool operator<(const Histo1DDef &right) const
ordering operator (to please BoundedVerifier)
Definition: HistoDef.cpp:68
Gaudi::Histo1DDef::title
const std::string & title() const
get the title
Definition: HistoDef.h:70
std::string
STL class.
Gaudi::Histo1DDef::operator==
bool operator==(const Histo1DDef &right) const
equality operator
Definition: HistoDef.cpp:87
Gaudi::Histo1DDef
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
Definition: HistoDef.h:30
IHistogramSvc
Definition of the IHistogramSvc interface class.
Definition: IHistogramSvc.h:47
std::move
T move(T...args)
Gaudi::Histo1DDef::bins
int bins() const
get the number of bins
Definition: HistoDef.h:68
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:28
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:58
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:102
HistoDef.h
IHistogramSvc.h