ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
aborters.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/base_actor.hpp"
15#include "detray/propagator/base_stepper.hpp"
16#include "detray/utils/logging.hpp"
17
18// System include(s)
19#include <limits>
20
21namespace detray::actor {
22
24template <concepts::scalar scalar_t>
27 struct state {
29 scalar_t _path_limit = std::numeric_limits<scalar_t>::max();
30
32 DETRAY_HOST_DEVICE
33 inline void set_path_limit(const scalar_t pl) { _path_limit = pl; }
34
36 DETRAY_HOST_DEVICE
37 inline scalar_t path_limit() const { return _path_limit; }
38 };
39
44 template <typename propagator_state_t>
45 DETRAY_HOST_DEVICE void operator()(state &abrt_state,
46 propagator_state_t &prop_state) const {
47 DETRAY_VERBOSE_HOST_DEVICE("Aborter: Check path limits");
48
49 auto &step_state = prop_state.stepping();
50 auto &nav_state = prop_state.navigation();
51
52 // Nothing left to do. Propagation will exit successfully
53 if (nav_state.finished()) {
54 return;
55 }
56
57 const scalar_t step_limit =
58 abrt_state.path_limit() -
59 math::fabs(prop_state.stepping().abs_path_length());
60
61 // Check the path limit
62 if (step_limit <= 0.f) {
63 DETRAY_VERBOSE_HOST_DEVICE(
64 "Path lengths: %f mm",
65 math::fabs(prop_state.stepping().abs_path_length()));
66
67 // Stop navigation
68 nav_state.abort("Aborter: Maximal path length reached");
69 prop_state.heartbeat(false);
70 }
71
72 // Don't go over the path limit in the next step
73 step_state.template set_constraint<step::constraint::e_aborter>(step_limit);
74 }
75};
76
78template <concepts::scalar scalar_t>
81 struct state {
83 DETRAY_HOST_DEVICE
84 constexpr scalar_t p_limit() const { return m_min_p; }
85
87 DETRAY_HOST_DEVICE
88 constexpr scalar_t pT_limit() const { return m_min_pT; }
89
92 DETRAY_HOST_DEVICE
93 constexpr void min_p(const scalar_t p) { m_min_p = p; }
94
97 DETRAY_HOST_DEVICE
98 constexpr void min_pT(const scalar_t pT) { m_min_pT = pT; }
99
100 private:
102 scalar_t m_min_p = 10.f * unit<scalar_t>::MeV;
103 scalar_t m_min_pT = 10.f * unit<scalar_t>::MeV;
104 };
105
110 template <typename propagator_state_t>
111 DETRAY_HOST_DEVICE void operator()(state &abrt_state,
112 propagator_state_t &prop_state) const {
113 DETRAY_VERBOSE_HOST_DEVICE("Aborter: Check momentum");
114
115 auto &step_state = prop_state.stepping();
116 auto &nav_state = prop_state.navigation();
117
118 // Nothing left to do. Propagation will exit successfully
119 if (nav_state.finished()) {
120 return;
121 }
122
123 const auto &track = step_state();
124 const scalar_t q{step_state.particle_hypothesis().charge()};
125
126 if (track.pT(q) <= abrt_state.pT_limit()) {
127 DETRAY_VERBOSE_HOST_DEVICE("Track |pT| = %f MeV", track.pT(q));
128
129 // Stop navigation
130 nav_state.abort("Aborter: Minimum transverse momentum (pT) reached");
131 prop_state.heartbeat(false);
132 return;
133 }
134
135 if (track.p(q) <= abrt_state.p_limit()) {
136 DETRAY_VERBOSE_HOST_DEVICE("Track |p| = %f MeV", track.p(q));
137
138 // Stop navigation
139 nav_state.abort("Aborter: Minimum momentum (p) reached");
140 prop_state.heartbeat(false);
141 }
142 }
143};
144
146struct target_aborter : public base_actor {
152
157 template <typename propagator_state_t>
158 DETRAY_HOST_DEVICE void operator()(const state &abrt_state,
159 propagator_state_t &prop_state) const {
160 DETRAY_VERBOSE_HOST_DEVICE("Aborter: Check target surface");
161
162 auto &navigation = prop_state.navigation();
163 const auto &stepping = prop_state.stepping();
164
165 // In case the propagation starts on a module, make sure to not abort
166 // directly
167 if (navigation.is_on_surface() &&
168 (navigation.geometry_identifier() == abrt_state._target_surface) &&
169 (stepping.path_length() > 0.f)) {
170 navigation.abort("Aborter: Reached target surface");
171 prop_state.heartbeat(false);
172 }
173 }
174};
175
176} // namespace detray::actor
Unique identifier for geometry objects, based on the ACTS GeometryIdentifier.
Definition identifier.hpp:36
Per-propagation minimum momentum thresholds.
Definition aborters.hpp:81
constexpr scalar_t p_limit() const
Definition aborters.hpp:84
constexpr scalar_t pT_limit() const
Definition aborters.hpp:88
constexpr void min_p(const scalar_t p)
Set the momentum limit to p.
Definition aborters.hpp:93
constexpr void min_pT(const scalar_t pT)
Set the transverse momentum limit to pT.
Definition aborters.hpp:98
Aborter that checks whether the track fell below a minimum momentum.
Definition aborters.hpp:79
void operator()(state &abrt_state, propagator_state_t &prop_state) const
Actor interface: Enforces a minimum momentum magnitude.
Definition aborters.hpp:111
Pathlimit for a single propagation workflow.
Definition aborters.hpp:27
scalar_t path_limit() const
Definition aborters.hpp:37
scalar_t _path_limit
Absolute path limit.
Definition aborters.hpp:29
void set_path_limit(const scalar_t pl)
Set the path limit to a scalar.
Definition aborters.hpp:33
Aborter that checks whether the track has exceeded its pathlimit.
Definition aborters.hpp:25
void operator()(state &abrt_state, propagator_state_t &prop_state) const
Enforces the path limit on a stepper state.
Definition aborters.hpp:45
Keeps the index for the target surface.
Definition aborters.hpp:148
geometry::identifier _target_surface
Unique surface id of the target.
Definition aborters.hpp:150
Aborter checks whether a specific surface was reached.
Definition aborters.hpp:146
void operator()(const state &abrt_state, propagator_state_t &prop_state) const
Exits the navigation as soon as the target surface has been found.
Definition aborters.hpp:158
Base class actor implementation.
Definition base_actor.hpp:20
static constexpr scalar_t MeV
Megaelectronvolt expressed in GeV.
Definition units.hpp:79