12#include "detray/builders/detector_builder.hpp"
13#include "detray/builders/homogeneous_material_builder.hpp"
14#include "detray/builders/homogeneous_material_factory.hpp"
15#include "detray/core/concepts.hpp"
16#include "detray/definitions/algebra.hpp"
17#include "detray/definitions/indexing.hpp"
18#include "detray/io/backend/detail/basic_converter.hpp"
19#include "detray/io/backend/detail/type_info.hpp"
20#include "detray/io/frontend/payloads.hpp"
21#include "detray/material/material.hpp"
41 static constexpr std::string_view
tag =
"homogeneous_material";
51 template <
class detector_t>
55 DETRAY_VERBOSE_HOST(
"Reading payload object...");
58 using mat_id =
typename detector_t::material::id;
60 DETRAY_DEBUG_HOST(
"Converting material for " << det_mat_data.
volumes.size()
64 for (
const auto& mv_data : det_mat_data.
volumes) {
66 detail::basic_converter::from_payload(mv_data.volume_link)};
68 DETRAY_DEBUG_HOST(
" - volume index from payload is " << vol_idx);
70 if (!det_builder.has_volume(vol_idx)) {
71 std::stringstream err_stream;
72 err_stream <<
"Volume " << vol_idx <<
": "
73 <<
"Cannot build homogeneous material for volume "
74 <<
"(volume not registered in detector builder)";
75 DETRAY_FATAL_HOST(err_stream.str());
76 throw std::invalid_argument(err_stream.str());
82 .template decorate<homogeneous_material_builder<detector_t>>(
85 "Retrieved volume builder from detector build using vol_idx="
90 std::make_shared<homogeneous_material_factory<detector_t>>();
92 DETRAY_DEBUG_HOST(
"Adding " << mv_data.surface_mat.size()
93 <<
" material slabs to material factory");
94 for (
const auto& mat_data : mv_data.surface_mat) {
96 mat_id mat_type{mat_id::e_none};
98 if (mat_data.type == io::material_id::rod) {
99 mat_type = mat_id::e_material_rod;
103 if (mat_data.type == io::material_id::slab) {
104 mat_type = mat_id::e_material_slab;
107 assert(mat_type != mat_id::e_none);
109 const auto mat_idx{mat_data.index_in_coll.has_value()
110 ? mat_data.index_in_coll.value()
111 : detray::detail::invalid_value<std::size_t>()};
113 DETRAY_DEBUG_HOST(
"-> Surface link is: " << mat_idx);
120 DETRAY_DEBUG_HOST(
"Adding material factory to the builder");
121 vm_builder->add_surfaces(mat_factory);
127 template <detray::concepts::scalar scalar_t>
130 return {
static_cast<scalar_t
>(slab_data.
thickness),
132 detail::basic_converter::from_payload(slab_data.
surface)};
136 template <detray::concepts::scalar scalar_t>
139 static_cast<scalar_t
>(mat_data.
params[0]),
140 static_cast<scalar_t
>(mat_data.
params[1]),
141 static_cast<scalar_t
>(mat_data.
params[2]),
142 static_cast<scalar_t
>(mat_data.
params[3]),
143 static_cast<scalar_t
>(mat_data.
params[4]),
Provides functionality to build a detray detector volume by volume.
Definition detector_builder.hpp:40
Homogeneous material reader backend.
Definition homogeneous_material_reader.hpp:34
detector_homogeneous_material_payload payload_type
Payload type that the reader processes.
Definition homogeneous_material_reader.hpp:44
static constexpr std::string_view tag
Tag the reader as "homogeneous material".
Definition homogeneous_material_reader.hpp:41
static auto from_payload(const material_param_payload &mat_data)
Definition homogeneous_material_reader.hpp:137
static void from_payload(detector_builder< typename detector_t::metadata, volume_builder > &det_builder, const payload_type &det_mat_data)
Convert the detector material det_mat_data from its IO payload.
Definition homogeneous_material_reader.hpp:52
static material_data< scalar_t > from_payload(const surface_material_payload &slab_data)
Definition homogeneous_material_reader.hpp:128
Bind components for material together.
Definition homogeneous_material_factory.hpp:35
Provides basic functionality to build detector volumes.
Definition volume_builder.hpp:36
Check for the the presence of material rods in a detector definition.
Definition concepts.hpp:146
Check for the the presence of material slabs in a detector definition.
Definition concepts.hpp:141
The following enums are global for all detectors.
Definition concepts.hpp:18
material_id
Enumerate the different material types.
Definition definitions.hpp:59
get_scalar_t< A, T > dscalar
Scalar type for algebra A and value type T.
Definition algebra.hpp:64
material_state
Material State.
Definition material.hpp:27
A payload for the homogeneous material description of a detector.
Definition payloads.hpp:257
std::vector< material_volume_payload > volumes
Material payloads grouped by detector volume.
Definition payloads.hpp:259
A payload object for a material parametrization.
Definition payloads.hpp:210
std::array< io::scalar, 7u > params
Material parametrization 0: X0 1: L0 2: Ar 3: Z 4: Mass density 5: Molar densitty (unused) 6: materia...
Definition payloads.hpp:219
A payload object for a material slab/rod.
Definition payloads.hpp:223
io::scalar thickness
Thickness of the material slab.
Definition payloads.hpp:235
single_link_payload surface
Index of the surface in the volume the material belongs to.
Definition payloads.hpp:233
material_param_payload mat
Material parameters.
Definition payloads.hpp:237
Material composition properties and density data used by interactions.
Definition material.hpp:36