Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:17:58

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 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Detector/DetectorVolume.hpp"
0013 #include "Acts/Detector/PortalGenerators.hpp"
0014 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
0015 #include "Acts/Geometry/GeometryContext.hpp"
0016 #include "Acts/Geometry/GeometryIdentifier.hpp"
0017 #include "Acts/Geometry/TrackingVolume.hpp"
0018 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0019 #include "Acts/Material/IntersectionMaterialAssigner.hpp"
0020 #include "Acts/Navigation/InternalNavigation.hpp"
0021 #include "Acts/Surfaces/CylinderSurface.hpp"
0022 #include "Acts/Utilities/Enumerate.hpp"
0023 
0024 #include <limits>
0025 
0026 namespace Acts::Test {
0027 
0028 auto tContext = GeometryContext();
0029 auto mContext = MagneticFieldContext();
0030 
0031 BOOST_AUTO_TEST_SUITE(IntersectionMaterialAssignerTestSuite)
0032 
0033 BOOST_AUTO_TEST_CASE(FindSurfaceIntersections) {
0034   // Create a vector of surfaces
0035   std::vector<std::shared_ptr<Surface>> surfaces = {
0036       Surface::makeShared<CylinderSurface>(Transform3::Identity(), 20.0, 100.0),
0037       Surface::makeShared<CylinderSurface>(Transform3::Identity(), 30.0, 100.0),
0038       Surface::makeShared<CylinderSurface>(Transform3::Identity(), 50.0,
0039                                            100.0)};
0040 
0041   IntersectionMaterialAssigner::Config imCfg;
0042   for (const auto &surface : surfaces) {
0043     imCfg.surfaces.push_back(surface.get());
0044   }
0045 
0046   IntersectionMaterialAssigner imAssigner(imCfg);
0047   auto [surfaceCandides, volumeCandidates] = imAssigner.assignmentCandidates(
0048       tContext, mContext, Vector3(0, 0, 0), Vector3(1, 1, 0).normalized());
0049 
0050   BOOST_CHECK_EQUAL(surfaceCandides.size(), 3u);
0051   BOOST_CHECK_EQUAL(volumeCandidates.size(), 0u);
0052 }
0053 
0054 BOOST_AUTO_TEST_CASE(FindTrackingVolumeIntersections) {
0055   auto cylinerVolumeBounds =
0056       std::make_shared<CylinderVolumeBounds>(20.0, 100.0, 400.0);
0057   auto volume = std::make_shared<TrackingVolume>(
0058       Transform3::Identity(), cylinerVolumeBounds, nullptr, nullptr, nullptr,
0059       MutableTrackingVolumeVector{}, "CylindricalTrackignVolume");
0060 
0061   IntersectionMaterialAssigner::Config imCfg;
0062   imCfg.trackingVolumes.push_back(volume.get());
0063 
0064   IntersectionMaterialAssigner imAssigner(imCfg);
0065   auto [surfaceCandides, volumeCandidates] = imAssigner.assignmentCandidates(
0066       tContext, mContext, Vector3(0, 0, 0), Vector3(1, 1, 0).normalized());
0067 
0068   BOOST_CHECK_EQUAL(surfaceCandides.size(), 0u);
0069   BOOST_CHECK_EQUAL(volumeCandidates.size(), 1u);
0070 }
0071 
0072 BOOST_AUTO_TEST_CASE(FindDetectorVolumeIntersections) {
0073   auto cylinerVolumeBounds =
0074       std::make_shared<CylinderVolumeBounds>(20.0, 100.0, 400.0);
0075 
0076   auto portalGenerator = Experimental::defaultPortalGenerator();
0077 
0078   auto volume = Experimental::DetectorVolumeFactory::construct(
0079       portalGenerator, tContext, "CylindricalDetectorVolume",
0080       Transform3::Identity(), std::move(cylinerVolumeBounds),
0081       Experimental::tryAllPortals());
0082 
0083   IntersectionMaterialAssigner::Config imCfg;
0084   imCfg.detectorVolumes.push_back(volume.get());
0085 
0086   IntersectionMaterialAssigner imAssigner(imCfg);
0087   auto [surfaceCandides, volumeCandidates] = imAssigner.assignmentCandidates(
0088       tContext, mContext, Vector3(0, 0, 0), Vector3(1, 1, 0).normalized());
0089 
0090   BOOST_CHECK_EQUAL(surfaceCandides.size(), 0u);
0091   BOOST_CHECK_EQUAL(volumeCandidates.size(), 1u);
0092 }
0093 
0094 BOOST_AUTO_TEST_SUITE_END()
0095 
0096 }  // namespace Acts::Test