Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2019 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/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
0014 #include "Acts/Geometry/TrackingVolume.hpp"
0015 
0016 namespace Acts::Test {
0017 
0018 using namespace Acts::UnitLiterals;
0019 
0020 BOOST_AUTO_TEST_SUITE(Geometry)
0021 BOOST_AUTO_TEST_SUITE(TrackingVolumeTests)
0022 
0023 std::size_t countVolumes(const TrackingVolume& tv) {
0024   std::size_t count = 0;
0025   tv.visitVolumes([&count](const auto&) { ++count; });
0026   return count;
0027 }
0028 
0029 BOOST_AUTO_TEST_CASE(TrackigVolumeChildren) {
0030   auto cylBounds =
0031       std::make_shared<Acts::CylinderVolumeBounds>(10_mm, 20_mm, 100_mm);
0032 
0033   TrackingVolume tv{Transform3::Identity(), cylBounds};
0034 
0035   BOOST_CHECK(tv.volumes().empty());
0036   BOOST_CHECK_EQUAL(countVolumes(tv), 1);
0037 
0038   auto& child1 = tv.addVolume(
0039       std::make_unique<TrackingVolume>(Transform3::Identity(), cylBounds));
0040 
0041   BOOST_CHECK_EQUAL(tv.volumes().size(), 1);
0042 
0043   auto it = tv.volumes().begin();
0044   static_assert(std::is_same_v<decltype(*it), TrackingVolume&>);
0045 
0046   const auto& tvConst = tv;
0047   auto cit = tvConst.volumes().begin();
0048   static_assert(std::is_same_v<decltype(*cit), const TrackingVolume&>);
0049 
0050   BOOST_CHECK_EQUAL(&*it, &child1);
0051 
0052   BOOST_CHECK_EQUAL(countVolumes(tv), 2);
0053 
0054   tv.addVolume(
0055       std::make_unique<TrackingVolume>(Transform3::Identity(), cylBounds));
0056 
0057   BOOST_CHECK_EQUAL(countVolumes(tv), 3);
0058 }
0059 
0060 BOOST_AUTO_TEST_SUITE_END()
0061 
0062 BOOST_AUTO_TEST_SUITE_END()
0063 
0064 }  // namespace Acts::Test