Skip to content

Commit

Permalink
Use algebra-plugins concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Dec 18, 2024
1 parent 93eb6ab commit b2d570a
Show file tree
Hide file tree
Showing 162 changed files with 647 additions and 501 deletions.
3 changes: 2 additions & 1 deletion core/include/detray/builders/cylinder_portal_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "detray/builders/surface_factory_interface.hpp"
#include "detray/builders/volume_builder.hpp"
#include "detray/core/detail/data_context.hpp"
#include "detray/definitions/detail/algebra.hpp"
#include "detray/definitions/detail/indexing.hpp"
#include "detray/definitions/detail/qualifiers.hpp"
#include "detray/definitions/geometry.hpp"
Expand All @@ -24,7 +25,7 @@
namespace detray {

/// @brief configuration for the cylinder portal generator
template <typename scalar_t>
template <concepts::scalar scalar_t>
struct cylinder_portal_config {
/// Build inner cylinder portal (will use the same distance to the layer
/// that was found for the outer cylinder portal)
Expand Down
7 changes: 4 additions & 3 deletions core/include/detray/builders/detail/associator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "detray/definitions/detail/algebra.hpp"
#include "detray/definitions/detail/math.hpp"
#include "detray/definitions/detail/qualifiers.hpp"
#include "detray/utils/concepts.hpp"

// System include(s).
#include <limits>
Expand All @@ -19,7 +20,7 @@
namespace detray::detail {

/// Struct that assigns the center of gravity to a rectangular bin
template <typename algebra_t>
template <detray::concepts::algebra algebra_t>
struct center_of_gravity_rectangle {
/// Call operator to the struct, allows to chain several chain operators
/// together
Expand Down Expand Up @@ -63,7 +64,7 @@ struct center_of_gravity_rectangle {
};

/// Check if center of mass is inside a generic polygon bin
template <typename algebra_t>
template <detray::concepts::algebra algebra_t>
struct center_of_gravity_generic {
/// Call operator to the struct, allows to chain several chain operators
/// together
Expand Down Expand Up @@ -104,7 +105,7 @@ struct center_of_gravity_generic {
};

/// Check if the egdes of the bin and surface contour overlap
template <typename algebra_t>
template <detray::concepts::algebra algebra_t>
struct edges_intersect_generic {

/// Call operator to the struct, allows to chain several chain operators
Expand Down
3 changes: 2 additions & 1 deletion core/include/detray/builders/detail/bin_association.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

// Project include(s)
#include "detray/builders/detail/associator.hpp"
#include "detray/definitions/detail/algebra.hpp"
#include "detray/definitions/units.hpp"
#include "detray/geometry/coordinates/concentric_cylindrical2D.hpp"
#include "detray/geometry/coordinates/cylindrical2D.hpp"
Expand Down Expand Up @@ -37,7 +38,7 @@ namespace detray::detail {
/// taken absolute or relative
template <typename context_t, typename surface_container_t,
typename transform_container_t, typename mask_container_t,
concepts::surface_grid grid_t, typename scalar_t>
concepts::surface_grid grid_t, concepts::scalar scalar_t>
static inline void bin_association(const context_t & /*context*/,
const surface_container_t &surfaces,
const transform_container_t &transforms,
Expand Down
3 changes: 2 additions & 1 deletion core/include/detray/builders/grid_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#pragma once

// Project include(s).
#include "detray/definitions/detail/algebra.hpp"
#include "detray/definitions/detail/containers.hpp"
#include "detray/definitions/units.hpp"
#include "detray/geometry/mask.hpp"
Expand Down Expand Up @@ -43,7 +44,7 @@ namespace detray {
/// @note that if non-zero axis_spans are provided the values of the
/// mask is overwritten
template <typename bin_t, template <std::size_t> class serializer_t,
typename algebra_t>
concepts::algebra algebra_t>
class grid_factory {

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

// Project include(s)
#include "detray/builders/surface_factory.hpp"
#include "detray/definitions/detail/algebra.hpp"
#include "detray/definitions/detail/indexing.hpp"
#include "detray/geometry/shapes/unmasked.hpp"
#include "detray/materials/material.hpp"
Expand All @@ -26,7 +27,7 @@
namespace detray {

/// @brief Bind components for material together.
template <typename scalar_t>
template <concepts::scalar scalar_t>
class material_data {
public:
/// Construct empty data for a given surface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// Project include(s)
#include "detray/builders/surface_factory_interface.hpp"
#include "detray/definitions/detail/algebra.hpp"
#include "detray/definitions/detail/indexing.hpp"
#include "detray/definitions/detail/qualifiers.hpp"
#include "detray/materials/material.hpp"
Expand All @@ -23,7 +24,7 @@
namespace detray {

/// @brief Configuration for the homogeneous material generator
template <typename scalar_t>
template <concepts::scalar scalar_t>
struct hom_material_config {
/// Type of material to put on the passive surfaces
material<scalar_t> m_passive_material{silicon<scalar_t>{}};
Expand Down
7 changes: 4 additions & 3 deletions core/include/detray/builders/material_map_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// Project include(s)
#include "detray/builders/surface_factory_interface.hpp"
#include "detray/definitions/detail/algebra.hpp"
#include "detray/definitions/detail/indexing.hpp"
#include "detray/definitions/detail/qualifiers.hpp"
#include "detray/geometry/detail/surface_kernels.hpp"
Expand All @@ -33,7 +34,7 @@ namespace detray {
namespace detail {

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

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

/// @brief Configuration for the material map generator
template <typename scalar_t>
template <concepts::scalar scalar_t>
struct material_map_config {

/// How to configure the generation for a specific type of material map
Expand Down
1 change: 1 addition & 0 deletions core/include/detray/builders/volume_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "detray/builders/volume_builder_interface.hpp"
#include "detray/definitions/geometry.hpp"
#include "detray/geometry/tracking_surface.hpp"
#include "detray/utils/concepts.hpp"
#include "detray/utils/grid/detail/concepts.hpp"

// System include(s)
Expand Down
3 changes: 2 additions & 1 deletion core/include/detray/core/detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "detray/definitions/detail/containers.hpp"
#include "detray/definitions/detail/qualifiers.hpp"
#include "detray/geometry/detail/volume_descriptor.hpp"
#include "detray/utils/concepts.hpp"

// Vecmem include(s)
#include <vecmem/memory/memory_resource.hpp>
Expand All @@ -34,7 +35,7 @@ namespace detray {
namespace detail {
/// Temporary way to manipulate transforms in the transform store
/// @todo Remove as soon as contices can be registered!
template <typename detector_t, typename transform3_t>
template <typename detector_t, concepts::transform3D transform3_t>
void set_transform(detector_t &det, const transform3_t &trf, unsigned int i) {
std::cout
<< "WARNING: Modifying transforms in the detector will be deprecated! "
Expand Down
6 changes: 6 additions & 0 deletions core/include/detray/definitions/detail/algebra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,10 @@ using namespace ::algebra::boolean;

} // namespace detail

namespace concepts {

using namespace algebra::concepts;

} // namespace concepts

} // namespace detray
5 changes: 3 additions & 2 deletions core/include/detray/definitions/pdg_particle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#pragma once

// Project include(s).
#include "detray/definitions/detail/algebra.hpp"
#include "detray/definitions/detail/qualifiers.hpp"
#include "detray/definitions/units.hpp"

Expand All @@ -16,7 +17,7 @@

namespace detray {

template <typename scalar_t>
template <concepts::scalar scalar_t>
struct pdg_particle {
using scalar_type = scalar_t;

Expand Down Expand Up @@ -44,7 +45,7 @@ struct pdg_particle {

// Macro for declaring the particle
#define DETRAY_DECLARE_PARTICLE(PARTICLE_NAME, PDG_NUM, MASS, CHARGE) \
template <typename scalar_t> \
template <concepts::scalar scalar_t> \
struct PARTICLE_NAME final : public pdg_particle<scalar_t> { \
using base_type = pdg_particle<scalar_t>; \
DETRAY_HOST_DEVICE \
Expand Down
17 changes: 9 additions & 8 deletions core/include/detray/definitions/track_parametrization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// Project include(s)
#include "detray/definitions/detail/algebra.hpp"
#include "detray/utils/concepts.hpp"

namespace detray {

Expand Down Expand Up @@ -63,35 +64,35 @@ enum free_indices : unsigned int {
};

/// Vector type for free track parametrization
template <typename algebra_t>
template <concepts::algebra algebra_t>
using free_vector = dmatrix<algebra_t, e_free_size, 1>;

/// Covariance matrix type for free track parametrization
template <typename algebra_t>
template <concepts::algebra algebra_t>
using free_matrix = dmatrix<algebra_t, e_free_size, e_free_size>;

/// Vector type for bound track parametrization
template <typename algebra_t>
template <concepts::algebra algebra_t>
using bound_vector = dmatrix<algebra_t, e_bound_size, 1>;

/// Covariance matrix type for bound track parametrization
template <typename algebra_t>
template <concepts::algebra algebra_t>
using bound_matrix = dmatrix<algebra_t, e_bound_size, e_bound_size>;

/// Mapping from bound to free track parameters.
template <typename algebra_t>
template <concepts::algebra algebra_t>
using bound_to_free_matrix = dmatrix<algebra_t, e_free_size, e_bound_size>;

/// Mapping from free to bound track parameters.
template <typename algebra_t>
template <concepts::algebra algebra_t>
using free_to_bound_matrix = dmatrix<algebra_t, e_bound_size, e_free_size>;

/// Mapping from free to path
template <typename algebra_t>
template <concepts::algebra algebra_t>
using free_to_path_matrix = dmatrix<algebra_t, 1, e_free_size>;

/// Mapping from path to free
template <typename algebra_t>
template <concepts::algebra algebra_t>
using path_to_free_matrix = dmatrix<algebra_t, e_free_size, 1>;

} // namespace detray
8 changes: 6 additions & 2 deletions core/include/detray/definitions/units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@

#pragma once

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

// System include(s)
#include <cmath>

namespace detray {

/// Unit conversion factors
template <typename scalar_t>
template <concepts::scalar scalar_t>
struct unit {

/// Length, native unit mm
Expand Down Expand Up @@ -96,7 +100,7 @@ struct unit {
};

/// Physical and mathematical constants
template <typename scalar_t>
template <concepts::scalar scalar_t>
struct constant {

/// Euler's number
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/geometry/coordinates/cartesian2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace detray {

/// Projection into a 2D cartesian coordinate frame
template <typename algebra_t>
template <concepts::algebra algebra_t>
struct cartesian2D {

using algebra_type = algebra_t;
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/geometry/coordinates/cartesian3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace detray {

/// Projection into a 3D cartesian coordinate frame
template <typename algebra_t>
template <concepts::algebra algebra_t>
struct cartesian3D {

using algebra_type = algebra_t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace detray {

/// Projection into a 2D concentric cylindrical frame
/// (No rotation in coordinate transformation)
template <typename algebra_t>
template <concepts::algebra algebra_t>
struct concentric_cylindrical2D {

using algebra_type = algebra_t;
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/geometry/coordinates/cylindrical2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace detray {

/// Projection into a 2D cylindrical coordinate frame
template <typename algebra_t>
template <concepts::algebra algebra_t>
struct cylindrical2D {

using algebra_type = algebra_t;
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/geometry/coordinates/cylindrical3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace detray {

/// Projection into a 3D cylindrical coordinate frame
template <typename algebra_t>
template <concepts::algebra algebra_t>
struct cylindrical3D {

using algebra_type = algebra_t;
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/geometry/coordinates/line2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace detray {

/// Projection into a line coordinate frame
template <typename algebra_t>
template <concepts::algebra algebra_t>
struct line2D {

using algebra_type = algebra_t;
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/geometry/coordinates/polar2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace detray {

/// Projection into a polar coordinate frame
template <typename algebra_t>
template <concepts::algebra algebra_t>
struct polar2D {

using algebra_type = algebra_t;
Expand Down
5 changes: 4 additions & 1 deletion core/include/detray/geometry/detail/shape_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

#pragma once

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

namespace detray::detail {

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

0 comments on commit b2d570a

Please sign in to comment.