ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
ray_line_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/line2D.hpp"
17#include "detray/navigation/intersection/intersection.hpp"
18#include "detray/tracks/ray.hpp"
19
20// System include(s)
21#include <type_traits>
22
23namespace detray {
24
25template <typename frame_t, concepts::algebra algebra_t, bool resolve_pos>
27
29template <detray::concepts::aos algebra_t, bool resolve_pos>
30struct ray_intersector_impl<line2D<algebra_t>, algebra_t, resolve_pos> {
32 using algebra_type = algebra_t;
37
39 template <typename surface_descr_t>
42
44 template <typename other_algebra_t>
46
48 static constexpr std::uint8_t n_solutions{1u};
49
53
59 DETRAY_HOST_DEVICE constexpr result_type point_of_intersection(
61 const dscalar<algebra_t> /*overstep_tol*/ = 0.f) const {
62 using scalar_t = dscalar<algebra_t>;
63 using point3_t = dpoint3D<algebra_t>;
64 using vector3_t = dvector3D<algebra_t>;
65
66 const vector3_t &rd = ray.dir();
67 const point3_t &ro = ray.pos();
68
69 // line direction
70 const vector3_t &_z = trf.z();
71 // line center
72 const point3_t &_t = trf.translation();
73
74 // Projection of line to track direction
75 const scalar_t zd{vector::dot(_z, rd)};
76
77 const scalar_t denom{1.f - (zd * zd)};
78
79 // Case for wire is parallel to track
80 if (denom < 1e-5f) [[unlikely]] {
81 return {};
82 }
83
84 // vector from track position to line center
85 const point3_t t2l = _t - ro;
86
87 // t2l projection on line direction
88 const scalar_t t2l_on_line{vector::dot(t2l, _z)};
89
90 // t2l projection on track direction
91 const scalar_t t2l_on_track{vector::dot(t2l, rd)};
92
93 // path length to the point of closest approach on the track
94 const scalar_t s{1.f / denom * (t2l_on_track - t2l_on_line * zd)};
95 const point3_t glob_pos = ro + s * rd;
96
97 return {s, glob_pos};
98 }
99};
100
101} // 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
Result of intersector: Point of intersection on a surface.
Definition intersection.hpp:43
Projection into a line coordinate frame.
Definition line2D.hpp:20
algebra_t algebra_type
Algebra policy used by the geometric calculation.
Definition ray_line_intersector.hpp:32
static constexpr std::uint8_t n_solutions
Maximum number of solutions this intersector can produce.
Definition ray_line_intersector.hpp:48
dpoint3D< algebra_t > point_type
Three-dimensional point type used for the closest-approach result.
Definition ray_line_intersector.hpp:36
line2D< algebra_t > frame_type
Coordinate frame of the line mask.
Definition ray_line_intersector.hpp:34
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 line mask.
Definition ray_line_intersector.hpp:59
detail::ray< other_algebra_t > trajectory_type
Ray trajectory type accepted by this intersector.
Definition ray_line_intersector.hpp:45
intersection2D< surface_descr_t, algebra_t, resolve_pos > intersection_type
Intersection result type associated with a surface descriptor.
Definition ray_line_intersector.hpp:40
intersection_point< algebra_t, point_type, intersection::contains_pos > result_type
Result containing the path and closest-approach point.
Definition ray_line_intersector.hpp:51
Intersection implementation for detector surfaces using a ray trajectory.
Definition ray_intersector.hpp:31