File indexing completed on 2025-01-18 09:11:31
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Utilities/AxisDefinitions.hpp"
0010
0011 #include <algorithm>
0012 #include <ostream>
0013 #include <stdexcept>
0014
0015 namespace Acts {
0016
0017 namespace {
0018
0019
0020
0021
0022 const std::vector<std::string> s_legacyBinningValueNames = {
0023 "binX", "binY", "binZ", "binR", "binPhi",
0024 "binRPhi", "binH", "binEta", "binMag"};
0025
0026
0027 const std::vector<std::string> s_axisDirectionNames = {
0028 "AxisX", "AxisY", "AxisZ", "AxisR", "AxisPhi",
0029 "AxisRPhi", "AxisTheta", "AxisEta", "AxisMag"};
0030
0031 const std::vector<AxisDirection> s_axisDirections = {
0032 AxisDirection::AxisX, AxisDirection::AxisY, AxisDirection::AxisZ,
0033 AxisDirection::AxisR, AxisDirection::AxisPhi, AxisDirection::AxisRPhi,
0034 AxisDirection::AxisTheta, AxisDirection::AxisEta, AxisDirection::AxisMag};
0035
0036 }
0037
0038 const std::vector<AxisDirection>& allAxisDirections() {
0039 return s_axisDirections;
0040 }
0041
0042 AxisDirection axisDirectionFromName(const std::string& name) {
0043 auto it = std::ranges::find(s_axisDirectionNames, name);
0044 if (it == s_axisDirectionNames.end()) {
0045
0046 it = std::ranges::find(s_legacyBinningValueNames, name);
0047 if (it == s_legacyBinningValueNames.end()) {
0048 throw std::invalid_argument("Unknown AxisDirection value name: " + name);
0049 }
0050
0051 }
0052 return static_cast<AxisDirection>(
0053 std::distance(s_axisDirectionNames.begin(), it));
0054 }
0055
0056 const std::string& axisDirectionName(AxisDirection aDir) {
0057 return s_axisDirectionNames.at(
0058 static_cast<std::underlying_type_t<AxisDirection>>(aDir));
0059 }
0060
0061 std::ostream& operator<<(std::ostream& os, AxisDirection aDir) {
0062 os << axisDirectionName(aDir);
0063 return os;
0064 }
0065
0066 }