Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:18

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2022-2023 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Detector/MultiWireStructureBuilder.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Surfaces/LineBounds.hpp"
0015 #include "Acts/Surfaces/RectangleBounds.hpp"
0016 #include "Acts/Surfaces/StrawSurface.hpp"
0017 #include "Acts/Surfaces/Surface.hpp"
0018 #include "Acts/Visualization/GeometryView3D.hpp"
0019 #include "Acts/Visualization/IVisualization3D.hpp"
0020 #include "Acts/Visualization/ObjVisualization3D.hpp"
0021 
0022 #include <algorithm>
0023 #include <iterator>
0024 #include <memory>
0025 #include <utility>
0026 #include <vector>
0027 
0028 using namespace Acts;
0029 using namespace Acts::Experimental;
0030 
0031 GeometryContext tContext;
0032 
0033 BOOST_AUTO_TEST_SUITE(Detector)
0034 
0035 BOOST_AUTO_TEST_CASE(Multi_Wire_Structure_Builder_StrawSurfacesCreation) {
0036   // Create the surfaces of the multiwire structure-straw surfaces
0037   std::vector<std::shared_ptr<Acts::Surface>> strawSurfaces = {};
0038 
0039   // Set the number of surfaces along each dimension of the multi wire structure
0040   // aligned along z axis
0041   std::size_t nSurfacesY = 3;
0042   std::size_t nSurfacesX = 15;
0043 
0044   double radius = 15.;
0045   double halfZ = 250.;
0046 
0047   // The transform of the 1st surface
0048   Vector3 ipos = {-0.5 * nSurfacesX * 2 * radius + radius,
0049                   -0.5 * nSurfacesY * 2 * radius + radius, 0.};
0050   AngleAxis3 rotation(M_PI / 2, Acts::Vector3(0., 1., 0.));
0051 
0052   Vector3 pos = ipos;
0053 
0054   // Generate the surfaces
0055   for (std::size_t i = 0; i < nSurfacesY; i++) {
0056     for (std::size_t j = 0; j < nSurfacesX; j++) {
0057       auto surface = Surface::makeShared<StrawSurface>(
0058           Transform3(Translation3(pos)), radius, halfZ);
0059       strawSurfaces.push_back(surface);
0060       pos.x() = ipos.x() + 2 * j * radius;
0061       pos.y() = ipos.y() + 2 * i * radius;
0062     }
0063   }
0064 
0065   std::vector<ActsScalar> vBounds = {0.5 * nSurfacesX * 2 * radius,
0066                                      0.5 * nSurfacesX * 2 * radius,
0067                                      0.5 * nSurfacesY * 2 * radius, halfZ};
0068 
0069   MultiWireStructureBuilder::Config mlCfg;
0070   mlCfg.name = "Multi_Layer_With_Wires";
0071   mlCfg.mlSurfaces = strawSurfaces;
0072   mlCfg.mlBounds = vBounds;
0073   mlCfg.mlBinning = {
0074       ProtoBinning(Acts::binX, Acts::detail::AxisBoundaryType::Bound,
0075                    -vBounds[0], vBounds[0], nSurfacesX, 1u),
0076       ProtoBinning(Acts::binY, Acts::detail::AxisBoundaryType::Bound,
0077                    -vBounds[1], vBounds[1], nSurfacesY, 0u)};
0078 
0079   MultiWireStructureBuilder mlBuilder(mlCfg);
0080   auto [volumes, portals, roots] = mlBuilder.construct(tContext);
0081 
0082   BOOST_CHECK_EQUAL(volumes.size(), 1u);
0083   BOOST_CHECK_EQUAL(volumes.front()->surfaces().size(),
0084                     nSurfacesX * nSurfacesY);
0085   BOOST_CHECK(volumes.front()->volumes().empty());
0086   BOOST_CHECK(volumes.front()->surfaceCandidatesUpdater().connected());
0087 }
0088 
0089 BOOST_AUTO_TEST_SUITE_END()