File indexing completed on 2025-01-18 09:27:42
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Surfaces/SurfaceBounds.hpp"
0012 #include "Acts/Utilities/BinningData.hpp"
0013
0014 #include <string>
0015 #include <tuple>
0016
0017 #include <nlohmann/json.hpp>
0018
0019 namespace Acts::DetrayJsonHelper {
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 inline static std::tuple<unsigned int, std::vector<ActsScalar>> maskFromBounds(
0044 const Acts::SurfaceBounds& sBounds, bool portal = false) {
0045 auto bType = sBounds.type();
0046 auto bValues = sBounds.values();
0047
0048 unsigned int type = 13u;
0049 std::vector<double> boundaries = bValues;
0050
0051 if (portal && bType == SurfaceBounds::BoundsType::eCylinder) {
0052 boundaries = {bValues[0u], -bValues[1u], bValues[1u]};
0053 type = 4u;
0054 } else {
0055 switch (bType) {
0056 case SurfaceBounds::BoundsType::eAnnulus: {
0057 type = 0u;
0058 } break;
0059 case SurfaceBounds::BoundsType::eRectangle: {
0060 type = 5u;
0061
0062
0063 boundaries = {0.5 * (bValues[2] - bValues[0]),
0064 0.5 * (bValues[3] - bValues[1])};
0065 } break;
0066 case SurfaceBounds::BoundsType::eCylinder: {
0067 boundaries = {bValues[0u], -bValues[1u], bValues[1u]};
0068 type = 2u;
0069 } break;
0070 case SurfaceBounds::BoundsType::eTrapezoid: {
0071 type = 7u;
0072 boundaries = {bValues[0u], bValues[1u], bValues[2u],
0073 1 / (2 * bValues[2u])};
0074 } break;
0075 case SurfaceBounds::BoundsType::eDisc: {
0076 boundaries = {bValues[0u], bValues[1u]};
0077 type = 6u;
0078 } break;
0079 default:
0080 break;
0081 }
0082 }
0083 return std::tie(type, boundaries);
0084 }
0085
0086
0087
0088
0089
0090 inline static void addVolumeLink(nlohmann::json& jSurface, int vLink) {
0091 jSurface["volume_link"] = vLink;
0092 }
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107 template <typename binning_values_t>
0108 inline static std::size_t accelerationLink(const binning_values_t& casts) {
0109
0110 std::size_t accLink = 0u;
0111 if (casts.size() == 2u) {
0112 if (casts[0u] == binX && casts[1u] == binY) {
0113 accLink = 1u;
0114 } else if (casts[0u] == binR && casts[1u] == binPhi) {
0115 accLink = 3u;
0116 } else if (casts[0u] == binZ && casts[1u] == binPhi) {
0117 accLink = 4u;
0118 } else if (casts[0u] == binZ && casts[1u] == binR) {
0119 accLink = 5u;
0120 }
0121 } else if (casts.size() == 3u) {
0122 if (casts[0u] == binX && casts[1u] == binY && casts[2u] == binZ) {
0123 accLink = 2u;
0124 } else if (casts[0u] == binZ && casts[1u] == binPhi && casts[2u] == binR) {
0125 accLink = 5u;
0126 }
0127 }
0128 return accLink;
0129 }
0130
0131 }