Skip to content

Commit

Permalink
Update ITk metadata and add ODD specific metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Jan 9, 2025
1 parent b4abb48 commit cfeb189
Show file tree
Hide file tree
Showing 6 changed files with 524 additions and 251 deletions.
31 changes: 18 additions & 13 deletions core/include/detray/builders/material_map_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,26 @@ struct add_sf_material_map {
// The detector only knows the non-owning grid types
using non_owning_t =
typename decltype(mat_grid)::template type<false>;
static_assert(materials_t::template is_defined<non_owning_t>());

// Add the material slabs to the grid
for (const auto& bin : bin_data) {
mat_grid.template populate<replace<>>(bin.local_bin_idx,
bin.single_element);
// Not every mask shape might be used for material maps
if constexpr (materials_t::template is_defined<non_owning_t>()) {
// Add the material slabs to the grid
for (const auto& bin : bin_data) {
mat_grid.template populate<replace<>>(bin.local_bin_idx,
bin.single_element);
}

// Add the material grid to the detector
constexpr auto gid{
materials_t::template get_id<non_owning_t>()};
mat_store.template push_back<gid>(mat_grid);

// Return the index of the new material map
return {gid, static_cast<dindex>(
mat_store.template size<gid>() - 1u)};
} else {
return {materials_t::id::e_none, dindex_invalid};
}

// Add the material grid to the detector
constexpr auto gid{materials_t::template get_id<non_owning_t>()};
mat_store.template push_back<gid>(mat_grid);

// Return the index of the new material map
return {gid,
static_cast<dindex>(mat_store.template size<gid>() - 1u)};
} else {
return {materials_t::id::e_none, dindex_invalid};
}
Expand Down
232 changes: 127 additions & 105 deletions detectors/include/detray/detectors/default_metadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ struct default_metadata {
/// Mask-to-(next)-volume link (potentially switchable for SoA)
using nav_link = std::uint_least16_t;

/// How to store coordinate transform matrices
template <template <typename...> class vector_t = dvector>
using transform_store =
single_store<dtransform3D<algebra_type>, vector_t, geometry_context>;

//
// Surface Primitives
//

/// Mask types
/// @TODO: Need to duplicate for pixel/strip measurement dimensions?
using rectangle = mask<rectangle2D, algebra_type, nav_link>;
Expand Down Expand Up @@ -67,9 +76,51 @@ struct default_metadata {
mask<unbounded<line_square>, algebra_type, nav_link>;
using unmasked_plane = mask<unmasked<>, algebra_type, nav_link>;

/// Material types
/// Give your mask types a name (needs to be consecutive and has to match
/// the types position in the mask store!)
enum class mask_ids : std::uint_least8_t {
e_rectangle2 = 0,
e_portal_rectangle2 = 0,
e_trapezoid2 = 1,
e_annulus2 = 2,
e_cylinder2 = 3,
e_portal_cylinder2 = 4,
e_ring2 = 5,
e_portal_ring2 = 5,
e_straw_tube = 6,
e_drift_cell = 7,
/*e_single1 = 8,
e_single2 = 9,
e_single3 = 10,
e_unbounded_rectangle2 = 11,
e_unbounded_trapezoid2 = 12,
e_unbounded_annulus2 = 13,
e_unbounded_cylinder2 = 14,
e_unbounded_disc2 = 15,
e_unbounded_line_circular2 = 16,
e_unbounded_cell2 = 17,
e_unmasked2 = 18,*/
};

/// How to store masks
template <template <typename...> class vector_t = dvector>
using mask_store = regular_multi_store<mask_ids, empty_context, dtuple,
vector_t, rectangle, trapezoid,
annulus, cylinder, cylinder_portal,
disc, straw_tube, drift_cell /*,
single_1, single_2, single_3, unbounded_rectangle, unbounded_trapezoid,
unbounded_annulus, unbounded_cylinder, unbounded_disc, unbounded_straw_tube,
unbounded_cell, unmasked_plane*/>;

//
// Material Description
//

/// Homogeneous material description
/// @{
using slab = material_slab<scalar_t>;
using rod = material_rod<scalar_t>;
/// @}

/// Material grid types (default: closed bounds, regular binning)
/// @{
Expand Down Expand Up @@ -102,6 +153,46 @@ struct default_metadata {

/// @}

/// Give your material types a name (needs to be consecutive and has to
/// match the types position in the mask store!)
enum class material_ids : std::uint_least8_t {
// Material texture (grid) shapes
e_concentric_cylinder2_map = 0u,
e_disc2_map = 1u,
e_cylinder2_map = 2u,
e_rectangle2_map = 3u,
e_trapezoid2_map = 3u,
e_annulus2_map = 0u,
e_drift_cell_map = 5u,
e_straw_tube_map = 5u,
// Volume material
e_cuboid3_map = 7,
e_cylinder3_map = 8u,
// Homogeneous mapetrial
e_slab = 4u,
e_rod = 5u,
e_raw_material = 6u,
e_none = 9u,
};

/// How to store materials
template <typename container_t = host_container_types>
using material_store = multi_store<
material_ids, empty_context, dtuple,
grid_collection<concentric_cylinder2_map_t<container_t>>,
grid_collection<disc_map_t<container_t>>,
grid_collection<cylinder2_map_t<container_t>>,
grid_collection<rectangular_map_t<container_t>>,
typename container_t::template vector_type<slab>,
typename container_t::template vector_type<rod>,
typename container_t::template vector_type<material<scalar_t>>,
grid_collection<cuboid_map_t<container_t>>,
grid_collection<cylinder3_map_t<container_t>>>;

//
// Acceleration structures
//

/// surface grid types (default boundaries: closed binning)
/// @TODO: Will we need the types for all grid configurations (binnning,
/// bin boundaries, serializers)?
Expand Down Expand Up @@ -151,83 +242,19 @@ struct default_metadata {

/// @}

/// How to store coordinate transform matrices
template <template <typename...> class vector_t = dvector>
using transform_store =
single_store<dtransform3D<algebra_type>, vector_t, geometry_context>;

/// Give your mask types a name (needs to be consecutive and has to match
/// the types position in the mask store!)
enum class mask_ids : std::uint_least8_t {
e_rectangle2 = 0,
e_portal_rectangle2 = 0,
e_trapezoid2 = 1,
e_annulus2 = 2,
e_cylinder2 = 3,
e_portal_cylinder2 = 4,
e_ring2 = 5,
e_portal_ring2 = 5,
e_straw_tube = 6,
e_drift_cell = 7,
/*e_single1 = 8,
e_single2 = 9,
e_single3 = 10,
e_unbounded_rectangle2 = 11,
e_unbounded_trapezoid2 = 12,
e_unbounded_annulus2 = 13,
e_unbounded_cylinder2 = 14,
e_unbounded_disc2 = 15,
e_unbounded_line_circular2 = 16,
e_unbounded_cell2 = 17,
e_unmasked2 = 18,*/
};

/// How to store masks
template <template <typename...> class vector_t = dvector>
using mask_store = regular_multi_store<mask_ids, empty_context, dtuple,
vector_t, rectangle, trapezoid,
annulus, cylinder, cylinder_portal,
disc, straw_tube, drift_cell /*,
single_1, single_2, single_3, unbounded_rectangle, unbounded_trapezoid,
unbounded_annulus, unbounded_cylinder, unbounded_disc, unbounded_straw_tube,
unbounded_cell, unmasked_plane*/>;

/// Give your material types a name (needs to be consecutive and has to
/// match the types position in the mask store!)
enum class material_ids : std::uint_least8_t {
// Material texture (grid) shapes
e_disc2_map = 0u,
e_concentric_cylinder2_map = 1u,
e_cylinder2_map = 2u,
e_rectangle2_map = 3u,
e_trapezoid2_map = 3u,
e_annulus2_map = 0u,
e_drift_cell_map = 5u,
e_straw_tube_map = 5u,
// Volume material
e_cuboid3_map = 7,
e_cylinder3_map = 8u,
// Homogeneous mapetrial
e_slab = 4u,
e_rod = 5u,
e_raw_material = 6u,
e_none = 9u,
/// Acceleration data structures
enum class accel_ids : std::uint_least8_t {
e_brute_force = 0, // test all surfaces in a volume (brute force)
e_cylinder2_grid = 1, // e.g. barrel layers
e_disc_grid = 2, // e.g. endcap layers
e_irr_cylinder2_grid = 3,
e_irr_disc_grid = 4,
// e_cylinder3_grid = 5,
// e_irr_cylinder3_grid = 6,
// ... e.g. frustum navigation types
e_default = e_brute_force,
};

/// How to store materials
template <typename container_t = host_container_types>
using material_store = multi_store<
material_ids, empty_context, dtuple,
grid_collection<disc_map_t<container_t>>,
grid_collection<concentric_cylinder2_map_t<container_t>>,
grid_collection<cylinder2_map_t<container_t>>,
grid_collection<rectangular_map_t<container_t>>,
typename container_t::template vector_type<slab>,
typename container_t::template vector_type<rod>,
typename container_t::template vector_type<material<scalar_t>>,
grid_collection<cuboid_map_t<container_t>>,
grid_collection<cylinder3_map_t<container_t>>>;

/// How to link to the entries in the data stores
using transform_link = typename transform_store<>::link_type;
using mask_link = typename mask_store<>::single_link;
Expand All @@ -236,6 +263,27 @@ unbounded_cell, unmasked_plane*/>;
using surface_type =
surface_descriptor<mask_link, material_link, transform_link, nav_link>;

/// How to store the acceleration data structures
template <typename container_t = host_container_types>
using accelerator_store =
multi_store<accel_ids, empty_context, dtuple,
brute_force_collection<surface_type, container_t>,
grid_collection<
cylinder2D_sf_grid<surface_type, container_t>>,
grid_collection<disc_sf_grid<surface_type, container_t>>,
grid_collection<
irr_cylinder2D_sf_grid<surface_type, container_t>>,
grid_collection<
irr_disc_sf_grid<surface_type, container_t>> /*,
grid_collection<cylinder3D_sf_grid<surface_type,
container_t>>,
grid_collection<irr_cylinder3D_sf_grid<surface_type,
container_t>>*/>;

//
// Volume descriptors
//

/// How to index the constituent objects (surfaces) in a volume
/// If they share the same index value here, they will be added into the
/// same acceleration data structure (brute force is always at 0)
Expand All @@ -247,40 +295,14 @@ unbounded_cell, unmasked_plane*/>;
e_all = e_size, // i.e. the brute force method and one grid type
};

/// Acceleration data structures
enum class accel_ids : std::uint_least8_t {
e_brute_force = 0, // test all surfaces in a volume (brute force)
e_disc_grid = 1, // e.g. endcap layers
e_cylinder2_grid = 2, // e.g. barrel layers
e_irr_disc_grid = 3,
e_irr_cylinder2_grid = 4,
// e_cylinder3_grid = 5,
// e_irr_cylinder3_grid = 6,
// ... e.g. frustum navigation types
e_default = e_brute_force,
};

/// How a volume links to the accelration data structures
/// In this case: One link for portals/passives and one sensitive surfaces
using object_link_type =
dmulti_index<dtyped_index<accel_ids, dindex>, geo_objects::e_size>;

/// How to store the acceleration data structures
template <typename container_t = host_container_types>
using accelerator_store =
multi_store<accel_ids, empty_context, dtuple,
brute_force_collection<surface_type, container_t>,
grid_collection<disc_sf_grid<surface_type, container_t>>,
grid_collection<
cylinder2D_sf_grid<surface_type, container_t>>,
grid_collection<
irr_disc_sf_grid<surface_type, container_t>>,
grid_collection<irr_cylinder2D_sf_grid<
surface_type, container_t>> /*,
grid_collection<cylinder3D_sf_grid<surface_type,
container_t>>,
grid_collection<irr_cylinder3D_sf_grid<surface_type,
container_t>>*/>;
//
// Volume acceleration structure
//

/// Volume search grid
template <typename container_t = host_container_types>
Expand Down
Loading

0 comments on commit cfeb189

Please sign in to comment.