File indexing completed on 2026-07-19 08:31:39
0001
0002
0003
0004
0005
0006 #ifndef YODA_BinningUtils_h
0007 #define YODA_BinningUtils_h
0008
0009 #include <type_traits>
0010 #include <string>
0011
0012 namespace YODA {
0013
0014
0015
0016
0017
0018 template <typename... EdgeT>
0019 using all_CAxes = typename std::conjunction<std::is_floating_point<EdgeT>...>;
0020
0021
0022 template <typename... EdgeT>
0023 using enable_if_all_CAxisT = std::enable_if_t<all_CAxes<EdgeT...>::value>;
0024
0025
0026 template <typename EdgeT>
0027 using enable_if_CAxisT = std::enable_if_t<std::is_floating_point<EdgeT>::value, EdgeT>;
0028
0029
0030 template <typename EdgeT>
0031 using enable_if_DAxisT = std::enable_if_t<!std::is_floating_point<EdgeT>::value, EdgeT>;
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 template <typename T>
0047 struct TypeID {
0048 static const char* name() { return typeid(T).name(); }
0049 };
0050
0051
0052 template <>
0053 struct TypeID<std::string> {
0054 static const char* name() { return "s"; }
0055 };
0056
0057
0058 template<typename A, typename... As>
0059 std::string mkAxisConfig() {
0060 return (std::string(TypeID<A>::name()) + ... + TypeID<As>::name());
0061 }
0062
0063
0064
0065 template <ssize_t DbnN, typename A, typename... As>
0066 std::string mkTypeString() {
0067
0068 constexpr size_t N = sizeof...(As)+1;
0069
0070 if constexpr (all_CAxes<A, As...>::value) {
0071 if constexpr (DbnN < 0) {
0072 return "Estimate"+std::to_string(N)+"D";
0073 }
0074 if constexpr (DbnN == N+1) {
0075 return "Profile"+std::to_string(N)+"D";
0076 }
0077 if constexpr (DbnN == N) {
0078 return "Histo"+std::to_string(N)+"D";
0079 }
0080 }
0081
0082 std::string type = "Binned";
0083 if (DbnN < 0) type += "Estimate";
0084 else if (DbnN == N) type += "Histo";
0085 else if (DbnN == N+1) type += "Profile";
0086 else type += "Dbn" + std::to_string(DbnN);
0087
0088 std::string axes = (TypeID<A>::name() + ... + (std::string{","} + TypeID<As>::name()));
0089
0090 return (type + "<" + axes + ">");
0091 }
0092
0093
0094 template <typename A, typename... As>
0095 std::string mkTypeString() { return mkTypeString<-1, A, As...>(); }
0096
0097
0098
0099 }
0100
0101 #endif