ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
prefill_detector.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/homogeneous_material_builder.hpp"
13#include "detray/builders/homogeneous_material_factory.hpp"
14#include "detray/builders/surface_factory.hpp"
15#include "detray/builders/volume_builder.hpp"
16#include "detray/core/concepts.hpp"
17#include "detray/definitions/indexing.hpp"
18#include "detray/geometry/mask.hpp"
19#include "detray/geometry/shapes.hpp"
20#include "detray/material/predefined_materials.hpp"
21
22namespace detray {
23
28template <concepts::detector detector_t>
29void prefill_detector(detector_t& d,
30 typename detector_t::geometry_context ctx) {
31 using algebra_t = typename detector_t::algebra_type;
32 using scalar_t = dscalar<algebra_t>;
33 using point3_t = dpoint3D<algebra_t>;
34 using transform3_t = dtransform3D<algebra_t>;
35
36 using nav_link_t = typename detector_t::surface_type::navigation_link;
37 using material_id = typename detector_t::material::id;
38
39 using annulus_factory_t = surface_factory<detector_t, annulus2D>;
40 using rectangle_factory_t = surface_factory<detector_t, rectangle2D>;
41 using trapezoid_factory_t = surface_factory<detector_t, trapezoid2D>;
42
43 // Build a volume
44 auto v_builder =
45 std::make_unique<volume_builder<detector_t>>(volume_id::e_cylinder);
46
47 // Volume position
48 v_builder->add_volume_placement(transform3_t(point3_t{0.f, 0.f, 2.f}));
49
50 // Build homogeneous material on surfaces inside the voume
51 auto v_mat_builder =
52 homogeneous_material_builder<detector_t>{std::move(v_builder)};
53 const auto vol_link{static_cast<nav_link_t>(v_mat_builder.vol_index())};
54
55 // Surface 0
56 auto rectangle_factory =
57 std::make_shared<homogeneous_material_factory<detector_t>>(
58 std::make_unique<rectangle_factory_t>());
59
60 rectangle_factory->push_back({surface_id::e_sensitive,
61 transform3_t(point3_t{0.f, 0.f, 0.f}), vol_link,
62 std::vector<scalar_t>{-3.f, 3.f}});
63 rectangle_factory->add_material(
64 material_id::e_material_slab,
66 // Surface 1
67 auto annulus_factory =
68 std::make_shared<homogeneous_material_factory<detector_t>>(
69 std::make_unique<annulus_factory_t>());
70
71 annulus_factory->push_back(
72 {surface_id::e_sensitive, transform3_t(point3_t{1.f, 0.f, 0.f}), vol_link,
73 std::vector<scalar_t>{1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f}});
74 annulus_factory->add_material(
75 material_id::e_material_slab,
77
78 // Surface 2
79 auto trapezoid_factory =
80 std::make_shared<homogeneous_material_factory<detector_t>>(
81 std::make_unique<trapezoid_factory_t>());
82
83 trapezoid_factory->push_back(
84 {surface_id::e_sensitive, transform3_t(point3_t{2.f, 0.f, 0.f}), vol_link,
85 std::vector<scalar_t>{1.f, 2.f, 3.f, 1.f / 6.f}});
86 trapezoid_factory->add_material(
87 material_id::e_material_rod,
89
90 // Build the volume with three surfaces and homogenenous material
91 v_mat_builder.add_surfaces(rectangle_factory, ctx);
92 v_mat_builder.add_surfaces(annulus_factory, ctx);
93 v_mat_builder.add_surfaces(trapezoid_factory, ctx);
94
95 const volume_builder_options builder_opts{};
96 v_mat_builder.build(d, builder_opts);
97}
98
99} // namespace detray
Build a volume containing surfaces with material.
Definition homogeneous_material_builder.hpp:32
Generates a number of surfaces for a volume (can be portals, passives or sensitives) and fills them i...
Definition surface_factory.hpp:43
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
void prefill_detector(detector_t &d, typename detector_t::geometry_context ctx)
Adds a few surfaces to the detector for testing the builder code on non-empty detectors.
Definition prefill_detector.hpp:29
get_transform3D_t< A, T > dtransform3D
Three-dimensional transform type for algebra A and value type T.
Definition algebra.hpp:84
get_point3D_t< A, T > dpoint3D
Three-dimensional point type for algebra A and value type T.
Definition algebra.hpp:72
Predefined aluminium material with tabulated bulk properties.
Definition predefined_materials.hpp:108
Predefined gold material with tabulated bulk properties.
Definition predefined_materials.hpp:191
Predefined tungsten material with tabulated bulk properties.
Definition predefined_materials.hpp:183
static constexpr scalar_t mm
Native length unit, the millimetre.
Definition units.hpp:27
Options for the volume builder classes.
Definition volume_builder_interface.hpp:29