ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
ray_cylinder_intersector.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// Project include(s)
12#include "detray/definitions/algebra.hpp"
13#include "detray/definitions/detail/qualifiers.hpp"
14#include "detray/definitions/math.hpp"
15#include "detray/definitions/units.hpp"
16#include "detray/geometry/coordinates/cylindrical2D.hpp"
17#include "detray/navigation/intersection/intersection.hpp"
18#include "detray/tracks/ray.hpp"
19#include "detray/utils/quadratic_equation.hpp"
20
21// System include(s)
22#include <type_traits>
23
24namespace detray {
25
26template <typename frame_t, concepts::algebra algebra_t, bool resolve_pos>
28
30template <detray::concepts::soa algebra_t, bool resolve_pos>
31struct ray_intersector_impl<cylindrical2D<algebra_t>, algebra_t, resolve_pos> {
34 using algebra_type = algebra_t;
44
46 template <typename surface_descr_t>
49
51 template <typename other_algebra_t>
53
54 // Maximum number of solutions this intersector can produce
55 static constexpr std::uint8_t n_solutions{2u};
56
61
68 template <typename mask_t, concepts::algebra other_algebra_t>
69 DETRAY_HOST_DEVICE constexpr result_type point_of_intersection(
71 const mask_t &mask, const scalar_type /*overstep_tol*/ = 0.f) const {
72 // One or both of these solutions might be invalid
73 const auto qe = solve_intersection(ray, mask, trf);
74
75 const auto &pos = ray.pos();
76 const auto &dir = ray.dir();
77 const point3_type ro{pos[0], pos[1], pos[2]};
78 const vector3_type rd{dir[0], dir[1], dir[2]};
79
80 result_type results;
81
82 results[0].path = qe.smaller();
83 results[0].point = ro + qe.smaller() * rd;
84
85 results[1].path = qe.larger();
86 results[1].point = ro + qe.larger() * rd;
87
88 return results;
89 }
90
91 protected:
99 template <typename mask_t, typename other_algebra_t>
100 DETRAY_HOST_DEVICE inline auto solve_intersection(
101 const trajectory_type<other_algebra_t> &ray, const mask_t &mask,
102 const transform3_type &trf) const {
103 const vector3_type &sz = trf.z();
104 const point3_type &sc = trf.translation();
105
106 const scalar_type r = mask[mask_t::shape::e_r];
107
108 const auto &pos = ray.pos();
109 const auto &dir = ray.dir();
110 const point3_type ro{pos[0], pos[1], pos[2]};
111 const vector3_type rd{dir[0], dir[1], dir[2]};
112
113 const vector3_type tmp = ro - sc;
114 const auto pc_cross_sz = vector::cross(tmp, sz);
115 const auto rd_cross_sz = vector::cross(rd, sz);
116 const scalar_type a = vector::dot(rd_cross_sz, rd_cross_sz);
117 const scalar_type b = 2.f * vector::dot(rd_cross_sz, pc_cross_sz);
118 const scalar_type c = vector::dot(pc_cross_sz, pc_cross_sz) - (r * r);
119
121 }
122};
123
124} // namespace detray
Definition quadratic_equation.hpp:24
describes a straight-line trajectory
Definition ray.hpp:22
This class holds the intersection information.
Definition intersection.hpp:212
Mask a region on a surface and link it to a volume.
Definition mask.hpp:46
Detray include(s).
Definition array_operators.hpp:18
get_scalar_t< A, T > dscalar
Scalar type for algebra A and value type T.
Definition algebra.hpp:64
std::array< value_t, kDIM > darray
Fixed-size array container.
Definition containers.hpp:30
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
get_point3D_t< A, T > dpoint3D
Three-dimensional point type for algebra A and value type T.
Definition algebra.hpp:72
Projection into a 2D cylindrical coordinate frame.
Definition cylindrical2D.hpp:20
Result of intersector: Point of intersection on a surface.
Definition intersection.hpp:43
algebra_t algebra_type
Algebra policy used by this intersector.
Definition ray_cylinder_intersector.hpp:34
dpoint3D< algebra_t > point3_type
Three-dimensional point type used by this intersector.
Definition ray_cylinder_intersector.hpp:38
intersection2D< surface_descr_t, algebra_t, resolve_pos > intersection_type
Intersection result type associated with a surface descriptor.
Definition ray_cylinder_intersector.hpp:42
detail::quadratic_equation< dscalar< algebra_t > > solve_intersection(const trajectory_type< algebra_t > &ray, const mask_t &mask, const dtransform3D< algebra_t > &trf) const
Calculates the distance to the (two) intersection points on the cylinder in global coordinates.
Definition ray_cylinder_intersector.hpp:105
static constexpr std::uint8_t n_solutions
Maximum number of solutions produced by this intersector.
Definition ray_cylinder_intersector.hpp:51
detail::ray< other_algebra_t > trajectory_type
Trajectory representation accepted by this intersector.
Definition ray_cylinder_intersector.hpp:47
darray< intersection_point< algebra_t, point_type, intersection::contains_pos >, n_solutions > result_type
Result type returned by the geometric intersection calculation.
Definition ray_cylinder_intersector.hpp:54
dvector3D< algebra_t > vector3_type
Three-dimensional vector type used by this intersector.
Definition ray_cylinder_intersector.hpp:40
auto solve_intersection(const trajectory_type< other_algebra_t > &ray, const mask_t &mask, const transform3_type &trf) const
Calculates the distance to the (two) intersection points on the cylinder in global coordinates.
Definition ray_cylinder_intersector.hpp:100
constexpr result_type point_of_intersection(const trajectory_type< other_algebra_t > &ray, const transform3_type &trf, const mask_t &mask, const scalar_type=0.f) const
Operator function to find intersections between ray and planar mask.
Definition ray_cylinder_intersector.hpp:69
dscalar< algebra_t > scalar_type
Scalar calculation type for the configured algebra layout.
Definition ray_cylinder_intersector.hpp:36
dtransform3D< algebra_t > transform3_type
Transform type used to place the surface.
Definition ray_cylinder_intersector.hpp:42
Intersection implementation for detector surfaces using a ray trajectory.
Definition ray_intersector.hpp:31