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/geometry/coordinates/line2D.hpp"
16#include "detray/navigation/intersection/intersection.hpp"
17#include "detray/tracks/ray.hpp"
18
19namespace detray {
20
21template <typename frame_t, concepts::algebra algebra_t, bool resolve_pos>
23
25template <detray::concepts::soa algebra_t, bool resolve_pos>
26struct ray_intersector_impl<line2D<algebra_t>, algebra_t, resolve_pos> {
29 using algebra_type = algebra_t;
39
41 template <typename surface_descr_t>
44
46 template <typename other_algebra_t>
48
50 static constexpr std::uint8_t n_solutions{1u};
51
55
61 template <concepts::algebra other_algebra_t>
62 DETRAY_HOST_DEVICE constexpr result_type point_of_intersection(
64 const scalar_type /*overstep_tol*/ = 0.f) const {
65 // line direction
66 const vector3_type &sz = trf.z();
67
68 // line center
69 const point3_type &st = trf.translation();
70
71 // Broadcast ray data
72 const auto &pos = ray.pos();
73 const auto &dir = ray.dir();
74 const vector3_type ro{pos[0], pos[1], pos[2]};
75 const vector3_type rd{dir[0], dir[1], dir[2]};
76
77 // Projection of line to track direction
78 const scalar_type zd = vector::dot(sz, rd);
79
80 const scalar_type denom = 1.f - (zd * zd);
81
82 // Case for wire is parallel to track
83 if (detray::detail::all_of(denom < 1e-5f)) {
84 return {};
85 }
86
87 // vector from track position to line center
88 const vector3_type t2l = st - ro;
89
90 // t2l projection on line direction
91 const scalar_type t2l_on_line = vector::dot(t2l, sz);
92
93 // t2l projection on track direction
94 const scalar_type t2l_on_track = vector::dot(t2l, rd);
95
96 // path length to the point of closest approach on the track
97 scalar_type s = (t2l_on_track - t2l_on_line * zd) / denom;
98
99 // point of closest approach on the track
100 point3_type glob_pos = ro + s * rd;
101
102 return {s, glob_pos};
103 }
104};
105
106} // 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
dscalar< algebra_t > scalar_type
Scalar calculation type for the configured algebra layout.
Definition ray_line_intersector.hpp:31
static constexpr std::uint8_t n_solutions
Maximum number of solutions this intersector can produce.
Definition ray_line_intersector.hpp:48
dtransform3D< algebra_t > transform3_type
Transform type defining the line placement.
Definition ray_line_intersector.hpp:37
dvector3D< algebra_t > vector3_type
Three-dimensional vector type for ray directions.
Definition ray_line_intersector.hpp:35
constexpr result_type point_of_intersection(const trajectory_type< other_algebra_t > &ray, const transform3_type &trf, const scalar_type=0.f) const
Operator function to find intersections between ray and planar mask.
Definition ray_line_intersector.hpp:62
dpoint3D< algebra_t > point3_type
Three-dimensional point type for the returned closest approach.
Definition ray_line_intersector.hpp:33
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