| The Gaudi Framework v32r1 (f65d50dc)

H1.h
Go to the documentation of this file.
1 #ifndef GAUDIUTILS_H1_H
2 #define GAUDIUTILS_H1_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 namespace {
7 // ==========================================================================
9 typedef std::pair<double, double> Bin;
11 typedef std::vector<Bin> Bins;
12 // ==========================================================================
18 struct Edges final {
19 //
20 void setHighEdge( double value ) { high = value; }
21 void setLowEdge( double value ) { low = value; }
22 void setNBins( unsigned int value ) { nbins = value; }
23 void setEdges( std::vector<double> value ) { edges = std::move( value ); }
24 //
25 Edges& operator-=( double value ) {
26 setLowEdge( value );
27 return *this;
28 }
29 Edges& operator+=( double value ) {
30 setHighEdge( value );
31 return *this;
32 }
33 Edges& operator*=( std::vector<double> value ) {
34 setEdges( std::move( value ) );
35 return *this;
36 }
37 Edges& operator/=( unsigned int value ) {
38 setNBins( value );
39 return *this;
40 }
41 //
42 bool ok() const { return edges.empty() ? low < high && 0 < nbins : 2 < edges.size(); }
43 unsigned int nBins() const { return edges.empty() ? nbins : edges.size() - 1; }
44 //
45 double low;
46 double high;
47 unsigned int nbins;
48 std::vector<double> edges;
49 };
50 // ==========================================================================
56 struct H1 final {
57 //
58 void setName( std::string value ) { m_name = std::move( value ); }
59 void setTitle( std::string value ) { m_title = std::move( value ); }
60
61 void setEdges( Edges value ) { m_edges = std::move( value ); }
62 void setHighEdge( const double value ) { m_edges.setHighEdge( value ); }
63 void setLowEdge( const double value ) { m_edges.setLowEdge( value ); }
64 void setNBins( const unsigned int value ) { m_edges.setNBins( value ); }
65
66 void setBins( Bins value ) { m_bins = std::move( value ); }
67 //
68 H1& operator*=( std::string value ) {
69 setName( std::move( value ) );
70 return *this;
71 }
72 H1& operator/=( std::string value ) {
73 setTitle( std::move( value ) );
74 return *this;
75 }
76 H1& operator^=( const double value ) {
77 setHighEdge( value );
78 return *this;
79 }
80 H1& operator-=( const double value ) {
81 setLowEdge( value );
82 return *this;
83 }
84 H1& operator|=( const unsigned int value ) {
85 setNBins( value );
86 return *this;
87 }
88
89 H1& operator&=( Edges value ) {
90 setEdges( std::move( value ) );
91 return *this;
92 }
93 H1& operator+=( Bins value ) {
94 setBins( std::move( value ) );
95 return *this;
96 }
97 //
98 bool ok() const {
99 if ( m_bins.empty() ) { return false; }
100 if ( !m_edges.ok() ) { return false; }
101 if ( m_bins.size() != m_edges.nBins() + 2 ) { return false; }
102 return true;
103 }
104 //
105 std::string m_name;
106 std::string m_title;
107 Edges m_edges;
108 Bins m_bins;
109 };
110 // ==========================================================================
116 struct H2 final {
117 //
118 void setName( std::string value ) { m_name = std::move( value ); }
119 void setTitle( std::string value ) { m_title = std::move( value ); }
120 void setXEdges( Edges value ) { m_xedges = std::move( value ); }
121 void setYEdges( Edges value ) { m_yedges = std::move( value ); }
122 void setBins( Bins value ) { m_bins = std::move( value ); }
123 //
124 H2& operator*=( std::string value ) {
125 setName( std::move( value ) );
126 return *this;
127 }
128 H2& operator/=( std::string value ) {
129 setTitle( std::move( value ) );
130 return *this;
131 }
132 H2& operator&=( Edges value ) {
133 setXEdges( std::move( value ) );
134 return *this;
135 }
136 H2& operator|=( Edges value ) {
137 setYEdges( std::move( value ) );
138 return *this;
139 }
140 H2& operator+=( Bins value ) {
141 setBins( std::move( value ) );
142 return *this;
143 }
144 //
145 bool ok() const {
146 if ( m_bins.empty() ) { return false; }
147 if ( !m_xedges.ok() ) { return false; }
148 if ( !m_yedges.ok() ) { return false; }
149 if ( m_bins.size() != ( m_xedges.nBins() + 2 ) * ( m_yedges.nBins() + 2 ) ) { return false; }
150 return true;
151 }
152 //
153 //
154 std::string m_name;
155 std::string m_title;
156 Edges m_xedges;
157 Edges m_yedges;
158 Bins m_bins;
159 };
160 // ==========================================================================
161 } // end of anonymous namespace
162 // ============================================================================
163 // The END
164 // ============================================================================
165 #endif // GAUDIUTILS_H1_H
std::string
STL class.
std::move
T move(T... args)
std::pair
std::vector
STL class.
operator|=
bool & operator|=(bool &lhs, const StatusCode &sc)
Boolean OR assignment operator.
Definition: StatusCode.h:325
operator&=
bool & operator&=(bool &lhs, const StatusCode &sc)
Boolean AND assignment operator.
Definition: StatusCode.h:322