Skip to content

Commit 2e41d90

Browse files
authored
feat: use algebra concepts (#902)
Use algebra-plugins concepts and update to patched algebra-plugins version. Also adds a few missing includes here and there.
1 parent a4b6ab1 commit 2e41d90

File tree

163 files changed

+650
-502
lines changed

Some content is hidden

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

163 files changed

+650
-502
lines changed

core/include/detray/builders/cylinder_portal_generator.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "detray/builders/surface_factory_interface.hpp"
1212
#include "detray/builders/volume_builder.hpp"
1313
#include "detray/core/detail/data_context.hpp"
14+
#include "detray/definitions/detail/algebra.hpp"
1415
#include "detray/definitions/detail/indexing.hpp"
1516
#include "detray/definitions/detail/qualifiers.hpp"
1617
#include "detray/definitions/geometry.hpp"
@@ -24,7 +25,7 @@
2425
namespace detray {
2526

2627
/// @brief configuration for the cylinder portal generator
27-
template <typename scalar_t>
28+
template <concepts::scalar scalar_t>
2829
struct cylinder_portal_config {
2930
/// Build inner cylinder portal (will use the same distance to the layer
3031
/// that was found for the outer cylinder portal)

core/include/detray/builders/detail/associator.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "detray/definitions/detail/algebra.hpp"
1212
#include "detray/definitions/detail/math.hpp"
1313
#include "detray/definitions/detail/qualifiers.hpp"
14+
#include "detray/utils/concepts.hpp"
1415

1516
// System include(s).
1617
#include <limits>
@@ -19,7 +20,7 @@
1920
namespace detray::detail {
2021

2122
/// Struct that assigns the center of gravity to a rectangular bin
22-
template <typename algebra_t>
23+
template <detray::concepts::algebra algebra_t>
2324
struct center_of_gravity_rectangle {
2425
/// Call operator to the struct, allows to chain several chain operators
2526
/// together
@@ -63,7 +64,7 @@ struct center_of_gravity_rectangle {
6364
};
6465

6566
/// Check if center of mass is inside a generic polygon bin
66-
template <typename algebra_t>
67+
template <detray::concepts::algebra algebra_t>
6768
struct center_of_gravity_generic {
6869
/// Call operator to the struct, allows to chain several chain operators
6970
/// together
@@ -104,7 +105,7 @@ struct center_of_gravity_generic {
104105
};
105106

106107
/// Check if the egdes of the bin and surface contour overlap
107-
template <typename algebra_t>
108+
template <detray::concepts::algebra algebra_t>
108109
struct edges_intersect_generic {
109110

110111
/// Call operator to the struct, allows to chain several chain operators

core/include/detray/builders/detail/bin_association.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// Project include(s)
1212
#include "detray/builders/detail/associator.hpp"
13+
#include "detray/definitions/detail/algebra.hpp"
1314
#include "detray/definitions/units.hpp"
1415
#include "detray/geometry/coordinates/concentric_cylindrical2D.hpp"
1516
#include "detray/geometry/coordinates/cylindrical2D.hpp"
@@ -37,7 +38,7 @@ namespace detray::detail {
3738
/// taken absolute or relative
3839
template <typename context_t, typename surface_container_t,
3940
typename transform_container_t, typename mask_container_t,
40-
concepts::surface_grid grid_t, typename scalar_t>
41+
concepts::surface_grid grid_t, concepts::scalar scalar_t>
4142
static inline void bin_association(const context_t & /*context*/,
4243
const surface_container_t &surfaces,
4344
const transform_container_t &transforms,

core/include/detray/builders/grid_factory.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#pragma once
99

1010
// Project include(s).
11+
#include "detray/definitions/detail/algebra.hpp"
1112
#include "detray/definitions/detail/containers.hpp"
1213
#include "detray/definitions/units.hpp"
1314
#include "detray/geometry/mask.hpp"
@@ -43,7 +44,7 @@ namespace detray {
4344
/// @note that if non-zero axis_spans are provided the values of the
4445
/// mask is overwritten
4546
template <typename bin_t, template <std::size_t> class serializer_t,
46-
typename algebra_t>
47+
concepts::algebra algebra_t>
4748
class grid_factory {
4849

4950
public:

core/include/detray/builders/homogeneous_material_factory.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// Project include(s)
1111
#include "detray/builders/surface_factory.hpp"
12+
#include "detray/definitions/detail/algebra.hpp"
1213
#include "detray/definitions/detail/indexing.hpp"
1314
#include "detray/geometry/shapes/unmasked.hpp"
1415
#include "detray/materials/material.hpp"
@@ -26,7 +27,7 @@
2627
namespace detray {
2728

2829
/// @brief Bind components for material together.
29-
template <typename scalar_t>
30+
template <concepts::scalar scalar_t>
3031
class material_data {
3132
public:
3233
/// Construct empty data for a given surface

core/include/detray/builders/homogeneous_material_generator.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// Project include(s)
1111
#include "detray/builders/surface_factory_interface.hpp"
12+
#include "detray/definitions/detail/algebra.hpp"
1213
#include "detray/definitions/detail/indexing.hpp"
1314
#include "detray/definitions/detail/qualifiers.hpp"
1415
#include "detray/materials/material.hpp"
@@ -23,7 +24,7 @@
2324
namespace detray {
2425

2526
/// @brief Configuration for the homogeneous material generator
26-
template <typename scalar_t>
27+
template <concepts::scalar scalar_t>
2728
struct hom_material_config {
2829
/// Type of material to put on the passive surfaces
2930
material<scalar_t> m_passive_material{silicon<scalar_t>{}};

core/include/detray/builders/material_map_generator.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// Project include(s)
1111
#include "detray/builders/surface_factory_interface.hpp"
12+
#include "detray/definitions/detail/algebra.hpp"
1213
#include "detray/definitions/detail/indexing.hpp"
1314
#include "detray/definitions/detail/qualifiers.hpp"
1415
#include "detray/geometry/detail/surface_kernels.hpp"
@@ -33,7 +34,7 @@ namespace detray {
3334
namespace detail {
3435

3536
/// Generate material along z bins for a cylinder material grid
36-
template <typename scalar_t>
37+
template <concepts::scalar scalar_t>
3738
inline std::vector<material_slab<scalar_t>> generate_cyl_mat(
3839
const std::vector<scalar_t> &bounds, const std::size_t nbins,
3940
material<scalar_t> mat, const scalar_t t, const scalar_t scalor) {
@@ -55,7 +56,7 @@ inline std::vector<material_slab<scalar_t>> generate_cyl_mat(
5556
}
5657

5758
/// Generate material along r bins for a disc material grid
58-
template <typename scalar_t>
59+
template <concepts::scalar scalar_t>
5960
inline std::vector<material_slab<scalar_t>> generate_disc_mat(
6061
const std::vector<scalar_t> &bounds, const std::size_t nbins,
6162
material<scalar_t> mat, const scalar_t t, const scalar_t scalor) {
@@ -78,7 +79,7 @@ inline std::vector<material_slab<scalar_t>> generate_disc_mat(
7879
} // namespace detail
7980

8081
/// @brief Configuration for the material map generator
81-
template <typename scalar_t>
82+
template <concepts::scalar scalar_t>
8283
struct material_map_config {
8384

8485
/// How to configure the generation for a specific type of material map

core/include/detray/builders/volume_builder.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "detray/builders/volume_builder_interface.hpp"
1313
#include "detray/definitions/geometry.hpp"
1414
#include "detray/geometry/tracking_surface.hpp"
15+
#include "detray/utils/concepts.hpp"
1516
#include "detray/utils/grid/detail/concepts.hpp"
1617

1718
// System include(s)

core/include/detray/core/detector.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "detray/definitions/detail/containers.hpp"
2121
#include "detray/definitions/detail/qualifiers.hpp"
2222
#include "detray/geometry/detail/volume_descriptor.hpp"
23+
#include "detray/utils/concepts.hpp"
2324

2425
// Vecmem include(s)
2526
#include <vecmem/memory/memory_resource.hpp>
@@ -34,7 +35,7 @@ namespace detray {
3435
namespace detail {
3536
/// Temporary way to manipulate transforms in the transform store
3637
/// @todo Remove as soon as contices can be registered!
37-
template <typename detector_t, typename transform3_t>
38+
template <typename detector_t, concepts::transform3D transform3_t>
3839
void set_transform(detector_t &det, const transform3_t &trf, unsigned int i) {
3940
std::cout
4041
<< "WARNING: Modifying transforms in the detector will be deprecated! "

core/include/detray/definitions/detail/algebra.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,10 @@ using namespace ::algebra::boolean;
6565

6666
} // namespace detail
6767

68+
namespace concepts {
69+
70+
using namespace algebra::concepts;
71+
72+
} // namespace concepts
73+
6874
} // namespace detray

core/include/detray/definitions/pdg_particle.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#pragma once
99

1010
// Project include(s).
11+
#include "detray/definitions/detail/algebra.hpp"
1112
#include "detray/definitions/detail/qualifiers.hpp"
1213
#include "detray/definitions/units.hpp"
1314

@@ -16,7 +17,7 @@
1617

1718
namespace detray {
1819

19-
template <typename scalar_t>
20+
template <concepts::scalar scalar_t>
2021
struct pdg_particle {
2122
using scalar_type = scalar_t;
2223

@@ -44,7 +45,7 @@ struct pdg_particle {
4445

4546
// Macro for declaring the particle
4647
#define DETRAY_DECLARE_PARTICLE(PARTICLE_NAME, PDG_NUM, MASS, CHARGE) \
47-
template <typename scalar_t> \
48+
template <concepts::scalar scalar_t> \
4849
struct PARTICLE_NAME final : public pdg_particle<scalar_t> { \
4950
using base_type = pdg_particle<scalar_t>; \
5051
DETRAY_HOST_DEVICE \

core/include/detray/definitions/track_parametrization.hpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// Project include(s)
1111
#include "detray/definitions/detail/algebra.hpp"
12+
#include "detray/utils/concepts.hpp"
1213

1314
namespace detray {
1415

@@ -63,35 +64,35 @@ enum free_indices : unsigned int {
6364
};
6465

6566
/// Vector type for free track parametrization
66-
template <typename algebra_t>
67+
template <concepts::algebra algebra_t>
6768
using free_vector = dmatrix<algebra_t, e_free_size, 1>;
6869

6970
/// Covariance matrix type for free track parametrization
70-
template <typename algebra_t>
71+
template <concepts::algebra algebra_t>
7172
using free_matrix = dmatrix<algebra_t, e_free_size, e_free_size>;
7273

7374
/// Vector type for bound track parametrization
74-
template <typename algebra_t>
75+
template <concepts::algebra algebra_t>
7576
using bound_vector = dmatrix<algebra_t, e_bound_size, 1>;
7677

7778
/// Covariance matrix type for bound track parametrization
78-
template <typename algebra_t>
79+
template <concepts::algebra algebra_t>
7980
using bound_matrix = dmatrix<algebra_t, e_bound_size, e_bound_size>;
8081

8182
/// Mapping from bound to free track parameters.
82-
template <typename algebra_t>
83+
template <concepts::algebra algebra_t>
8384
using bound_to_free_matrix = dmatrix<algebra_t, e_free_size, e_bound_size>;
8485

8586
/// Mapping from free to bound track parameters.
86-
template <typename algebra_t>
87+
template <concepts::algebra algebra_t>
8788
using free_to_bound_matrix = dmatrix<algebra_t, e_bound_size, e_free_size>;
8889

8990
/// Mapping from free to path
90-
template <typename algebra_t>
91+
template <concepts::algebra algebra_t>
9192
using free_to_path_matrix = dmatrix<algebra_t, 1, e_free_size>;
9293

9394
/// Mapping from path to free
94-
template <typename algebra_t>
95+
template <concepts::algebra algebra_t>
9596
using path_to_free_matrix = dmatrix<algebra_t, e_free_size, 1>;
9697

9798
} // namespace detray

core/include/detray/definitions/units.hpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77

88
#pragma once
99

10+
// Project include(s)
11+
#include "detray/definitions/detail/algebra.hpp"
12+
13+
// System include(s)
1014
#include <cmath>
1115

1216
namespace detray {
1317

1418
/// Unit conversion factors
15-
template <typename scalar_t>
19+
template <concepts::scalar scalar_t>
1620
struct unit {
1721

1822
/// Length, native unit mm
@@ -96,7 +100,7 @@ struct unit {
96100
};
97101

98102
/// Physical and mathematical constants
99-
template <typename scalar_t>
103+
template <concepts::scalar scalar_t>
100104
struct constant {
101105

102106
/// Euler's number

core/include/detray/geometry/coordinates/cartesian2D.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace detray {
1515

1616
/// Projection into a 2D cartesian coordinate frame
17-
template <typename algebra_t>
17+
template <concepts::algebra algebra_t>
1818
struct cartesian2D {
1919

2020
using algebra_type = algebra_t;

core/include/detray/geometry/coordinates/cartesian3D.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace detray {
1515

1616
/// Projection into a 3D cartesian coordinate frame
17-
template <typename algebra_t>
17+
template <concepts::algebra algebra_t>
1818
struct cartesian3D {
1919

2020
using algebra_type = algebra_t;

core/include/detray/geometry/coordinates/concentric_cylindrical2D.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace detray {
1616

1717
/// Projection into a 2D concentric cylindrical frame
1818
/// (No rotation in coordinate transformation)
19-
template <typename algebra_t>
19+
template <concepts::algebra algebra_t>
2020
struct concentric_cylindrical2D {
2121

2222
using algebra_type = algebra_t;

core/include/detray/geometry/coordinates/cylindrical2D.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace detray {
1616

1717
/// Projection into a 2D cylindrical coordinate frame
18-
template <typename algebra_t>
18+
template <concepts::algebra algebra_t>
1919
struct cylindrical2D {
2020

2121
using algebra_type = algebra_t;

core/include/detray/geometry/coordinates/cylindrical3D.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace detray {
1616

1717
/// Projection into a 3D cylindrical coordinate frame
18-
template <typename algebra_t>
18+
template <concepts::algebra algebra_t>
1919
struct cylindrical3D {
2020

2121
using algebra_type = algebra_t;

core/include/detray/geometry/coordinates/line2D.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace detray {
1616

1717
/// Projection into a line coordinate frame
18-
template <typename algebra_t>
18+
template <concepts::algebra algebra_t>
1919
struct line2D {
2020

2121
using algebra_type = algebra_t;

core/include/detray/geometry/coordinates/polar2D.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace detray {
1616

1717
/// Projection into a polar coordinate frame
18-
template <typename algebra_t>
18+
template <concepts::algebra algebra_t>
1919
struct polar2D {
2020

2121
using algebra_type = algebra_t;

core/include/detray/geometry/detail/shape_utils.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
#pragma once
99

10+
// Project include(s)
11+
#include "detray/definitions/detail/algebra.hpp"
12+
1013
namespace detray::detail {
1114

1215
/// Generate phi tolerance from distance tolerance
@@ -16,7 +19,7 @@ namespace detray::detail {
1619
///
1720
/// @return the opening angle of a chord the size of tol (= 2*arcsin(c/(2r)))
1821
/// using a small angle approximation
19-
template <typename scalar_t>
22+
template <concepts::scalar scalar_t>
2023
constexpr scalar_t phi_tolerance(scalar_t tol, scalar_t radius) {
2124
return radius > 0.f ? tol / radius : tol;
2225
}

0 commit comments

Comments
 (0)