Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Jul 24, 2023
1 parent b30f678 commit 140750e
Show file tree
Hide file tree
Showing 37 changed files with 207 additions and 166 deletions.
4 changes: 2 additions & 2 deletions Core/include/Acts/Detector/DetectorComponents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Detector/PortalGenerators.hpp"
#include "Acts/Navigation/DetectorVolumeUpdators.hpp"
#include "Acts/Navigation/SurfaceCandidatesUpdators.hpp"
#include "Acts/Navigation/SurfaceCandidatesProviders.hpp"

#include <map>
#include <memory>
Expand Down Expand Up @@ -82,7 +82,7 @@ struct InternalStructure {
/// Contained volumes of this volume, handled by the volumeUpdator
std::vector<std::shared_ptr<DetectorVolume>> volumes = {};
/// Navigation delegate for surfaces
SurfaceCandidatesUpdator surfacesUpdator;
SurfaceCandidatesProvider surfacesUpdator;
// Navigation delegate for volumes
DetectorVolumeUpdator volumeUpdator;
};
Expand Down
20 changes: 10 additions & 10 deletions Core/include/Acts/Detector/DetectorVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
std::vector<std::shared_ptr<Surface>> surfaces,
std::vector<std::shared_ptr<DetectorVolume>> volumes,
DetectorVolumeUpdator detectorVolumeUpdator,
SurfaceCandidatesUpdator surfaceCandidateUpdator) noexcept(false);
SurfaceCandidatesProvider surfaceCandidateUpdator) noexcept(false);

/// Create a detector volume - empty/gap volume constructor
///
Expand All @@ -127,7 +127,7 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
DetectorVolume(
const GeometryContext& gctx, std::string name,
const Transform3& transform, std::shared_ptr<VolumeBounds> bounds,
SurfaceCandidatesUpdator surfaceCandidateUpdator) noexcept(false);
SurfaceCandidatesProvider surfaceCandidateUpdator) noexcept(false);

/// Factory method for producing memory managed instances of DetectorVolume.
///
Expand All @@ -138,15 +138,15 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
std::vector<std::shared_ptr<Surface>> surfaces,
std::vector<std::shared_ptr<DetectorVolume>> volumes,
DetectorVolumeUpdator detectorVolumeUpdator,
SurfaceCandidatesUpdator surfaceCandidateUpdator);
SurfaceCandidatesProvider surfaceCandidateUpdator);

/// Factory method for producing memory managed instances of DetectorVolume.
///
/// @note This is called by the @class DetectorVolumeFactory
static std::shared_ptr<DetectorVolume> makeShared(
const GeometryContext& gctx, std::string name,
const Transform3& transform, std::shared_ptr<VolumeBounds> bounds,
SurfaceCandidatesUpdator surfaceCandidateUpdator);
SurfaceCandidatesProvider surfaceCandidateUpdator);

