Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 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/DetectorVolume.hpp"
0013 #include "Acts/Detector/PortalGenerators.hpp"
0014 #include "Acts/Detector/detail/DetectorVolumeConsistency.hpp"
0015 #include "Acts/Geometry/CuboidVolumeBounds.hpp"
0016 #include "Acts/Geometry/GeometryContext.hpp"
0017 #include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp"
0018 
0019 auto portalGenerator = Acts::Experimental::defaultPortalGenerator();
0020 auto tContext = Acts::GeometryContext();
0021 
0022 BOOST_AUTO_TEST_SUITE(Detector)
0023 
0024 BOOST_AUTO_TEST_CASE(DetectorVolumeConsistencyFail) {
0025   // A perfect box shape
0026   auto box = std::make_shared<Acts::CuboidVolumeBounds>(10, 10, 10);
0027 
0028   // Create volume A
0029   auto volumeA = Acts::Experimental::DetectorVolumeFactory::construct(
0030       portalGenerator, tContext, "VolumeA", Acts::Transform3::Identity(), box,
0031       Acts::Experimental::tryAllPortals());
0032 
0033   // Move it into the bval direction
0034   auto transformB = Acts::Transform3::Identity();
0035   Acts::Vector3 translationB = Acts::Vector3::Zero();
0036   translationB[Acts::binX] = 20;
0037   translationB[Acts::binY] = 5;
0038   transformB.pretranslate(translationB);
0039   // Create volume B
0040   auto volumeB = Acts::Experimental::DetectorVolumeFactory::construct(
0041       portalGenerator, tContext, "VolumeB", transformB, box,
0042       Acts::Experimental::tryAllPortals());
0043   // Build the container
0044   std::vector<std::shared_ptr<Acts::Experimental::DetectorVolume>> volumes = {
0045       volumeA, volumeB};
0046 
0047   BOOST_CHECK_THROW(
0048       Acts::Experimental::detail::DetectorVolumeConsistency::
0049           checkCenterAlignment(tContext, {volumeA, volumeB}, Acts::binX),
0050       std::invalid_argument);
0051 }
0052 
0053 BOOST_AUTO_TEST_CASE(DetectorVolumeConsistencyPass) {
0054   // A perfect box shape
0055   auto box = std::make_shared<Acts::CuboidVolumeBounds>(10, 10, 10);
0056 
0057   // Create volume A
0058   auto volumeA = Acts::Experimental::DetectorVolumeFactory::construct(
0059       portalGenerator, tContext, "VolumeA", Acts::Transform3::Identity(), box,
0060       Acts::Experimental::tryAllPortals());
0061 
0062   // Move it into the bval direction
0063   auto transformB = Acts::Transform3::Identity();
0064   Acts::Vector3 translationB = Acts::Vector3::Zero();
0065   translationB[Acts::binX] = 20;
0066   transformB.pretranslate(translationB);
0067   // Create volume B
0068   auto volumeB = Acts::Experimental::DetectorVolumeFactory::construct(
0069       portalGenerator, tContext, "VolumeB", transformB, box,
0070       Acts::Experimental::tryAllPortals());
0071   // Build the container
0072   std::vector<std::shared_ptr<Acts::Experimental::DetectorVolume>> volumes = {
0073       volumeA, volumeB};
0074 
0075   BOOST_CHECK_NO_THROW(
0076       Acts::Experimental::detail::DetectorVolumeConsistency::
0077           checkCenterAlignment(tContext, {volumeA, volumeB}, Acts::binX));
0078 }
0079 
0080 BOOST_AUTO_TEST_SUITE_END()