ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
planes_along_direction.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Detray core include(s).
12#include "detray/definitions/algebra.hpp"
13#include "detray/definitions/containers.hpp"
14#include "detray/geometry/surface_descriptor.hpp"
15#include "detray/utils/ranges.hpp"
16
17// Detray tests include(s).
18#include "detray/test/framework/types.hpp"
19
20namespace detray::test {
21
22enum class plane_mask_id : unsigned int {
23 e_plane_rectangle2D = 0u,
24};
25
26enum class plane_material_id : unsigned int {
27 e_plane_material_slab = 0u,
28};
29
30// Helper type definitions.
31using plane_mask_link_t = dtyped_index<plane_mask_id, dindex>;
32using plane_material_link_t = dtyped_index<plane_material_id, dindex>;
33
35template <concepts::algebra algebra_t = test::algebra>
36auto planes_along_direction(const dvector<dscalar<algebra_t>> &distances,
37 const dvector3D<algebra_t> &direction) {
38 using vector3_t = dvector3D<algebra_t>;
39 using transform3_t = dtransform3D<algebra_t>;
40
41 // New z- and x-axes
42 vector3_t z{vector::normalize(direction)};
43 vector3_t x = vector::normalize(
44 vector3_t{static_cast<dscalar<algebra_t>>(0.f), -z[2], z[1]});
45
47 surfaces;
48 dvector<transform3_t> transforms;
49
50 surfaces.reserve(distances.size());
51 transforms.reserve(distances.size());
52
53 for (const auto [idx, d] : detray::views::enumerate(distances)) {
54 vector3_t t = d * direction;
55 transforms.emplace_back(t, z, x);
56
57 plane_mask_link_t mask_link{plane_mask_id::e_plane_rectangle2D, idx};
58 plane_material_link_t material_link{
59 plane_material_id::e_plane_material_slab, 0u};
60 surfaces.emplace_back(idx, std::move(mask_link), std::move(material_link),
61 0u, surface_id::e_sensitive);
62 surfaces.back().set_index(idx);
63 }
64
65 return std::make_tuple(std::move(surfaces), std::move(transforms));
66}
67
68} // namespace detray::test
constexpr double u
atomic mass unit u
Definition Units.hpp:155
get_scalar_t< A, T > dscalar
Scalar type for algebra A and value type T.
Definition algebra.hpp:64
vecmem::vector< value_t > dvector
Vector container backed by vecmem.
Definition containers.hpp:34
detail::typed_index< id_t, index_t, value_t, id_mask, index_mask > dtyped_index
Link consisting of a type ID and an index.
Definition indexing.hpp:39
get_vector3D_t< A, T > dvector3D
Three-dimensional vector type for algebra A and value type T.
Definition algebra.hpp:80
get_transform3D_t< A, T > dtransform3D
Three-dimensional transform type for algebra A and value type T.
Definition algebra.hpp:84