public:
/// Retrieve a @c std::shared_ptr for this surface (non-const version)
Expand Down Expand Up @@ -289,13 +289,13 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
/// @param surfaces the surfaces the new navigation state updator points to
/// @param volumes the volumes the new navigation state updator points to
///
void assignSurfaceCandidatesUpdator(
SurfaceCandidatesUpdator surfaceCandidateUpdator,
void assignSurfaceCandidatesProvider(
SurfaceCandidatesProvider surfaceCandidateUpdator,
const std::vector<std::shared_ptr<Surface>>& surfaces = {},
const std::vector<std::shared_ptr<DetectorVolume>>& volumes = {});

/// Const access to the navigation state updator
const SurfaceCandidatesUpdator& surfaceCandidatesUpdator() const;
const SurfaceCandidatesProvider& surfaceCandidatesProvider() const;

/// Update a portal given a portal index
///
Expand Down Expand Up @@ -385,7 +385,7 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
DetectorVolumeUpdator m_detectorVolumeUpdator;

/// The navigation state updator
SurfaceCandidatesUpdator m_surfaceCandidatesUpdator;
SurfaceCandidatesProvider m_surfaceCandidatesProvider;

/// Volume material (optional)
std::shared_ptr<IVolumeMaterial> m_volumeMaterial = nullptr;
Expand All @@ -410,7 +410,7 @@ class DetectorVolumeFactory {
const std::vector<std::shared_ptr<Surface>>& surfaces,
const std::vector<std::shared_ptr<DetectorVolume>>& volumes,
DetectorVolumeUpdator detectorVolumeUpdator,
SurfaceCandidatesUpdator surfaceCandidateUpdator) {
SurfaceCandidatesProvider surfaceCandidateUpdator) {
auto dVolume = DetectorVolume::makeShared(
gctx, name, transform, std::move(bounds), surfaces, volumes,
std::move(detectorVolumeUpdator), std::move(surfaceCandidateUpdator));
Expand All @@ -423,7 +423,7 @@ class DetectorVolumeFactory {
const PortalGenerator& portalGenerator, const GeometryContext& gctx,
std::string name, const Transform3& transform,
std::shared_ptr<VolumeBounds> bounds,
SurfaceCandidatesUpdator surfaceCandidateUpdator) {
SurfaceCandidatesProvider surfaceCandidateUpdator) {
auto dVolume = DetectorVolume::makeShared(
gctx, std::move(name), transform, std::move(bounds),
std::move(surfaceCandidateUpdator));
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Detector/detail/IndexedGridFiller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "Acts/Detector/detail/ReferenceGenerators.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/Polyhedron.hpp"
#include "Acts/Navigation/SurfaceCandidatesUpdators.hpp"
#include "Acts/Navigation/SurfaceCandidatesProviders.hpp"
#include "Acts/Utilities/Delegate.hpp"
#include "Acts/Utilities/Enumerate.hpp"
#include "Acts/Utilities/IAxis.hpp"
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/Detector/detail/IndexedGridFiller.hpp"
#include "Acts/Navigation/SurfaceCandidatesUpdators.hpp"
#include "Acts/Navigation/SurfaceCandidatesProviders.hpp"
#include "Acts/Utilities/Enumerate.hpp"

#include <algorithm>
Expand All @@ -23,7 +23,7 @@ namespace detail {

/// @brief A templated indexed grid generator.
///
/// This Generator creates a SurfaceCandidatesUpdator delegate
/// This Generator creates a SurfaceCandidatesProvider delegate
/// which can then be used in the DetectorVolume class for updating
/// given surface candidates based on an index grid.
///
Expand Down Expand Up @@ -60,7 +60,7 @@ struct IndexedSurfacesGenerator {
///
/// @return a SurfaceCandidateUpdator delegate
template <typename axis_generator, typename reference_generator>
SurfaceCandidatesUpdator operator()(
SurfaceCandidatesProvider operator()(
const GeometryContext& gctx, const axis_generator& aGenerator,
const reference_generator& rGenerator) const {
ACTS_DEBUG("Indexing " << surfaces.size() << " surface, "
Expand Down Expand Up @@ -96,7 +96,7 @@ struct IndexedSurfacesGenerator {
std::tie(allPortals, indexedSurfaces));

// Create the delegate and connect it
SurfaceCandidatesUpdator nStateUpdator;
SurfaceCandidatesProvider nStateUpdator;
nStateUpdator.connect<&DelegateType::update>(
std::move(indesSurfacesAllPortals));
return nStateUpdator;
Expand Down
55 changes: 55 additions & 0 deletions Core/include/Acts/Navigation/NavigationDelegateHelpers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// This file is part of the Acts project.
//
// Copyright (C) 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
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Common.hpp"
#include "Acts/Navigation/NavigationDelegates.hpp"
#include "Acts/Navigation/NavigationState.hpp"
#include "Acts/Utilities/BinningType.hpp"
#include "Acts/Utilities/Enumerate.hpp"
#include "Acts/Utilities/IAxis.hpp"
#include "Acts/Utilities/VectorHelpers.hpp"

#include <array>
#include <memory>

namespace Acts {
namespace Experimental {

/// Helper struct that allows to fill surfaces into the candidate vector it
/// allows to use common navigation structs for volume, portal, surfaces
///
/// @param surfaces the surfaces that are filled in
/// @param candidates the surface candidates to be updated
inline static void fillSurfaceCandidates(
NavigationState::SurfaceCandidates& candidates,
const std::vector<const Surface*>& surfaces, bool boundaryCheck) {
for (const auto& surface : surfaces) {
candidates.push_back(NavigationState::SurfaceCandidate{
ObjectIntersection<Surface>{}, surface, nullptr, boundaryCheck});
}
}

/// Helper struct that allows to fill surfaces into the candidate vector it
/// allows to use common navigation structs for volume, portal, surfaces
///
/// @param portals the portals that are filled in
/// @param candidates the surface candidates to be filled
inline static void fillSurfaceCandidates(
NavigationState::SurfaceCandidates& candidates,
const std::vector<const Portal*>& portals) {
for (const auto& portal : portals) {
candidates.push_back(NavigationState::SurfaceCandidate{
ObjectIntersection<Surface>{}, nullptr, portal, true});
}
}

} // namespace Experimental
} // namespace Acts
34 changes: 27 additions & 7 deletions Core/include/Acts/Navigation/NavigationDelegates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ class INavigationDelegate {
virtual ~INavigationDelegate() = default;
};

class ISurfaceCandidatesProvider {
public:
virtual ~ISurfaceCandidatesProvider() = default;

virtual void update(const GeometryContext& gctx,
const NavigationState& nState,
NavigationState::SurfaceCandidates& candidates) const = 0;
};

/// Declare an updator for the local navigation, i.e. the
/// navigation inside a detector volume. This can be called
/// either directly after a volume switch or in order to update
Expand All @@ -36,14 +45,16 @@ class INavigationDelegate {
/// to a dedicated struct or function that is optimised for
/// the given environment.
///
/// @param gctx is the current geometry context
/// @param nState [in,out] is the navigation state to be updated
/// @param gctx [in] is the current geometry context
/// @param nState [in] is the navigation state
/// @param candidates [out] are the candidates to be updated
///
/// @note it relies on the detector volume to be set to the state
/// Memory managed navigation state updator
using SurfaceCandidatesUpdator =
OwningDelegate<void(const GeometryContext& gctx, NavigationState& nState),
INavigationDelegate>;
/// @note it relies on the detector volume to be set to the state memory managed navigation state updator
using SurfaceCandidatesProvider =
OwningDelegate<void(const GeometryContext& gctx,
const NavigationState& nState,
NavigationState::SurfaceCandidates& candidates),
ISurfaceCandidatesProvider>;

/// Declare a Detctor Volume finding or switching delegate
///
Expand All @@ -62,5 +73,14 @@ inline static DetectorVolumeUpdator unconnectedUpdator() {
return unconnected;
}

template <typename Derived, typename... Args>
inline static SurfaceCandidatesProvider makeSurfaceCandidatesProvider(
Args... args) {
SurfaceCandidatesProvider provider;
provider.template connect<&Derived::update>(
std::make_unique<Derived>(std::forward<Args>(args)...));
return provider;
}

} // namespace Experimental
} // namespace Acts
33 changes: 0 additions & 33 deletions Core/include/Acts/Navigation/NavigationStateFillers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,5 @@ struct DetectorVolumeFiller {
}
};

/// Fillers and attachers for surfaces to act on the navigation state
struct SurfacesFiller {
/// Helper struct that allows to fill surfaces into the candidate vector it
/// allows to use common navigation structs for volume, portal, surfaces
///
/// @param nState the navigation state
/// @param surfaces the surfaces that are filled in
inline static void fill(NavigationState& nState,
const std::vector<const Surface*>& surfaces) {
std::for_each(surfaces.begin(), surfaces.end(), [&](const auto& s) {
nState.surfaceCandidates.push_back(NavigationState::SurfaceCandidate{
ObjectIntersection<Surface>{}, s, nullptr,
nState.surfaceBoundaryCheck});
});
}
};

/// Fillers and attachers for portals to act on the navigation state
struct PortalsFiller {
/// Helper struct that allows to fill surfaces into the candidate vector it
/// allows to use common navigation structs for volume, portal, surfaces
///
/// @param nState the navigation state
/// @param portals the portals that are filled in
inline static void fill(NavigationState& nState,
const std::vector<const Portal*>& portals) {
std::for_each(portals.begin(), portals.end(), [&](const auto& p) {
nState.surfaceCandidates.push_back(NavigationState::SurfaceCandidate{
ObjectIntersection<Surface>{}, nullptr, p, true});
});
}
};

} // namespace Experimental
} // namespace Acts
Loading

0 comments on commit 140750e

Please sign in to comment.