| The Gaudi Framework v32r1 (f65d50dc)

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 /* 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 // ============================================================================
42 std::ostream& Gaudi::Histo1DDef::fillStream( std::ostream& o ) const {
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 // ============================================================================
Gaudi::operator!=
bool operator!=(const T &v, const Property< TP, V, H > &p)
delegate (value != property) to property operator!=
Definition: Property.h:702
Gaudi::operator==
bool operator==(const T &v, const Property< TP, V, H > &p)
delegate (value == property) to property operator==
Definition: Property.h:696
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
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:87
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:334
std
STL namespace.
std::string
STL class.
Gaudi::Histo1DDef::fillStream
std::ostream & fillStream(std::ostream &o) const
printout of the histogram definition
Definition: HistoDef.cpp:42
Gaudi::Histo1DDef
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
Definition: HistoDef.h:31
IHistogramSvc
Definition of the IHistogramSvc interface class.
Definition: IHistogramSvc.h:46
Gaudi::Histo1DDef::title
const std::string & title() const
get the title
Definition: HistoDef.h:59
Gaudi::Histo1DDef::bins
int bins() const
get the number of bins
Definition: HistoDef.h:57
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::highEdge
double highEdge() const
get the high edge
Definition: HistoDef.h:55
std::ostream
STL class.
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
Gaudi::Histo1DDef::lowEdge
double lowEdge() const
get the low edge
Definition: HistoDef.h:53
Gaudi::operator<
bool operator<(const Gaudi::Histo1DDef &left, const Gaudi::Histo1DDef &right)
Definition: HistoDef.cpp:49
Gaudi::operator<<
std::ostream & operator<<(std::ostream &o, const Gaudi::StringKey &key)
printout of the object reply on the native printout for the string
Definition: StringKey.h:235
HistoDef.h
IHistogramSvc.h