Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:14

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 // Project include(s)
0012 #include "detray/builders/homogeneous_material_builder.hpp"
0013 #include "detray/builders/homogeneous_material_factory.hpp"
0014 #include "detray/builders/surface_factory.hpp"
0015 #include "detray/builders/volume_builder.hpp"
0016 #include "detray/definitions/indexing.hpp"
0017 #include "detray/geometry/mask.hpp"
0018 #include "detray/geometry/shapes.hpp"
0019 #include "detray/material/predefined_materials.hpp"
0020 
0021 namespace detray {
0022 
0023 /// Adds a few surfaces to the detector for testing the builder code on
0024 /// non-empty detectors
0025 template <typename detector_t>
0026 void prefill_detector(detector_t& d,
0027                       typename detector_t::geometry_context ctx) {
0028   using algebra_t = typename detector_t::algebra_type;
0029   using scalar_t = dscalar<algebra_t>;
0030   using point3_t = dpoint3D<algebra_t>;
0031   using transform3_t = dtransform3D<algebra_t>;
0032 
0033   using nav_link_t = typename detector_t::surface_type::navigation_link;
0034   using material_id = typename detector_t::material::id;
0035 
0036   using annulus_factory_t = surface_factory<detector_t, annulus2D>;
0037   using rectangle_factory_t = surface_factory<detector_t, rectangle2D>;
0038   using trapezoid_factory_t = surface_factory<detector_t, trapezoid2D>;
0039 
0040   // Build a volume
0041   auto v_builder =
0042       std::make_unique<volume_builder<detector_t>>(volume_id::e_cylinder);
0043 
0044   // Volume position
0045   v_builder->add_volume_placement(transform3_t(point3_t{0.f, 0.f, 2.f}));
0046 
0047   // Build homogeneous material on surfaces inside the voume
0048   auto v_mat_builder =
0049       homogeneous_material_builder<detector_t>{std::move(v_builder)};
0050   const auto vol_link{static_cast<nav_link_t>(v_mat_builder.vol_index())};
0051 
0052   // Surface 0
0053   auto rectangle_factory =
0054       std::make_shared<homogeneous_material_factory<detector_t>>(
0055           std::make_unique<rectangle_factory_t>());
0056 
0057   rectangle_factory->push_back({surface_id::e_sensitive,
0058                                 transform3_t(point3_t{0.f, 0.f, 0.f}), vol_link,
0059                                 std::vector<scalar_t>{-3.f, 3.f}});
0060   rectangle_factory->add_material(
0061       material_id::e_material_slab,
0062       {3.f * unit<scalar_t>::mm, detray::gold<scalar_t>()});
0063   // Surface 1
0064   auto annulus_factory =
0065       std::make_shared<homogeneous_material_factory<detector_t>>(
0066           std::make_unique<annulus_factory_t>());
0067 
0068   annulus_factory->push_back(
0069       {surface_id::e_sensitive, transform3_t(point3_t{1.f, 0.f, 0.f}), vol_link,
0070        std::vector<scalar_t>{1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f}});
0071   annulus_factory->add_material(
0072       material_id::e_material_slab,
0073       {12.f * unit<scalar_t>::mm, detray::tungsten<scalar_t>()});
0074 
0075   // Surface 2
0076   auto trapezoid_factory =
0077       std::make_shared<homogeneous_material_factory<detector_t>>(
0078           std::make_unique<trapezoid_factory_t>());
0079 
0080   trapezoid_factory->push_back(
0081       {surface_id::e_sensitive, transform3_t(point3_t{2.f, 0.f, 0.f}), vol_link,
0082        std::vector<scalar_t>{1.f, 2.f, 3.f, 1.f / 6.f}});
0083   trapezoid_factory->add_material(
0084       material_id::e_material_rod,
0085       {4.f * unit<scalar_t>::mm, detray::aluminium<scalar_t>()});
0086 
0087   // Build the volume with three surfaces and homogenenous material
0088   v_mat_builder.add_surfaces(rectangle_factory, ctx);
0089   v_mat_builder.add_surfaces(annulus_factory, ctx);
0090   v_mat_builder.add_surfaces(trapezoid_factory, ctx);
0091 
0092   v_mat_builder.build(d);
0093 }
0094 
0095 }  // namespace detray