Skip to content

Commit

Permalink
feat(geo): Add method to connect all outer links on portal
Browse files Browse the repository at this point in the history
This works for single cylinders and for cylinder stacks
  • Loading branch information
paulgessinger committed Aug 27, 2024
1 parent 0b42b41 commit fd8bf1f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Core/include/Acts/Geometry/PortalShell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class PortalShellBase {

virtual ~PortalShellBase() = default;

virtual void connectOuter(TrackingVolume& volume) = 0;

private:
};

Expand All @@ -51,6 +53,8 @@ class CylinderPortalShell : public PortalShellBase {
virtual const std::shared_ptr<Portal>& portalPtr(Face face) = 0;

virtual void setPortal(std::shared_ptr<Portal> portal, Face face) = 0;

void connectOuter(TrackingVolume& volume) override;
};

class SingleCylinderPortalShell : public CylinderPortalShell {
Expand Down
10 changes: 10 additions & 0 deletions Core/src/Geometry/PortalShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@

namespace Acts {

void CylinderPortalShell::connectOuter(TrackingVolume& volume) {
for (Face face : {PositiveDisc, NegativeDisc, OuterCylinder, InnerCylinder,
NegativePhiPlane, PositivePhiPlane}) {
auto* portalAtFace = portal(face);
if (portalAtFace != nullptr) {
portalAtFace->fill(volume);
}
}
}

SingleCylinderPortalShell::SingleCylinderPortalShell(TrackingVolume& volume) {
if (volume.volumeBounds().type() != VolumeBounds::BoundsType::eCylinder) {
throw std::invalid_argument("Invalid volume bounds type");
Expand Down
50 changes: 40 additions & 10 deletions Tests/UnitTests/Core/Geometry/PortalShellTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ using namespace Acts::UnitLiterals;
namespace Acts::Test {
GeometryContext gctx;

std::size_t getVolumeIndex() {
static std::size_t i = 1;
return i++;
}

auto makeVolume(auto&&... pars) {
TrackingVolume vol(Transform3::Identity(),
std::make_shared<CylinderVolumeBounds>(
std::forward<decltype(pars)>(pars)...));
vol.setVolumeName("cyl" + std::to_string(getVolumeIndex()));
return std::move(vol);
};

BOOST_AUTO_TEST_SUITE(PortalShellTests)

BOOST_AUTO_TEST_CASE(ConstructionFromVolume) {
Expand All @@ -35,15 +48,6 @@ BOOST_AUTO_TEST_CASE(ConstructionFromVolume) {
// | rMin > 0 | 1 | 3 |
// | rMin == 0 | 2 | 4 |

std::size_t i = 1;
auto makeVolume = [&](auto&&... pars) {
TrackingVolume vol(Transform3::Identity(),
std::make_shared<CylinderVolumeBounds>(
std::forward<decltype(pars)>(pars)...));
vol.setVolumeName("cyl" + std::to_string(i++));
return std::move(vol);
};

auto cyl1 = makeVolume(30_mm, 40_mm, 100_mm);
auto cyl2 = makeVolume(0_mm, 40_mm, 100_mm);
auto cyl3 = makeVolume(30_mm, 40_mm, 100_mm, 45_degree);
Expand Down Expand Up @@ -530,7 +534,33 @@ BOOST_AUTO_TEST_CASE(RDirection) {
}
}

// @TODO: Should CylinderStackPortalShell also do the fusing?
BOOST_AUTO_TEST_CASE(ConnectOuter) {
auto cyl1 = makeVolume(30_mm, 40_mm, 100_mm);
auto cyl2 = makeVolume(0_mm, 50_mm, 110_mm);

SingleCylinderPortalShell shell{cyl1};

using enum CylinderPortalShell::Face;
BOOST_CHECK_EQUAL(
shell.portal(OuterCylinder)->getLink(Direction::AlongNormal), nullptr);
BOOST_CHECK_EQUAL(
shell.portal(InnerCylinder)->getLink(Direction::OppositeNormal), nullptr);
BOOST_CHECK_EQUAL(shell.portal(PositiveDisc)->getLink(Direction::AlongNormal),
nullptr);
BOOST_CHECK_EQUAL(
shell.portal(NegativeDisc)->getLink(Direction::OppositeNormal), nullptr);

shell.connectOuter(cyl2);

BOOST_CHECK_NE(shell.portal(OuterCylinder)->getLink(Direction::AlongNormal),
nullptr);
BOOST_CHECK_NE(
shell.portal(InnerCylinder)->getLink(Direction::OppositeNormal), nullptr);
BOOST_CHECK_NE(shell.portal(PositiveDisc)->getLink(Direction::AlongNormal),
nullptr);
BOOST_CHECK_NE(shell.portal(NegativeDisc)->getLink(Direction::OppositeNormal),
nullptr);
}

BOOST_AUTO_TEST_SUITE_END() // CylinderStack
BOOST_AUTO_TEST_SUITE_END()
Expand Down

0 comments on commit fd8bf1f

Please sign in to comment.