9 #include <boost/test/unit_test.hpp>
39 namespace Experimental {
45 using namespace Experimental;
46 using namespace Experimental::detail;
47 using namespace Experimental::detail::CylindricalDetectorHelper;
52 std::vector<std::shared_ptr<DetectorVolume>>
eVolumes = {};
56 BOOST_AUTO_TEST_SUITE(Experimental)
61 auto cBounds0 = std::make_unique<CylinderVolumeBounds>(0., 100., 100);
67 std::make_unique<CylinderVolumeBounds>(0., 100., 100, 0.2, 1.);
72 ACTS_INFO(
"*** Test: nullptr in the list of volumes");
75 std::vector<std::shared_ptr<DetectorVolume>> volumesWithNullptr = {
76 volume0,
nullptr, volume1};
78 std::invalid_argument);
80 ACTS_INFO(
"*** Test: non-cylinder in the list of volumes");
82 auto cubeBounds = std::make_unique<CuboidVolumeBounds>(100., 100., 100);
88 std::vector<std::shared_ptr<DetectorVolume>> volumesWithCube = {
89 volume0, volume1, cube};
91 std::invalid_argument);
93 ACTS_INFO(
"*** Test: non-aligned volume in the list of volumes");
98 auto cBounds2 = std::make_unique<CylinderVolumeBounds>(0., 100., 100);
104 std::vector<std::shared_ptr<DetectorVolume>> volumesWithNonaligned = {
105 volume0, volume1, volume2};
107 std::invalid_argument);
112 ACTS_INFO(
"*** Test: connect DetectorVolumes in R, create proto container");
114 std::vector<ActsScalar> testOpenings = {M_PI, 0.5 * M_PI};
116 std::vector<ActsScalar> radii = {0., 10., 100., 200.};
120 for (
auto [io, opening] :
enumerate(testOpenings)) {
121 ACTS_INFO(
" -> test with phi opening: " << opening);
123 std::vector<std::shared_ptr<DetectorVolume>> rVolumes = {};
127 auto cBounds = std::make_unique<CylinderVolumeBounds>(
128 radii[
i - 1
u],
r, halfZ, opening, 0.);
137 BOOST_CHECK(rVolumes[0
u]->portalPtrs()[2
u] ==
138 rVolumes[1
u]->portalPtrs()[3
u]);
139 BOOST_CHECK(rVolumes[1
u]->portalPtrs()[2
u] ==
140 rVolumes[2
u]->portalPtrs()[3
u]);
141 BOOST_CHECK(rVolumes[0
u]->portalPtrs()[0
u] ==
142 rVolumes[1
u]->portalPtrs()[0
u]);
143 BOOST_CHECK(rVolumes[1
u]->portalPtrs()[0
u] ==
144 rVolumes[2
u]->portalPtrs()[0
u]);
145 BOOST_CHECK(rVolumes[0
u]->portalPtrs()[1
u] ==
146 rVolumes[1
u]->portalPtrs()[1
u]);
147 BOOST_CHECK(rVolumes[1
u]->portalPtrs()[1
u] ==
148 rVolumes[2
u]->portalPtrs()[1
u]);
149 BOOST_CHECK(rVolumes[0
u]->portalPtrs()[0
u] == protoContainer[0
u]);
150 BOOST_CHECK(rVolumes[0u]->portalPtrs()[1u] == protoContainer[1u]);
159 const auto& rBoundaries = boundaries[0
u];
160 const auto& zBoundaries = boundaries[1
u];
163 std::vector<ActsScalar> zvalues = {-halfZ, halfZ};
164 BOOST_CHECK(radii == rBoundaries);
165 BOOST_CHECK(zvalues == zBoundaries);
169 ACTS_INFO(
"*** Test: faulty empty vector");
171 std::invalid_argument);
174 ACTS_INFO(
"*** Test: volumes are not matching in R");
176 auto cBounds00 = std::make_unique<CylinderVolumeBounds>(0., 100., 100);
181 auto cBounds01 = std::make_unique<CylinderVolumeBounds>(101., 200., 100);
186 std::vector<std::shared_ptr<DetectorVolume>> volumesNotMatching = {volume00,
191 ACTS_INFO(
"*** Test: volume bounds are not aligned");
193 shifted.pretranslate(
Vector3(0., 0., 10.));
195 auto cBounds10 = std::make_unique<CylinderVolumeBounds>(0., 100., 100);
200 auto cBounds11 = std::make_unique<CylinderVolumeBounds>(100., 200., 90);
205 std::vector<std::shared_ptr<DetectorVolume>> volumesNotAligned = {volume10,
213 ACTS_INFO(
"*** Test: connect DetectorVolumes in Z, create proto container");
216 std::vector<Transform3> transforms = {Transform3::Identity()};
217 std::vector<std::array<ActsScalar, 2>> radii = {{0., 100.}, {20., 120.}};
218 std::vector<ActsScalar> zValues = {-100., -20, 10., 100., 200.};
221 ACTS_INFO(
" -> test series with transform id " <<
it);
225 ACTS_INFO(
" -> test series with radii setup "
226 << radii[ir][0
u] <<
", " << radii[ir][1
u]);
229 std::vector<std::shared_ptr<DetectorVolume>> zVolumes = {};
232 auto cBounds = std::make_unique<CylinderVolumeBounds>(
233 r[0], r[1], 0.5 * (
z - zValues[
i - 1
u]));
237 ti.pretranslate(
t.translation() +
238 zCenter *
t.rotation().matrix().col(2));
239 ti.prerotate(
t.rotation());
252 BOOST_CHECK(zVolumes[0u]->portalPtrs()[1u] ==
253 zVolumes[1u]->portalPtrs()[0u]);
254 BOOST_CHECK(zVolumes[1u]->portalPtrs()[1u] ==
255 zVolumes[2u]->portalPtrs()[0u]);
256 BOOST_CHECK(zVolumes[2u]->portalPtrs()[1u] ==
257 zVolumes[3u]->portalPtrs()[0u]);
258 BOOST_CHECK(protoContainer[0u] == zVolumes[0u]->portalPtrs()[0u]);
259 BOOST_CHECK(protoContainer[1u] == zVolumes[3u]->portalPtrs()[1u]);
262 std::vector<unsigned int> checkShared = {2u};
263 if (radii[ir][0u] > 0.) {
264 checkShared.push_back(3u);
267 for (
const auto& ip : checkShared) {
268 BOOST_CHECK(zVolumes[0u]->portalPtrs()[ip] ==
269 zVolumes[1u]->portalPtrs()[ip]);
270 BOOST_CHECK(zVolumes[1u]->portalPtrs()[ip] ==
271 zVolumes[2u]->portalPtrs()[ip]);
272 BOOST_CHECK(zVolumes[2u]->portalPtrs()[ip] ==
273 zVolumes[3u]->portalPtrs()[ip]);
274 BOOST_CHECK(protoContainer[ip] == zVolumes[0u]->portalPtrs()[ip]);
284 std::invalid_argument);
287 auto cBounds00 = std::make_unique<CylinderVolumeBounds>(0., 100., 100);
293 auto cBounds01 = std::make_unique<CylinderVolumeBounds>(0., 105., 100);
299 std::vector<std::shared_ptr<DetectorVolume>> volumesNonalignedBounds = {
305 auto cBounds10 = std::make_unique<CylinderVolumeBounds>(0., 100., 100);
311 auto cBounds11 = std::make_unique<CylinderVolumeBounds>(0., 100., 100);
317 std::vector<std::shared_ptr<DetectorVolume>> volumesNotAttached = {volume10,
325 ACTS_INFO(
"*** Test: connect DetectorVolumes in Phi, create proto container");
327 std::vector<Transform3> transforms = {Transform3::Identity()};
328 unsigned int phiSectors = 5;
332 ACTS_INFO(
" -> test series with transform id " <<
it);
334 std::vector<std::shared_ptr<DetectorVolume>> phiVolumes = {};
335 for (
unsigned int i = 0;
i < phiSectors; ++
i) {
336 auto cBounds = std::make_unique<CylinderVolumeBounds>(
337 10., 100., 100., phiHalfSector,
338 -M_PI + (2
u *
i + 1
u) * phiHalfSector);
349 std::vector<unsigned int> checkShared = {0
u, 1
u, 2
u, 3u};
353 auto last = phiVolumes[iv - 1
u];
354 for (
const auto& ch : checkShared) {
355 BOOST_CHECK(current->portalPtrs()[ch] == last->portalPtrs()[ch]);
366 std::invalid_argument);
372 "*** Test: wrap volume in Z-R with CutoutCylinderVolume, create proto "
376 std::vector<Transform3> transforms = {Transform3::Identity()};
379 std::vector<std::array<ActsScalar, 3u>> radii = {{0., 100., 500.},
387 ACTS_INFO(
" Test series with transform id " <<
it);
391 ACTS_INFO(
" -> test series with radii setup " << radii[ir][0
u] <<
", "
394 std::vector<std::shared_ptr<DetectorVolume>>
volumes = {};
398 auto iBounds = std::make_unique<CylinderVolumeBounds>(
399 radii[ir][0
u], radii[ir][1
u], innerHalfZ);
405 auto wBounds = std::make_unique<CutoutCylinderVolumeBounds>(
406 radii[ir][0
u], radii[ir][1
u], radii[ir][2
u], outerHalfZ, innerHalfZ);
418 std::invalid_argument);
423 ACTS_INFO(
"*** Test: create a container in Z-R.");
427 std::vector<ActsScalar> innerMostRadii = {0., 2.};
429 for (
auto [ir, imr] :
enumerate(innerMostRadii)) {
430 ACTS_INFO(
" -> test series innermost radius setup "
431 << innerMostRadii[ir]);
434 std::vector<ActsScalar> radii = {25., 100., 200.};
439 std::make_unique<CylinderVolumeBounds>(imr, radii[0
u], halfZ);
446 std::map<unsigned int, std::shared_ptr<Portal>> ipContainer;
447 for (
auto [ip,
p] :
enumerate(innerPipe->portalPtrs())) {
452 std::vector<std::shared_ptr<DetectorVolume>> rVolumes = {};
457 std::make_unique<CylinderVolumeBounds>(radii[
i - 1
u],
r, halfZ);
466 std::vector<ActsScalar> zValues = {-200., -120, 10., 100., 200.};
467 std::vector<std::shared_ptr<DetectorVolume>> zVolumes = {};
470 auto cBounds = std::make_unique<CylinderVolumeBounds>(
471 200., 300., 0.5 * (
z - zValues[
i - 1
u]));
475 ti.pretranslate(
transform.translation() +
476 zCenter *
transform.rotation().matrix().col(2));
487 tContext, {ipContainer, protoContainerInR, protoContainerInZ}, {},
492 auto necBounds = std::make_unique<CylinderVolumeBounds>(imr, 300., 50.);
494 auto necTransform = Transform3::Identity();
495 necTransform.pretranslate(
Vector3(0., 0., -250));
500 std::map<unsigned int, std::shared_ptr<Portal>> necContainer;
501 for (
auto [ip,
p] :
enumerate(necVolume->portalPtrs())) {
502 necContainer[ip] =
p;
506 auto pecInnerBounds =
507 std::make_unique<CylinderVolumeBounds>(imr, 175., 100.);
509 auto pecOuterBounds =
510 std::make_unique<CylinderVolumeBounds>(175., 300., 100.);
512 auto pecTransform = Transform3::Identity();
513 pecTransform.pretranslate(
Vector3(0., 0., 300));
521 std::vector<std::shared_ptr<DetectorVolume>> pecVolumes = {pecInner,
529 std::vector<std::shared_ptr<DetectorVolume>> dVolumes;
530 dVolumes.push_back(innerPipe);
531 dVolumes.push_back(necVolume);
532 dVolumes.insert(dVolumes.end(), rVolumes.begin(), rVolumes.end());
533 dVolumes.insert(dVolumes.end(), zVolumes.begin(), zVolumes.end());
534 dVolumes.push_back(pecInner);
535 dVolumes.push_back(pecOuter);
544 ACTS_INFO(
"*** Test: create a container in Z-R by wrapping.");
547 std::vector<std::array<ActsScalar, 3u>> radii = {{0., 100., 500.},
552 ActsScalar innerEndcapHalfZ = 0.5 * (innerHalfZ - innerBarrelHalfZ);
560 ACTS_INFO(
" -> test series innermost radius setup " << radii[ir][0
u]);
563 std::vector<std::shared_ptr<DetectorVolume>> iVolumes = {};
565 auto iNecBounds = std::make_unique<CylinderVolumeBounds>(
566 radii[ir][0
u], radii[ir][1
u], innerEndcapHalfZ);
568 ntf.pretranslate(
Vector3(0., 0., -innerBarrelHalfZ - innerEndcapHalfZ));
573 auto iBarrelBounds = std::make_unique<CylinderVolumeBounds>(
574 radii[ir][0
u], radii[ir][1
u], innerBarrelHalfZ);
579 auto iPecBounds = std::make_unique<CylinderVolumeBounds>(
580 radii[ir][0
u], radii[ir][1
u], innerEndcapHalfZ);
582 ptf.pretranslate(
Vector3(0., 0., innerBarrelHalfZ + innerEndcapHalfZ));
590 auto wBounds = std::make_unique<CutoutCylinderVolumeBounds>(
591 radii[ir][0
u], radii[ir][1
u], radii[ir][2
u], outerHalfZ, innerHalfZ);
596 std::vector<DetectorComponent::PortalContainer> containers;
597 containers.push_back(innerContainer);
600 for (
auto [ip,
p] :
enumerate(wVolume->portalPtrs())) {
601 outerContainer[ip] =
p;
603 containers.push_back(outerContainer);
612 auto innerB = std::make_unique<CylinderVolumeBounds>(0., 20., 100);
617 auto middleLB = std::make_unique<CylinderVolumeBounds>(20., 60., 5);
618 auto middleLT = Transform3::Identity();
619 middleLT.pretranslate(
Vector3(0., 0., -95));
624 auto middleDB = std::make_unique<CylinderVolumeBounds>(20., 40., 90);
629 auto middleUB = std::make_unique<CylinderVolumeBounds>(40., 60., 90);
634 auto middleRB = std::make_unique<CylinderVolumeBounds>(20., 60., 5);
635 auto middleRT = Transform3::Identity();
636 middleRT.pretranslate(
Vector3(0., 0., 95));
641 auto outerB = std::make_unique<CylinderVolumeBounds>(60., 120., 100);
646 std::vector<std::shared_ptr<DetectorVolume>>
volumes = {
647 innerV, middleLV, middleDV, middleUV, middleRV, outerV};
650 BOOST_CHECK(boundaries.size() == 3
u);
652 std::vector<ActsScalar> rBoundaries = {0., 20., 40., 60., 120.};
653 BOOST_CHECK(boundaries[0
u] == rBoundaries);
655 std::vector<ActsScalar> zBoundaries = {-100., -90., 90., 100.};
656 BOOST_CHECK(boundaries[1
u] == zBoundaries);
657 BOOST_CHECK(boundaries[2
u].
size() == 2
u);
660 BOOST_AUTO_TEST_SUITE_END()