Skip to content

Commit

Permalink
chore: move new style navigation into Core/Navigation (#1841)
Browse files Browse the repository at this point in the history
This PR moves the new navigation classes for the still `Experimental` geometry into a separate `Navigation` folder in order to better separate `Geometry` and `Navigation` objects.

The following classes, files and definitions build the new-style navigation approach:

* `NavigationDelegates.hpp` this files defines the different navigation structs/functions following the `Delegate=` implementation (or `OwnedDelegate` if needed)

* `NavigationState` a struct that holds navigation candidates (a `NavigationCandidate` is either a `Surface` or a `Portal`, this should be the state of the of the new `Experimental::Navigator` or at least attached to it

* `NavigationStateUpdators` these are updaters that are attached to `DetectorVolume` and `PortalObjects` that allow to update the `NavigationCandidate` list during propagation

* `DetectorVolumeFinders` are delegates that allow to find an associated `DetectorVolume` purely from position information, these can exist as brute-force (tryAll), grid (Indexed) or future boundary box implementations

* `SurfaceCandidateUpdators` are updaters that fill the surfaces within a volume into the `NavigationState`, they are pluggable components into the `NavigationStateUpdators`
  • Loading branch information
asalzburger committed Feb 9, 2023
1 parent af53024 commit a141736
Show file tree
Hide file tree
Showing 26 changed files with 178 additions and 106 deletions.
2 changes: 1 addition & 1 deletion Core/include/Acts/Geometry/Detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "Acts/Definitions/Common.hpp"
#include "Acts/Geometry/DetectorVolume.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/NavigationDelegates.hpp"
#include "Acts/Navigation/NavigationDelegates.hpp"
#include "Acts/Utilities/Delegate.hpp"

#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Geometry/DetectorVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#include "Acts/Definitions/Common.hpp"
#include "Acts/Geometry/Extent.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/NavigationDelegates.hpp"
#include "Acts/Geometry/NavigationState.hpp"
#include "Acts/Geometry/VolumeBounds.hpp"
#include "Acts/Material/IVolumeMaterial.hpp"
#include "Acts/Navigation/NavigationDelegates.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Utilities/BoundingBox.hpp"
#include "Acts/Utilities/Delegate.hpp"
Expand Down
7 changes: 7 additions & 0 deletions Core/include/Acts/Geometry/Extent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ class Extent {
return 0.5 * (m_range[bValue].min() + m_range[bValue].max());
}

/// Access the parameter internval
///
/// @param bValue the binning identification
ActsScalar interval(BinningValue bValue) const {
return m_range[bValue].size();
}

/// Contains check
///
/// @param rhs the extent that is check if it is contained
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Geometry/Portal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "Acts/Definitions/Common.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/Geometry/NavigationDelegates.hpp"
#include "Acts/Geometry/NavigationState.hpp"
#include "Acts/Navigation/NavigationDelegates.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Surfaces/BoundaryCheck.hpp"
#include "Acts/Surfaces/Surface.hpp"

Expand Down
27 changes: 25 additions & 2 deletions Core/include/Acts/Geometry/ProtoDetector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,32 @@
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/BinningData.hpp"

#include <functional>
#include <map>
#include <optional>
#include <string>
#include <vector>

namespace Acts {

struct ProtoVolume;

namespace Experimental {
class DetectorVolume;
class Portal;

/// Current volumes (connected)
using DetectorVolumes = std::vector<std::shared_ptr<DetectorVolume>>;
/// Current shell (i.e. outside portals)
using ProtoContainer = std::map<unsigned int, std::shared_ptr<Portal>>;
/// Current block (volumes and shell)
using DetectorBlock = std::tuple<DetectorVolumes, ProtoContainer>;

/// The detector builder function
using DetectorBlockBuilder = std::function<void(
DetectorBlock&, const GeometryContext&, Acts::Logging::Level)>;
} // namespace Experimental

/// A proto volume description being used to define an overall
/// structure of either a TrackingVolume or Experimental::DetectorVolume
struct ProtoVolume {
Expand All @@ -45,12 +65,15 @@ struct ProtoVolume {
/// The extent of this volume
Extent extent;

/// Information about internal structure
/// Information about internal structure - legacy building
std::optional<InternalStructure> internal = std::nullopt;

/// Information about container structure
/// Information about container structure - legacy building
std::optional<ContainerStructure> container = std::nullopt;

/// An attached Detector volume Builder - new detector schema
Experimental::DetectorBlockBuilder blockBuilder;

/// Define an operator==
///
/// @param ptVolume the proto volume to be checked
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Geometry/detail/PortalGenerators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/Portal.hpp"
#include "Acts/Geometry/VolumeBounds.hpp"
#include "Acts/Geometry/detail/DetectorVolumeUpdators.hpp"
#include "Acts/Navigation/DetectorVolumeUpdators.hpp"
#include "Acts/Utilities/Helpers.hpp"

#include <exception>
Expand Down
56 changes: 55 additions & 1 deletion Core/include/Acts/Geometry/detail/PortalHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,60 @@ defaultPortalAndSubPortalGenerator() {
return pGenerator;
}

/// Definition of a portal replacement when building proto containers
/// It consists of the new portal, the index, the direction, the parameters
/// gathered from the sub volumes, the binning description
using PortalReplacement =
std::tuple<std::shared_ptr<Experimental::Portal>, unsigned int,
NavigationDirection, std::vector<ActsScalar>, BinningValue>;

/// @brief Create and attach the multi link updator
///
/// @param gctx the geometry context
/// @param volumes are the volumes that are pointed to
/// @param pReplacements are the portal replacements that are newly connected
///
///
void attachDetectorVolumeUpdators(
const GeometryContext& gctx,
const std::vector<std::shared_ptr<DetectorVolume>>& volumes,
std::vector<PortalReplacement>& pReplacements) {
// Unpack to navigation bare points
auto cVolumes = unpack_shared_const_vector(volumes);
// Set to the contructed portals (p), at index (i), in direction (d)
// using boundaries and binning
for (auto& [p, i, dir, boundaries, binning] : pReplacements) {
// Check if the boundaries need a transform
const auto pTransform = p->surface().transform(gctx);
// Creating a link to the mother
auto volumes1D = std::make_unique<const BoundVolumesGrid1Impl>(
boundaries, binning, cVolumes, pTransform.inverse());
DetectorVolumeUpdator dVolumeUpdator;
dVolumeUpdator.connect<&BoundVolumesGrid1Impl::update>(
std::move(volumes1D));
p->assignDetectorVolumeUpdator(dir, std::move(dVolumeUpdator), volumes);
}
}

/// @brief Method that strips out attached volumes from portals
///
/// @note it throws an exception if both sides are already taken
///
/// @param portal the portal to be resolved
///
/// @return a vector of attached volumes
std::vector<std::shared_ptr<DetectorVolume>> attachedDetectorVolumes(
Portal& portal) noexcept(false) {
auto& attachedVolumes = portal.attachedDetectorVolumes();
if (not attachedVolumes[0u].empty() and not attachedVolumes[1u].empty()) {
throw std::invalid_argument(
"PortalHelper: trying to get attachedVolumes from already populated "
"portal.");
}
unsigned int iu = attachedVolumes[0u].empty() ? 1u : 0u;
return attachedVolumes[iu];
}

} // namespace detail
} // namespace Experimental
} // namespace Acts
} // namespace Acts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2022 CERN for the benefit of the Acts project
// Copyright (C) 2022-2023 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
Expand All @@ -11,9 +11,9 @@
#include "Acts/Geometry/Detector.hpp"
#include "Acts/Geometry/DetectorVolume.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/NavigationDelegates.hpp"
#include "Acts/Geometry/NavigationState.hpp"
#include "Acts/Geometry/detail/NavigationStateUpdators.hpp"
#include "Acts/Navigation/NavigationDelegates.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Navigation/NavigationStateUpdators.hpp"
#include "Acts/Utilities/detail/Axis.hpp"
#include "Acts/Utilities/detail/Grid.hpp"

Expand All @@ -22,8 +22,6 @@
namespace Acts {
namespace Experimental {

namespace detail {

/// @brief The end of world sets the volume pointer of the
/// navigation state to nullptr, usually indicates the end of
/// the known world, hence the name
Expand Down Expand Up @@ -93,6 +91,5 @@ using IndexedDetectorVolumeImpl =
IndexedUpdatorImpl<grid_type, IndexedDetectorVolumeExtractor,
DetectorVolumeFiller>;

} // namespace detail
} // namespace Experimental
} // namespace Acts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the Acts project.
//
// Copyright (C) 2022 CERN for the benefit of the Acts project
// Copyright (C) 2022-2023 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
Expand All @@ -9,9 +9,9 @@
#pragma once

#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/NavigationDelegates.hpp"
#include "Acts/Geometry/NavigationState.hpp"
#include "Acts/Geometry/detail/NavigationStateUpdators.hpp"
#include "Acts/Navigation/NavigationDelegates.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Navigation/NavigationStateUpdators.hpp"
#include "Acts/Utilities/detail/Axis.hpp"
#include "Acts/Utilities/detail/Grid.hpp"

Expand All @@ -22,8 +22,6 @@ namespace Experimental {

class DetectorVolume;

namespace detail {

/// @brief The end of world sets the volume pointer of the
/// navigation state to nullptr, usually indicates the end of
/// the known world, hence the name
Expand Down Expand Up @@ -111,7 +109,7 @@ struct BoundVolumesGrid1Impl : public INavigationDelegate {
/// @param gBoundaries the grid boundaries
/// @param bValue the binning value
/// @param cVolumes the contained volumes
/// @param bTransfrom is the optional transform
/// @param bTransform is the optional transform
BoundVolumesGrid1Impl(
const std::vector<ActsScalar>& gBoundaries, BinningValue bValue,
const std::vector<const DetectorVolume*>& cVolumes,
Expand Down Expand Up @@ -143,6 +141,5 @@ struct BoundVolumesGrid1Impl : public INavigationDelegate {
}
};

} // namespace detail
} // namespace Experimental
} // namespace Acts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once

#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/NavigationState.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Utilities/Delegate.hpp"

namespace Acts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#include <any>
#include <vector>

/// @note this is foreseen for the 'Geometry' module

namespace Acts {

class Surface;
Expand All @@ -29,13 +27,14 @@ class Portal;
class Detector;
class DetectorVolume;

/// @brief A navigation state struct that is
/// holding the current navigation information
/// about volume, surfaces, and portals
/// @brief A navigation state struct that is holding the current navigation information
///
/// It relies on Surfaces and Portals, all navigation entities have to be
/// described in these terms.
struct NavigationState {
/// @brief A surface candidate and its intersection
///
/// candidates can either be surfaces or portals (which contain a surface)
/// A candidates can either be a surface or a portal (which contain a surface)
struct SurfaceCandidate {
/// A candidate intersection, in Surface view
ObjectIntersection<Surface> objectIntersection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Common.hpp"
#include "Acts/Geometry/NavigationDelegates.hpp"
#include "Acts/Navigation/NavigationDelegates.hpp"
#include "Acts/Utilities/BinningType.hpp"
#include "Acts/Utilities/Helpers.hpp"

Expand All @@ -19,7 +19,6 @@

namespace Acts {
namespace Experimental {
namespace detail {

/// @brief This sets a single object, e.g. single surface or single volume
/// @tparam object_type the type of the object to be filled
Expand Down Expand Up @@ -173,6 +172,5 @@ class ChainedUpdatorImpl : public INavigationDelegate {
std::tuple<updators_t...> updators;
};

} // namespace detail
} // namespace Experimental
} // namespace Acts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
#include "Acts/Definitions/Common.hpp"
#include "Acts/Geometry/DetectorVolume.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/NavigationState.hpp"
#include "Acts/Geometry/Portal.hpp"
#include "Acts/Geometry/detail/NavigationStateUpdators.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Navigation/NavigationStateUpdators.hpp"
#include "Acts/Surfaces/Surface.hpp"

#include <tuple>

namespace Acts {
namespace Experimental {
namespace detail {

/// Helper method to update the candidates (portals/surfaces),
/// this can be called for initial surface/portal estimation,
Expand Down Expand Up @@ -189,6 +188,5 @@ template <typename grid_type>
using IndexedSurfacesImpl =
IndexedUpdatorImpl<grid_type, IndexedSurfacesExtractor, SurfacesFiller>;

} // namespace detail
} // namespace Experimental
} // namespace Acts
2 changes: 1 addition & 1 deletion Core/src/Geometry/Detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include "Acts/Geometry/Detector.hpp"

#include "Acts/Definitions/Common.hpp"
#include "Acts/Geometry/NavigationState.hpp"
#include "Acts/Geometry/Portal.hpp"
#include "Acts/Geometry/VolumeBounds.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Enumerate.hpp"
#include "Acts/Utilities/Helpers.hpp"
Expand Down
8 changes: 4 additions & 4 deletions Core/src/Geometry/DetectorVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#include "Acts/Geometry/DetectorVolume.hpp"

#include "Acts/Geometry/NavigationState.hpp"
#include "Acts/Geometry/Portal.hpp"
#include "Acts/Geometry/VolumeBounds.hpp"
#include "Acts/Geometry/detail/DetectorVolumeUpdators.hpp"
#include "Acts/Navigation/DetectorVolumeUpdators.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Enumerate.hpp"
#include "Acts/Utilities/Helpers.hpp"
Expand Down Expand Up @@ -180,9 +180,9 @@ void Acts::Experimental::DetectorVolume::closePortals() {
for (auto [ivu, vu] : enumerate(p->detectorVolumeUpdators())) {
if (not vu.connected()) {
auto eowDir = Acts::directionFromIndex(ivu);
auto eow = std::make_unique<const detail::EndOfWorldImpl>();
auto eow = std::make_unique<const EndOfWorldImpl>();
Acts::Experimental::DetectorVolumeUpdator eowLink;
eowLink.connect<&detail::EndOfWorldImpl::update>(std::move(eow));
eowLink.connect<&EndOfWorldImpl::update>(std::move(eow));
p->assignDetectorVolumeUpdator(eowDir, std::move(eowLink), {});
}
}
Expand Down
1 change: 1 addition & 0 deletions Tests/UnitTests/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_subdirectory(EventData)
add_subdirectory(Geometry)
add_subdirectory(MagneticField)
add_subdirectory(Material)
add_subdirectory(Navigation)
add_subdirectory(Propagator)
add_subdirectory(Seeding)
add_subdirectory(SpacePointFormation)
Expand Down

0 comments on commit a141736

Please sign in to comment.