Skip to content

Commit

Permalink
fix: Return nullptr if outside tracking geometry in `TrackingGeomet…
Browse files Browse the repository at this point in the history
…ry::lowestTrackingVolume` (#3481)

Currently `TrackingGeometry::lowestTrackingVolume` will always return at least the world volume even though the given position is not inside the world volume. In this PR I change the behavior to return `nullptr` in case we are outside the tracking geometry.

Same is done for `TrackingVolume::lowestTrackingVolume`. The rest are necessary fixes and downstream changes to make this work.

blocked by
- #3581
  • Loading branch information
andiwand authored Aug 31, 2024
1 parent 073fe42 commit c962d5a
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 13 deletions.
Binary file modified CI/physmon/reference/trackfinding_ttbar_pu200/performance_ckf.root
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Core/include/Acts/Geometry/TrackingVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ class TrackingVolume : public Volume {
/// static layers
std::unique_ptr<const LayerArray> m_confinedLayers = nullptr;

/// Array of Volumes inside the Volume when actin as container
/// Array of Volumes inside the Volume when acting as container
std::shared_ptr<const TrackingVolumeArray> m_confinedVolumes = nullptr;

/// confined dense
Expand Down
5 changes: 5 additions & 0 deletions Core/include/Acts/Propagator/Navigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ class Navigator {
: nullptr;
if (state.navigation.startVolume != nullptr) {
ACTS_VERBOSE(volInfo(state) << "Start volume resolved.");
} else {
ACTS_VERBOSE(volInfo(state)
<< "No start volume resolved. Nothing left to do.");
// set the navigation break
state.navigation.navigationBreak = true;
}
}

Expand Down
13 changes: 5 additions & 8 deletions Core/src/Geometry/TrackingGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,7 @@ Acts::TrackingGeometry::~TrackingGeometry() = default;

const Acts::TrackingVolume* Acts::TrackingGeometry::lowestTrackingVolume(
const GeometryContext& gctx, const Acts::Vector3& gp) const {
const TrackingVolume* searchVolume = m_world.get();
const TrackingVolume* currentVolume = nullptr;
while (currentVolume != searchVolume && (searchVolume != nullptr)) {
currentVolume = searchVolume;
searchVolume = searchVolume->lowestTrackingVolume(gctx, gp);
}
return currentVolume;
return m_world->lowestTrackingVolume(gctx, gp);
}

const Acts::TrackingVolume* Acts::TrackingGeometry::highestTrackingVolume()
Expand All @@ -63,7 +57,10 @@ Acts::TrackingGeometry::highestTrackingVolumeShared() const {

const Acts::Layer* Acts::TrackingGeometry::associatedLayer(
const GeometryContext& gctx, const Acts::Vector3& gp) const {
const TrackingVolume* lowestVol = (lowestTrackingVolume(gctx, gp));
const TrackingVolume* lowestVol = lowestTrackingVolume(gctx, gp);
if (lowestVol == nullptr) {
return nullptr;
}
return lowestVol->associatedLayer(gctx, gp);
}

Expand Down
11 changes: 9 additions & 2 deletions Core/src/Geometry/TrackingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,18 @@ TrackingVolume::TrackingVolume(const Transform3& transform,
TrackingVolume::~TrackingVolume() = default;

const TrackingVolume* TrackingVolume::lowestTrackingVolume(
const GeometryContext& /*gctx*/, const Vector3& position,
const GeometryContext& gctx, const Vector3& position,
const double tol) const {
if (!inside(position, tol)) {
return nullptr;
}

// confined static volumes - highest hierarchy
if (m_confinedVolumes) {
return (m_confinedVolumes->object(position).get());
const TrackingVolume* volume = m_confinedVolumes->object(position).get();
if (volume != nullptr) {
return volume->lowestTrackingVolume(gctx, position, tol);
}
}

// search for dense volumes
Expand Down
7 changes: 5 additions & 2 deletions Tests/UnitTests/Core/Geometry/CuboidVolumeBuilderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,16 @@ BOOST_AUTO_TEST_CASE(CuboidVolumeBuilderTest) {
std::unique_ptr<const TrackingGeometry> detector =
tgb.trackingGeometry(tgContext);
BOOST_CHECK_EQUAL(
detector->lowestTrackingVolume(tgContext, Vector3(1., 0., 0.))
detector->lowestTrackingVolume(tgContext, Vector3(1_mm, 0_mm, 0_mm))
->volumeName(),
volumeConfig.name);
BOOST_CHECK_EQUAL(
detector->lowestTrackingVolume(tgContext, Vector3(-1., 0., 0.))
detector->lowestTrackingVolume(tgContext, Vector3(-1_mm, 0_mm, 0_mm))
->volumeName(),
volumeConfig2.name);
BOOST_CHECK_EQUAL(
detector->lowestTrackingVolume(tgContext, Vector3(1000_m, 0_m, 0_m)),
nullptr);
}

} // namespace Acts::Test

0 comments on commit c962d5a

Please sign in to comment.