Skip to content

Commit

Permalink
Update to detray version 0.87.0
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Dec 19, 2024
1 parent c06d483 commit 1ff46c8
Show file tree
Hide file tree
Showing 78 changed files with 297 additions and 224 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@

# VSCode build output.
out/
build/
data/
18 changes: 9 additions & 9 deletions benchmarks/common/benchmarks/toy_detector_benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "traccc/definitions/common.hpp"
#include "traccc/finding/finding_config.hpp"
#include "traccc/fitting/fitting_config.hpp"
#include "traccc/geometry/detector.hpp"
#include "traccc/io/utils.hpp"
#include "traccc/seeding/seeding_algorithm.hpp"
#include "traccc/seeding/track_params_estimation.hpp"
Expand All @@ -17,11 +18,8 @@
#include "traccc/simulation/smearing_writer.hpp"

// Detray include(s).
#include "detray/core/detector.hpp"
#include "detray/definitions/units.hpp"
#include "detray/detectors/bfield.hpp"
#include "detray/geometry/mask.hpp"
#include "detray/geometry/shapes/rectangle2D.hpp"
#include "detray/io/frontend/detector_reader.hpp"
#include "detray/io/frontend/detector_writer.hpp"
#include "detray/navigation/detail/ray.hpp"
Expand Down Expand Up @@ -68,11 +66,12 @@ class ToyDetectorBenchmark : public benchmark::Fixture {
static inline const std::string sim_dir = "toy_detector_benchmark/";

// Detector type
using detector_type = detray::detector<detray::toy_metadata>;
using detector_type = traccc::toy_detector::host;
using scalar_type = detector_type::scalar_type;

// B field value and its type
// @TODO: Set B field as argument
using b_field_t = covfie::field<detray::bfield::const_bknd_t>;
using b_field_t = covfie::field<detray::bfield::const_bknd_t<scalar_type>>;

static constexpr traccc::vector3 B{0, 0,
2 * detray::unit<traccc::scalar>::T};
Expand All @@ -89,10 +88,11 @@ class ToyDetectorBenchmark : public benchmark::Fixture {

// Build the detector
auto [det, name_map] =
detray::build_toy_detector(host_mr, get_toy_config());
detray::build_toy_detector<traccc::default_algebra>(
host_mr, get_toy_config());

// B field
auto field = detray::bfield::create_const_field(B);
auto field = detray::bfield::create_const_field<scalar_type>(B);

// Origin of particles
using generator_type =
Expand Down Expand Up @@ -143,10 +143,10 @@ class ToyDetectorBenchmark : public benchmark::Fixture {
detray::io::write_detector(det, name_map, writer_cfg);
}

detray::toy_det_config get_toy_config() const {
detray::toy_det_config<traccc::scalar> get_toy_config() const {

// Create the toy geometry
detray::toy_det_config toy_cfg{};
detray::toy_det_config<traccc::scalar> toy_cfg{};
toy_cfg.n_brl_layers(4u).n_edc_layers(7u).do_check(false);

// @TODO: Increase the material budget again
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/cpu/toy_detector_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ BENCHMARK_F(ToyDetectorBenchmark, CPU)(benchmark::State& state) {
sim_dir + "toy_detector_surface_grids.json");

// B field
auto field = detray::bfield::create_const_field(B);
auto field = detray::bfield::create_const_field<scalar_type>(B);

// Algorithms
traccc::seeding_algorithm sa(seeding_cfg, grid_cfg, filter_cfg, host_mr);
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/cuda/toy_detector_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@
BENCHMARK_F(ToyDetectorBenchmark, CUDA)(benchmark::State& state) {

// Type declarations
using rk_stepper_type =
detray::rk_stepper<b_field_t::view_t,
typename detector_type::algebra_type,
detray::constrained_step<>>;
using rk_stepper_type = detray::rk_stepper<
b_field_t::view_t, typename detector_type::algebra_type,
detray::constrained_step<typename detector_type::scalar_type>>;
using host_detector_type = traccc::default_detector::host;
using device_detector_type = traccc::default_detector::device;
using device_navigator_type = detray::navigator<const device_detector_type>;
Expand All @@ -73,7 +72,8 @@ BENCHMARK_F(ToyDetectorBenchmark, CUDA)(benchmark::State& state) {
sim_dir + "toy_detector_surface_grids.json");

// B field
auto field = detray::bfield::create_const_field(B);
auto field =
detray::bfield::create_const_field<host_detector_type::scalar_type>(B);

// Algorithms
traccc::cuda::seeding_algorithm sa_cuda(seeding_cfg, grid_cfg, filter_cfg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ namespace traccc::host {
class combinatorial_kalman_filter_algorithm
: public algorithm<track_candidate_container_types::host(
const default_detector::host&,
const detray::bfield::const_field_t::view_t&,
const detray::bfield::const_field_t<traccc::scalar>::view_t&,
const measurement_collection_types::const_view&,
const bound_track_parameters_collection_types::const_view&)>,
public algorithm<track_candidate_container_types::host(
const telescope_detector::host&,
const detray::bfield::const_field_t::view_t&,
const detray::bfield::const_field_t<traccc::scalar>::view_t&,
const measurement_collection_types::const_view&,
const bound_track_parameters_collection_types::const_view&)> {

Expand All @@ -58,7 +58,7 @@ class combinatorial_kalman_filter_algorithm
///
output_type operator()(
const default_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const detray::bfield::const_field_t<traccc::scalar>::view_t& field,
const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds)
const override;
Expand All @@ -75,7 +75,7 @@ class combinatorial_kalman_filter_algorithm
///
output_type operator()(
const telescope_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const detray::bfield::const_field_t<traccc::scalar>::view_t& field,
const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds)
const override;
Expand Down
5 changes: 3 additions & 2 deletions core/include/traccc/finding/details/find_tracks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ track_candidate_container_types::host find_tracks(
*****************************************************************/

using algebra_type = typename navigator_t::detector_type::algebra_type;
using scalar_type = detray::dscalar<algebra_type>;

using transporter_type = detray::parameter_transporter<algebra_type>;
using interactor_type = detray::pointwise_material_interactor<algebra_type>;

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

using propagator_type =
Expand Down Expand Up @@ -304,7 +305,7 @@ track_candidate_container_types::host find_tracks(
.template set_constraint<detray::step::constraint::e_accuracy>(
config.propagation.stepping.step_constraint);

detray::pathlimit_aborter::state s0;
typename detray::pathlimit_aborter<scalar_type>::state s0;
typename detray::parameter_transporter<algebra_type>::state s1;
typename interactor_type::state s3;
typename interaction_register<interactor_type>::state s2{s3};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class kalman_fitter {
using bfield_type = typename stepper_t::magnetic_field_type;

// Actor types
using aborter = detray::pathlimit_aborter;
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>;
Expand Down
22 changes: 12 additions & 10 deletions core/include/traccc/fitting/kalman_fitting_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ namespace traccc::host {
class kalman_fitting_algorithm
: public algorithm<track_state_container_types::host(
const default_detector::host&,
const detray::bfield::const_field_t::view_t&,
const detray::bfield::const_field_t<traccc::scalar>::view_t&,
const track_candidate_container_types::const_view&)>,
public algorithm<track_state_container_types::host(
const telescope_detector::host&,
const detray::bfield::const_field_t::view_t&,
const detray::bfield::const_field_t<traccc::scalar>::view_t&,
const track_candidate_container_types::const_view&)> {

public:
Expand All @@ -57,10 +57,11 @@ class kalman_fitting_algorithm
///
/// @return A container of the fitted track states
///
output_type operator()(const default_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const track_candidate_container_types::const_view&
track_candidates) const override;
output_type operator()(
const default_detector::host& det,
const detray::bfield::const_field_t<traccc::scalar>::view_t& field,
const track_candidate_container_types::const_view& track_candidates)
const override;

/// Execute the algorithm
///
Expand All @@ -70,10 +71,11 @@ class kalman_fitting_algorithm
///
/// @return A container of the fitted track states
///
output_type operator()(const telescope_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const track_candidate_container_types::const_view&
track_candidates) const override;
output_type operator()(
const telescope_detector::host& det,
const detray::bfield::const_field_t<traccc::scalar>::view_t& field,
const track_candidate_container_types::const_view& track_candidates)
const override;

private:
/// Algorithm configuration
Expand Down
12 changes: 9 additions & 3 deletions core/include/traccc/geometry/detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

#pragma once

// Project include(s).
#include "traccc/definitions/primitives.hpp"

// Detray include(s).
#include <detray/core/detector.hpp>
#include <detray/detectors/default_metadata.hpp>
#include <detray/detectors/telescope_metadata.hpp>
#include <detray/detectors/toy_metadata.hpp>

Expand Down Expand Up @@ -38,12 +42,14 @@ struct detector {
}; // struct default_detector

/// Default detector (also used for ODD)
using default_detector = detector<detray::default_metadata>;
using default_detector =
detector<detray::default_metadata<traccc::default_algebra>>;

/// Telescope detector
using telescope_detector = detector<detray::telescope_metadata<> >;
using telescope_detector = detector<
detray::telescope_metadata<traccc::default_algebra, detray::rectangle2D>>;

/// Toy detector
using toy_detector = detector<detray::toy_metadata>;
using toy_detector = detector<detray::toy_metadata<traccc::default_algebra>>;

} // namespace traccc
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ namespace traccc::host {
combinatorial_kalman_filter_algorithm::output_type
combinatorial_kalman_filter_algorithm::operator()(
const default_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const detray::bfield::const_field_t<
default_detector::host::scalar_type>::view_t& field,
const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds) const {

using scalar_type = default_detector::host::scalar_type;

// Perform the track finding using the templated implementation.
return details::find_tracks<
detray::rk_stepper<detray::bfield::const_field_t::view_t,
detray::rk_stepper<detray::bfield::const_field_t<scalar_type>::view_t,
default_detector::host::algebra_type,
detray::constrained_step<>>,
detray::constrained_step<scalar_type>>,
detray::navigator<const default_detector::host>>(
det, field, measurements, seeds, m_config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ namespace traccc::host {
combinatorial_kalman_filter_algorithm::output_type
combinatorial_kalman_filter_algorithm::operator()(
const telescope_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const detray::bfield::const_field_t<
telescope_detector::host::scalar_type>::view_t& field,
const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds) const {

using scalar_type = telescope_detector::host::scalar_type;

// Perform the track finding using the templated implementation.
return details::find_tracks<
detray::rk_stepper<detray::bfield::const_field_t::view_t,
detray::rk_stepper<detray::bfield::const_field_t<scalar_type>::view_t,
telescope_detector::host::algebra_type,
detray::constrained_step<>>,
detray::constrained_step<scalar_type>>,
detray::navigator<const telescope_detector::host>>(
det, field, measurements, seeds, m_config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ namespace traccc::host {

kalman_fitting_algorithm::output_type kalman_fitting_algorithm::operator()(
const default_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const detray::bfield::const_field_t<
traccc::default_detector::host::scalar_type>::view_t& field,
const track_candidate_container_types::const_view& track_candidates) const {

using scalar_type = traccc::default_detector::host::scalar_type;

// Create the fitter object.
kalman_fitter<
detray::rk_stepper<detray::bfield::const_field_t::view_t,
detray::rk_stepper<detray::bfield::const_field_t<scalar_type>::view_t,
traccc::default_detector::host::algebra_type,
detray::constrained_step<>>,
detray::constrained_step<scalar_type>>,
detray::navigator<const traccc::default_detector::host>>
fitter{det, field, m_config};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ namespace traccc::host {

kalman_fitting_algorithm::output_type kalman_fitting_algorithm::operator()(
const telescope_detector::host& det,
const detray::bfield::const_field_t::view_t& field,
const detray::bfield::const_field_t<
traccc::telescope_detector::host::scalar_type>::view_t& field,
const track_candidate_container_types::const_view& track_candidates) const {

using scalar_type = traccc::telescope_detector::host::scalar_type;

// Create the fitter object.
kalman_fitter<
detray::rk_stepper<detray::bfield::const_field_t::view_t,
detray::rk_stepper<detray::bfield::const_field_t<scalar_type>::view_t,
traccc::telescope_detector::host::algebra_type,
detray::constrained_step<>>,
detray::constrained_step<scalar_type>>,
detray::navigator<const traccc::telescope_detector::host>>
fitter{det, field, m_config};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

// Project include(s).
#include "detray/core/detail/tuple_container.hpp"
#include "detray/propagator/constrained_step.hpp"
#include "detray/utils/tuple.hpp"
#include "traccc/definitions/primitives.hpp"
#include "traccc/definitions/qualifiers.hpp"
Expand Down
9 changes: 4 additions & 5 deletions device/cuda/include/traccc/cuda/finding/finding_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ 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,
detray::parameter_transporter<algebra_type>,
interaction_register<interactor>, interactor,
ckf_aborter>;
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 propagator_type =
detray::propagator<stepper_t, navigator_t, actor_type>;
Expand Down
14 changes: 7 additions & 7 deletions device/cuda/src/finding/finding_algorithm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/edm/device/sort_key.hpp"
#include "traccc/finding/candidate_link.hpp"
#include "traccc/geometry/detector.hpp"
#include "traccc/utils/projections.hpp"

// detray include(s).
#include "detray/core/detector.hpp"
#include "detray/core/detector_metadata.hpp"
#include "detray/detectors/bfield.hpp"
#include "detray/navigation/navigator.hpp"
#include "detray/propagator/rk_stepper.hpp"
Expand Down Expand Up @@ -409,11 +408,12 @@ finding_algorithm<stepper_t, navigator_t>::operator()(
}

// Explicit template instantiation
using default_detector_type =
detray::detector<detray::default_metadata, detray::device_container_types>;
using default_stepper_type =
detray::rk_stepper<covfie::field<detray::bfield::const_bknd_t>::view_t,
traccc::default_algebra, detray::constrained_step<>>;
using default_detector_type = traccc::default_detector::device;
using default_stepper_type = detray::rk_stepper<
covfie::field<detray::bfield::const_bknd_t<
default_detector_type::scalar_type>>::view_t,
traccc::default_algebra,
detray::constrained_step<default_detector_type::scalar_type>>;
using default_navigator_type = detray::navigator<const default_detector_type>;
template class finding_algorithm<default_stepper_type, default_navigator_type>;

Expand Down
Loading

0 comments on commit 1ff46c8

Please sign in to comment.