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 // ============================================================================
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 // ============================================================================
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 // ============================================================================
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
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 // ============================================================================
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 
117 
118 // ============================================================================
119 /* helper function to book 1D-histogram
120  * @param svc pointer to Histogram Service
121  * @param path full path in Histogram Data Store
122  * @param hist histogram desctriprion
123  */
124 // ============================================================================
125 AIDA::IHistogram1D*
128  const std::string& path ,
129  const Gaudi::Histo1DDef& hist )
130 {
131  if ( 0 == svc ) { return 0 ; }
132  return svc -> book
133  ( path ,
134  hist.title() , hist.bins() , hist.lowEdge() , hist.lowEdge() ) ;
135 }
136 // ============================================================================
137 /* helper function to book 1D-histogram
138  * @param svc pointer to Histogram Service
139  * @param dir directory path in Histogram Data Store
140  * @param id histogram identifier
141  * @param hist histogram desctriprion
142  */
143 // ============================================================================
144 AIDA::IHistogram1D*
147  const std::string& dir ,
148  const std::string& id ,
149  const Gaudi::Histo1DDef& hist )
150 {
151  if ( 0 == svc ) { return 0 ; }
152  return svc -> book
153  ( dir , id ,
154  hist.title() , hist.bins() , hist.lowEdge() , hist.lowEdge() ) ;
155 }
156 // ============================================================================
157 /* helper function to book 1D-histogram
158  * @param svc pointer to Histogram Service
159  * @param dir directory path in Histogram Data Store
160  * @param id histogram identifier
161  * @param hist histogram desctriprion
162  */
163 // ============================================================================
164 AIDA::IHistogram1D*
167  const std::string& dir ,
168  const int id ,
169  const Gaudi::Histo1DDef& hist )
170 {
171  if ( 0 == svc ) { return 0 ; }
172  return svc -> book
173  ( dir , id ,
174  hist.title() , hist.bins() , hist.lowEdge() , hist.lowEdge() ) ;
175 }
176 // ============================================================================
177 
178 
179 
180 
181 // ============================================================================
182 // The END
183 // ============================================================================
GAUDI_API std::ostream & operator<<(std::ostream &o, const Gaudi::Histo1DDef &histo)
the streamer operator for class Gaudi::Histo1DDef
Definition: HistoDef.cpp:109
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:400
list path
Definition: __init__.py:15
double highEdge() const
get the high edge
Definition: HistoDef.h:66
double lowEdge() const
get the low edge
Definition: HistoDef.h:64
bool operator<(const Histo1DDef &right) const
ordering operator (to please BoundedVerifier)
Definition: HistoDef.cpp:68
const std::string & title() const
get the title
Definition: HistoDef.h:70
bool operator==(const Histo1DDef &right) const
equality operator
Definition: HistoDef.cpp:87
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
Definition: HistoDef.h:30
Definition of the IHistogramSvc interface class.
Definition: IHistogramSvc.h:47
int bins() const
get the number of bins
Definition: HistoDef.h:68
Histo1DDef(double low, double high, int bins=100, std::string title="")
full constructor from edges, bins and the title
Definition: HistoDef.cpp:28
std::ostream & fillStream(std::ostream &o) const
printout of the histogram definition
Definition: HistoDef.cpp:58
GAUDI_API AIDA::IHistogram1D * book(IHistogramSvc *svc, const std::string &path, const Gaudi::Histo1DDef &hist)
helper function to book 1D-histogram
Definition: HistoDef.cpp:127
Helper functions to set/get the application return code.
Definition: __init__.py:1
bool operator!=(const Histo1DDef &right) const
non-equality
Definition: HistoDef.cpp:102