Skip to content

Commit

Permalink
Update to detray version v0.88.1
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Feb 13, 2025
1 parent 5412f1a commit a3eeb14
Show file tree
Hide file tree
Showing 22 changed files with 67 additions and 94 deletions.
2 changes: 1 addition & 1 deletion benchmarks/common/benchmarks/toy_detector_benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
#include "detray/detectors/bfield.hpp"
#include "detray/io/frontend/detector_reader.hpp"
#include "detray/io/frontend/detector_writer.hpp"
#include "detray/navigation/detail/ray.hpp"
#include "detray/navigation/navigator.hpp"
#include "detray/propagator/propagator.hpp"
#include "detray/propagator/rk_stepper.hpp"
#include "detray/test/utils/detectors/build_toy_detector.hpp"
#include "detray/test/utils/simulation/event_generator/track_generators.hpp"
#include "detray/tracks/ray.hpp"

// VecMem include(s).
#include <vecmem/memory/host_memory_resource.hpp>
Expand Down
8 changes: 2 additions & 6 deletions core/include/traccc/finding/details/find_tracks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
#include "traccc/utils/projections.hpp"

// Detray include(s).
#include <detray/propagator/actor_chain.hpp>
#include <detray/propagator/actors/aborters.hpp>
#include <detray/propagator/actors/parameter_resetter.hpp>
#include <detray/propagator/actors/parameter_transporter.hpp>
#include <detray/propagator/actors/pointwise_material_interactor.hpp>
#include <detray/propagator/actors.hpp>
#include <detray/propagator/propagator.hpp>

// System include(s).
Expand Down Expand Up @@ -71,7 +67,7 @@ track_candidate_container_types::host find_tracks(
using interactor_type = detray::pointwise_material_interactor<algebra_type>;

using actor_type = detray::actor_chain<
detray::tuple, detray::pathlimit_aborter<scalar_type>, transporter_type,
detray::pathlimit_aborter<scalar_type>, transporter_type,
interaction_register<interactor_type>, interactor_type, ckf_aborter>;

using propagator_type =
Expand Down
7 changes: 3 additions & 4 deletions core/include/traccc/fitting/details/fit_tracks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ track_state_container_types::host fit_tracks(
}

// Make a fitter state
typename fitter_t::state fitter_state(std::move(input_states));
typename fitter_t::state fitter_state(vecmem::get_data(input_states));

// Run the fitter.
fitter.fit(track_candidates.get_headers()[i], fitter_state);

// Save the results into the output container.
result.push_back(
std::move(fitter_state.m_fit_res),
std::move(fitter_state.m_fit_actor_state.m_track_states));
result.push_back(std::move(fitter_state.m_fit_res),
std::move(input_states));
}

// Return the fitted track states.
Expand Down
28 changes: 11 additions & 17 deletions core/include/traccc/fitting/kalman_filter/kalman_actor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,33 @@
#include "traccc/utils/particle.hpp"

// detray include(s).
#include "detray/propagator/base_actor.hpp"
#include <detray/propagator/base_actor.hpp>

// vecmem include(s)
#include <vecmem/containers/device_vector.hpp>

