Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:31

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
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 // Legacy binning value names
0020 //
0021 // NOTE: this should be removed once the BinUtility is removed
0022 const std::vector<std::string> s_legacyBinningValueNames = {
0023     "binX",    "binY", "binZ",   "binR",  "binPhi",
0024     "binRPhi", "binH", "binEta", "binMag"};
0025 // end of legacy binning values
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 }  // namespace
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     // Legacy binning check - this should be removed once BinUtility is gone
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     // both legacy and current failed
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 }  // namespace Acts