The Gaudi Framework  v30r3 (a5ef0a68)
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"
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 // ============================================================================
47 {
48  return o << "(" << Gaudi::Utils::toString( title() ) << "," << lowEdge() << "," << highEdge() << "," << bins() << ")";
49 }
50 namespace Gaudi
51 {
52  // ============================================================================
53  // ordering operator (to please BoundedVerifier)
54  // ============================================================================
55  bool operator<( const Gaudi::Histo1DDef& left, const Gaudi::Histo1DDef& right )
56  {
57  return std::tie( left.m_title, left.m_low, left.m_high, left.m_bins ) <
58  std::tie( right.m_title, right.m_low, right.m_high, right.m_bins );
59  }
60 // ============================================================================
61 // equality operator
62 // ============================================================================
63 #ifdef __ICC
64 // disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
65 #pragma warning( push )
66 #pragma warning( disable : 1572 )
67 #endif
68  bool operator==( const Gaudi::Histo1DDef& left, const Gaudi::Histo1DDef& right )
69  {
70  return std::tie( left.m_title, left.m_low, left.m_high, left.m_bins ) ==
71  std::tie( right.m_title, right.m_low, right.m_high, right.m_bins );
72  }
73 #ifdef __ICC
74 // re-enable icc remark #1572
75 #pragma warning( pop )
76 #endif
77  // ============================================================================
78  // non-equality
79  // ============================================================================
80  bool operator!=( const Gaudi::Histo1DDef& left, const Gaudi::Histo1DDef& right ) { return !( left == right ); }
81  // ============================================================================
82  // the streamer operator for class Gaudi::Histo1DDef
83  // ============================================================================
84  std::ostream& operator<<( std::ostream& o, const Gaudi::Histo1DDef& histo ) { return histo.fillStream( o ); }
85 }
86 // ============================================================================
87 
88 // ============================================================================
89 /* helper function to book 1D-histogram
90  * @param svc pointer to Histogram Service
91  * @param path full path in Histogram Data Store
92  * @param hist histogram desctriprion
93  */
94 // ============================================================================
95 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& path, const Gaudi::Histo1DDef& hist )
96 {
97  return svc ? svc->book( path, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
98 }
99 // ============================================================================
100 /* helper function to book 1D-histogram
101  * @param svc pointer to Histogram Service
102  * @param dir directory path in Histogram Data Store
103  * @param id histogram identifier
104  * @param hist histogram desctriprion
105  */
106 // ============================================================================
107 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& dir, const std::string& id,
108  const Gaudi::Histo1DDef& hist )
109 {
110  return svc ? svc->book( dir, id, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
111 }
112 // ============================================================================
113 /* helper function to book 1D-histogram
114  * @param svc pointer to Histogram Service
115  * @param dir directory path in Histogram Data Store
116  * @param id histogram identifier
117  * @param hist histogram desctriprion
118  */
119 // ============================================================================
120 AIDA::IHistogram1D* Gaudi::Histos::book( IHistogramSvc* svc, const std::string& dir, const int id,
121  const Gaudi::Histo1DDef& hist )
122 {
123  return svc ? svc->book( dir, id, hist.title(), hist.bins(), hist.lowEdge(), hist.highEdge() ) : nullptr;
124 }
125 // ============================================================================
126 
127 // ============================================================================
128 // The END
129 // ============================================================================
friend bool operator==(const Histo1DDef &left, const Histo1DDef &right)
equality operator
Definition: HistoDef.cpp:68
T tie(T...args)
GAUDI_API AIDA::IHistogram1D * book(IHistogramSvc *svc, const std::string &path, const Gaudi::Histo1DDef &hist)
helper function to book 1D-histogram
Definition: HistoDef.cpp:95
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:356
STL namespace.
double highEdge() const
get the high edge
Definition: HistoDef.h:58
double lowEdge() const
get the low edge
Definition: HistoDef.h:56
friend bool operator!=(const Histo1DDef &left, const Histo1DDef &right)
non-equality
Definition: HistoDef.cpp:80
const std::string & title() const
get the title
Definition: HistoDef.h:62
STL class.
double m_high
High Edge.
Definition: HistoDef.h:104
friend bool operator<(const Histo1DDef &left, const Histo1DDef &right)
ordering operator (to please BoundedVerifier)
Definition: HistoDef.cpp:55
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
Definition: HistoDef.h:33
std::string m_title
Histogram title.
Definition: HistoDef.h:100
Definition of the IHistogramSvc interface class.
Definition: IHistogramSvc.h:47
friend std::ostream & operator<<(std::ostream &o, const Gaudi::Histo1DDef &histo)
the streamer operator for class Gaudi::Histo1DDef
Definition: HistoDef.cpp:84
int bins() const
get the number of bins
Definition: HistoDef.h:60
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.
Histo1DDef(double low, double high, int bins=100, std::string title="")
full constructor from edges, bins and the title
Definition: HistoDef.cpp:27
implementation of various functions for streaming.
std::ostream & fillStream(std::ostream &o) const
printout of the histogram definition
Definition: HistoDef.cpp:46
int m_bins
Number of bins.
Definition: HistoDef.h:106
STL class.
Helper functions to set/get the application return code.
Definition: __init__.py:1
double m_low
Low Edge.
Definition: HistoDef.h:102