File indexing completed on 2026-08-16 08:17:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "detray/definitions/algebra.hpp"
0013 #include "detray/definitions/detail/qualifiers.hpp"
0014 #include "detray/definitions/navigation.hpp"
0015 #include "detray/propagator/actors/parameter_updater.hpp"
0016 #include "detray/tracks/bound_track_parameters.hpp"
0017 #include "detray/tracks/free_track_parameters.hpp"
0018
0019
0020 #include <optional>
0021
0022 namespace detray {
0023
0024
0025 template <typename detector_t>
0026 struct intersection_record {
0027 using algebra_type = typename detector_t::algebra_type;
0028 using scalar_type = dscalar<algebra_type>;
0029 using point3_type = dpoint3D<algebra_type>;
0030 using vector3_type = dvector3D<algebra_type>;
0031 using intersection_type =
0032 intersection2D<typename detector_t::surface_type, algebra_type,
0033 intersection::contains_pos>;
0034
0035 constexpr intersection_record() = default;
0036
0037
0038
0039 DETRAY_HOST_DEVICE
0040 constexpr intersection_record(
0041 const point3_type& position, const vector3_type& direction,
0042 const intersection_type& intr,
0043 const scalar_type q = detray::detail::invalid_value<scalar_type>(),
0044 const scalar_type p = detray::detail::invalid_value<scalar_type>(),
0045 dindex v_idx = dindex_invalid)
0046 : pos{position},
0047 dir{direction},
0048 intersection{intr},
0049 vol_idx{v_idx},
0050 charge{q},
0051 p_mag{p} {}
0052
0053
0054 point3_type pos{0.f, 0.f, 0.f};
0055
0056 vector3_type dir{0.f, 0.f, 1.f};
0057
0058 intersection_type intersection{};
0059
0060 dindex vol_idx{dindex_invalid};
0061
0062 scalar_type charge{detray::detail::invalid_value<scalar_type>()};
0063
0064 scalar_type p_mag{1.f * unit<scalar_type>::GeV};
0065
0066
0067 DETRAY_HOST_DEVICE
0068 free_track_parameters<algebra_type> track_param() const {
0069 assert(p_mag > 0.f);
0070 return {pos, detail::invalid_value<scalar_type>(), p_mag * dir, charge};
0071 }
0072 };
0073
0074
0075 template <concepts::algebra algebra_t>
0076 struct step_record {
0077 using scalar_type = dscalar<algebra_t>;
0078 using vector3_type = dvector3D<algebra_t>;
0079 using track_param_type = free_track_parameters<algebra_t>;
0080 using bound_param_type = bound_track_parameters<algebra_t>;
0081 using free_matrix_type = free_matrix<algebra_t>;
0082
0083 scalar_type step_size{0.f};
0084 scalar_type path_length{0.f};
0085 std::size_t n_total_trials{0u};
0086 navigation::direction nav_dir = navigation::direction::e_forward;
0087 geometry::identifier identifier{};
0088 track_param_type free_params{};
0089 bound_param_type bound_params{};
0090 free_matrix_type jacobian{};
0091 };
0092
0093
0094 template <concepts::scalar scalar_t>
0095 struct material_record {
0096
0097 geometry::identifier geo_id{};
0098
0099 scalar_t path{detail::invalid_value<scalar_t>()};
0100
0101 scalar_t thickness{detail::invalid_value<scalar_t>()};
0102
0103 scalar_t mat_X0{0.f};
0104
0105 scalar_t mat_L0{0.f};
0106 };
0107
0108
0109 template <typename detector_t>
0110 struct propagation_record {
0111 using algebra_type = typename detector_t::algebra_type;
0112 using scalar_type = dscalar<algebra_type>;
0113 using free_param_type = free_track_parameters<algebra_type>;
0114 using bound_param_type = bound_track_parameters<algebra_type>;
0115 using free_matrix_type = free_matrix<algebra_type>;
0116 using intersection_type = intersection_record<detector_t>::intersection_type;
0117
0118
0119 DETRAY_HOST_DEVICE
0120 scalar_type step_size() const { return m_step_record.step_size; }
0121
0122 DETRAY_HOST_DEVICE
0123 void step_size(scalar_type step_size) { m_step_record.step_size = step_size; }
0124
0125
0126 DETRAY_HOST_DEVICE
0127 scalar_type path_length() const { return m_step_record.path_length; }
0128
0129 DETRAY_HOST_DEVICE
0130 void path_length(scalar_type path_length) {
0131 m_step_record.path_length = path_length;
0132 }
0133
0134
0135 DETRAY_HOST_DEVICE
0136 std::size_t n_rkn_trials() const { return m_step_record.n_total_trials; }
0137
0138 DETRAY_HOST_DEVICE
0139 void n_rkn_trials(std::size_t n_rkn_trials) {
0140 m_step_record.n_total_trials = n_rkn_trials;
0141 }
0142
0143
0144 DETRAY_HOST_DEVICE
0145 scalar_type charge() const { return m_intersection_record.charge; }
0146
0147 DETRAY_HOST_DEVICE
0148 void charge(scalar_type charge) { m_intersection_record.charge = charge; }
0149
0150
0151 DETRAY_HOST_DEVICE
0152 scalar_type p_mag() const { return m_intersection_record.p_mag; }
0153
0154 DETRAY_HOST_DEVICE
0155 void p_mag(scalar_type p_mag) { m_intersection_record.p_mag = p_mag; }
0156
0157
0158 DETRAY_HOST_DEVICE
0159 geometry::identifier identifier() const {
0160 assert(intersection().is_outside() &&
0161 m_step_record.bound_params.surface_link() ==
0162 intersection().surface().identifier());
0163 return m_step_record.bound_params.surface_link();
0164 }
0165
0166
0167 DETRAY_HOST_DEVICE
0168 void identifier(geometry::identifier geo_id) {
0169 m_step_record.bound_params.surface_link() = geo_id;
0170 }
0171
0172
0173 DETRAY_HOST_DEVICE
0174 const intersection_type& intersection() const {
0175 return m_intersection_record.intersection;
0176 }
0177
0178 DETRAY_HOST_DEVICE
0179 intersection_type& intersection() {
0180 return m_intersection_record.intersection;
0181 }
0182
0183 DETRAY_HOST_DEVICE
0184 void intersection(const intersection_type& intr) {
0185 m_intersection_record.intersection = intr;
0186 }
0187
0188
0189 DETRAY_HOST_DEVICE
0190 free_param_type free_track_param() const { return m_step_record.free_params; }
0191
0192 DETRAY_HOST_DEVICE
0193 void free_track_param(const free_param_type& free_param) {
0194 m_step_record.free_params = free_param;
0195 }
0196
0197
0198 DETRAY_HOST_DEVICE
0199 bound_param_type& bound_track_param() { return m_step_record.bound_params; }
0200
0201 DETRAY_HOST_DEVICE
0202 void bound_track_param(const bound_param_type& bound_param) {
0203 m_step_record.bound_params = bound_param;
0204 }
0205
0206 DETRAY_HOST_DEVICE
0207 const bound_param_type& bound_track_param() const {
0208 return m_step_record.bound_params;
0209 }
0210
0211
0212 DETRAY_HOST_DEVICE
0213 free_matrix_type& jacobian() { return m_step_record.jacobian; }
0214
0215 DETRAY_HOST_DEVICE
0216 const free_matrix_type& jacobian() const { return m_step_record.jacobian; }
0217
0218 DETRAY_HOST_DEVICE
0219 void jacobian(const free_matrix_type& jac) { m_step_record.jacobian = jac; }
0220
0221 private:
0222
0223 step_record<algebra_type> m_step_record;
0224
0225 std::optional<intersection_record<detector_t>> m_intersection_record{};
0226
0227 std::optional<material_record<scalar_type>> m_material_record{};
0228 };
0229
0230 }