ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
line_stepper.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/material/material.hpp"
16#include "detray/navigation/policies.hpp"
17#include "detray/propagator/base_stepper.hpp"
18#include "detray/utils/logging.hpp"
19
20namespace detray {
21
23template <concepts::algebra algebra_t,
24 typename constraint_t = unconstrained_step<dscalar<algebra_t>>,
26 typename inspector_t = stepping::void_inspector>
27class line_stepper final
28 : public base_stepper<algebra_t, constraint_t, policy_t, inspector_t> {
29 using base_type =
31
32 public:
34 static constexpr bool uses_gradient = true;
35
37 using algebra_type = algebra_t;
51 template <std::size_t ROWS, std::size_t COLS>
53
55 struct state : public base_type::template state<> {
57 static constexpr const stepping::id id = stepping::id::e_linear;
58
60 using base_state = typename base_type::template state<>;
61
63 using base_state::base_state;
64
66 DETRAY_HOST_DEVICE
67 inline void advance_track() {
68 auto& track = (*this)();
69 track.set_pos(track.pos() + track.dir() * this->step_size());
70
71 this->update_path_lengths(this->step_size());
72 }
73
75 DETRAY_HOST_DEVICE
76 inline void advance_jacobian() {
77 DETRAY_VERBOSE_HOST_DEVICE("Advance Jacobian");
78
79 // The step transport matrix in global coordinates
80 free_matrix<algebra_t> D = matrix::identity<free_matrix<algebra_t>>();
81
82 // d(x,y,z)/d(n_x,n_y,n_z)
84 this->step_size() * matrix::identity<matrix_type<3, 3>>();
85 getter::set_block(D, dxdn, e_free_pos0, e_free_dir0);
86
89 this->transport_jacobian() = D * this->transport_jacobian();
90 }
91
94 DETRAY_HOST_DEVICE
95 constexpr vector3_type dtds() const { return {0.f, 0.f, 0.f}; }
96
99 DETRAY_HOST_DEVICE
101 const material<scalar_type>* /*unused*/) const {
102 return 0.f;
103 }
104 };
105
113 DETRAY_HOST_DEVICE bool step(
114 const scalar_type dist_to_next, state& stepping,
115 const stepping::config& cfg, const bool /*unused*/ = true,
116 const material<scalar_type>* /*unused*/ = nullptr) const {
117 // In case of an overlap do nothing
118 if (math::fabs(dist_to_next) <= 1.f * unit<scalar_type>::um) {
119 stepping.run_inspector(cfg, "Step skipped (Overlap): ", dist_to_next);
120 return true;
121 }
122
123 // Straight line stepping: The distance given by the navigator is exact
124 stepping.set_step_size(dist_to_next);
125
126 DETRAY_VERBOSE_HOST_DEVICE("Take step: %f mm", stepping.step_size());
127
128 // Check constraints
129 if (const scalar_type max_step =
130 stepping.constraints().template size<>(stepping.direction());
131 math::fabs(stepping.step_size()) > math::fabs(max_step)) {
132 // Run inspection before step size is cut
133 stepping.run_inspector(cfg, "Before constraint: ", dist_to_next);
134
135 stepping.set_step_size(max_step);
136 }
137
138 // Update track state
139 stepping.advance_track();
140
141 // Advance jacobian transport
142 if (cfg.do_covariance_transport) {
143 stepping.advance_jacobian();
144 }
145
146 // Count the number of steps
147 stepping.count_trials();
148
149 // Run inspection if needed
150 stepping.run_inspector(cfg, "Step complete: ", dist_to_next);
151
152 return true;
153 }
154};
155
156} // namespace detray
Base stepper implementation.
Definition base_stepper.hpp:49
bound_track_parameters< algebra_t > bound_track_parameters_type
Definition base_stepper.hpp:57
free_track_parameters< algebra_t > free_track_parameters_type
Definition base_stepper.hpp:55
Straight line stepper implementation.
Definition line_stepper.hpp:28
bool step(const scalar_type dist_to_next, state &stepping, const stepping::config &cfg, const bool=true, const material< scalar_type > *=nullptr) const
Take a step, regulared by a constrained step.
Definition line_stepper.hpp:113
dscalar< algebra_t > scalar_type
Scalar type for step lengths and material derivatives.
Definition line_stepper.hpp:39
static constexpr bool uses_gradient
This stepper has a nonzero position-direction transport gradient.
Definition line_stepper.hpp:34
algebra_t algebra_type
Algebra backend used by the stepper.
Definition line_stepper.hpp:37
dmatrix< algebra_t, ROWS, COLS > matrix_type
Matrix type with dimensions selected by the template arguments.
Definition line_stepper.hpp:52
typename base_type::free_track_parameters_type free_track_parameters_type
Free track parameter representation.
Definition line_stepper.hpp:45
typename base_type::bound_track_parameters_type bound_track_parameters_type
Bound track parameter representation.
Definition line_stepper.hpp:48
dvector3D< algebra_t > vector3_type
Three-dimensional vector type.
Definition line_stepper.hpp:41
dtransform3D< algebra_t > transform3_type
Three-dimensional transform type.
Definition line_stepper.hpp:43
Algebra plugin concept.
Definition concepts.hpp:147
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
dmatrix< algebra_t, e_free_size, e_free_size > free_matrix
Covariance matrix type for free track parametrization.
Definition track_parametrization.hpp:73
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_matrix_t< A, R, C, T > dmatrix
R by C matrix type for algebra A and value type T.
Definition algebra.hpp:88
State carried by the straight-line stepper.
Definition line_stepper.hpp:55
void advance_jacobian()
Advance the free-parameter transport Jacobian for a straight segment.
Definition line_stepper.hpp:76
constexpr scalar_type dqopds(const material< scalar_type > *) const
Derivative of q/p with respect to path length in vacuum.
Definition line_stepper.hpp:100
typename base_type::template state<> base_state
Base state providing common track, path, and constraint storage.
Definition line_stepper.hpp:60
void advance_track()
Update the track state in a straight line.
Definition line_stepper.hpp:67
constexpr vector3_type dtds() const
Derivative of time with respect to path length for straight motion.
Definition line_stepper.hpp:95
Material composition properties and density data used by interactions.
Definition material.hpp:36
Default navigation update policy for the steppers: If a constraint has been hit, lower the trustlevel...
Definition policies.hpp:63
Configuration flags and limits consumed by a stepper.
Definition stepping_config.hpp:29
bool do_covariance_transport
Do covariance transport.
Definition stepping_config.hpp:48
A void inpector that does nothing.
Definition base_stepper.hpp:34
Struct that represents unconstrained stepping.
Definition constrained_step.hpp:50
static constexpr scalar_t um
Length, native unit mm.
Definition units.hpp:25