12#include "detray/builders/surface_factory_interface.hpp"
13#include "detray/core/concepts.hpp"
14#include "detray/definitions/algebra.hpp"
15#include "detray/definitions/detail/qualifiers.hpp"
16#include "detray/definitions/indexing.hpp"
17#include "detray/material/material.hpp"
18#include "detray/material/material_rod.hpp"
19#include "detray/material/material_slab.hpp"
20#include "detray/material/predefined_materials.hpp"
21#include "detray/utils/logging.hpp"
22#include "detray/utils/ranges.hpp"
23#include "detray/utils/type_registry.hpp"
32template <concepts::scalar scalar_t>
98template <concepts::detector detector_t>
114 "No homogeneous surface material in detector type");
128 typename detector_t::surface_lookup_container &surfaces,
129 typename detector_t::transform_container &transforms,
130 typename detector_t::mask_container &masks,
131 typename detector_t::geometry_context ctx = {})
134 (*this->
get_factory())(volume, surfaces, transforms, masks, ctx);
136 m_surface_range = idx_range;
150 auto operator()(
typename detector_t::surface_lookup_container &surfaces,
151 typename detector_t::material_container &materials) {
152 DETRAY_VERBOSE_HOST(
"Generate homogeneous material...");
154 using material_id =
typename detector_t::material::id;
155 using link_t =
typename detector_t::surface_type::material_link;
157 assert(surfaces.size() >= (m_surface_range[1] - m_surface_range[0]));
159 DETRAY_VERBOSE_HOST(
"-> Material surface range: "
160 << m_surface_range[0] <<
" - " << m_surface_range[1]);
169 case surface_id::e_passive: {
170 const auto &mat = m_cfg.passive_material();
171 mat_ptr = (mat != vac) ? &mat :
nullptr;
174 case surface_id::e_sensitive: {
175 const auto &mat = m_cfg.sensitive_material();
176 mat_ptr = (mat != vac) ? &mat :
nullptr;
179 case surface_id::e_portal: {
180 const auto &mat = m_cfg.portal_material();
181 mat_ptr = (mat != vac) ? &mat :
nullptr;
184 case surface_id::e_unknown: {
185 std::stringstream err_stream{};
186 err_stream <<
"-> Encountered surface of unknown type during "
187 "material generation: "
190 DETRAY_FATAL_HOST(err_stream.str());
191 throw std::runtime_error(err_stream.str());
200 if (mat_ptr ==
nullptr) {
209 using mask_id =
typename detector_t::masks::id;
212 const mask_id sf_mask_id = sf.mask().id();
213 if (sf_mask_id == mask_id::e_straw_tube ||
214 sf_mask_id == mask_id::e_drift_cell) {
219 mat_coll.emplace_back(*mat_ptr, m_cfg.thickness());
221 mat_link = {material_id::e_material_rod,
222 static_cast<dindex>(mat_coll.size() - 1u)};
231 mat_coll.emplace_back(*mat_ptr, m_cfg.thickness());
233 mat_link = {material_id::e_material_slab,
234 static_cast<dindex>(mat_coll.size() - 1u)};
240 sf.material() = mat_link;
242 DETRAY_DEBUG_HOST(
"-> Added material to surface: " << sf);
const surface_factory_interface< detector_t > * get_factory() const
Definition surface_factory_interface.hpp:215
factory_decorator(std::unique_ptr< surface_factory_interface< detector_t > > factory)
Wrap a concrete surface factory and forward interface calls to it.
Definition surface_factory_interface.hpp:203
auto operator()(typename detector_t::surface_lookup_container &surfaces, typename detector_t::material_container &materials)
Create material slabs or rods for all surfaces that the underlying surface factory builds.
Definition homogeneous_material_generator.hpp:150
auto operator()(typename detector_t::volume_type &volume, typename detector_t::surface_lookup_container &surfaces, typename detector_t::transform_container &transforms, typename detector_t::mask_container &masks, typename detector_t::geometry_context ctx={}) -> dindex_range override
Call the underlying surface factory and record the surface range that was produced.
Definition homogeneous_material_generator.hpp:127
homogeneous_material_generator(std::unique_ptr< surface_factory_interface< detector_t > > factory, const hom_material_config< scalar_t > cfg)
Construct from configuration cfg.
Definition homogeneous_material_generator.hpp:108
How to generate surfaces with their corresponding masks and transforms.
Definition surface_factory_interface.hpp:120
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
Detray include(s).
Definition array_operators.hpp:18
get_scalar_t< A, T > dscalar
Scalar type for algebra A and value type T.
Definition algebra.hpp:64
detail::index_range< dindex > dindex_range
Index ranges and sequences.
Definition indexing.hpp:24
unsigned int dindex
Default index type.
Definition indexing.hpp:18
const auto & get(const detray::tuple< Ts... > &t) noexcept
Get a tuple element by index from a const tuple.
Definition tuple.hpp:152
Configuration for the homogeneous material generator.
Definition homogeneous_material_generator.hpp:33
constexpr hom_material_config & portal_material(const material< scalar_t > &m)
Set the material assigned to portal surfaces.
Definition homogeneous_material_generator.hpp:63
scalar_t m_thickness
Minimal envelope for the portals (used in autofitting).
Definition homogeneous_material_generator.hpp:41
constexpr const material< scalar_t > & passive_material() const
Getters.
Definition homogeneous_material_generator.hpp:79
material< scalar_t > m_portal_material
Type of material to put on the portal surfaces.
Definition homogeneous_material_generator.hpp:39
material< scalar_t > m_sensitive_material
Type of material to put on the sensitive surfaces.
Definition homogeneous_material_generator.hpp:37
constexpr hom_material_config & passive_material(const material< scalar_t > &m)
SettersSet the material assigned to passive surfaces.
Definition homogeneous_material_generator.hpp:48
material< scalar_t > m_passive_material
Type of material to put on the passive surfaces.
Definition homogeneous_material_generator.hpp:35
constexpr scalar_t thickness() const
Definition homogeneous_material_generator.hpp:91
constexpr const material< scalar_t > & sensitive_material() const
Definition homogeneous_material_generator.hpp:83
constexpr hom_material_config & thickness(const scalar_t t)
Set the thickness used when creating portal material.
Definition homogeneous_material_generator.hpp:70
constexpr hom_material_config & sensitive_material(const material< scalar_t > &m)
Set the material assigned to sensitive surfaces.
Definition homogeneous_material_generator.hpp:55
constexpr const material< scalar_t > & portal_material() const
Definition homogeneous_material_generator.hpp:87
Material composition properties and density data used by interactions.
Definition material.hpp:36
interface type to construct a subrange_view with CTAD
Definition subrange.hpp:90
Predefined silicon material with tabulated bulk properties.
Definition predefined_materials.hpp:116
static constexpr scalar_t mm
Native length unit, the millimetre.
Definition units.hpp:27
Elements Declaration.
Definition predefined_materials.hpp:34