File indexing completed on 2025-01-18 09:12:18
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Plugins/Detray/DetrayConversionUtils.hpp"
0010
0011 detray::axis::label Acts::DetrayConversionUtils::convertAxisDirection(
0012 AxisDirection bValue) {
0013 switch (bValue) {
0014 case AxisDirection::AxisX:
0015 return detray::axis::label::e_x;
0016 case AxisDirection::AxisY:
0017 return detray::axis::label::e_y;
0018 case AxisDirection::AxisZ:
0019 return detray::axis::label::e_z;
0020 case AxisDirection::AxisR:
0021 return detray::axis::label::e_r;
0022 case AxisDirection::AxisPhi:
0023 return detray::axis::label::e_phi;
0024 case AxisDirection::AxisRPhi:
0025 return detray::axis::label::e_rphi;
0026 default:
0027 throw std::invalid_argument(
0028 "DetrayMaterialConverter: unknown binning value detected.");
0029 }
0030 }
0031
0032 detray::axis::bounds Acts::DetrayConversionUtils::convertBinningOption(
0033 BinningOption bOption) {
0034
0035
0036
0037
0038 switch (bOption) {
0039 case BinningOption::closed:
0040 return detray::axis::bounds::e_circular;
0041 case BinningOption::open:
0042 return detray::axis::bounds::e_closed;
0043 default:
0044 throw std::invalid_argument(
0045 "DetrayMaterialConverter: unknown binning option detected.");
0046 }
0047 }
0048
0049 detray::axis::binning Acts::DetrayConversionUtils::convertBinningType(
0050 BinningType bType) {
0051 switch (bType) {
0052 case BinningType::equidistant:
0053 return detray::axis::binning::e_regular;
0054 case BinningType::arbitrary:
0055 return detray::axis::binning::e_irregular;
0056 default:
0057 throw std::invalid_argument(
0058 "DetrayMaterialConverter: unknown binning type detected.");
0059 }
0060 }
0061
0062 detray::io::axis_payload Acts::DetrayConversionUtils::convertBinningData(
0063 const BinningData& bData) {
0064 detray::io::axis_payload axis;
0065
0066 axis.bins = bData.bins();
0067
0068 axis.binning = convertBinningType(bData.type);
0069
0070 axis.bounds = convertBinningOption(bData.option);
0071
0072 axis.label = convertAxisDirection(bData.binvalue);
0073
0074 axis.edges = {};
0075 if (bData.type == BinningType::equidistant) {
0076 axis.edges = {bData.min, bData.max};
0077 } else {
0078 axis.edges.insert(axis.edges.end(), bData.boundaries().begin(),
0079 bData.boundaries().end());
0080 }
0081 return axis;
0082 }