Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 09:31:05

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