namespace traccc {

/// Detray actor for Kalman filtering
template <typename algebra_t, template <typename...> class vector_t>
template <typename algebra_t>
struct kalman_actor : detray::actor {

// Type declarations
using track_state_type = track_state<algebra_t>;
using track_state_coll = vecmem::device_vector<track_state<algebra_t>>;

// Actor state
struct state {

/// Constructor with the vector of track states
TRACCC_HOST_DEVICE
state(vector_t<track_state_type>&& track_states)
: m_track_states(std::move(track_states)) {
m_it = m_track_states.begin();
m_it_rev = m_track_states.rbegin();
}

/// Constructor with the vector of track states
TRACCC_HOST_DEVICE
state(const vector_t<track_state_type>& track_states)
: m_track_states(track_states) {
state(track_state_coll track_states) : m_track_states(track_states) {
m_it = m_track_states.begin();
m_it_rev = m_track_states.rbegin();
}

/// @return the reference of track state pointed by the iterator
TRACCC_HOST_DEVICE
track_state_type& operator()() {
typename track_state_coll::value_type& operator()() {
if (!backward_mode) {
return *m_it;
} else {
Expand Down Expand Up @@ -84,13 +78,13 @@ struct kalman_actor : detray::actor {
}

// vector of track states
vector_t<track_state_type> m_track_states;
track_state_coll m_track_states;

// iterator for forward filtering
typename vector_t<track_state_type>::iterator m_it;
typename track_state_coll::iterator m_it;

// iterator for backward filtering
typename vector_t<track_state_type>::reverse_iterator m_it_rev;
typename track_state_coll::reverse_iterator m_it_rev;

// The number of holes (The number of sensitive surfaces which do not
// have a measurement for the track pattern)
Expand Down
36 changes: 17 additions & 19 deletions core/include/traccc/fitting/kalman_filter/kalman_fitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
#include "traccc/utils/particle.hpp"

// detray include(s).
#include "detray/propagator/actor_chain.hpp"
#include "detray/propagator/actors/aborters.hpp"
#include "detray/propagator/actors/parameter_resetter.hpp"
#include "detray/propagator/actors/parameter_transporter.hpp"
#include "detray/propagator/actors/pointwise_material_interactor.hpp"
#include "detray/propagator/propagator.hpp"
#include <detray/propagator/actors.hpp>
#include <detray/propagator/propagator.hpp>

// vecmem include(s)
#include <vecmem/containers/device_vector.hpp>

// System include(s).
#include <limits>
Expand All @@ -47,10 +46,6 @@ class kalman_fitter {
// scalar type
using scalar_type = detray::dscalar<algebra_type>;

// vector type
template <typename T>
using vector_type = typename detector_type::template vector_type<T>;

/// Configuration type
using config_type = fitting_config;

Expand All @@ -61,16 +56,16 @@ class kalman_fitter {
using aborter = detray::pathlimit_aborter<scalar_type>;
using transporter = detray::parameter_transporter<algebra_type>;
using interactor = detray::pointwise_material_interactor<algebra_type>;
using fit_actor = traccc::kalman_actor<algebra_type, vector_type>;
using fit_actor = traccc::kalman_actor<algebra_type>;
using resetter = detray::parameter_resetter<algebra_type>;

using actor_chain_type =
detray::actor_chain<detray::dtuple, aborter, transporter, interactor,
fit_actor, resetter, kalman_step_aborter>;
detray::actor_chain<aborter, transporter, interactor, fit_actor,
resetter, kalman_step_aborter>;

using backward_actor_chain_type =
detray::actor_chain<detray::dtuple, aborter, transporter, fit_actor,
interactor, resetter, kalman_step_aborter>;
detray::actor_chain<aborter, transporter, fit_actor, interactor,
resetter, kalman_step_aborter>;

// Propagator type
using propagator_type =
Expand All @@ -94,14 +89,17 @@ class kalman_fitter {
///
/// @param track_states the vector of track states
TRACCC_HOST_DEVICE
state(vector_type<track_state<algebra_type>>&& track_states)
: m_fit_actor_state(std::move(track_states)) {}
state(vecmem::data::vector_view<track_state<algebra_type>> track_states)
: m_fit_actor_state(
vecmem::device_vector<track_state<algebra_type>>(
track_states)) {}

/// State constructor
///
/// @param track_states the vector of track states
TRACCC_HOST_DEVICE
state(const vector_type<track_state<algebra_type>>& track_states)
state(const vecmem::device_vector<track_state<algebra_type>>&
track_states)
: m_fit_actor_state(track_states) {}

/// @return the actor chain state
Expand Down Expand Up @@ -252,7 +250,7 @@ class kalman_fitter {

} else {
// Run the Rauch–Tung–Striebel (RTS) smoother
for (typename vector_type<
for (typename vecmem::device_vector<
track_state<algebra_type>>::reverse_iterator it =
track_states.rbegin() + 1;
it != track_states.rend(); ++it) {
Expand Down
2 changes: 1 addition & 1 deletion core/include/traccc/seeding/detail/spacepoint_grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "traccc/edm/spacepoint.hpp"

// detray core
#include <detray/definitions/detail/indexing.hpp>
#include <detray/definitions/indexing.hpp>
#include <detray/grids/axis.hpp>
#include <detray/grids/grid2.hpp>
#include <detray/grids/populator.hpp>
Expand Down
12 changes: 5 additions & 7 deletions core/include/traccc/utils/seed_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
// detray include(s).
#include "detray/geometry/barcode.hpp"
#include "detray/geometry/tracking_surface.hpp"
#include "detray/propagator/actor_chain.hpp"
#include "detray/propagator/actors/aborters.hpp"
#include "detray/propagator/actors/parameter_resetter.hpp"
#include "detray/propagator/actors/parameter_transporter.hpp"
#include "detray/propagator/actors/pointwise_material_interactor.hpp"
#include "detray/propagator/actors.hpp"
#include "detray/propagator/base_actor.hpp"
#include "detray/propagator/propagator.hpp"

Expand Down Expand Up @@ -76,8 +72,10 @@ struct seed_generator {

for (std::size_t i = 0; i < e_bound_size; i++) {

bound_param[i] = std::normal_distribution<scalar>(
bound_param[i], m_stddevs[i])(m_generator);
if (m_stddevs[i] != 0.f) {
bound_param[i] = std::normal_distribution<scalar>(
bound_param[i], m_stddevs[i])(m_generator);
}

getter::element(bound_param.covariance(), i, i) =
m_stddevs[i] * m_stddevs[i];
Expand Down
2 changes: 1 addition & 1 deletion core/src/seeding/spacepoint_binning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Library include(s).
#include "traccc/seeding/spacepoint_binning.hpp"

#include <detray/definitions/detail/indexing.hpp>
#include <detray/definitions/indexing.hpp>

#include "traccc/definitions/primitives.hpp"
#include "traccc/seeding/spacepoint_binning_helper.hpp"
Expand Down
15 changes: 6 additions & 9 deletions device/cuda/include/traccc/cuda/finding/finding_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
#include "traccc/utils/memory_resource.hpp"

// detray include(s).
#include "detray/propagator/actor_chain.hpp"
#include "detray/propagator/actors/aborters.hpp"
#include "detray/propagator/actors/parameter_resetter.hpp"
#include "detray/propagator/actors/parameter_transporter.hpp"
#include "detray/propagator/actors/pointwise_material_interactor.hpp"
#include "detray/propagator/actors.hpp"
#include "detray/propagator/propagator.hpp"

// VecMem include(s).
Expand Down Expand Up @@ -57,10 +53,11 @@ class finding_algorithm
using interactor = detray::pointwise_material_interactor<algebra_type>;

/// Actor chain for propagate to the next surface and its propagator type
using actor_type = detray::actor_chain<
detray::dtuple, detray::pathlimit_aborter<scalar_type>,
detray::parameter_transporter<algebra_type>,
interaction_register<interactor>, interactor, ckf_aborter>;
using actor_type =
detray::actor_chain<detray::pathlimit_aborter<scalar_type>,
detray::parameter_transporter<algebra_type>,
interaction_register<interactor>, interactor,
ckf_aborter>;

using propagator_type =
detray::propagator<stepper_t, navigator_t, actor_type>;
Expand Down
6 changes: 1 addition & 5 deletions device/cuda/src/finding/kernels/specializations/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
#pragma once

#include "detray/detectors/bfield.hpp"
#include "detray/propagator/actor_chain.hpp"
#include "detray/propagator/actors/aborters.hpp"
#include "detray/propagator/actors/parameter_resetter.hpp"
#include "detray/propagator/actors/parameter_transporter.hpp"
#include "detray/propagator/actors/pointwise_material_interactor.hpp"
#include "detray/propagator/actors.hpp"
#include "detray/propagator/propagator.hpp"
#include "detray/propagator/rk_stepper.hpp"
#include "traccc/cuda/finding/finding_algorithm.hpp"
Expand Down
9 changes: 2 additions & 7 deletions device/sycl/src/finding/find_tracks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@
#include "traccc/utils/projections.hpp"

// Detray include(s).
#include "detray/propagator/actor_chain.hpp"
#include "detray/propagator/actors/aborters.hpp"
#include "detray/propagator/actors/parameter_resetter.hpp"
#include "detray/propagator/actors/parameter_transporter.hpp"
#include "detray/propagator/actors/pointwise_material_interactor.hpp"
#include "detray/propagator/actors.hpp"
#include "detray/propagator/propagator.hpp"

// VecMem include(s).
Expand Down Expand Up @@ -370,8 +366,7 @@ track_candidate_container_types::buffer find_tracks(
using interactor_type =
detray::pointwise_material_interactor<algebra_type>;
using actor_type =
detray::actor_chain<detray::dtuple,
detray::pathlimit_aborter<scalar_type>,
detray::actor_chain<detray::pathlimit_aborter<scalar_type>,
detray::parameter_transporter<algebra_type>,
interaction_register<interactor_type>,
interactor_type, ckf_aborter>;
Expand Down
2 changes: 1 addition & 1 deletion examples/simulation/simulate_telescope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include "detray/geometry/shapes/rectangle2D.hpp"
#include "detray/io/frontend/detector_writer.hpp"
#include "detray/materials/material.hpp"
#include "detray/navigation/detail/ray.hpp"
#include "detray/test/utils/detectors/build_telescope_detector.hpp"
#include "detray/test/utils/simulation/event_generator/track_generators.hpp"
#include "detray/tracks/ray.hpp"

// VecMem include(s).
#include <vecmem/memory/host_memory_resource.hpp>
Expand Down
6 changes: 2 additions & 4 deletions extern/detray/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ message( STATUS "Building Detray as part of the TRACCC project" )

# Declare where to get Detray from.
set( TRACCC_DETRAY_SOURCE
"URL;https://github.com/acts-project/detray/archive/refs/tags/v0.87.0.tar.gz;URL_MD5;0e30107edebfd41fbb3fc1974f665ea9"
"GIT_REPOSITORY;https://github.com/niermann999/detray;GIT_TAG;fix-assertion"
CACHE STRING "Source for Detray, when built as part of this project" )
mark_as_advanced( TRACCC_DETRAY_SOURCE )
FetchContent_Declare( Detray SYSTEM ${TRACCC_DETRAY_SOURCE} )

# Options used in the build of Detray.
set( DETRAY_CUSTOM_SCALARTYPE "float" CACHE STRING
set( DETRAY_CUSTOM_SCALARTYPE "${TRACCC_CUSTOM_SCALARTYPE}" CACHE STRING
"Scalar type to use in the Detray code" )

set( DETRAY_BUILD_UNITTESTS FALSE CACHE BOOL
Expand Down Expand Up @@ -48,8 +48,6 @@ set( DETRAY_SETUP_GOOGLETEST FALSE CACHE BOOL
"Do not set up GoogleTest as part of Detray" )
set( DETRAY_SETUP_BENCHMARK FALSE CACHE BOOL
"Do not set up Google Benchmark as part of Detray" )
set( DETRAY_SETUP_THRUST FALSE CACHE BOOL
"Do not set up Thrust as part of Detray" )
set( DETRAY_SETUP_COVFIE FALSE CACHE BOOL
"Do not set up covfie as part of Detray" )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once

// Detray include(s).
#include "detray/definitions/detail/algebra.hpp"
#include "detray/definitions/algebra.hpp"

// Algebra Plugins include(s).
#include <algebra/array_cmath.hpp>
Expand Down
9 changes: 6 additions & 3 deletions simulation/include/traccc/simulation/measurement_smearer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ struct measurement_smearer {
std::mt19937_64 generator{rd()};

std::array<scalar_type, 2> get_offset() {
return {
std::normal_distribution<scalar_type>(0.f, stddev[0])(generator),
std::normal_distribution<scalar_type>(0.f, stddev[1])(generator)};
auto generate_offset = [&gen = generator](const scalar_type sigma) {
return sigma == 0.f
? 0.f
: std::normal_distribution<scalar_type>(0.f, sigma)(gen);
};
return {generate_offset(stddev[0]), generate_offset(stddev[1])};
}

template <typename mask_t>
Expand Down
3 changes: 1 addition & 2 deletions simulation/include/traccc/simulation/simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ struct simulator {
using bfield_type = bfield_t;

using actor_chain_type =
detray::actor_chain<detray::dtuple,
detray::parameter_transporter<algebra_type>,
detray::actor_chain<detray::parameter_transporter<algebra_type>,
detray::random_scatterer<algebra_type>,
detray::parameter_resetter<algebra_type>, writer_t>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "detray/geometry/mask.hpp"
#include "detray/geometry/shapes/rectangle2D.hpp"
#include "detray/io/frontend/detector_writer.hpp"
#include "detray/navigation/detail/ray.hpp"
#include "detray/test/utils/detectors/build_telescope_detector.hpp"
#include "detray/tracks/ray.hpp"

namespace traccc {

Expand Down
Loading

0 comments on commit a3eeb14

Please sign in to comment.