| The Gaudi Framework v30r0 (c919700c)

- 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/HistoDef.h"
11 #include "GaudiKernel/IHistogramSvc.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 // ============================================================================
46 std::ostream& Gaudi::Histo1DDef::fillStream( std::ostream& o ) const
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 // ============================================================================
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:895
Gaudi::Histo1DDef::operator==
friend bool operator==(const Histo1DDef &left, const Histo1DDef &right)
equality operator
Definition: HistoDef.cpp:68
std::tie
T tie(T...args)
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:95
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:346
std
STL namespace.
Gaudi::Histo1DDef::highEdge
double highEdge() const
get the high edge
Definition: HistoDef.h:58
Gaudi::Histo1DDef::lowEdge
double lowEdge() const
get the low edge
Definition: HistoDef.h:56
Gaudi::Histo1DDef::operator!=
friend bool operator!=(const Histo1DDef &left, const Histo1DDef &right)
non-equality
Definition: HistoDef.cpp:80
Gaudi::Histo1DDef::title
const std::string & title() const
get the title
Definition: HistoDef.h:62
std::string
STL class.
Gaudi::Histo1DDef::m_high
double m_high
High Edge.
Definition: HistoDef.h:104
Gaudi::Histo1DDef::operator<
friend bool operator<(const Histo1DDef &left, const Histo1DDef &right)
ordering operator (to please BoundedVerifier)
Definition: HistoDef.cpp:55
Gaudi::Histo1DDef
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
Definition: HistoDef.h:33
Gaudi::Histo1DDef::m_title
std::string m_title
Histogram title.
Definition: HistoDef.h:100
IHistogramSvc
Definition of the IHistogramSvc interface class.
Definition: IHistogramSvc.h:47
Gaudi::Histo1DDef::operator<<
friend std::ostream & operator<<(std::ostream &o, const Gaudi::Histo1DDef &histo)
the streamer operator for class Gaudi::Histo1DDef
Definition: HistoDef.cpp:84
Gaudi::Histo1DDef::bins
int bins() const
get the number of bins
Definition: HistoDef.h:60
IHistogramSvc::book
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.
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:27
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:46
Gaudi::Histo1DDef::m_bins
int m_bins
Number of bins.
Definition: HistoDef.h:106
std::ostream
STL class.
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::Histo1DDef::m_low
double m_low
Low Edge.
Definition: HistoDef.h:102
HistoDef.h
IHistogramSvc.h