Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:15:17

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 // For whatever reason, this compilation unit does not compile
0010 // with those assertions and GCC 13. For now just disable the
0011 // flags in this case.
0012 #if defined(_GLIBCXX_ASSERTIONS) && __GNUC__ == 13
0013 #undef _GLIBCXX_ASSERTIONS
0014 #endif
0015 
0016 #include "Acts/Plugins/Json/DetrayJsonHelper.hpp"
0017 
0018 namespace Acts::DetrayJsonHelper {
0019 
0020 std::tuple<unsigned int, std::vector<double>> maskFromBounds(
0021     const Acts::SurfaceBounds& sBounds, bool portal) {
0022   auto bType = sBounds.type();
0023   auto bValues = sBounds.values();
0024   // Return value
0025   unsigned int type = 13u;
0026   std::vector<double> boundaries = bValues;
0027   // Special treatment for some portals
0028   if (portal && bType == SurfaceBounds::BoundsType::eCylinder) {
0029     boundaries = {bValues[0u], -bValues[1u], bValues[1u]};
0030     type = 4u;
0031   } else {
0032     switch (bType) {
0033       case SurfaceBounds::BoundsType::eAnnulus: {
0034         type = 0u;
0035       } break;
0036       case SurfaceBounds::BoundsType::eRectangle: {
0037         type = 5u;
0038         // ACTS: eMinX = 0, eMinY = 1, eMaxX = 2, eMaxY = 3,
0039         // detray: e_half_x, e_half_y
0040         boundaries = {0.5 * (bValues[2] - bValues[0]),
0041                       0.5 * (bValues[3] - bValues[1])};
0042       } break;
0043       case SurfaceBounds::BoundsType::eCylinder: {
0044         boundaries = {bValues[0u], -bValues[1u], bValues[1u]};
0045         type = 2u;
0046       } break;
0047       case SurfaceBounds::BoundsType::eTrapezoid: {
0048         type = 7u;
0049         boundaries = {bValues[0u], bValues[1u], bValues[2u],
0050                       1 / (2 * bValues[2u])};
0051       } break;
0052       case SurfaceBounds::BoundsType::eDisc: {
0053         boundaries = {bValues[0u], bValues[1u]};
0054         type = 6u;
0055       } break;
0056       default:
0057         break;
0058     }
0059   }
0060   return {type, boundaries};
0061 }
0062 
0063 void addVolumeLink(nlohmann::json& jSurface, int vLink) {
0064   jSurface["volume_link"] = vLink;
0065 }
0066 
0067 std::size_t accelerationLink(std::span<const AxisDirection> casts) {
0068   // Default is `brute_force`
0069   using enum AxisDirection;
0070   std::size_t accLink = 0u;
0071   if (casts.size() == 2u) {
0072     if (casts[0u] == AxisX && casts[1u] == AxisY) {
0073       accLink = 1u;
0074     } else if (casts[0u] == AxisR && casts[1u] == AxisPhi) {
0075       accLink = 3u;
0076     } else if (casts[0u] == AxisZ && casts[1u] == AxisPhi) {
0077       accLink = 4u;
0078     } else if (casts[0u] == AxisZ && casts[1u] == AxisR) {
0079       accLink = 5u;
0080     }
0081   } else if (casts.size() == 3u) {
0082     if (casts[0u] == AxisX && casts[1u] == AxisY && casts[2u] == AxisZ) {
0083       accLink = 2u;
0084     } else if (casts[0u] == AxisZ && casts[1u] == AxisPhi &&
0085                casts[2u] == AxisR) {
0086       accLink = 5u;
0087     }
0088   }
0089   return accLink;
0090 }
0091 }  // namespace Acts::DetrayJsonHelper