Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions Core/include/Acts/Geometry/IndexGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <algorithm>
#include <array>
#include <functional>
#include <set>
#include <string>
#include <vector>
Expand Down Expand Up @@ -233,17 +234,38 @@ class IndexGrid {
/// These are the cast parameters - copied from constructor
std::array<AxisDirection, grid_type::DIM> casts{};

/// A transform to be applied to the position
Transform3 transform = Transform3::Identity();
/// Abrivation of the delegate to transform the
/// external point into the grid's coordinate system
using Delegate_t =
std::function<const Transform3&(const GeometryContext& gctx)>;

/// @brief Constructor for a grid based surface attacher
/// Delegate to transform the external points into the grid's
/// coordinate system
Delegate_t toLocalFrame = nullptr;

/// Constructor for a grid based surface attacher
/// @param igrid the grid that is moved into this attacher
/// @param icasts is the cast values array
/// @param itr a transform applied to the global position
IndexGrid(grid_type&& igrid,
const std::array<AxisDirection, grid_type::DIM>& icasts,
const Transform3& itr = Transform3::Identity())
: grid(std::move(igrid)), casts(icasts), transform(itr) {}
: grid{std::move(igrid)},
casts{icasts},
toLocalFrame{
[itr](const GeometryContext& /*gctx*/) -> const Transform3& {
return itr;
}} {}
/// Constructor for a grid based surface attacher with alignable delegate
/// @param igrid the grid that is moved into this attacher
/// @param icasts is the cast values array
/// @param trfFunc a transform applied to the global position
IndexGrid(grid_type&& igrid,
const std::array<AxisDirection, grid_type::DIM>& icasts,
Delegate_t trfFunc)
: grid{std::move(igrid)},
casts{icasts},
toLocalFrame{std::move(trfFunc)} {}

IndexGrid() = delete;
};
Expand Down Expand Up @@ -299,7 +321,7 @@ struct IndexGridFiller {
// Cast the transform according to the grid binning
gridQueries.push_back(
GridAccessHelpers::castPosition<decltype(iGrid.grid)>(
iGrid.transform * ref, iGrid.casts));
iGrid.toLocalFrame(gctx) * ref, iGrid.casts));
}
ACTS_DEBUG(gridQueries.size() << " reference points generated.");
// These are now in the grid frame, can be expanded
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Navigation/IndexGridNavigationPolicy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class IndexGridNavigationPolicy : public INavigationPolicy {
const auto& surfaces = m_volume.surfaces();
const auto& indices =
m_indexGrid.grid.atPosition(GridAccessHelpers::castPosition<GridType>(
m_indexGrid.transform * position, m_indexGrid.casts));
m_indexGrid.toLocalFrame(gctx) * position, m_indexGrid.casts));
// Fill the navigation stream with the container
for (const auto& idx : indices) {
stream.addSurfaceCandidate(surfaces[idx], args.tolerance);
Expand Down
14 changes: 13 additions & 1 deletion Core/src/Geometry/AlignablePortalVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void AlignablePortalVisitor::visitVolume(TrackingVolume& volume) {
assert(alignable.back() != nullptr);
}
ACTS_DEBUG("AlignablePortalVisitor() - Associate "
<< alignable.size() << " porttals with the volume.");
<< alignable.size() << " portals with the volume.");
std::vector<Transform3> portalTrfBefore{};
// If the visitor is in inspection mode, cache the transforms of the
// unaligned portals
Expand Down Expand Up @@ -94,6 +94,18 @@ void AlignablePortalVisitor::visitVolume(TrackingVolume& volume) {
}
// Ensure that the portal remain where they were supposed to be
for (std::size_t p = 0; p < alignable.size(); ++p) {
if (!alignable[p]->isAlignable()) {
ACTS_ERROR("AlignablePortalVisitor() - the "
<< p << "-the portal remains not alignable");
throw std::runtime_error(
"AlignablePortalVisitor() - The portal alignment failed");
}
if (alignable[p]->isSensitive()) {
ACTS_ERROR("AlignablePortalVisitor() - the "
<< p << "-the portal became sensitive");
throw std::runtime_error(
"AlignablePortalVisitor() - The portal alignment failed");
}
if (!isSame(alignable[p]->localToGlobalTransform(m_gctx),
portalTrfBefore[p])) {
ACTS_ERROR("AlignablePortalVisitor() - the "
Expand Down
17 changes: 13 additions & 4 deletions Core/src/Geometry/MultiWireVolumeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,19 @@ MultiWireVolumeBuilder::createNavigationPolicyFactory() const {
axisB);

// The indexed grid to be filled from the navigation policy
IndexGrid<decltype(grid)> indexedGrid(
std::move(grid),
{protoAxisA.getAxisDirection(), protoAxisB.getAxisDirection()},
m_config.transform.inverse());
const auto* placement = m_config.alignablePlacement;
auto indexedGrid =
placement == nullptr
? IndexGrid<decltype(grid)>{std::move(grid),
{protoAxisA.getAxisDirection(),
protoAxisB.getAxisDirection()},
m_config.transform.inverse()}
: IndexGrid<decltype(grid)>{
std::move(grid),
{protoAxisA.getAxisDirection(), protoAxisB.getAxisDirection()},
[placement](const GeometryContext& gctx) -> const Transform3& {
return placement->localToGlobalTransform(gctx);
}};

TryAllNavigationPolicy::Config tryAllConfig;
tryAllConfig.portals = true;
Expand Down
17 changes: 15 additions & 2 deletions Core/src/Navigation/MultiLayerNavigationPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
#include "Acts/Geometry/ReferenceGenerators.hpp"
#include "Acts/Surfaces/detail/IntersectionHelper2D.hpp"
#include "Acts/Utilities/GridAccessHelpers.hpp"
#include "Acts/Utilities/StringHelpers.hpp"
namespace {
std::string printCandidates(const std::vector<const Acts::Surface*>& surfaces) {
std::stringstream sstr{};
for (const auto* surf : surfaces) {
sstr << " --- " << surf->geometryId() << std::endl;
}
return sstr.str();
}
} // namespace

namespace Acts::Experimental {

Expand Down Expand Up @@ -40,7 +50,9 @@ void MultiLayerNavigationPolicy::initializeCandidates(
NavigationPolicyState& /*state*/, AppendOnlyNavigationStream& stream,
const Logger& logger) const {
ACTS_VERBOSE("MultiLayerNavigationPolicy Candidates initialization for volume"
<< m_volume.volumeName());
<< m_volume.volumeName() << " @ "
<< toString(m_volume.localToGlobalTransform(gctx)));

const Transform3& itransform = m_volume.globalToLocalTransform(gctx);
const Vector3 locPosition = itransform * args.position;
const Vector3 locDirection = itransform.linear() * args.direction;
Expand All @@ -61,7 +73,8 @@ void MultiLayerNavigationPolicy::initializeCandidates(
}

ACTS_VERBOSE("MultiLayerNavigationPolicy Candidates reported "
<< surfCandidates.size() << " candidates");
<< surfCandidates.size() << " candidates. "
<< "\n " << printCandidates(surfCandidates));

// fill the navigation stream with the container
for (const auto* surf : surfCandidates) {
Expand Down
5 changes: 3 additions & 2 deletions Plugins/Json/src/IndexGridNavigationJsonConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ void writeSurfacesAndProjections(
std::array<Acts::AxisDirection, 2u> rphi = {
Acts::AxisDirection::AxisR, Acts::AxisDirection::AxisPhi};
auto pVertex = Acts::GridAccessHelpers::castPosition<
Acts::RegularDiscIndexGrid>(indexGrid.transform * vertex, rphi);
Acts::RegularDiscIndexGrid>(
indexGrid.toLocalFrame(gctx) * vertex, rphi);
// Update reference range
referenceRange[0] = std::min(referenceRange[0], pVertex[0]);
referenceRange[1] = std::max(referenceRange[1], pVertex[0]);
Expand All @@ -61,7 +62,7 @@ void writeSurfacesAndProjections(
// Write the projected vertices
jProjectedSurface.push_back(
Acts::GridAccessHelpers::castPosition<decltype(indexGrid.grid)>(
indexGrid.transform * vertex, indexGrid.casts));
indexGrid.toLocalFrame(gctx) * vertex, indexGrid.casts));
}
}
jProjectedSurfaces.push_back(jProjectedSurface);
Expand Down
Loading