ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
surface_sequencer.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/utils/logging.hpp"
16
17// Vecmem include(s)
18#include <vecmem/containers/device_vector.hpp>
19
20// System includes
21#include <utility>
22
23namespace detray::actor {
24
27template <typename sf_descriptor_t>
30 struct state {
32 using surface_type = sf_descriptor_t;
34 using sequence_type = vecmem::device_vector<sf_descriptor_t>;
35
38 DETRAY_HOST_DEVICE
39 explicit state(sequence_type seq) : m_sequence(seq) {}
40
42 DETRAY_HOST_DEVICE void set_overflow() { m_overflow = true; }
43
45 DETRAY_HOST_DEVICE bool overflow() const { return m_overflow; }
46
49 DETRAY_HOST_DEVICE void collect_only_material_surfaces(bool material_only) {
50 m_collect_only_material_surfaces = material_only;
51 }
52
54 DETRAY_HOST_DEVICE bool collect_only_material_surfaces() const {
55 return m_collect_only_material_surfaces;
56 }
57
59 DETRAY_HOST_DEVICE const sequence_type& sequence() const {
60 return m_sequence;
61 }
62
64 DETRAY_HOST_DEVICE sequence_type& sequence() { return m_sequence; }
65
66 private:
68 sequence_type m_sequence;
70 bool m_overflow = false;
72 bool m_collect_only_material_surfaces = false;
73 };
74
80 template <typename propagator_state_t>
81 requires std::same_as<
82 sf_descriptor_t,
83 typename propagator_state_t::detector_type::surface_type>
84 DETRAY_HOST_DEVICE void operator()(state& actor_state,
85 propagator_state_t& propagation) const {
86 const auto& navigation = propagation.navigation();
87
88 DETRAY_VERBOSE_HOST_DEVICE(
89 "Actor: Checking for next surface in sequence...");
90
91 if (actor_state.collect_only_material_surfaces() &&
92 navigation.is_on_sensitive()) {
93 return;
94 } else if (!(navigation.is_on_sensitive() ||
95 navigation.encountered_sf_material())) {
96 return;
97 }
98
99 if (actor_state.sequence().size() == actor_state.sequence().capacity()) {
100 if (actor_state.sequence().capacity() == 0) {
101 DETRAY_VERBOSE_HOST_DEVICE(
102 "Actor: No capacity to store surface candidate - skipping");
103 } else {
104 DETRAY_VERBOSE_HOST_DEVICE("Actor: Sequence overflow!");
105 actor_state.set_overflow();
106 propagation.navigation().exit();
107 propagation.heartbeat(false);
108 }
109 return;
110 }
111
112 const auto& sf_desc = std::as_const(navigation).current().surface();
113 assert(!sf_desc.identifier().is_invalid());
114
115 actor_state.sequence().push_back(sf_desc);
116 DETRAY_VERBOSE_HOST("Actor: Added surface: " << sf_desc);
117 }
118};
119
120} // namespace detray::actor
Buffer and collection options maintained for one propagation.
Definition surface_sequencer.hpp:30
bool overflow() const
Definition surface_sequencer.hpp:45
state(sequence_type seq)
Constructor with the vector of track states.
Definition surface_sequencer.hpp:39
vecmem::device_vector< sf_descriptor_t > sequence_type
Device vector storing the encountered surface sequence.
Definition surface_sequencer.hpp:34
void collect_only_material_surfaces(bool material_only)
Configure whether to collect only material surfaces.
Definition surface_sequencer.hpp:49
sf_descriptor_t surface_type
Surface descriptor type recorded by the actor.
Definition surface_sequencer.hpp:32
bool collect_only_material_surfaces() const
Definition surface_sequencer.hpp:54
sequence_type & sequence()
Definition surface_sequencer.hpp:64
void set_overflow()
Flags that the internal buffer has experienced an overflow.
Definition surface_sequencer.hpp:42
const sequence_type & sequence() const
Definition surface_sequencer.hpp:59
Actor that records sensitive or material-bearing surfaces along a propagation.
Definition surface_sequencer.hpp:28
void operator()(state &actor_state, propagator_state_t &propagation) const
Record detector surfaces in sequence if they are sensitive or have material.
Definition surface_sequencer.hpp:84
Base class actor implementation.
Definition base_actor.hpp:20