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/helix.hpp"
19#include "detray/utils/logging.hpp"
20#include "detray/utils/root_finding.hpp"
24template <
typename frame_t, concepts::algebra algebra_t>
32template <detray::concepts::aos algebra_t>
42 template <
typename surface_descr_t>
47 template <
typename other_algebra_t>
66 const scalar_t = 0.f)
const {
71 const vector3_t l = getter::vector<3>(trf.matrix(), 0u, 2u);
74 const point3_t c = trf.translation();
77 const vector3_t t0 = h.dir(0.f);
80 const point3_t r0 = h.pos(0.f);
83 const scalar_t lt0{vector::dot(l, t0)};
85 const scalar_t denom{1.f - (lt0 * lt0)};
91 DETRAY_ERROR_HOST(
"Helix line intersector encountered invalid value!");
96 const vector3_t D = c - r0;
99 const scalar_t P{vector::dot(D, l)};
102 const scalar_t Q{vector::dot(D, t0)};
107 scalar_t s_ini{1.f / denom * (Q - P * lt0)};
110 auto line_inters_func = [&h, &c, &l](
const scalar_t x) {
112 const vector3_t t = h.dir(x);
115 const point3_t r = h.pos(x);
118 const scalar_t A = vector::dot(r - c, l);
122 const vector3_t w = r - (c + A * l);
125 const scalar_t f = vector::dot(t, w);
128 const vector3_t dtds = h.qop() * vector::cross(t, h.b_field());
130 const vector3_t dwds = t - vector::dot(t, l) * l;
133 const scalar_t dfds = vector::dot(dtds, w) + vector::dot(t, dwds);
135 return std::make_tuple(f, dfds);
151 return {s, h.pos(s), ds};
describes a helical trajectory in a given B-field.
Definition helix.hpp:33
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
std::pair< scalar_t, scalar_t > newton_raphson_safe(function_t &evaluate_func, scalar_t s, const scalar_t convergence_tolerance=1.f *unit< scalar_t >::um, const std::size_t max_n_tries=1000u, const scalar_t max_path=5.f *unit< scalar_t >::m)
Find a root using the Newton-Raphson and Bisection algorithms.
Definition root_finding.hpp:193
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
std::pair< scalar_t, scalar_t > newton_raphson(function_t &evaluate_func, scalar_t s, const scalar_t convergence_tolerance=1.f *unit< scalar_t >::um, const std::size_t max_n_tries=1000u, const scalar_t max_path=5.f *unit< scalar_t >::m)
Find a root using the Newton-Raphson algorithm.
Definition root_finding.hpp:121
get_point3D_t< A, T > dpoint3D
Three-dimensional point type for algebra A and value type T.
Definition algebra.hpp:72
intersection_point_err< algebra_t > result_type
Result type returned by the geometric intersection calculation.
Definition helix_line_intersector.hpp:55
intersection2D< surface_descr_t, algebra_t, intersection::contains_pos > intersection_type
Intersection result type associated with a surface descriptor.
Definition helix_line_intersector.hpp:43
bool run_rtsafe
Complement the Newton algorithm with Bisection steps.
Definition helix_line_intersector.hpp:161
algebra_t algebra_type
Algebra policy used by this intersector.
Definition helix_line_intersector.hpp:39
static constexpr std::uint8_t n_solutions
Maximum number of solutions produced by this intersector.
Definition helix_line_intersector.hpp:52
detail::helix< other_algebra_t > trajectory_type
Trajectory representation accepted by this intersector.
Definition helix_line_intersector.hpp:48
constexpr result_type point_of_intersection(const trajectory_type< algebra_t > &h, const dtransform3D< algebra_t > &trf, const scalar_t=0.f) const
Operator function to find intersections between a helix and a line surface.
Definition helix_line_intersector.hpp:64
scalar_t max_path
Early exit, if the intersection is too far away.
Definition helix_line_intersector.hpp:159
std::size_t max_n_tries
Guard against infinite loops.
Definition helix_line_intersector.hpp:157
scalar_t convergence_tolerance
Tolerance for convergence.
Definition helix_line_intersector.hpp:155
Intersection implementation for detector surfaces using a helix trajectory.
Definition helix_intersector.hpp:29
Result of intersector: Distance, intersection point (2D or 3D, local/global) and error estimate on di...
Definition intersection.hpp:150
Projection into a line coordinate frame.
Definition line2D.hpp:20
static constexpr scalar_t um
Length, native unit mm.
Definition units.hpp:25
static constexpr scalar_t m
Metre expressed in millimetres.
Definition units.hpp:31