ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
ray_plane_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/cartesian2D.hpp"
17#include "detray/geometry/coordinates/polar2D.hpp"
18#include "detray/navigation/intersection/intersection.hpp"
19#include "detray/tracks/ray.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::aos algebra_t, bool resolve_pos>
31struct ray_intersector_impl<cartesian2D<algebra_t>, algebra_t, resolve_pos> {
33 using algebra_type = algebra_t;
38
40 template <typename surface_descr_t>
43
45 template <typename other_algebra_t>
47
48 // Maximum number of solutions this intersector can produce
50 static constexpr std::uint8_t n_solutions{1u};
51
55
61 DETRAY_HOST_DEVICE constexpr result_type point_of_intersection(
63 const dscalar<algebra_t> /*overstep_tol*/ = 0.f) const {
64 using scalar_t = dscalar<algebra_t>;
65 using point3_t = dpoint3D<algebra_t>;
66 using vector3_t = dvector3D<algebra_t>;
67
68 // Retrieve the surface normal & translation (context resolved)
69 const vector3_t &sn = trf.z();
70 const vector3_t &st = trf.translation();
71
72 // Intersection code
73 const point3_t &ro = ray.pos();
74 const vector3_t &rd = ray.dir();
75 const scalar_t denom = vector::dot(rd, sn);
76
77 // this is dangerous
78 if (denom == 0.f) [[unlikely]] {
79 return {};
80 }
81
82 scalar_t s{vector::dot(sn, st - ro) / denom};
83 point3_t glob_pos = ro + s * rd;
84
85 return {s, glob_pos};
86 }
87};
88
89template <detray::concepts::aos algebra_t, bool resolve_pos>
90struct ray_intersector_impl<polar2D<algebra_t>, algebra_t, resolve_pos>
91 : public ray_intersector_impl<cartesian2D<algebra_t>, algebra_t,
92 resolve_pos> {};
93
94} // namespace detray
describes a straight-line trajectory
Definition ray.hpp:22
This class holds the intersection information.
Definition intersection.hpp:212
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
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 cartesian coordinate frame.
Definition cartesian2D.hpp:19
Result of intersector: Point of intersection on a surface.
Definition intersection.hpp:43
Projection into a polar coordinate frame.
Definition polar2D.hpp:20
detail::ray< other_algebra_t > trajectory_type
Trajectory representation accepted by this intersector.
Definition ray_plane_intersector.hpp:46
intersection_point< algebra_t, point_type, intersection::contains_pos > result_type
Always includes the intersection position, in order to resolve the mask.
Definition ray_plane_intersector.hpp:53
static constexpr std::uint8_t n_solutions
Maximum number of solutions produced by this intersector.
Definition ray_plane_intersector.hpp:50
constexpr result_type point_of_intersection(const trajectory_type< algebra_t > &ray, const dtransform3D< algebra_t > &trf, const dscalar< algebra_t >=0.f) const
Operator function to find intersections between ray and planar mask.
Definition ray_plane_intersector.hpp:61
algebra_t algebra_type
Algebra policy used by this intersector.
Definition ray_plane_intersector.hpp:33
intersection2D< surface_descr_t, algebra_t, resolve_pos > intersection_type
Intersection result type associated with a surface descriptor.
Definition ray_plane_intersector.hpp:41
dpoint3D< algebra_t > point_type
Point type used for the intersection result.
Definition ray_plane_intersector.hpp:37
cartesian2D< algebra_t > frame_type
Coordinate frame of the intersected surface.
Definition ray_plane_intersector.hpp:35
Intersection implementation for detector surfaces using a ray trajectory.
Definition ray_intersector.hpp:31