ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
data_record.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/core/concepts.hpp"
13#include "detray/definitions/algebra.hpp"
14#include "detray/definitions/detail/qualifiers.hpp"
15#include "detray/definitions/navigation.hpp"
16#include "detray/propagator/actors/parameter_updater.hpp"
17#include "detray/tracks/bound_track_parameters.hpp"
18#include "detray/tracks/free_track_parameters.hpp"
19
20// System include(s)
21#include <optional>
22
23namespace detray {
24
26template <concepts::detector detector_t>
27struct intersection_record {
28 private:
30
31 public:
41 using intersection_type = intersection2D<typename detector_t::surface_type,
42 typename detector_t::algebra_type,
43 intersection::contains_pos>;
44
45 constexpr intersection_record() = default;
46
55 DETRAY_HOST_DEVICE
57 const typename detector_t::point3_type& position,
58 const typename detector_t::vector3_type& direction,
59 const intersection_type& intr,
60 const double q = detray::detail::invalid_value<double>(),
61 const double p = detray::detail::invalid_value<double>(),
62 const dindex v_idx = dindex_invalid)
63 : m_pos{algebra::cast_to<double>(position)},
64 m_dir{algebra::cast_to<double>(direction)},
65 m_intersection{intr},
66 m_vol_idx{v_idx},
67 m_charge{q},
68 m_p_mag{p} {}
69
74 template <concepts::value V = value_t>
75 DETRAY_HOST_DEVICE auto position() const {
76 return algebra::cast_to<V>(m_pos);
77 }
78
80 template <concepts::value V = value_t>
81 DETRAY_HOST_DEVICE auto direction() const {
82 return algebra::cast_to<V>(m_dir);
83 }
84
86 DETRAY_HOST_DEVICE
87 const intersection_type& intersection() const { return m_intersection; }
90 DETRAY_HOST_DEVICE
91 intersection_type& intersection() { return m_intersection; }
94 DETRAY_HOST_DEVICE
95 dindex volume() const { return m_vol_idx; }
98 template <concepts::value V = value_t>
99 DETRAY_HOST_DEVICE auto charge() const {
100 return algebra::cast_to<V>(m_charge);
101 }
102
104 template <concepts::value V = value_t>
105 DETRAY_HOST_DEVICE auto p() const {
106 return algebra::cast_to<V>(m_p_mag);
107 }
108
110 DETRAY_HOST_DEVICE
112 assert(m_p_mag > 0.f);
113 return {algebra::cast_to<value_t>(m_pos),
114 detail::invalid_value<typename detector_t::scalar_type>(),
115 algebra::cast_to<value_t>(m_p_mag * m_dir),
116 algebra::cast_to<value_t>(m_charge)};
117 }
118
119
124 template <concepts::point3D point_t>
125 DETRAY_HOST_DEVICE void position(const point_t& position) {
126 m_pos = algebra::cast_to<double>(position);
127 }
128
130 template <concepts::vector3D vector_t>
131 DETRAY_HOST_DEVICE void direction(const vector_t& dir) {
132 m_dir = algebra::cast_to<double>(dir);
133 }
134
136 DETRAY_HOST_DEVICE
137 void intersection(const intersection_type& intr) { m_intersection = intr; }
140 DETRAY_HOST_DEVICE
141 void volume(dindex vol_idx) { m_vol_idx = vol_idx; }
142
145 template <concepts::scalar scalar_t>
146 DETRAY_HOST_DEVICE void charge(const scalar_t q) {
147 m_charge = algebra::cast_to<double>(q);
148 }
149
151 template <concepts::scalar scalar_t>
152 DETRAY_HOST_DEVICE void p(const scalar_t p) {
153 m_p_mag = algebra::cast_to<double>(p);
154 }
155
156
157 private:
159 point3_type m_pos{0., 0., 0.};
161 vector3_type m_dir{0., 0., 1.};
163 intersection_type m_intersection{};
165 dindex m_vol_idx{dindex_invalid};
167 scalar_type m_charge{detray::detail::invalid_value<scalar_type>()};
170};
171
173template <concepts::algebra algebra_t>
189
195 std::size_t m_n_total_trials{0u};
197 navigation::direction m_nav_dir = navigation::direction::e_forward;
206
211 template <concepts::value V = value_t>
212 DETRAY_HOST_DEVICE scalar_type step_size() const {
213 return algebra::cast_to<V>(m_step_size);
214 }
215
217 template <concepts::value V = value_t>
218 DETRAY_HOST_DEVICE scalar_type path_length() const {
219 return algebra::cast_to<V>(m_path_length);
220 }
221
223 DETRAY_HOST_DEVICE std::size_t n_trials() const { return m_n_total_trials; }
226 DETRAY_HOST_DEVICE navigation::direction nav_direction() const {
227 return m_nav_dir;
228 }
229
231 DETRAY_HOST_DEVICE geometry::identifier identifier() const {
232 return m_identifier;
233 }
234
236 template <concepts::value V = value_t>
237 DETRAY_HOST_DEVICE track_param_type free_param() const {
238 return algebra::cast_to<V>(m_free_params);
239 }
240
242 template <concepts::value V = value_t>
243 DETRAY_HOST_DEVICE bound_param_type bound_param() const {
244 return algebra::cast_to<V>(m_bound_params);
245 }
246
248 template <concepts::value V = value_t>
249 DETRAY_HOST_DEVICE free_matrix_type jacobian() const {
250 return algebra::cast_to<V>(m_jacobian);
251 }
252
253
258 DETRAY_HOST_DEVICE void step_size(const scalar_type step_size) {
259 m_step_size = algebra::cast_to<double>(step_size);
260 }
261
263 DETRAY_HOST_DEVICE void path_length(const scalar_type path_length) {
264 m_path_length = algebra::cast_to<double>(path_length);
265 }
266
268 DETRAY_HOST_DEVICE void n_trials(const std::size_t n_trial) {
269 m_n_total_trials = n_trial;
270 }
271
273 DETRAY_HOST_DEVICE void nav_direction(const navigation::direction nav_dir) {
274 m_nav_dir = nav_dir;
275 }
276
278 DETRAY_HOST_DEVICE void identifier(const geometry::identifier geo_id) {
279 m_identifier = geo_id;
280 }
281
283 template <typename free_param_t>
284 DETRAY_HOST_DEVICE void free_param(const free_param_t& param) {
285 m_free_params = algebra::cast_to<double>(param);
286 }
287
289 template <typename bound_param_t>
290 DETRAY_HOST_DEVICE void bound_param(const bound_param_t& param) {
291 m_bound_params = algebra::cast_to<double>(param);
292 }
293
295 template <typename jacobian_t>
296 DETRAY_HOST_DEVICE void jacobian(const jacobian_t& jac) {
297 m_jacobian = algebra::cast_to<double>(jac);
298 }
299
300};
301
307 double path{detail::invalid_value<double>()};
309 double thickness{detail::invalid_value<double>()};
311 double mat_X0{0.};
313 double mat_L0{0.};
314};
315
317template <concepts::detector detector_t>
320 using algebra_type = typename detector_t::algebra_type;
335
337 DETRAY_HOST_DEVICE
338 scalar_type step_size() const { return m_step_record.step_size(); }
340 DETRAY_HOST_DEVICE
341 void step_size(scalar_type step_size) { m_step_record.step_size(step_size); }
342
344 DETRAY_HOST_DEVICE
345 scalar_type path_length() const { return m_step_record.path_length(); }
347 DETRAY_HOST_DEVICE
349 m_step_record.path_length(path_length);
350 }
351
353 DETRAY_HOST_DEVICE
354 std::size_t n_rkn_trials() const { return m_step_record.n_trials(); }
356 DETRAY_HOST_DEVICE
357 void n_rkn_trials(std::size_t n_rkn_trials) {
358 m_step_record.n_trials(n_rkn_trials);
359 }
360
362 DETRAY_HOST_DEVICE
364 return m_intersection_record.template charge<value_type>();
365 }
366
367 DETRAY_HOST_DEVICE
368 void charge(scalar_type charge) { m_intersection_record.charge(charge); }
369
371 DETRAY_HOST_DEVICE
373 return m_intersection_record.template p<value_type>();
374 }
375
376 DETRAY_HOST_DEVICE
377 void p_mag(scalar_type p_mag) { m_intersection_record.p(p_mag); }
378
380 DETRAY_HOST_DEVICE
382 assert(intersection().is_outside() &&
383 m_step_record.bound_params.surface_link() ==
384 intersection().surface().identifier());
385 return m_step_record.bound_params.surface_link();
386 }
387
389 DETRAY_HOST_DEVICE
391 m_step_record.bound_param().surface_link() = geo_id;
392 }
393
395 DETRAY_HOST_DEVICE
397 return m_intersection_record.intersection();
398 }
399
400 DETRAY_HOST_DEVICE
402 return m_intersection_record.intersection();
403 }
404
407 DETRAY_HOST_DEVICE
408 void intersection(const intersection_type& intr) {
409 m_intersection_record.intersection(intr);
410 }
411
413 DETRAY_HOST_DEVICE
415 return m_step_record.free_param();
416 }
417
418 DETRAY_HOST_DEVICE
419 void free_track_param(const free_param_type& free_param) {
420 m_step_record.free_param(free_param);
421 }
422
424 DETRAY_HOST_DEVICE
425 bound_param_type& bound_track_param() { return m_step_record.bound_param(); }
427 DETRAY_HOST_DEVICE
428 void bound_track_param(const bound_param_type& bound_param) {
429 m_step_record.bound_param(bound_param);
430 }
431
432 DETRAY_HOST_DEVICE
434 return m_step_record.bound_params;
435 }
436
438 DETRAY_HOST_DEVICE
439 free_matrix_type& jacobian() { return m_step_record.jacobian(); }
441 DETRAY_HOST_DEVICE
442 const free_matrix_type& jacobian() const { return m_step_record.jacobian(); }
444 DETRAY_HOST_DEVICE
445 void jacobian(const free_matrix_type& jac) { m_step_record.jacobian(jac); }
446
447 private:
449 step_record<algebra_type> m_step_record;
451 std::optional<intersection_record<detector_t>> m_intersection_record{};
453 std::optional<material_record> m_material_record{};
454};
455
456} // namespace detray
Unique identifier for geometry objects, based on the ACTS GeometryIdentifier.
Definition identifier.hpp:36
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
unsigned int dindex
Default index type.
Definition indexing.hpp:18
dmatrix< algebra_t, e_free_size, e_free_size > free_matrix
Covariance matrix type for free track parametrization.
Definition track_parametrization.hpp:73
constexpr dindex dindex_invalid
Global invalid index definition.
Definition indexing.hpp:21
get_algebra_t< A, T > dalgebra
Select the algebra backend with value type T.
Definition algebra.hpp:44
get_vector3D_t< A, T > dvector3D
Three-dimensional vector type for algebra A and value type T.
Definition algebra.hpp:80
get_value_t< A > dvalue
Value scalar type of the algebra backend.
Definition algebra.hpp:48
get_point3D_t< A, T > dpoint3D
Three-dimensional point type for algebra A and value type T.
Definition algebra.hpp:72
free_parameters_vector< algebra_t > free_track_parameters
The free track parameters consist only of the parameter vector.
Definition free_track_parameters.hpp:249
Combine the bound track parameter vector with the covariance and associated surface.
Definition bound_track_parameters.hpp:297
dscalar< algebra_type > scalar_type
Scalar type used by this record.
Definition data_record.hpp:35
auto p() const
Definition data_record.hpp:105
intersection2D< typename detector_t::surface_type, typename detector_t::algebra_type, intersection::contains_pos > intersection_type
Intersection result type stored by this record.
Definition data_record.hpp:41
free_track_parameters< typename detector_t::algebra_type > track_param() const
Definition data_record.hpp:111
auto charge() const
Get the particle charge.
Definition data_record.hpp:99
dpoint3D< algebra_type > point3_type
3D point type used to store positions.
Definition data_record.hpp:37
void intersection(const intersection_type &intr)
Set the intersection result.
Definition data_record.hpp:137
auto direction() const
Definition data_record.hpp:81
void p(const scalar_t p)
Set the momentum magnitude.
Definition data_record.hpp:152
void direction(const vector_t &dir)
Set the track direction.
Definition data_record.hpp:131
const intersection_type & intersection() const
Get the intersection result.
Definition data_record.hpp:87
void volume(dindex vol_idx)
Set the containing volume index.
Definition data_record.hpp:141
intersection_type & intersection()
Get the mutable intersection result.
Definition data_record.hpp:91
dvector3D< algebra_type > vector3_type
3D vector type used to store directions.
Definition data_record.hpp:39
void charge(const scalar_t q)
Set the particle charge.
Definition data_record.hpp:146
constexpr intersection_record(const typename detector_t::point3_type &position, const typename detector_t::vector3_type &direction, const intersection_type &intr, const double q=detray::detail::invalid_value< double >(), const double p=detray::detail::invalid_value< double >(), const dindex v_idx=dindex_invalid)
The particle charge is not known in the navigation, but might be provided in a different context.
Definition data_record.hpp:56
auto position() const
Definition data_record.hpp:75
dindex volume() const
Get the containing volume index.
Definition data_record.hpp:95
void position(const point_t &position)
SettersSet the intersection position.
Definition data_record.hpp:125
dalgebra< typename detector_t::algebra_type, double > algebra_type
Algebra type used to store values in double precision.
Definition data_record.hpp:33
Contains the material parameters and the pathlength.
Definition data_record.hpp:303
double path
Pathlength of the track through the material.
Definition data_record.hpp:307
geometry::identifier geo_id
The surface the material belongs to.
Definition data_record.hpp:305
double mat_X0
Radiation length.
Definition data_record.hpp:311
double mat_L0
Interaction length.
Definition data_record.hpp:313
double thickness
Material thickness/radius.
Definition data_record.hpp:309
Data for a single step.
Definition data_record.hpp:318
std::size_t n_rkn_trials() const
Definition data_record.hpp:354
geometry::identifier identifier() const
Definition data_record.hpp:381
intersection_type & intersection()
Definition data_record.hpp:401
intersection_record< detector_t >::intersection_type intersection_type
Intersection type associated with the detector.
Definition data_record.hpp:334
void step_size(scalar_type step_size)
Set the new step size.
Definition data_record.hpp:341
typename step_record_type::bound_param_type bound_param_type
Bound track parameter type.
Definition data_record.hpp:330
step_record< algebra_type > step_record_type
Type storing the propagation step data.
Definition data_record.hpp:326
void p_mag(scalar_type p_mag)
Set the new total momentum magnitude.
Definition data_record.hpp:377
scalar_type path_length() const
Definition data_record.hpp:345
void bound_track_param(const bound_param_type &bound_param)
Set the new bound parameters.
Definition data_record.hpp:428
void n_rkn_trials(std::size_t n_rkn_trials)
Set the new number of RKN iterations.
Definition data_record.hpp:357
scalar_type p_mag() const
Definition data_record.hpp:372
typename step_record_type::free_matrix_type free_matrix_type
Free track matrix type.
Definition data_record.hpp:332
void identifier(geometry::identifier geo_id)
Set the new geometry identifier.
Definition data_record.hpp:390
dscalar< algebra_type > scalar_type
Scalar type associated with the detector algebra.
Definition data_record.hpp:324
void charge(scalar_type charge)
Set the new charge.
Definition data_record.hpp:368
bound_param_type & bound_track_param()
Definition data_record.hpp:425
scalar_type step_size() const
Definition data_record.hpp:338
dvalue< algebra_type > value_type
Value type associated with the detector algebra.
Definition data_record.hpp:322
free_param_type free_track_param() const
Definition data_record.hpp:414
void path_length(scalar_type path_length)
Set the new path length.
Definition data_record.hpp:348
typename step_record_type::track_param_type free_param_type
Free track parameter type.
Definition data_record.hpp:328
scalar_type charge() const
Definition data_record.hpp:363
void free_track_param(const free_param_type &free_param)
Set the new free track parameters.
Definition data_record.hpp:419
void intersection(const intersection_type &intr)
Set the new intersection data.
Definition data_record.hpp:408
void jacobian(const free_matrix_type &jac)
Set the new Jacobian.
Definition data_record.hpp:445
const bound_param_type & bound_track_param() const
Definition data_record.hpp:433
free_matrix_type & jacobian()
Definition data_record.hpp:439
const free_matrix_type & jacobian() const
Definition data_record.hpp:442
const intersection_type & intersection() const
Definition data_record.hpp:396
typename detector_t::algebra_type algebra_type
Detector algebra type.
Definition data_record.hpp:320
Data for a single step.
Definition data_record.hpp:174
dvector3D< algebra_t > vector3_type
3D vector type used by the record.
Definition data_record.hpp:182
dalgebra< algebra_t, double > algebra_type
Algebra type used to store values in double precision.
Definition data_record.hpp:176
scalar_type m_step_size
Definition data_record.hpp:191
scalar_type step_size() const
GettersGet the step size.
Definition data_record.hpp:212
free_track_parameters< algebra_t > track_param_type
Free track parameter type stored by the record.
Definition data_record.hpp:184
void jacobian(const jacobian_t &jac)
Set the transport Jacobian.
Definition data_record.hpp:296
void nav_direction(const navigation::direction nav_dir)
Set the navigation direction.
Definition data_record.hpp:273
std::size_t m_n_total_trials
Definition data_record.hpp:195
dscalar< algebra_t > scalar_type
Scalar type used by the record.
Definition data_record.hpp:180
track_param_type m_free_params
Definition data_record.hpp:201
void identifier(const geometry::identifier geo_id)
Set the geometry identifier.
Definition data_record.hpp:278
free_matrix_type jacobian() const
Get the transport Jacobian.
Definition data_record.hpp:249
dvalue< algebra_t > value_t
Value type associated with the algebra.
Definition data_record.hpp:178
void path_length(const scalar_type path_length)
Set the accumulated path length.
Definition data_record.hpp:263
navigation::direction nav_direction() const
Get the navigation direction.
Definition data_record.hpp:226
scalar_type path_length() const
Get the accumulated path length.
Definition data_record.hpp:218
void free_param(const free_param_t &param)
Set the free track parameters.
Definition data_record.hpp:284
bound_track_parameters< algebra_t > bound_param_type
Bound track parameter type stored by the record.
Definition data_record.hpp:186
navigation::direction m_nav_dir
Definition data_record.hpp:197
scalar_type m_path_length
Definition data_record.hpp:193
free_matrix_type m_jacobian
Definition data_record.hpp:205
std::size_t n_trials() const
Get the number of propagation trials.
Definition data_record.hpp:223
free_matrix< algebra_t > free_matrix_type
Free track matrix type stored by the record.
Definition data_record.hpp:188
geometry::identifier m_identifier
Definition data_record.hpp:199
bound_param_type bound_param() const
Get the bound track parameters.
Definition data_record.hpp:243
void n_trials(const std::size_t n_trial)
Set the number of propagation trials.
Definition data_record.hpp:268
geometry::identifier identifier() const
Get the geometry identifier.
Definition data_record.hpp:231
void bound_param(const bound_param_t &param)
Set the bound track parameters.
Definition data_record.hpp:290
bound_param_type m_bound_params
Definition data_record.hpp:203
void step_size(const scalar_type step_size)
SettersSet the step size.
Definition data_record.hpp:258
track_param_type free_param() const
Get the free track parameters.
Definition data_record.hpp:237
static constexpr scalar_t GeV
Native energy unit, the gigaelectronvolt.
Definition units.hpp:81