All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HistoDef.cpp
Go to the documentation of this file.
1 // $Id: HistoDef.cpp,v 1.1 2007/09/26 16:13:42 marcocle Exp $
2 // ============================================================================
3 // Include files
4 // ============================================================================
5 // ST D& STL
6 // ============================================================================
7 #include <ostream>
8 // ============================================================================
9 // GaudiKernel
10 // ============================================================================
12 #include "GaudiKernel/HistoDef.h"
13 #include "GaudiKernel/ToStream.h"
14 // ============================================================================
20 // ============================================================================
21 /* full constructor from edges, #bins and the title
22  * @param low the low edge of the histogram
23  * @param high the high edge of the histogram
24  * @param bins number of bins
25  * @param title the historgam title
26  */
27 // ============================================================================
29 ( const double low ,
30  const double high ,
31  const int bins ,
32  const std::string& title )
33  : m_title ( title )
34  , m_low ( low )
35  , m_high ( high )
36  , m_bins ( bins )
37 {}
38 // ============================================================================
39 /* full constructor from edges, #bins and the title
40  * @param title the historgam title
41  * @param low the low edge of the histogram
42  * @param high the high edge of the histogram
43  * @param bins number of bins
44  */
45 // ============================================================================
47 ( const std::string& title ,
48  const double low ,
49  const double high ,
50  const int bins )
51  : m_title ( title )
52  , m_low ( low )
53  , m_high ( high )
54  , m_bins ( bins )
55 {}
56 // ============================================================================
57 // destructor
58 // ============================================================================
60 // ============================================================================
61 // printout of the histogram definition
62 // ============================================================================
63 std::ostream& Gaudi::Histo1DDef::fillStream( std::ostream& o ) const
64 {
65  return o << "(" << Gaudi::Utils::toString ( title () )
66  << "," << lowEdge ()
67  << "," << highEdge ()
68  << "," << bins () << ")" ;
69 }
70 // ============================================================================
71 // ordering operator (to please BoundedVerifier)
72 // ============================================================================
74 {
75  return
76  this == &right ? false :
77  title () < right.title () ? true :
78  title () > right.title () ? false :
79  lowEdge () < right.lowEdge () ? true :
80  lowEdge () > right.lowEdge () ? false :
81  highEdge () < right.highEdge () ? true :
82  highEdge () > right.highEdge () ? false : bins () < right.bins () ;
83 }
84 // ============================================================================
85 // equality operator
86 // ============================================================================
87 #ifdef __ICC
88 // disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
89 #pragma warning(push)
90 #pragma warning(disable:1572)
91 #endif
93 {
94  return ( this == &right ) ||
95  ( title () == right.title () &&
96  lowEdge () == right.lowEdge () &&
97  highEdge () == right.highEdge () &&
98  bins () == right.bins () );
99 }
100 #ifdef __ICC
101 // re-enable icc remark #1572
102 #pragma warning(pop)
103 #endif
104 // ============================================================================
105 // non-equality
106 // ============================================================================
108 { return !( *this == right ) ; }
109 // ============================================================================
110 // the streamer operator for class Gaudi::Histo1DDef
111 // ============================================================================
112 namespace Gaudi
113 {
114  std::ostream& operator<<( std::ostream& o , const Gaudi::Histo1DDef& histo )
115  { return histo.fillStream ( o ) ; }
116 }
117 // ============================================================================
118 
119 
120 
121 
122 
123 // ============================================================================
124 /* helper function to book 1D-histogram
125  * @param svc pointer to Histogram Service
126  * @param path full path in Histogram Data Store
127  * @param hist histogram desctriprion
128  */
129 // ============================================================================
130 AIDA::IHistogram1D*
133  const std::string& path ,
134  const Gaudi::Histo1DDef& hist )
135 {
136  if ( 0 == svc ) { return 0 ; }
137  return svc -> book
138  ( path ,
139  hist.title() , hist.bins() , hist.lowEdge() , hist.lowEdge() ) ;
140 }
141 // ============================================================================
142 /* helper function to book 1D-histogram
143  * @param svc pointer to Histogram Service
144  * @param dir directory path in Histogram Data Store
145  * @param id historgam identifier
146  * @param hist histogram desctriprion
147  */
148 // ============================================================================
149 AIDA::IHistogram1D*
152  const std::string& dir ,
153  const std::string& id ,
154  const Gaudi::Histo1DDef& hist )
155 {
156  if ( 0 == svc ) { return 0 ; }
157  return svc -> book
158  ( dir , id ,
159  hist.title() , hist.bins() , hist.lowEdge() , hist.lowEdge() ) ;
160 }
161 // ============================================================================
162 /* helper function to book 1D-histogram
163  * @param svc pointer to Histogram Service
164  * @param dir directory path in Histogram Data Store
165  * @param id historgam identifier
166  * @param hist histogram desctriprion
167  */
168 // ============================================================================
169 AIDA::IHistogram1D*
172  const std::string& dir ,
173  const int id ,
174  const Gaudi::Histo1DDef& hist )
175 {
176  if ( 0 == svc ) { return 0 ; }
177  return svc -> book
178  ( dir , id ,
179  hist.title() , hist.bins() , hist.lowEdge() , hist.lowEdge() ) ;
180 }
181 // ============================================================================
182 
183 
184 
185 
186 // ============================================================================
187 // The END
188 // ============================================================================
GAUDI_API std::ostream & operator<<(std::ostream &o, const Gaudi::Histo1DDef &histo)
the streamer operator for class Gaudi::Histo1DDef
Definition: HistoDef.cpp:114
GAUDI_API AIDA::IHistogram1D * book(IHistogramSvc *svc, const std::string &path, const Gaudi::Histo1DDef &hist)
helper function to book 1D-histogram
Definition: HistoDef.cpp:132
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:367
virtual ~Histo1DDef()
destructor
Definition: HistoDef.cpp:59
double highEdge() const
get the high edge
Definition: HistoDef.h:68
double lowEdge() const
get the low edge
Definition: HistoDef.h:66
bool operator<(const Histo1DDef &right) const
ordering operator (to please BoundedVerifier)
Definition: HistoDef.cpp:73
const std::string & title() const
get the title
Definition: HistoDef.h:72
Histo1DDef(const double low, const double high, const int bins=100, const std::string &title="")
full constructor from edges, bins and the title
Definition: HistoDef.cpp:29
bool operator==(const Histo1DDef &right) const
equality operator
Definition: HistoDef.cpp:92
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
Definition: HistoDef.h:32
Definition of the IHistogramSvc interface class.
Definition: IHistogramSvc.h:47
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
int bins() const
get the number of bins
Definition: HistoDef.h:70
implemenattiono fvarioud functions for streaming.
This is a number of static methods for bootstrapping the Gaudi framework.
Definition: Bootstrap.h:15
std::ostream & fillStream(std::ostream &o) const
printout of the histogram definition
Definition: HistoDef.cpp:63
bool operator!=(const Histo1DDef &right) const
non-equality
Definition: HistoDef.cpp:107