ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
step_tracer.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/propagator/actors/parameter_updater.hpp"
15#include "detray/propagator/base_actor.hpp"
16#include "detray/tracks/bound_track_parameters.hpp"
17#include "detray/tracks/free_track_parameters.hpp"
18
19// Test include(s)
20#include "detray/test/utils/data_record.hpp"
21
22namespace detray::actor {
23
25template <concepts::algebra algebra_t, template <typename...> class vector_t>
26struct step_tracer : public base_actor {
29
31 struct state {
32 friend struct step_tracer;
33
34 state() = delete;
35
38 DETRAY_HOST
39 explicit state(vecmem::memory_resource& resource) : m_steps(&resource) {}
40
42 DETRAY_HOST_DEVICE
43 explicit state(vector_t<step_data_t>&& steps) : m_steps(std::move(steps)) {}
44
48 DETRAY_HOST_DEVICE
49 const auto& get_step_data() const { return m_steps; }
50
53 DETRAY_HOST
54 auto&& release_step_data() && { return std::move(m_steps); }
55
56 private:
58 vector_t<step_data_t> m_steps;
59 };
60
65 template <typename propagator_state_t>
66 DETRAY_HOST_DEVICE void operator()(state& tracer_state,
67 propagator_state_t& prop_state) const {
68 tracer_state.m_steps.push_back(collect_data(prop_state));
69 }
70
76 template <typename propagator_state_t>
77 DETRAY_HOST_DEVICE void operator()(
78 state& tracer_state, propagator_state_t& prop_state,
80 const auto& navigation = prop_state.navigation();
81 assert(navigation.is_on_surface());
82
83 // If the state has already been collected by the other call operator,
84 // update the bound track parameters
85 if (!tracer_state.m_steps.empty() &&
86 navigation.geometry_identifier() ==
87 tracer_state.m_steps.back().identifier()) {
88 tracer_state.m_steps.back().bound_param() = res.destination_params();
89 } else {
90 tracer_state.m_steps.push_back(
91 collect_data(prop_state, res.destination_params()));
92 }
93 }
94
95 private:
97 template <typename propagator_state_t>
98 DETRAY_HOST_DEVICE step_data_t collect_data(
99 propagator_state_t& prop_state,
100 const bound_track_parameters<algebra_t>& bound_param = {}) const {
101 const auto& navigation = prop_state.navigation();
102 const auto& stepping = prop_state.stepping();
103
104 const auto geo_id{navigation.is_on_surface()
105 ? navigation.geometry_identifier()
107
108 return {stepping.step_size(),
109 stepping.path_length(),
110 stepping.n_total_trials(),
111 navigation.direction(),
112 geo_id,
113 stepping(),
114 bound_param,
115 stepping.transport_jacobian()};
116 }
117};
118
119} // namespace detray::actor
Unique identifier for geometry objects, based on the ACTS GeometryIdentifier.
Definition identifier.hpp:36
Result of the param. transporter: bound track parameters at dest. sf.
Definition parameter_updater.hpp:210
constexpr const bound_track_parameters< algebra_t > & destination_params() const
Definition parameter_updater.hpp:236
Actor state that collects the data.
Definition step_tracer.hpp:31
state(vector_t< step_data_t > &&steps)
Construct from externally provided vector for the.
Definition step_tracer.hpp:43
auto && release_step_data() &&
Move the recorded step data out of the actor.
Definition step_tracer.hpp:54
state(vecmem::memory_resource &resource)
Construct the vector containers with a given resource.
Definition step_tracer.hpp:39
const auto & get_step_data() const
Access to the recorded step data of every step along the track - const.
Definition step_tracer.hpp:49
Collect information at every step.
Definition step_tracer.hpp:26
void operator()(state &tracer_state, propagator_state_t &prop_state, const parameter_transporter_result< algebra_t > &res) const
Collect only when transport to bound track parameters happens.
Definition step_tracer.hpp:77
step_record< algebra_t > step_data_t
Type used to store one step's data.
Definition step_tracer.hpp:28
void operator()(state &tracer_state, propagator_state_t &prop_state) const
Collect data at every step.
Definition step_tracer.hpp:66
Base class actor implementation.
Definition base_actor.hpp:20
Combine the bound track parameter vector with the covariance and associated surface.
Definition bound_track_parameters.hpp:297
Data for a single step.
Definition data_record.hpp:174