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