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/concentric_cylindrical2D.hpp"
17#include "detray/geometry/coordinates/cylindrical2D.hpp"
18#include "detray/geometry/shapes/cylinder2D.hpp"
19#include "detray/navigation/intersection/intersection.hpp"
20#include "detray/navigation/intersection/ray_cylinder_intersector.hpp"
21#include "detray/tracks/helix.hpp"
22#include "detray/utils/invalid_values.hpp"
23#include "detray/utils/root_finding.hpp"
27template <
typename frame_t, concepts::algebra algebra_t>
36template <detray::concepts::aos algebra_t>
39 intersection::contains_pos> {
48 template <
typename surface_descr_t>
53 template <
typename other_algebra_t>
71 template <
typename mask_t>
74 const mask_t &
mask,
const scalar_t = 0.f)
const {
81 const vector3_t sz = trf.z();
83 const point3_t sc = trf.translation();
88 const scalar_t r{
mask[cylinder2D::e_r]};
93 const auto h_dir = h.dir(0.5f * r);
96 const scalar_t default_s{r * vector::perp(h_dir)};
105 const auto qe = this->solve_intersection(t,
mask, trf);
109 auto n_runs{
static_cast<unsigned int>(qe.solutions())};
113 switch (qe.solutions()) {
115 paths[1] = qe.larger();
121 paths[0] = qe.smaller();
132 auto cyl_inters_func = [&h, &r, &sz, &sc](
const scalar_t x) {
133 const vector3_t crp = vector::cross(h.pos(x) - sc, sz);
136 const scalar_t f_s{(vector::dot(crp, crp) - r * r)};
138 const scalar_t df_s{2.f * vector::dot(crp, vector::cross(h.dir(x), sz))};
140 return std::make_tuple(f_s, df_s);
143 for (
unsigned int i = 0u; i < n_runs; ++i) {
144 const scalar_t &s_ini = paths[i];
159 ret[i] = {s, h.pos(s), ds};
176template <concepts::algebra algebra_t>
183 template <
typename surface_descr_t>
188 template <
typename other_algebra_t>
205 template <
typename mask_t>
212 typename base_t::result_type results =
213 base_t::point_of_intersection(h, trf,
mask, 0.f);
217 return math::signbit(results[0].path) ? results[1] : results[0];
describes a helical trajectory in a given B-field.
Definition helix.hpp:33
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::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
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
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
Projection into a 2D concentric cylindrical frame (No rotation in coordinate transformation).
Definition concentric_cylindrical2D.hpp:21
Projection into a 2D cylindrical coordinate frame.
Definition cylindrical2D.hpp:20
algebra_t algebra_type
Algebra policy used by this intersector.
Definition helix_cylinder_intersector.hpp:180
intersection2D< surface_descr_t, algebra_t, intersection::contains_pos > intersection_type
Intersection result type associated with a surface descriptor.
Definition helix_cylinder_intersector.hpp:184
intersection_point_err< algebra_t > result_type
Result carrying the intersection point and path uncertainty.
Definition helix_cylinder_intersector.hpp:195
static constexpr std::uint8_t n_solutions
Maximum number of solutions this intersector can produce.
Definition helix_cylinder_intersector.hpp:192
detail::helix< other_algebra_t > trajectory_type
Helix trajectory type accepted by this intersector.
Definition helix_cylinder_intersector.hpp:189
constexpr result_type point_of_intersection(const trajectory_type< algebra_t > &h, const dtransform3D< algebra_t > &trf, const mask_t &mask, const dscalar< algebra_t >=0.f) const
Operator function to find intersections between helix and a concentric cylinder surface.
Definition helix_cylinder_intersector.hpp:206
static constexpr std::uint8_t n_solutions
Maximum number of solutions produced by this intersector.
Definition helix_cylinder_intersector.hpp:58
detail::helix< other_algebra_t > trajectory_type
Trajectory representation accepted by this intersector.
Definition helix_cylinder_intersector.hpp:54
scalar_t convergence_tolerance
Tolerance for convergence.
Definition helix_cylinder_intersector.hpp:166
darray< intersection_point_err< algebra_t >, n_solutions > result_type
Result type returned by the geometric intersection calculation.
Definition helix_cylinder_intersector.hpp:61
bool run_rtsafe
Complement the Newton algorithm with Bisection steps.
Definition helix_cylinder_intersector.hpp:172
intersection2D< surface_descr_t, algebra_t, intersection::contains_pos > intersection_type
Intersection result type associated with a surface descriptor.
Definition helix_cylinder_intersector.hpp:49
scalar_t max_path
Early exit, if the intersection is too far away.
Definition helix_cylinder_intersector.hpp:170
constexpr result_type point_of_intersection(const trajectory_type< algebra_t > &h, const dtransform3D< algebra_t > &trf, const mask_t &mask, const scalar_t=0.f) const
Operator function to find intersections between a helix and a cylinder surface.
Definition helix_cylinder_intersector.hpp:72
algebra_t algebra_type
Algebra policy used by this intersector.
Definition helix_cylinder_intersector.hpp:45
std::size_t max_n_tries
Guard against infinite loops.
Definition helix_cylinder_intersector.hpp:168
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
Intersection implementation for detector surfaces using a ray trajectory.
Definition ray_intersector.hpp:31
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