Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:13:36

0001 // -*- C++ -*-
0002 //
0003 // This file is part of YODA -- Yet more Objects for Data Analysis
0004 // Copyright (C) 2008-2024 The YODA collaboration (see AUTHORS for details)
0005 //
0006 #ifndef YODA_BinUtils_h
0007 #define YODA_BinUtils_h
0008 
0009 #include "YODA/Utils/BinningUtils.h"
0010 
0011 namespace YODA {
0012 
0013   /// @name Mixin of convenience methods using CRTP
0014   /// @{
0015 
0016   /// @brief CRTP mixin introducing convenience aliases along X axis.
0017   template <class Derived, typename EdgeT = double>
0018   struct XBinMixin {
0019 
0020     /// @name Bin-interval properties
0021     /// @{
0022 
0023     /// @brief Upper bin edge along X axis.
0024     ///
0025     /// @note These are only supported for a continuous axis
0026     template<typename T = EdgeT>
0027     enable_if_CAxisT<T> xMax() const noexcept {
0028       return static_cast<const Derived*>(this)->template max<0>();
0029     }
0030 
0031     /// @brief Lower bin edge along X axis.
0032     ///
0033     /// @note These are only supported for a continuous axis
0034     template<typename T = EdgeT>
0035     enable_if_CAxisT<T> xMin() const noexcept {
0036       return static_cast<const Derived*>(this)->template min<0>();
0037     }
0038 
0039     /// @brief Bin centre along X axis.
0040     ///
0041     /// @note These are only supported for a continuous axis
0042     template<typename T = EdgeT>
0043     enable_if_CAxisT<T> xMid() const noexcept {
0044       return static_cast<const Derived*>(this)->template mid<0>();
0045     }
0046 
0047     /// @brief Bin width along X axis.
0048     ///
0049     /// @note These are only supported for a continuous axis
0050     template<typename T = EdgeT>
0051     enable_if_CAxisT<T> xWidth() const noexcept {
0052       return static_cast<const Derived*>(this)->template width<0>();
0053     }
0054 
0055     /// @brief Bin edge along X axis.
0056     ///
0057     /// @note These are only supported for a discrete axis
0058     template<typename T = EdgeT>
0059     enable_if_DAxisT<T> xEdge() const noexcept {
0060       return static_cast<const Derived*>(this)->template edge<0>();
0061     }
0062 
0063     /// @}
0064 
0065   };
0066 
0067 
0068   /// @brief CRTP mixin introducing convenience aliases along Y axis.
0069   template <class Derived, typename EdgeT = double>
0070   struct YBinMixin {
0071 
0072     /// @name Bin-interval properties
0073     /// @{
0074 
0075     /// @brief Upper bin edge along Y axis.
0076     ///
0077     /// @note These are only supported for a continuous axis
0078     template<typename T = EdgeT>
0079     enable_if_CAxisT<T> yMax() const noexcept {
0080       return static_cast<const Derived*>(this)->template max<1>();
0081     }
0082 
0083     /// @brief Lower bin edge along Y axis.
0084     ///
0085     /// @note These are only supported for a continuous axis
0086     template<typename T = EdgeT>
0087     enable_if_CAxisT<T> yMin() const noexcept {
0088       return static_cast<const Derived*>(this)->template min<1>();
0089     }
0090 
0091     /// @brief Bin centre along Y axis.
0092     ///
0093     /// @note These are only supported for a continuous axis
0094     template<typename T = EdgeT>
0095     enable_if_CAxisT<T> yMid() const noexcept {
0096       return static_cast<const Derived*>(this)->template mid<1>();
0097     }
0098 
0099     /// @brief Bin width along Y axis.
0100     ///
0101     /// @note These are only supported for a continuous axis
0102     template<typename T = EdgeT>
0103     enable_if_CAxisT<T> yWidth() const noexcept {
0104       return static_cast<const Derived*>(this)->template width<1>();
0105     }
0106 
0107     /// @brief Bin edge along Y axis.
0108     ///
0109     /// @note These are only supported for a discrete axis
0110     template<typename T = EdgeT>
0111     enable_if_DAxisT<T> yEdge() const noexcept {
0112       return static_cast<const Derived*>(this)->template edge<1>();
0113     }
0114 
0115     /// @}
0116 
0117   };
0118 
0119 
0120   /// @brief CRTP mixin introducing convenience aliases along Z axis.
0121   template <class Derived, typename EdgeT = double>
0122   struct ZBinMixin {
0123 
0124     /// @name Bin-interval properties
0125     /// @{
0126 
0127     /// @brief Upper bin edge along Z axis.
0128     template<typename T = EdgeT>
0129     enable_if_CAxisT<T> zMax() const noexcept {
0130       return static_cast<const Derived*>(this)->template max<2>();
0131     }
0132 
0133     /// @brief Lower bin edge along Z axis.
0134     ///
0135     /// @note These are only supported for a continuous axis
0136     template<typename T = EdgeT>
0137     enable_if_CAxisT<T> zMin() const noexcept {
0138       return static_cast<const Derived*>(this)->template min<2>();
0139     }
0140 
0141     /// @brief Bin centre along Z axis.
0142     ///
0143     /// @note These are only supported for a continuous axis
0144     template<typename T = EdgeT>
0145     enable_if_CAxisT<T> zMid() const noexcept {
0146       return static_cast<const Derived*>(this)->template mid<2>();
0147     }
0148 
0149     /// @brief Bin width along Z axis.
0150     ///
0151     /// @note These are only supported for a continuous axis
0152     template<typename T = EdgeT>
0153     enable_if_CAxisT<T> zWidth() const noexcept {
0154       return static_cast<const Derived*>(this)->template width<2>();
0155     }
0156 
0157     /// @brief Bin edge along Z axis.
0158     ///
0159     /// @note These are only supported for a discrete axis
0160     template<typename T = EdgeT>
0161     enable_if_DAxisT<T> zEdge() const noexcept {
0162       return static_cast<const Derived*>(this)->template edge<2>();
0163     }
0164 
0165     /// @}
0166 
0167   };
0168 
0169   /// @}
0170 
0171 }
0172 
0173 #endif