ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
homogeneous_volume_material_builder.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s).
12#include "detray/builders/volume_builder.hpp"
13#include "detray/builders/volume_builder_interface.hpp"
14#include "detray/material/material.hpp"
15#include "detray/material/predefined_materials.hpp"
16#include "detray/utils/ranges.hpp"
17
18// System include(s)
19#include <iostream>
20#include <map>
21#include <memory>
22
23namespace detray {
24
29template <typename detector_t>
31 : public volume_decorator<detector_t> {
32 static_assert(concepts::detector<detector_t>);
33
34 public:
37
40 DETRAY_HOST
42 std::unique_ptr<volume_builder_interface<detector_t>> vol_builder)
43 : volume_decorator<detector_t>(std::move(vol_builder)) {}
44
48 DETRAY_HOST
49 void set_material(material<scalar_type> mat) { m_volume_material = mat; }
50
56 DETRAY_HOST
57 auto build(detector_t &det, const volume_builder_options &opt,
58 typename detector_t::geometry_context ctx = {}) ->
59 typename detector_t::volume_type * override {
60 // Call the underlying volume builder(s)
61 typename detector_t::volume_type *vol =
63
64 // Nothing left to do
65 if (m_volume_material == detray::vacuum<scalar_type>{}) {
66 DETRAY_WARN_HOST("Volume " << this->vol_index()
67 << " has vacuum material");
68
69 return vol;
70 }
71
72 constexpr auto material_id{detector_t::material::id::e_raw_material};
73
74 // Update the volume material link
75 dindex coll_size{det.material_store().template size<material_id>()};
76 vol->set_material(material_id, coll_size);
77
78 // Append the material
79 det._materials.template push_back<material_id>(m_volume_material);
80
81 // Give the volume to the next decorator
82 return vol;
83 }
84
85 private:
86 // Material for this volume
87 material<scalar_type> m_volume_material{};
88};
89
90} // namespace detray
dscalar< typename detector_t::algebra_type > scalar_type
Scalar type used by the detector's material definitions.
Definition homogeneous_volume_material_builder.hpp:36
auto build(detector_t &det, const volume_builder_options &opt, typename detector_t::geometry_context ctx={}) -> typename detector_t::volume_type *override
Add the volume and the material to the detector det.
Definition homogeneous_volume_material_builder.hpp:57
homogeneous_volume_material_builder(std::unique_ptr< volume_builder_interface< detector_t > > vol_builder)
Definition homogeneous_volume_material_builder.hpp:41
void set_material(material< scalar_type > mat)
Add all necessary components for the volume material.
Definition homogeneous_volume_material_builder.hpp:49
Interface for volume builders (and volume builder decorators).
Definition volume_builder_interface.hpp:66
volume_decorator(std::unique_ptr< volume_builder_interface< detector_t > > vol_builder)
Wraps a volume builder.
Definition volume_builder_interface.hpp:178
auto build(detector_t &det, const volume_builder_options &opt, typename detector_t::geometry_context={}) -> typename detector_t::volume_type *override
Builds the wrapped volume in the detector.
Definition volume_builder_interface.hpp:229
auto vol_index() const -> dindex override
Returns the index assigned by the wrapped builder.
Definition volume_builder_interface.hpp:201
Check if a type can be used as a detector.
Definition concepts.hpp:47
material_id
Enumerate the different material types.
Definition definitions.hpp:59
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
unsigned int dindex
Default index type.
Definition indexing.hpp:18
Material composition properties and density data used by interactions.
Definition material.hpp:36
Elements Declaration.
Definition predefined_materials.hpp:34
Options for the volume builder classes.
Definition volume_builder_interface.hpp:29