Skip to content

Commit e57a5d6

Browse files
authored
Inhomogeneous Magnetic Field, main branch (2025.06.23.) (#1033)
* Switch to the v10 data file(s). * Introduced a generic traccc::bfield type. Along with an additional type definition for inhomogeneous fields to use in host code. * Introduced I/O code for inhomogeneous magnetic fields. Along with a trivial unit test for the code. * Added inhomogeneous field host algorithms. * Adapted all clients to the modified host algorithm APIs. * Added inhomogeneous field CUDA algorithms. * Adapted all clients to the modified CUDA algorithm APIs. * Added inhomogeneous field SYCL algorithms. * Adapted all clients to the modified SYCL algorithm APIs. * Added inhomogeneous field support to the Alpaka algorithms. But didn't actually implement the support in the device code yet. * Adapted all clients to the modified Alpaka algorithm APIs. * Made the GitLab CI use Ubuntu 24.04 based images. The same ones that the GitLab CI has been using since a while. In order to avoid issues with too old GCC versions.
1 parent 6418a96 commit e57a5d6

File tree

99 files changed

+1308
-634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1308
-634
lines changed

.gitlab-ci.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ stages:
1212
# Base job template.
1313
.base_template: &base_job
1414
before_script:
15+
- apt install -y zstd
16+
- curl --retry 5 --retry-delay 10 --output deps.tar.zst https://acts.web.cern.ch/ACTS/ci/ubuntu-24.04/deps.v6.tar.zst
17+
- tar -xf deps.tar.zst -C /usr/local --strip-components=1
18+
- rm deps.tar.zst
1519
- git clone $CLONE_URL src
1620
- git -C src checkout $HEAD_SHA
1721
- source ./src/.github/ci_setup.sh ${TRACCC_BUILD_TYPE}
@@ -54,15 +58,15 @@ stages:
5458
# CUDA build job.
5559
build:cuda:
5660
<<: *build_job
57-
image: ghcr.io/acts-project/ubuntu2204_cuda:56
61+
image: ghcr.io/acts-project/ubuntu2404_cuda:69
5862
variables:
5963
TRACCC_BUILD_TYPE: CUDA
6064
TRACCC_BUILD_PRESET: cuda-fp32
6165

6266
# CUDA test job.
6367
test:cuda:
6468
<<: *nvidia_test_job
65-
image: ghcr.io/acts-project/ubuntu2204_cuda:56
69+
image: ghcr.io/acts-project/ubuntu2404_cuda:69
6670
variables:
6771
TRACCC_BUILD_TYPE: CUDA
6872
dependencies:
@@ -71,7 +75,7 @@ test:cuda:
7175
# SYCL build job (with an Intel backend).
7276
build:sycl_intel:
7377
<<: *build_job
74-
image: ghcr.io/acts-project/ubuntu2404_oneapi:56
78+
image: ghcr.io/acts-project/ubuntu2404_oneapi:69
7579
variables:
7680
TRACCC_BUILD_TYPE: SYCL
7781
TRACCC_BUILD_PRESET: sycl-fp32
@@ -81,7 +85,7 @@ build:sycl_intel:
8185
# SYCL test job (with an Intel backend).
8286
test:sycl_intel:
8387
<<: *intel_test_job
84-
image: ghcr.io/acts-project/ubuntu2404_oneapi:56
88+
image: ghcr.io/acts-project/ubuntu2404_oneapi:69
8589
variables:
8690
TRACCC_BUILD_TYPE: SYCL
8791
ONEAPI_DEVICE_SELECTOR: opencl:*
@@ -91,7 +95,7 @@ test:sycl_intel:
9195
# SYCL build job (with an NVIDIA backend).
9296
build:sycl_nvidia:
9397
<<: *build_job
94-
image: ghcr.io/acts-project/ubuntu2204_cuda_oneapi:56
98+
image: ghcr.io/acts-project/ubuntu2404_cuda_oneapi:69
9599
variables:
96100
TRACCC_BUILD_TYPE: SYCL
97101
TRACCC_BUILD_PRESET: sycl-fp32
@@ -102,7 +106,7 @@ build:sycl_nvidia:
102106
# SYCL test job (with an NVIDIA backend).
103107
test:sycl_nvidia:
104108
<<: *nvidia_test_job
105-
image: ghcr.io/acts-project/ubuntu2204_cuda_oneapi:56
109+
image: ghcr.io/acts-project/ubuntu2404_cuda_oneapi:69
106110
variables:
107111
TRACCC_BUILD_TYPE: SYCL
108112
ONEAPI_DEVICE_SELECTOR: cuda:*

benchmarks/cpu/toy_detector_cpu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ BENCHMARK_DEFINE_F(ToyDetectorBenchmark, CPU)(benchmark::State& state) {
4949
sim_dir + "toy_detector_surface_grids.json");
5050

5151
// B field
52-
auto field = traccc::construct_const_bfield<scalar_type>(B);
52+
const traccc::bfield field{traccc::construct_const_bfield<scalar_type>(B)};
5353

5454
// Algorithms
5555
traccc::host::seeding_algorithm sa(seeding_cfg, grid_cfg, filter_cfg,

benchmarks/cuda/toy_detector_cuda.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ BENCHMARK_DEFINE_F(ToyDetectorBenchmark, CUDA)(benchmark::State& state) {
5656
sim_dir + "toy_detector_surface_grids.json");
5757

5858
// B field
59-
b_field_t field = traccc::construct_const_bfield<
60-
traccc::default_detector::host::scalar_type>(B);
59+
const traccc::bfield field{traccc::construct_const_bfield<
60+
traccc::default_detector::host::scalar_type>(B)};
6161

6262
// Algorithms
6363
traccc::cuda::seeding_algorithm sa_cuda(seeding_cfg, grid_cfg, filter_cfg,

core/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ traccc_add_library( traccc_core core TYPE SHARED
7272
"include/traccc/finding/details/combinatorial_kalman_filter.hpp"
7373
"include/traccc/finding/combinatorial_kalman_filter_algorithm.hpp"
7474
"src/finding/combinatorial_kalman_filter_algorithm.cpp"
75-
"src/finding/combinatorial_kalman_filter_algorithm_constant_field_default_detector.cpp"
76-
"src/finding/combinatorial_kalman_filter_algorithm_constant_field_telescope_detector.cpp"
75+
"src/finding/combinatorial_kalman_filter_algorithm_default_detector.cpp"
76+
"src/finding/combinatorial_kalman_filter_algorithm_telescope_detector.cpp"
7777
# Fitting algorithmic code
7878
"include/traccc/fitting/kalman_filter/gain_matrix_updater.hpp"
7979
"include/traccc/fitting/kalman_filter/kalman_actor.hpp"
@@ -85,8 +85,8 @@ traccc_add_library( traccc_core core TYPE SHARED
8585
"include/traccc/fitting/details/kalman_fitting.hpp"
8686
"include/traccc/fitting/kalman_fitting_algorithm.hpp"
8787
"src/fitting/kalman_fitting_algorithm.cpp"
88-
"src/fitting/kalman_fitting_algorithm_constant_field_default_detector.cpp"
89-
"src/fitting/kalman_fitting_algorithm_constant_field_telescope_detector.cpp"
88+
"src/fitting/kalman_fitting_algorithm_default_detector.cpp"
89+
"src/fitting/kalman_fitting_algorithm_telescope_detector.cpp"
9090
# Seed finding algorithmic code.
9191
"include/traccc/seeding/detail/lin_circle.hpp"
9292
"include/traccc/seeding/detail/doublet.hpp"

core/include/traccc/finding/combinatorial_kalman_filter_algorithm.hpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,11 @@ namespace traccc::host {
3232
///
3333
class combinatorial_kalman_filter_algorithm
3434
: public algorithm<edm::track_candidate_collection<default_algebra>::host(
35-
const default_detector::host&,
36-
const covfie::field<const_bfield_backend_t<
37-
default_detector::host::scalar_type>>::view_t&,
35+
const default_detector::host&, const bfield&,
3836
const measurement_collection_types::const_view&,
3937
const bound_track_parameters_collection_types::const_view&)>,
4038
public algorithm<edm::track_candidate_collection<default_algebra>::host(
41-
const telescope_detector::host&,
42-
const covfie::field<traccc::const_bfield_backend_t<
43-
telescope_detector::host::scalar_type>>::view_t&,
39+
const telescope_detector::host&, const bfield&,
4440
const measurement_collection_types::const_view&,
4541
const bound_track_parameters_collection_types::const_view&)>,
4642
public messaging {
@@ -59,35 +55,31 @@ class combinatorial_kalman_filter_algorithm
5955
/// Execute the algorithm
6056
///
6157
/// @param det The (default) detector object
62-
/// @param field The (constant) magnetic field object
58+
/// @param field The magnetic field object
6359
/// @param measurements All measurements in an event
6460
/// @param seeds All seeds in an event to start the track finding
6561
/// with
6662
///
6763
/// @return A container of the found track candidates
6864
///
6965
output_type operator()(
70-
const default_detector::host& det,
71-
const covfie::field<traccc::const_bfield_backend_t<
72-
default_detector::host::scalar_type>>::view_t& field,
66+
const default_detector::host& det, const bfield& field,
7367
const measurement_collection_types::const_view& measurements,
7468
const bound_track_parameters_collection_types::const_view& seeds)
7569
const override;
7670

7771
/// Execute the algorithm
7872
///
7973
/// @param det The (telescope) detector object
80-
/// @param field The (constant) magnetic field object
74+
/// @param field The magnetic field object
8175
/// @param measurements All measurements in an event
8276
/// @param seeds All seeds in an event to start the track finding
8377
/// with
8478
///
8579
/// @return A container of the found track candidates
8680
///
8781
output_type operator()(
88-
const telescope_detector::host& det,
89-
const covfie::field<traccc::const_bfield_backend_t<
90-
telescope_detector::host::scalar_type>>::view_t& field,
82+
const telescope_detector::host& det, const bfield& field,
9183
const measurement_collection_types::const_view& measurements,
9284
const bound_track_parameters_collection_types::const_view& seeds)
9385
const override;

core/include/traccc/fitting/kalman_fitting_algorithm.hpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,10 @@ namespace traccc::host {
3030
/// Kalman filter based track fitting algorithm
3131
class kalman_fitting_algorithm
3232
: public algorithm<track_state_container_types::host(
33-
const default_detector::host&,
34-
const covfie::field<const_bfield_backend_t<
35-
default_detector::host::scalar_type>>::view_t&,
33+
const default_detector::host&, const bfield&,
3634
const edm::track_candidate_container<default_algebra>::const_view&)>,
3735
public algorithm<track_state_container_types::host(
38-
const telescope_detector::host&,
39-
const covfie::field<const_bfield_backend_t<
40-
telescope_detector::host::scalar_type>>::view_t&,
36+
const telescope_detector::host&, const bfield&,
4137
const edm::track_candidate_container<default_algebra>::const_view&)>,
4238
public messaging {
4339

@@ -59,30 +55,26 @@ class kalman_fitting_algorithm
5955
/// Execute the algorithm
6056
///
6157
/// @param det The (default) detector object
62-
/// @param field The (constant) magnetic field object
58+
/// @param field The magnetic field object
6359
/// @param track_candidates All track candidates to fit
6460
///
6561
/// @return A container of the fitted track states
6662
///
6763
output_type operator()(
68-
const default_detector::host& det,
69-
const covfie::field<traccc::const_bfield_backend_t<
70-
default_detector::host::scalar_type>>::view_t& field,
64+
const default_detector::host& det, const bfield& field,
7165
const edm::track_candidate_container<default_algebra>::const_view&
7266
track_candidates) const override;
7367

7468
/// Execute the algorithm
7569
///
7670
/// @param det The (telescope) detector object
77-
/// @param field The (constant) magnetic field object
71+
/// @param field The magnetic field object
7872
/// @param track_candidates All track candidates to fit
7973
///
8074
/// @return A container of the fitted track states
8175
///
8276
output_type operator()(
83-
const telescope_detector::host& det,
84-
const covfie::field<traccc::const_bfield_backend_t<
85-
telescope_detector::host::scalar_type>>::view_t& field,
77+
const telescope_detector::host& det, const bfield& field,
8678
const edm::track_candidate_container<default_algebra>::const_view&
8779
track_candidates) const override;
8880

core/include/traccc/utils/bfield.hpp

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,100 @@
77

88
#pragma once
99

10+
// Local include(s).
11+
#include "traccc/definitions/primitives.hpp"
12+
13+
// Covfie include(s).
1014
#include <covfie/core/backend/primitive/constant.hpp>
15+
#include <covfie/core/backend/transformer/affine.hpp>
16+
#include <covfie/core/backend/transformer/linear.hpp>
17+
#include <covfie/core/backend/transformer/strided.hpp>
1118
#include <covfie/core/field.hpp>
1219
#include <covfie/core/vector.hpp>
1320

21+
// System include(s).
22+
#include <any>
23+
1424
namespace traccc {
25+
26+
/// Typeless, owning, host-only magnetic field object
27+
class bfield {
28+
29+
public:
30+
/// Default constructor
31+
bfield() = default;
32+
33+
/// Constructor from a specific b-field object
34+
///
35+
/// @tparam bfield_backend_t The backend type of the b-field object
36+
/// @param obj The b-field object to construct from
37+
///
38+
template <typename bfield_backend_t>
39+
explicit bfield(covfie::field<bfield_backend_t>&& obj)
40+
: m_field(std::move(obj)) {}
41+
42+
/// Set a specific b-field object
43+
///
44+
/// @tparam bfield_backend_t The backend type of the b-field object
45+
/// @param obj The b-field object to set
46+
///
47+
template <typename bfield_backend_t>
48+
void set(covfie::field<bfield_backend_t>&& obj) {
49+
m_field = std::move(obj);
50+
}
51+
52+
/// Check if the b-field is of a certain type
53+
///
54+
/// @tparam bfield_backend_t The covfie backend type to check
55+
/// @return @c true if the b-field is of the specified type,
56+
/// @c false otherwise
57+
///
58+
template <typename bfield_backend_t>
59+
bool is() const {
60+
return (m_field.type() == typeid(covfie::field<bfield_backend_t>));
61+
}
62+
63+
/// Get a b-field view object as a specific type
64+
///
65+
/// @tparam bfield_backend_t The covfie backend type to use
66+
/// @return The b-field view object of the specified type
67+
///
68+
template <typename bfield_backend_t>
69+
typename covfie::field<bfield_backend_t>::view_t as() const {
70+
return typename covfie::field<bfield_backend_t>::view_t{
71+
std::any_cast<const covfie::field<bfield_backend_t>&>(m_field)};
72+
}
73+
74+
/// Get the b-field object as a specific type
75+
///
76+
/// @tparam bfield_backend_t The covfie backend type to use
77+
/// @return The b-field object cast to the specified type
78+
///
79+
template <typename bfield_backend_t>
80+
const covfie::field<bfield_backend_t>& get_covfie_field() const {
81+
return std::any_cast<const covfie::field<bfield_backend_t>&>(m_field);
82+
}
83+
84+
private:
85+
/// The actualy covfie b-field object
86+
std::any m_field;
87+
88+
}; // class bfield
89+
90+
/// Constant magnetic field backend type
1591
template <typename scalar_t>
1692
using const_bfield_backend_t =
1793
::covfie::backend::constant<::covfie::vector::vector_d<scalar_t, 3>,
1894
::covfie::vector::vector_d<scalar_t, 3>>;
1995

96+
/// Inhomogeneous magnetic field backend type
97+
template <typename scalar_t>
98+
using inhom_bfield_backend_t =
99+
covfie::backend::affine<covfie::backend::linear<covfie::backend::strided<
100+
covfie::vector::vector_d<std::size_t, 3>,
101+
covfie::backend::array<covfie::vector::vector_d<scalar_t, 3>>>>>;
102+
103+
/// Construct a constant magnetic field object
20104
template <typename scalar_t>
21105
::covfie::field<const_bfield_backend_t<scalar_t>> construct_const_bfield(
22106
scalar_t x, scalar_t y, scalar_t z) {
@@ -26,6 +110,7 @@ ::covfie::field<const_bfield_backend_t<scalar_t>> construct_const_bfield(
26110
z})};
27111
}
28112

113+
/// Construct a constant magnetic field object
29114
template <typename scalar_t>
30115
::covfie::field<const_bfield_backend_t<scalar_t>> construct_const_bfield(
31116
const vector3& v) {

core/src/finding/combinatorial_kalman_filter_algorithm_constant_field_default_detector.cpp

Lines changed: 0 additions & 27 deletions
This file was deleted.

core/src/finding/combinatorial_kalman_filter_algorithm_constant_field_telescope_detector.cpp

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)