Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IndexedRootVolumeFinderBuilderTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file IndexedRootVolumeFinderBuilderTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
21 
22 using namespace Acts;
23 using namespace Acts::Experimental;
24 
27 
28 BOOST_AUTO_TEST_SUITE(DetectorTests)
29 
30 BOOST_AUTO_TEST_CASE(IndexedRootVolumeFinderBuilderCylindrical) {
32 
33  auto innerB = std::make_unique<CylinderVolumeBounds>(0., 20., 100);
34  auto innerV = DetectorVolumeFactory::construct(
35  portalGenerator, tContext, "Inner", Transform3::Identity(),
36  std::move(innerB), tryAllPortals());
37 
38  auto middleLB = std::make_unique<CylinderVolumeBounds>(20., 60., 5);
39  auto middleLT = Transform3::Identity();
40  middleLT.pretranslate(Vector3(0., 0., -95));
41  auto middleLV = DetectorVolumeFactory::construct(
42  portalGenerator, tContext, "MiddleLeft", middleLT, std::move(middleLB),
43  tryAllPortals());
44 
45  auto middleDB = std::make_unique<CylinderVolumeBounds>(20., 40., 90);
46  auto middleDV = DetectorVolumeFactory::construct(
47  portalGenerator, tContext, "MiddleDown", Transform3::Identity(),
48  std::move(middleDB), tryAllPortals());
49 
50  auto middleUB = std::make_unique<CylinderVolumeBounds>(40., 60., 90);
51  auto middleUV = DetectorVolumeFactory::construct(
52  portalGenerator, tContext, "MiddleUp", Transform3::Identity(),
53  std::move(middleUB), tryAllPortals());
54 
55  auto middleRB = std::make_unique<CylinderVolumeBounds>(20., 60., 5);
56  auto middleRT = Transform3::Identity();
57  middleRT.pretranslate(Vector3(0., 0., 95));
58  auto middleRV = DetectorVolumeFactory::construct(
59  portalGenerator, tContext, "middleRight", middleRT, std::move(middleRB),
60  tryAllPortals());
61 
62  auto outerB = std::make_unique<CylinderVolumeBounds>(60., 120., 100);
63  auto outerV = DetectorVolumeFactory::construct(
64  portalGenerator, tContext, "Outer", Transform3::Identity(),
65  std::move(outerB), tryAllPortals());
66 
67  std::vector<std::shared_ptr<DetectorVolume>> rootVolumes = {
68  innerV, middleLV, middleDV, middleUV, middleRV, outerV};
69 
71 
72  // Let's construct a detector
73  auto rootVolumeFinder = builder.construct(tContext, rootVolumes);
74 
75  auto detectorIndexed = Detector::makeShared("IndexedDetector", rootVolumes,
76  std::move(rootVolumeFinder));
77 
78  BOOST_CHECK(detectorIndexed->findDetectorVolume(tContext, {10., 0., 0.}) ==
79  innerV.get());
80  BOOST_CHECK(detectorIndexed->findDetectorVolume(tContext, {25., 0., -93.}) ==
81  middleLV.get());
82  BOOST_CHECK(detectorIndexed->findDetectorVolume(tContext, {35., 0., 0.}) ==
83  middleDV.get());
84  BOOST_CHECK(detectorIndexed->findDetectorVolume(tContext, {55., 0., 0.}) ==
85  middleUV.get());
86  BOOST_CHECK(detectorIndexed->findDetectorVolume(tContext, {40., 0., 92.}) ==
87  middleRV.get());
88  BOOST_CHECK(detectorIndexed->findDetectorVolume(tContext, {65., 0., 0.}) ==
89  outerV.get());
90 }
91 
92 BOOST_AUTO_TEST_SUITE_END()