File indexing completed on 2025-04-19 09:13:36
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 template <typename... EdgeT>
0018 using all_CAxes = typename std::conjunction<std::is_floating_point<EdgeT>...>;
0019
0020
0021 template <typename... EdgeT>
0022 using enable_if_all_CAxisT = std::enable_if_t<all_CAxes<EdgeT...>::value>;
0023
0024
0025 template <typename EdgeT>
0026 using enable_if_CAxisT = std::enable_if_t<std::is_floating_point<EdgeT>::value, EdgeT>;
0027
0028
0029 template <typename EdgeT>
0030 using enable_if_DAxisT = std::enable_if_t<!std::is_floating_point<EdgeT>::value, EdgeT>;
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 template <typename T>
0046 struct TypeID {
0047 static const char* name() { return typeid(T).name(); }
0048 };
0049
0050
0051 template <>
0052 struct TypeID<std::string> {
0053 static const char* name() { return "s"; }
0054 };
0055
0056
0057 template<typename A, typename... As>
0058 std::string mkAxisConfig() {
0059 return (std::string(TypeID<A>::name()) + ... + TypeID<As>::name());
0060 }
0061
0062
0063
0064 template <ssize_t DbnN, typename A, typename... As>
0065 std::string mkTypeString() {
0066
0067 constexpr size_t N = sizeof...(As)+1;
0068
0069 if constexpr (all_CAxes<A, As...>::value) {
0070 if constexpr (DbnN < 0) {
0071 return "Estimate"+std::to_string(N)+"D";
0072 }
0073 if constexpr (DbnN == N+1) {
0074 return "Profile"+std::to_string(N)+"D";
0075 }
0076 if constexpr (DbnN == N) {
0077 return "Histo"+std::to_string(N)+"D";
0078 }
0079 }
0080
0081 std::string type = "Binned";
0082 if (DbnN < 0) type += "Estimate";
0083 else if (DbnN == N) type += "Histo";
0084 else if (DbnN == N+1) type += "Profile";
0085 else type += "Dbn" + std::to_string(DbnN);
0086
0087 std::string axes = (TypeID<A>::name() + ... + (std::string{","} + TypeID<As>::name()));
0088
0089 return (type + "<" + axes + ">");
0090 }
0091
0092
0093 template <typename A, typename... As>
0094 std::string mkTypeString() { return mkTypeString<-1, A, As...>(); }
0095
0096
0097
0098 }
0099
0100 #endif