Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:14

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 #pragma once
0010 
0011 // Detray core include(s).
0012 #include "detray/definitions/algebra.hpp"
0013 #include "detray/definitions/containers.hpp"
0014 #include "detray/geometry/surface_descriptor.hpp"
0015 #include "detray/utils/ranges.hpp"
0016 
0017 // Detray tests include(s).
0018 #include "detray/test/framework/types.hpp"
0019 
0020 namespace detray::test {
0021 
0022 enum class plane_mask_id : unsigned int {
0023   e_plane_rectangle2D = 0u,
0024 };
0025 
0026 enum class plane_material_id : unsigned int {
0027   e_plane_material_slab = 0u,
0028 };
0029 
0030 // Helper type definitions.
0031 using plane_mask_link_t = dtyped_index<plane_mask_id, dindex>;
0032 using plane_material_link_t = dtyped_index<plane_material_id, dindex>;
0033 
0034 /// This method creates a number (distances.size()) planes along a direction
0035 template <concepts::algebra algebra_t = test::algebra>
0036 auto planes_along_direction(const dvector<dscalar<algebra_t>> &distances,
0037                             const dvector3D<algebra_t> &direction) {
0038   using vector3_t = dvector3D<algebra_t>;
0039   using transform3_t = dtransform3D<algebra_t>;
0040 
0041   // New z- and x-axes
0042   vector3_t z{vector::normalize(direction)};
0043   vector3_t x = vector::normalize(
0044       vector3_t{static_cast<dscalar<algebra_t>>(0.f), -z[2], z[1]});
0045 
0046   dvector<surface_descriptor<plane_mask_link_t, plane_material_link_t>>
0047       surfaces;
0048   dvector<transform3_t> transforms;
0049 
0050   surfaces.reserve(distances.size());
0051   transforms.reserve(distances.size());
0052 
0053   for (const auto [idx, d] : detray::views::enumerate(distances)) {
0054     vector3_t t = d * direction;
0055     transforms.emplace_back(t, z, x);
0056 
0057     plane_mask_link_t mask_link{plane_mask_id::e_plane_rectangle2D, idx};
0058     plane_material_link_t material_link{
0059         plane_material_id::e_plane_material_slab, 0u};
0060     surfaces.emplace_back(idx, std::move(mask_link), std::move(material_link),
0061                           0u, surface_id::e_sensitive);
0062     surfaces.back().set_index(idx);
0063   }
0064 
0065   return std::make_tuple(std::move(surfaces), std::move(transforms));
0066 }
0067 
0068 }  // namespace detray::test