9 #include <boost/test/unit_test.hpp>
37 #include <nlohmann/json.hpp>
44 std::vector<std::shared_ptr<Acts::Surface>> unpackSurfaces(
45 const std::vector<const Acts::Surface*>& surfaces) {
46 std::vector<std::shared_ptr<Acts::Surface>> uSurfaces;
47 uSurfaces.reserve(surfaces.size());
48 for (
const auto s : surfaces) {
50 uSurfaces.push_back(ncs->getSharedPtr());
71 BOOST_AUTO_TEST_SUITE(DetectorJsonConverter)
78 auto bounds = std::make_unique<Acts::CylinderVolumeBounds>(0., 50., 100.);
84 std::vector<std::shared_ptr<Acts::Experimental::DetectorVolume>>
volumes = {
93 out.open(
"single-empty-volume-detector.json");
94 out << jDetector.dump(4);
103 auto bounds = std::make_unique<Acts::CylinderVolumeBounds>(0., 50., 100.);
105 auto cylinderBounds = std::make_shared<Acts::CylinderBounds>(30., 90.);
107 Acts::Surface::makeShared<Acts::CylinderSurface>(
nominal, cylinderBounds);
114 std::vector<std::shared_ptr<Acts::Experimental::DetectorVolume>>
volumes = {
123 out.open(
"single-volume-one-surface-detector.json");
124 out << jDetector.dump(4);
127 out.open(
"single-volume-one-surface-detector-detray.json");
139 std::vector<std::shared_ptr<Acts::Experimental::IDetectorComponentBuilder>>
143 auto rSurfaces =
cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0.,
146 auto endcapSurfaces = std::make_shared<
148 unpackSurfaces(rSurfaces));
151 lsConfig.
auxiliary =
"*** Endcap with 22 surfaces ***";
152 lsConfig.surfacesProvider = endcapSurfaces;
154 Acts::binPhi, Acts::detail::AxisBoundaryType::Closed, -M_PI, M_PI, 22
u,
158 std::make_shared<Acts::Experimental::LayerStructureBuilder>(
163 shapeConfig.
boundValues = {20, 100, 10., M_PI, 0.};
166 shapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder;
169 std::make_shared<Acts::Experimental::VolumeStructureBuilder>(
175 dvCfg.externalsBuilder = shapeBuilder;
176 dvCfg.internalsBuilder = layerBuilder;
179 std::make_shared<Acts::Experimental::DetectorVolumeBuilder>(
182 endcapBuilders.push_back(dvBuilder);
187 innerShapeConfig.
boundValues = {20., 60., 700., M_PI, 0.};
188 innerShapeConfig.
boundsType = Acts::VolumeBounds::BoundsType::eCylinder;
190 auto innerShapeBuilder =
191 std::make_shared<Acts::Experimental::VolumeStructureBuilder>(
196 ivCfg.
name =
"InnerBarrelGap";
197 ivCfg.externalsBuilder = innerShapeBuilder;
199 auto ivBuilder = std::make_shared<Acts::Experimental::DetectorVolumeBuilder>(
203 auto cSurfaces =
cGeometry.surfacesCylinder(dStore, 8.4, 36., 0.15, 0.145, 72,
206 auto barrelSurfaces = std::make_shared<
208 unpackSurfaces(cSurfaces));
212 lsConfig.
auxiliary =
"*** Barrel with 448 surfaces ***";
213 lsConfig.surfacesProvider = barrelSurfaces;
215 Acts::binZ, Acts::detail::AxisBoundaryType::Bound,
216 -480., 480., 14
u, 1
u},
219 -M_PI, M_PI, 32
u, 1
u)};
222 std::make_shared<Acts::Experimental::LayerStructureBuilder>(
227 shapeConfig.
boundValues = {60., 80., 700., M_PI, 0.};
228 shapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder;
231 std::make_shared<Acts::Experimental::VolumeStructureBuilder>(
236 dvCfg.
name =
"BarrelWithSurfaces";
237 dvCfg.externalsBuilder = shapeBuilder;
238 dvCfg.internalsBuilder = barrelBuilder;
240 auto dvBuilder = std::make_shared<Acts::Experimental::DetectorVolumeBuilder>(
245 outerShapeConfig.
boundValues = {80., 100., 700., M_PI, 0.};
246 outerShapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder;
248 auto outerShapeBuilder =
249 std::make_shared<Acts::Experimental::VolumeStructureBuilder>(
254 ovCfg.
name =
"OuterBarrelGap";
255 ovCfg.externalsBuilder = outerShapeBuilder;
257 auto ovBuilder = std::make_shared<Acts::Experimental::DetectorVolumeBuilder>(
262 ccBarrelBuilderCfg.
builders = {ivBuilder, dvBuilder, ovBuilder};
265 auto ccBarrelBuilder =
266 std::make_shared<Acts::Experimental::CylindricalContainerBuilder>(
272 ccBarrelEcBuilderCfg.
builders = {endcapBuilders[0
u], ccBarrelBuilder,
276 auto ccBarrelEndcapBuilder =
277 std::make_shared<Acts::Experimental::CylindricalContainerBuilder>(
283 bpShapeConfig.
boundValues = {0., 20., 720., M_PI, 0.};
284 bpShapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder;
286 auto bpShapeBuilder =
287 std::make_shared<Acts::Experimental::VolumeStructureBuilder>(
292 bpCfg.
name =
"BeamPipe";
293 bpCfg.externalsBuilder = bpShapeBuilder;
295 auto bpBuilder = std::make_shared<Acts::Experimental::DetectorVolumeBuilder>(
300 detCompBuilderCfg.
builders = {bpBuilder, ccBarrelEndcapBuilder};
303 auto detCompBuilder =
304 std::make_shared<Acts::Experimental::CylindricalContainerBuilder>(
309 std::make_shared<Acts::Experimental::GeometryIdGenerator>(gigConfig);
312 detBuilderCfg.
name =
"Detector";
313 detBuilderCfg.builder = detCompBuilder;
314 detBuilderCfg.geoIdGenerator = gig;
317 std::make_shared<Acts::Experimental::DetectorBuilder>(detBuilderCfg);
319 auto detector = detBuilder->construct(tContext);
325 out.open(
"barrel-endcap-detector.json");
326 out << jDetector.dump(4);
329 auto in = std::ifstream(
"barrel-endcap-detector.json",
332 BOOST_CHECK(
in.good());
333 nlohmann::json jDetectorIn;
340 BOOST_CHECK(detectorIn->name() == detector->name());
342 auto jDetectorInOut =
345 out.open(
"barrel-endcap-detector-closure.json");
346 out << jDetectorInOut.dump(4);
350 tContext, *detector, detrayOptions());
352 out.open(
"barrel-endcap-detector-detray.json");
353 out << jDetectorDetray.dump(4);
357 BOOST_AUTO_TEST_SUITE_END()