YODA::Axis< T, typename > Class Template Reference Discrete axis with edges of non-floating-point-type. More...
Detailed Descriptiontemplate<typename T, typename = void> class YODA::Axis< T, typename > Discrete axis with edges of non-floating-point-type.
Definition at line 91 of file BinnedAxis.h. Member Typedef Documentation◆ const_iterator
template<typename T , typename = void>
Definition at line 95 of file BinnedAxis.h. ◆ ContainerT
template<typename T , typename = void>
Definition at line 94 of file BinnedAxis.h. ◆ EdgeT
template<typename T , typename = void>
Definition at line 93 of file BinnedAxis.h. Constructor & Destructor Documentation◆ Axis() [1/6]
template<typename T , typename = void>
◆ Axis() [2/6]
template<typename T , typename U >
Constructs discrete Axis from edges vector.
Concept check shall appear inside body of type's member function or outside of type, since otherwise type is considered incomplete. Definition at line 223 of file BinnedAxis.h. 226 static_assert(MetaUtils::checkConcept<Axis<EdgeT>, YODAConcepts::AxisImpl>(),
227 "Axis<T> should implement Axis concept.");
228 }
std::vector< EdgeT > edges() const noexcept Returns a copy of the container of edges. Definition BinnedAxis.h:259 ◆ Axis() [3/6]
template<typename T , typename U >
Constructs discrete Axis from edges vector (rvalue).
Definition at line 231 of file BinnedAxis.h. 231 {
233 }
void fillEdges(std::vector< EdgeT > &&edges) noexcept Fills edge storage. Used in constructors. Definition BinnedAxis.h:309 ◆ Axis() [4/6]
template<typename T , typename U >
Constructs discrete Axis from an initializer list.
Definition at line 236 of file BinnedAxis.h. ◆ Axis() [5/6]
template<typename T , typename = void>
Move constructs Axis. Definition at line 119 of file BinnedAxis.h. 119: _edges(std::move(other._edges)) {}
◆ Axis() [6/6]
template<typename T , typename = void>
Member Function Documentation◆ begin()
template<typename T , typename = void>
Returns the const begin iterator for the edges container. Definition at line 182 of file BinnedAxis.h. 182{ return _edges.cbegin(); }
Referenced by YODA::Axis< T, typename >::sharedEdges(). ◆ edge()
template<typename T , typename U >
Returns edge corresponding to index i. Definition at line 248 of file BinnedAxis.h. 248 {
249 if (this->_edges.empty()) {
250 throw RangeError("Axis has no edges!");
251 }
252 if (!i || i > this->_edges.size()) {
253 throw RangeError("Invalid index, must be in range 1.." + std::to_string(this->_edges.size()));
254 }
255 return this->_edges.at(i-1);
256 }
◆ edges()
template<typename T , typename U >
Returns a copy of the container of edges. Definition at line 259 of file BinnedAxis.h. 259 {
260 return this->_edges;
261 }
◆ end()
template<typename T , typename = void>
Returns the const end iterator for the edges container. Definition at line 185 of file BinnedAxis.h. 185{ return _edges.cend(); }
◆ fillEdges()
template<typename T , typename U >
Fills edge storage. Used in constructors. Definition at line 309 of file BinnedAxis.h. 309 {
311 if (std::find(this->_edges.begin(),
313 _edges.emplace_back(std::move(edge));
314 }
315 }
◆ hasSameEdges()
template<typename T , typename U >
Checks if two axes have exactly the same edges. Definition at line 276 of file BinnedAxis.h. 276 {
277 return _edges.size() == other._edges.size() &&
278 std::equal(_edges.begin(), _edges.end(), other._edges.begin());
279 }
References YODA::Axis< T, typename >::size(). ◆ index()
template<typename T , typename U >
Returns index of edge x.
Definition at line 241 of file BinnedAxis.h. 241 {
242 auto it = std::find(this->_edges.begin(), this->_edges.end(), x);
243 if (it == this->_edges.end()) return 0; // otherflow
244 return it - this->_edges.begin() + 1;
245 }
◆ isSubsetEdges()
template<typename T , typename U >
Check if other axis edges are a subset of edges of this one.
Definition at line 294 of file BinnedAxis.h. 294 {
296
297 std::vector<T> edgesLhs(edges());
298 std::vector<T> edgesRhs(other.edges());
299
300 std::sort(edgesLhs.begin(), edgesLhs.end());
301 std::sort(edgesRhs.begin(), edgesRhs.end());
302
304 return std::includes(edgesLhs.begin(), edgesLhs.end(),
305 edgesRhs.begin(), edgesRhs.end());
306 }
bool hasSameEdges(const Axis< T > &other) const noexcept Checks if two axes have exactly the same edges. Definition BinnedAxis.h:276 ◆ maxEdgeWidth()
template<typename T , typename = void>
Definition at line 156 of file BinnedAxis.h. 156 {
157 int maxwidth = 0;
158 if constexpr (hasWidth<EdgeT>::value) {
159 auto it = std::max_element(_edges.begin(), _edges.end(),
160 [](const auto& a, const auto& b) {
161 return a.size() < b.size();
162 });
163 maxwidth = (*it).size();
164 }
165 return maxwidth;
166 }
◆ numBins()
template<typename T , typename U >
Returns number of bins of this axis. Includes +1 for the otherflow bin. Definition at line 271 of file BinnedAxis.h. 271 {
272 return _edges.size() + (includeOverflows? 1 : 0);
273 }
References YODA::Axis< T, typename >::size(). ◆ operator=() [1/2]
template<typename T , typename = void>
Definition at line 129 of file BinnedAxis.h. 129 {
130 if (this != &other) _edges = std::move(other._edges);
131 return *this;
132 }
◆ operator=() [2/2]
template<typename T , typename = void>
Definition at line 124 of file BinnedAxis.h. 124 {
125 if (this != &other) _edges = other._edges;
126 return *this;
127 }
◆ sharedEdges()
template<typename T , typename U >
Finds shared between Axes edges.
Definition at line 282 of file BinnedAxis.h. 282 {
283 std::vector<EdgeT> res;
284 const auto& otherBegin = other._edges.begin();
285 const auto& otherEnd = other._edges.end();
288 res.emplace_back(std::move(edge));
289 }
290 return res;
291 }
References YODA::Axis< T, typename >::begin(). ◆ size()
template<typename T , typename U >
Returns number of edges + 1 for this Axis. Includes +1 for the otherflow bin. Definition at line 265 of file BinnedAxis.h. 265 {
267 }
size_t numBins(const bool includeOverflows=false) const noexcept Returns number of bins of this axis. Definition BinnedAxis.h:271 Referenced by YODA::Axis< T, typename >::hasSameEdges(), YODA::Axis< T, typename >::numBins(), and YODA::Axis< T, isCAxis< T > >::numBins(). ◆ type()
template<typename T , typename = void>
The documentation for this class was generated from the following file:
Generated on Mon Oct 28 2024 13:47:24 for YODA - Yet more Objects for Data Analysis by 1.9.8 |