Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LayerStructureBuilderTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LayerStructureBuilderTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 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 
23 
24 #include <cmath>
25 #include <functional>
26 #include <memory>
27 #include <string>
28 #include <vector>
29 
30 using namespace Acts;
31 using namespace Acts::Test;
32 using namespace Acts::Experimental;
33 
36 
37 namespace {
41 std::vector<std::shared_ptr<Acts::Surface>> unpackSurfaces(
42  const std::vector<const Acts::Surface*>& surfaces) {
43  std::vector<std::shared_ptr<Acts::Surface>> uSurfaces;
44  uSurfaces.reserve(surfaces.size());
45  for (const auto& s : surfaces) {
46  Surface* ncs = const_cast<Surface*>(s);
47  uSurfaces.push_back(ncs->getSharedPtr());
48  }
49  return uSurfaces;
50 }
51 
52 } // namespace
53 
54 BOOST_AUTO_TEST_SUITE(Detector)
55 
56 // Test the creation of a ring like structure
57 BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationRing) {
58  // Detector store
60  auto rSurfaces = cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0.,
61  55., -800, 2., 22u);
62 
63  auto endcapSurfaces = std::make_shared<LayerStructureBuilder::SurfacesHolder>(
64  unpackSurfaces(rSurfaces));
65  // Configure the layer structure builder
67  lsConfig.auxiliary = "*** Endcap with 22 surfaces ***";
68  lsConfig.surfacesProvider = endcapSurfaces;
69  lsConfig.binnings = {ProtoBinning(Acts::binPhi,
70  Acts::detail::AxisBoundaryType::Closed,
71  -M_PI, M_PI, 22u, 1u)};
72 
73  auto endcapBuilder = Acts::Experimental::LayerStructureBuilder(
74  lsConfig, Acts::getDefaultLogger("EndcapBuilder", Logging::VERBOSE));
75 
76  auto [surfaces0, volumes0, surfacesUpdator0, volumeUpdator0] =
77  endcapBuilder.construct(tContext);
78 
79  BOOST_CHECK(surfaces0.size() == 22u);
80  BOOST_CHECK(surfacesUpdator0.connected());
81  BOOST_CHECK(volumes0.empty());
82  BOOST_CHECK(volumeUpdator0.connected());
83 
84  using LayerSupport = Acts::Experimental::ProtoSupport;
85 
86  lsConfig.auxiliary = "*** Endcap with 22 surfaces + 1 support disc ***";
87  lsConfig.supports = {LayerSupport{
88  {15., 10., 10., 0., 0.}, Acts::Surface::SurfaceType::Disc, {binZ, binR}}};
90  lsConfig, Acts::getDefaultLogger("EndcapBuilder", Logging::VERBOSE));
91 
92  auto [surfaces1, volumes1, surfacesUpdator1, volumeUpdator1] =
93  endcapBuilder.construct(tContext);
94 
95  BOOST_CHECK(surfaces1.size() == 22u + 1u);
96  BOOST_CHECK(surfaces1.back()->type() == Acts::Surface::SurfaceType::Disc);
97  BOOST_CHECK(surfacesUpdator1.connected());
98  BOOST_CHECK(volumes1.empty());
99  BOOST_CHECK(volumeUpdator1.connected());
100 
101  lsConfig.auxiliary =
102  "*** Endcap with 22 surfaces + 1 support -> split into 11 planes ***";
103  lsConfig.supports = {LayerSupport{{15., 10., 10., 0., 0.},
104  Acts::Surface::SurfaceType::Disc,
105  {binZ, binR},
106  11u}};
108  lsConfig, Acts::getDefaultLogger("EndcapBuilder", Logging::VERBOSE));
109 
110  auto [surfaces2, volumes2, surfacesUpdator2, volumeUpdator2] =
111  endcapBuilder.construct(tContext);
112 
113  BOOST_CHECK(surfaces2.size() == 22u + 11u);
114  BOOST_CHECK(surfaces2.back()->type() == Acts::Surface::SurfaceType::Plane);
115  BOOST_CHECK(surfacesUpdator2.connected());
116  BOOST_CHECK(volumes2.empty());
117  BOOST_CHECK(volumeUpdator2.connected());
118 }
119 
120 // Test the creation of a cylindrical structure
121 BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationCylinder) {
123  auto cSurfaces = cGeometry.surfacesCylinder(dStore, 8.4, 36., 0.15, 0.145, 72,
124  3., 2., {32u, 14u});
125 
126  auto barrelSurfaces = std::make_shared<LayerStructureBuilder::SurfacesHolder>(
127  unpackSurfaces(cSurfaces));
128 
129  // Configure the layer structure builder
131  lsConfig.auxiliary = "*** Barrel with 448 surfaces ***";
132  lsConfig.surfacesProvider = barrelSurfaces;
133  lsConfig.binnings = {Acts::Experimental::ProtoBinning{
134  Acts::binZ, Acts::detail::AxisBoundaryType::Bound,
135  -480., 480., 14u, 1u},
137  Acts::binPhi, Acts::detail::AxisBoundaryType::Closed,
138  -M_PI, M_PI, 32u, 1u)};
139 
140  auto barrelBuilder = Acts::Experimental::LayerStructureBuilder(
141  lsConfig, Acts::getDefaultLogger("BarrelBuilder", Logging::VERBOSE));
142 
143  auto [surfaces0, volumes0, surfacesUpdator0, volumeUpdator0] =
144  barrelBuilder.construct(tContext);
145 
146  BOOST_CHECK(surfaces0.size() == 448u);
147  BOOST_CHECK(surfacesUpdator0.connected());
148  BOOST_CHECK(volumes0.empty());
149  BOOST_CHECK(volumeUpdator0.connected());
150 
151  using LayerSupport = Acts::Experimental::ProtoSupport;
152 
153  lsConfig.auxiliary = "*** Barrel with 448 surfaces + 1 support cylinder ***";
154  lsConfig.supports = {LayerSupport{{15., 10., 10., 0., 0.},
155  Acts::Surface::SurfaceType::Cylinder,
156  {binZ, binR}}};
157 
159  lsConfig, Acts::getDefaultLogger("BarrelBuilder", Logging::VERBOSE));
160 
161  auto [surfaces1, volumes1, surfacesUpdator1, volumeUpdator1] =
162  barrelBuilder.construct(tContext);
163 
164  BOOST_CHECK(surfaces1.size() == 448u + 1u);
165  BOOST_CHECK(surfacesUpdator1.connected());
166  BOOST_CHECK(volumes1.empty());
167  BOOST_CHECK(volumeUpdator1.connected());
168 
169  lsConfig.auxiliary =
170  "*** Barrel with 448 surfaces + 1 support -> split into 32 planes ***";
171  lsConfig.supports = {LayerSupport{{15., 10., 10., 0., 0.},
172  Acts::Surface::SurfaceType::Cylinder,
173  {binZ, binR},
174  32u}};
175 
177  lsConfig, Acts::getDefaultLogger("BarrelBuilder", Logging::VERBOSE));
178 
179  auto [surfaces2, volumes2, surfacesUpdator2, volumeUpdator2] =
180  barrelBuilder.construct(tContext);
181 
182  BOOST_CHECK(surfaces2.size() == 448u + 32u);
183  BOOST_CHECK(surfacesUpdator2.connected());
184  BOOST_CHECK(volumes2.empty());
185  BOOST_CHECK(volumeUpdator2.connected());
186 }
187 
188 BOOST_AUTO_TEST_SUITE_END()