9 #include <boost/test/unit_test.hpp>
31 #include <nlohmann/json.hpp>
37 std::vector<std::shared_ptr<Acts::Surface>> unpackSurfaces(
38 const std::vector<const Acts::Surface*>& surfaces) {
39 std::vector<std::shared_ptr<Acts::Surface>> uSurfaces;
40 uSurfaces.reserve(surfaces.size());
41 for (
const auto s : surfaces) {
43 uSurfaces.push_back(ncs->getSharedPtr());
55 BOOST_AUTO_TEST_SUITE(DetectorVolumeJsonConverter)
60 auto bounds = std::make_unique<Acts::CylinderVolumeBounds>(0., 50., 100.);
71 out.open(
"single-empty-volume.json");
72 out << jVolume.dump(4);
75 auto in = std::ifstream(
"single-empty-volume.json",
78 BOOST_CHECK(
in.good());
79 nlohmann::json jVolumeIn;
86 BOOST_CHECK(volumeIn->name() == volume->name());
88 volumeIn->transform(tContext).isApprox(volume->transform(tContext)));
89 BOOST_CHECK(volumeIn->surfaces().size() == volume->surfaces().size());
90 BOOST_CHECK(volumeIn->volumes().size() == volume->volumes().size());
95 detrayOptions.transformOptions.transpose =
true;
96 detrayOptions.surfaceOptions.transformOptions =
97 detrayOptions.transformOptions;
98 detrayOptions.portalOptions.surfaceOptions = detrayOptions.surfaceOptions;
101 tContext, *volume, {volume.get()}, detrayOptions);
103 out.open(
"single-empty-volume-detray.json");
104 out << jVolumeDetray.dump(4);
112 std::make_unique<Acts::CylinderVolumeBounds>(0., 50., 100.);
113 auto surfaceBounds = std::make_unique<Acts::CylinderBounds>(25., 100.);
115 auto cylinderSurface = Acts::Surface::makeShared<Acts::CylinderSurface>(
120 std::move(volumeBounds), {cylinderSurface}, {},
129 out.open(
"single-surface-volume.json");
130 out << jVolume.dump(4);
133 auto in = std::ifstream(
"single-surface-volume.json",
136 BOOST_CHECK(
in.good());
137 nlohmann::json jVolumeIn;
144 BOOST_CHECK(volumeIn->name() == volume->name());
146 volumeIn->transform(tContext).isApprox(volume->transform(tContext)));
147 BOOST_CHECK(volumeIn->surfaces().size() == volume->surfaces().size());
148 BOOST_CHECK(volumeIn->volumes().size() == volume->volumes().size());
154 auto rSurfaces =
cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0.,
157 auto endcapSurfaces = std::make_shared<
159 unpackSurfaces(rSurfaces));
162 lsConfig.
auxiliary =
"*** Endcap with 22 surfaces ***";
163 lsConfig.surfacesProvider = endcapSurfaces;
165 Acts::binPhi, Acts::detail::AxisBoundaryType::Closed, -M_PI, M_PI, 22
u,
169 std::make_shared<Acts::Experimental::LayerStructureBuilder>(
174 shapeConfig.
boundValues = {10, 100, 10., M_PI, 0.};
177 shapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder;
180 std::make_shared<Acts::Experimental::VolumeStructureBuilder>(
185 dvCfg.
auxiliary =
"*** Test 1 - Cylinder with internal Surface ***";
186 dvCfg.name =
"CylinderWithSurface";
187 dvCfg.externalsBuilder = shapeBuilder;
188 dvCfg.internalsBuilder = layerBuilder;
190 auto dvBuilder = std::make_shared<Acts::Experimental::DetectorVolumeBuilder>(
193 auto [
volumes, portals, roots] = dvBuilder->construct(tContext);
194 auto volume = volumes.front();
200 out.open(
"endcap-volume-with-surfaces.json");
201 out << jVolume.dump(4);
204 auto in = std::ifstream(
"endcap-volume-with-surfaces.json",
207 BOOST_CHECK(
in.good());
208 nlohmann::json jVolumeIn;
215 BOOST_CHECK(volumeIn->name() == volume->name());
217 volumeIn->transform(tContext).isApprox(volume->transform(tContext)));
218 BOOST_CHECK(volumeIn->surfaces().size() == volume->surfaces().size());
219 BOOST_CHECK(volumeIn->volumes().size() == volume->volumes().size());
224 out.open(
"endcap-volume-with-surfaces-closure.json");
225 out << jVolume.dump(4);
231 auto cSurfaces =
cGeometry.surfacesCylinder(dStore, 8.4, 36., 0.15, 0.145, 72,
234 auto barrelSurfaces = std::make_shared<
236 unpackSurfaces(cSurfaces));
240 lsConfig.
auxiliary =
"*** Barrel with 448 surfaces ***";
241 lsConfig.surfacesProvider = barrelSurfaces;
243 Acts::binZ, Acts::detail::AxisBoundaryType::Bound,
244 -480., 480., 14
u, 1
u},
247 -M_PI, M_PI, 32
u, 1
u)};
250 std::make_shared<Acts::Experimental::LayerStructureBuilder>(
255 shapeConfig.
boundValues = {60., 80., 800., M_PI, 0.};
256 shapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder;
259 std::make_shared<Acts::Experimental::VolumeStructureBuilder>(
264 dvCfg.
auxiliary =
"*** Test 1 - Cylinder with internal Surface ***";
265 dvCfg.name =
"BarrelWithSurfaces";
266 dvCfg.externalsBuilder = shapeBuilder;
267 dvCfg.internalsBuilder = barrelBuilder;
269 auto dvBuilder = std::make_shared<Acts::Experimental::DetectorVolumeBuilder>(
272 auto [
volumes, portals, roots] = dvBuilder->construct(tContext);
274 auto volume = volumes.front();
280 out.open(
"barrel-volume-with-surfaces.json");
281 out << jVolume.dump(4);
284 auto in = std::ifstream(
"barrel-volume-with-surfaces.json",
287 BOOST_CHECK(
in.good());
288 nlohmann::json jVolumeIn;
295 BOOST_CHECK(volumeIn->name() == volume->name());
297 volumeIn->transform(tContext).isApprox(volume->transform(tContext)));
298 BOOST_CHECK(volumeIn->surfaces().size() == volume->surfaces().size());
299 BOOST_CHECK(volumeIn->volumes().size() == volume->volumes().size());
304 out.open(
"barrel-volume-with-surfaces-closure.json");
305 out << jVolume.dump(4);
309 BOOST_AUTO_TEST_SUITE_END()