From c43e3087cf5ea3c497ada65e6764c4079d6942eb Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 15 May 2024 18:11:06 +0200 Subject: [PATCH 01/19] chore: Use Fatras log level for propagation (#3191) While debugging I usually add this manually. I think this can be the default behavior. --- .../Algorithms/Fatras/src/FatrasSimulation.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Examples/Algorithms/Fatras/src/FatrasSimulation.cpp b/Examples/Algorithms/Fatras/src/FatrasSimulation.cpp index e7857a0ed1b..a470c28873e 100644 --- a/Examples/Algorithms/Fatras/src/FatrasSimulation.cpp +++ b/Examples/Algorithms/Fatras/src/FatrasSimulation.cpp @@ -122,12 +122,18 @@ struct FatrasSimulationT final : ActsExamples::detail::FatrasSimulation { Acts::Logging::Level lvl) : simulation( ChargedSimulation( - ChargedPropagator(ChargedStepper(cfg.magneticField), - Acts::Navigator{{cfg.trackingGeometry}}), + ChargedPropagator( + ChargedStepper(cfg.magneticField), + Acts::Navigator({cfg.trackingGeometry}, + Acts::getDefaultLogger("SimNav", lvl)), + Acts::getDefaultLogger("SimProp", lvl)), Acts::getDefaultLogger("Simulation", lvl)), NeutralSimulation( - NeutralPropagator(NeutralStepper(), - Acts::Navigator{{cfg.trackingGeometry}}), + NeutralPropagator( + NeutralStepper(), + Acts::Navigator({cfg.trackingGeometry}, + Acts::getDefaultLogger("SimNav", lvl)), + Acts::getDefaultLogger("SimProp", lvl)), Acts::getDefaultLogger("Simulation", lvl))) { using namespace ActsFatras; using namespace ActsFatras::detail; From 7120c6b5f8886fb79b65ef11335b35a2f2ed8942 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 16 May 2024 00:36:55 +0200 Subject: [PATCH 02/19] refactor!: Use `std::string_view` for `addColumn` in track EDM (#3187) This makes it easier for compile time known dynamic columns to add. Pulled out of https://github.com/acts-project/acts/pull/3161 --- Core/include/Acts/EventData/MultiTrajectory.hpp | 4 +++- Core/include/Acts/EventData/TrackContainer.hpp | 2 +- Core/include/Acts/EventData/VectorMultiTrajectory.hpp | 2 +- Core/include/Acts/EventData/VectorTrackContainer.hpp | 2 +- .../include/Acts/Plugins/Podio/PodioDynamicColumns.hpp | 9 +++++---- .../include/Acts/Plugins/Podio/PodioTrackContainer.hpp | 2 +- .../Acts/Plugins/Podio/PodioTrackStateContainer.hpp | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Core/include/Acts/EventData/MultiTrajectory.hpp b/Core/include/Acts/EventData/MultiTrajectory.hpp index d25e1ec72e7..b0410d52274 100644 --- a/Core/include/Acts/EventData/MultiTrajectory.hpp +++ b/Core/include/Acts/EventData/MultiTrajectory.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -383,11 +384,12 @@ class MultiTrajectory { /// Add a column to the @c MultiTrajectory /// @tparam T Type of the column values to add + /// @param key the name of the column to be added /// @note This takes a string argument rather than a hashed string to maintain /// compatibility with backends. /// @note Only available if the MultiTrajectory is not read-only template > - void addColumn(const std::string& key) { + void addColumn(std::string_view key) { self().template addColumn_impl(key); } diff --git a/Core/include/Acts/EventData/TrackContainer.hpp b/Core/include/Acts/EventData/TrackContainer.hpp index 1940c0cc344..93592b1afb8 100644 --- a/Core/include/Acts/EventData/TrackContainer.hpp +++ b/Core/include/Acts/EventData/TrackContainer.hpp @@ -220,7 +220,7 @@ class TrackContainer { /// @note Only available if the track container is not read-only /// @param key the name of the column to be added template > - constexpr void addColumn(const std::string& key) { + constexpr void addColumn(std::string_view key) { m_container->template addColumn_impl(key); } diff --git a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp index 8bcb34d8c9c..55757e3925d 100644 --- a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp +++ b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp @@ -455,7 +455,7 @@ class VectorMultiTrajectory final } template - void addColumn_impl(const std::string& key) { + void addColumn_impl(std::string_view key) { Acts::HashedString hashedKey = hashString(key); m_dynamic.insert({hashedKey, std::make_unique>()}); } diff --git a/Core/include/Acts/EventData/VectorTrackContainer.hpp b/Core/include/Acts/EventData/VectorTrackContainer.hpp index df70cdabcfa..9ee0d0996b7 100644 --- a/Core/include/Acts/EventData/VectorTrackContainer.hpp +++ b/Core/include/Acts/EventData/VectorTrackContainer.hpp @@ -224,7 +224,7 @@ class VectorTrackContainer final : public detail_vtc::VectorTrackContainerBase { void removeTrack_impl(IndexType itrack); template - constexpr void addColumn_impl(const std::string& key) { + constexpr void addColumn_impl(std::string_view key) { Acts::HashedString hashedKey = hashString(key); m_dynamic.insert({hashedKey, std::make_unique>()}); } diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioDynamicColumns.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioDynamicColumns.hpp index 80d48167814..39e6ec326df 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioDynamicColumns.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioDynamicColumns.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -17,7 +18,7 @@ namespace Acts::podio_detail { struct ConstDynamicColumnBase { - ConstDynamicColumnBase(const std::string& name) : m_name{name} {} + ConstDynamicColumnBase(std::string_view name) : m_name{name} {} virtual ~ConstDynamicColumnBase() = default; @@ -31,7 +32,7 @@ struct ConstDynamicColumnBase { template struct ConstDynamicColumn : public ConstDynamicColumnBase { - ConstDynamicColumn(const std::string& name, + ConstDynamicColumn(std::string_view name, const podio::UserDataCollection& collection) : ConstDynamicColumnBase(name), m_collection{collection} {} @@ -44,7 +45,7 @@ struct ConstDynamicColumn : public ConstDynamicColumnBase { }; struct DynamicColumnBase : public ConstDynamicColumnBase { - DynamicColumnBase(const std::string& name) : ConstDynamicColumnBase{name} {} + DynamicColumnBase(std::string_view name) : ConstDynamicColumnBase{name} {} virtual std::any get(std::size_t i) = 0; std::any get(std::size_t i) const override = 0; @@ -66,7 +67,7 @@ struct DynamicColumnBase : public ConstDynamicColumnBase { template struct DynamicColumn : public DynamicColumnBase { - DynamicColumn(const std::string& name, + DynamicColumn(std::string_view name, podio::UserDataCollection collection = {}) : DynamicColumnBase(name), m_collection{std::move(collection)} {} diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp index 9393d7fc8a9..1a75473efca 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp @@ -223,7 +223,7 @@ class MutablePodioTrackContainer : public PodioTrackContainerBase { void removeTrack_impl(IndexType itrack); template - constexpr void addColumn_impl(const std::string& key) { + constexpr void addColumn_impl(std::string_view key) { Acts::HashedString hashedKey = hashString(key); m_dynamic.insert( {hashedKey, std::make_unique>(key)}); diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp index ec2bd7cc489..1714fe9e770 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp @@ -603,7 +603,7 @@ class MutablePodioTrackStateContainer final } template - constexpr void addColumn_impl(const std::string& key) { + constexpr void addColumn_impl(std::string_view key) { HashedString hashedKey = hashString(key); m_dynamic.insert( {hashedKey, std::make_unique>(key)}); From a16e3e6b13c03a30312fa95c8ddd1d389a183839 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 16 May 2024 13:08:39 +0200 Subject: [PATCH 03/19] refactor: Simplify layer handling in `Navigator` (#3190) The `startSurface` should never be null which is checked and protected against now --- Core/include/Acts/Propagator/Navigator.hpp | 78 +++++++++------------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/Core/include/Acts/Propagator/Navigator.hpp b/Core/include/Acts/Propagator/Navigator.hpp index 30a05159794..c56d2124805 100644 --- a/Core/include/Acts/Propagator/Navigator.hpp +++ b/Core/include/Acts/Propagator/Navigator.hpp @@ -154,10 +154,12 @@ class Navigator { const Layer* startLayer = nullptr; /// Navigation state: the start surface const Surface* startSurface = nullptr; - /// Navigation state - external state: the current surface - const Surface* currentSurface = nullptr; /// Navigation state: the current volume const TrackingVolume* currentVolume = nullptr; + /// Navigation state: the current layer + const Layer* currentLayer = nullptr; + /// Navigation state - external state: the current surface + const Surface* currentSurface = nullptr; /// Navigation state: the target volume const TrackingVolume* targetVolume = nullptr; /// Navigation state: the target layer @@ -191,6 +193,8 @@ class Navigator { State makeState(const Surface* startSurface, const Surface* targetSurface) const { + assert(startSurface != nullptr && "Start surface must be set"); + State result; result.startSurface = startSurface; result.targetSurface = targetSurface; @@ -289,8 +293,6 @@ class Navigator { state.navigation.startSurface->associatedLayer(); state.navigation.startVolume = state.navigation.startLayer->trackingVolume(); - // Set the start volume as current volume - state.navigation.currentVolume = state.navigation.startVolume; } else if (state.navigation.startVolume) { ACTS_VERBOSE( volInfo(state) @@ -298,8 +300,6 @@ class Navigator { state.navigation.startLayer = state.navigation.startVolume->associatedLayer( state.geoContext, stepper.position(state.stepping)); - // Set the start volume as current volume - state.navigation.currentVolume = state.navigation.startVolume; } else { ACTS_VERBOSE(volInfo(state) << "Slow start initialization through search."); @@ -317,12 +317,14 @@ class Navigator { ? state.navigation.startVolume->associatedLayer( state.geoContext, stepper.position(state.stepping)) : nullptr; - // Set the start volume as current volume - state.navigation.currentVolume = state.navigation.startVolume; if (state.navigation.startVolume) { ACTS_VERBOSE(volInfo(state) << "Start volume resolved."); } } + // Set the start volume as current volume + state.navigation.currentVolume = state.navigation.startVolume; + // Set the start layer as current layer + state.navigation.currentLayer = state.navigation.startLayer; } /// @brief Navigator pre step call @@ -443,6 +445,7 @@ class Navigator { ACTS_VERBOSE(volInfo(state) << "Post step: in layer handling."); if (state.navigation.currentSurface != nullptr) { ACTS_VERBOSE(volInfo(state) << "On layer: update layer information."); + state.navigation.currentLayer = state.navigation.navLayer().second; if (resolveSurfaces(state, stepper)) { // Set the navigation stage back to surface handling state.navigation.navigationStage = Stage::surfaceTarget; @@ -471,10 +474,11 @@ class Navigator { state.navigation.lastHierarchySurfaceReached = false; // Update volume information // get the attached volume information - auto boundary = state.navigation.navBoundary().second; + const BoundarySurface* boundary = state.navigation.navBoundary().second; state.navigation.currentVolume = boundary->attachedVolume( state.geoContext, stepper.position(state.stepping), state.options.direction * stepper.direction(state.stepping)); + state.navigation.currentLayer = nullptr; // No volume anymore : end of known world if (!state.navigation.currentVolume) { ACTS_VERBOSE( @@ -598,8 +602,7 @@ class Navigator { ACTS_VERBOSE(volInfo(state) << "Start layer to be resolved."); // We provide the layer to the resolve surface method in this case state.navigation.startLayerResolved = true; - bool startResolved = - resolveSurfaces(state, stepper, state.navigation.startLayer); + bool startResolved = resolveSurfaces(state, stepper); if (!startResolved && state.navigation.startLayer == state.navigation.targetLayer) { ACTS_VERBOSE(volInfo(state) @@ -836,7 +839,7 @@ class Navigator { NavigationOptions navOpts; // Exclude the current surface in case it's a boundary navOpts.startObject = state.navigation.currentSurface; - navOpts.nearLimit = stepper.overstepLimit(state.stepping); + navOpts.nearLimit = state.options.surfaceTolerance; navOpts.farLimit = stepper.getStepSize(state.stepping, ConstrainedStep::aborter); navOpts.forceIntersectBoundaries = @@ -1009,25 +1012,21 @@ class Navigator { /// /// @param [in,out] state is the propagation state object /// @param [in] stepper Stepper in use - /// @param [in] cLayer is the already assigned current layer, e.g. start layer /// /// boolean return triggers exit to stepper template - bool resolveSurfaces(propagator_state_t& state, const stepper_t& stepper, - const Layer* cLayer = nullptr) const { + bool resolveSurfaces(propagator_state_t& state, + const stepper_t& stepper) const { // get the layer and layer surface - auto layerSurface = cLayer ? state.navigation.startSurface - : state.navigation.navLayer().first.object(); - auto navLayer = cLayer ? cLayer : state.navigation.navLayer().second; - // are we on the start layer - bool onStart = (navLayer == state.navigation.startLayer); - auto startSurface = onStart ? state.navigation.startSurface : layerSurface; + const Layer* currentLayer = state.navigation.currentLayer; + assert(currentLayer != nullptr && "Current layer is not set."); + const Surface* layerSurface = ¤tLayer->surfaceRepresentation(); // Use navigation parameters and NavigationOptions NavigationOptions navOpts; navOpts.resolveSensitive = m_cfg.resolveSensitive; navOpts.resolveMaterial = m_cfg.resolveMaterial; navOpts.resolvePassive = m_cfg.resolvePassive; - navOpts.startObject = startSurface; + navOpts.startObject = state.navigation.currentSurface; navOpts.endObject = state.navigation.targetSurface; std::vector externalSurfaces; @@ -1042,16 +1041,12 @@ class Navigator { navOpts.externalSurfaces.push_back(itSurface->second); } } - // No overstepping on start layer, otherwise ask the stepper - navOpts.nearLimit = (cLayer != nullptr) - ? state.options.surfaceTolerance - : stepper.overstepLimit(state.stepping); - // Check the limit + navOpts.nearLimit = state.options.surfaceTolerance; navOpts.farLimit = stepper.getStepSize(state.stepping, ConstrainedStep::aborter); // get the surfaces - state.navigation.navSurfaces = navLayer->compatibleSurfaces( + state.navigation.navSurfaces = currentLayer->compatibleSurfaces( state.geoContext, stepper.position(state.stepping), state.options.direction * stepper.direction(state.stepping), navOpts); // the number of layer candidates @@ -1099,19 +1094,14 @@ class Navigator { const stepper_t& stepper) const { ACTS_VERBOSE(volInfo(state) << "Searching for compatible layers."); - // Check if we are in the start volume - auto startLayer = - (state.navigation.currentVolume == state.navigation.startVolume) - ? state.navigation.startLayer - : nullptr; // Create the navigation options // - and get the compatible layers, start layer will be excluded NavigationOptions navOpts; navOpts.resolveSensitive = m_cfg.resolveSensitive; navOpts.resolveMaterial = m_cfg.resolveMaterial; navOpts.resolvePassive = m_cfg.resolvePassive; - navOpts.startObject = startLayer; - navOpts.nearLimit = stepper.overstepLimit(state.stepping); + navOpts.startObject = state.navigation.currentLayer; + navOpts.nearLimit = state.options.surfaceTolerance; navOpts.farLimit = stepper.getStepSize(state.stepping, ConstrainedStep::aborter); // Request the compatible layers @@ -1136,17 +1126,13 @@ class Navigator { // Set the index to the first state.navigation.navLayerIndex = 0; // Setting the step size towards first - if (state.navigation.startLayer && - state.navigation.navLayer().second != state.navigation.startLayer) { - ACTS_VERBOSE(volInfo(state) << "Target at layer."); - // The stepper updates the step size ( single / multi component) - stepper.updateStepSize(state.stepping, - state.navigation.navLayer().first, - state.options.direction, true); - ACTS_VERBOSE(volInfo(state) << "Navigation stepSize updated to " - << stepper.outputStepSize(state.stepping)); - return true; - } + ACTS_VERBOSE(volInfo(state) << "Target at layer."); + // The stepper updates the step size ( single / multi component) + stepper.updateStepSize(state.stepping, state.navigation.navLayer().first, + state.options.direction, true); + ACTS_VERBOSE(volInfo(state) << "Navigation stepSize updated to " + << stepper.outputStepSize(state.stepping)); + return true; } // Set the index to the end of the list From eeb854aa6061211e02c338e1d7cb87cc225e58b0 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Tue, 21 May 2024 14:12:07 +0200 Subject: [PATCH 04/19] chore: rename navigation delegates (#3196) Thi PR sits on top of #3194 and cleans up naming and file location, in fact - it overwrites some of the changes. `NavigationDelegates.hpp` - contains definition of the delegates and the internal and external navigation interfaces `NavigationStateFillers.hpp` - contains the fillers into the navigation state which can be used to specify the updators `NavigationStateUpdaters.hpp` - contains the generic updaters code that can be used to implement `IInternalNavigation` and `IExternalNavigation` `InternalNavigation.hpp` - a standard set of internal navigation implementations, many of them using the navigation state updators `MultiWireNavigation.hpp` - a dedciated implementation of internal navigation for multi wire chambers `PortalNavigation.hpp` - single and multiple connected portal navigation implementations `DetectorVolumeFinders.hpp` - global volume finder implementations Individual `....Navigation` classes implement either the internal or the external navigation interface. --- Core/include/Acts/Detector/Detector.hpp | 15 +++-- .../Acts/Detector/DetectorComponents.hpp | 10 +-- Core/include/Acts/Detector/DetectorVolume.hpp | 62 +++++++++--------- .../IndexedRootVolumeFinderBuilder.hpp | 4 +- Core/include/Acts/Detector/Portal.hpp | 23 +++---- .../Detector/detail/IndexedGridFiller.hpp | 2 +- .../detail/IndexedSurfacesGenerator.hpp | 14 ++-- .../Acts/Detector/detail/PortalHelper.hpp | 8 +-- .../interface/IRootVolumeFinderBuilder.hpp | 4 +- .../Acts/Navigation/DetectorVolumeFinders.hpp | 26 ++++---- ...tesUpdaters.hpp => InternalNavigation.hpp} | 44 +++++++------ ...esUpdater.hpp => MultiLayerNavigation.hpp} | 15 +++-- .../Acts/Navigation/NavigationDelegates.hpp | 25 +++++--- .../Navigation/NavigationStateUpdaters.hpp | 49 ++++++++++---- ...olumeUpdaters.hpp => PortalNavigation.hpp} | 46 ++++--------- Core/src/Detector/Detector.cpp | 22 +++---- Core/src/Detector/DetectorVolume.cpp | 64 +++++++++---------- Core/src/Detector/DetectorVolumeBuilder.cpp | 2 +- .../IndexedRootVolumeFinderBuilder.cpp | 8 +-- Core/src/Detector/LayerStructureBuilder.cpp | 16 ++--- .../Detector/MultiWireStructureBuilder.cpp | 7 +- Core/src/Detector/Portal.cpp | 47 +++++++------- Core/src/Detector/PortalGenerators.cpp | 20 +++--- .../detail/CuboidalDetectorHelper.cpp | 2 +- .../detail/CylindricalDetectorHelper.cpp | 9 +-- .../src/Detector/detail/IndexedGridFiller.cpp | 2 +- Core/src/Detector/detail/PortalHelper.cpp | 46 ++++++------- Core/src/Visualization/GeometryView3D.cpp | 2 +- .../src/MockupSectorBuilder.cpp | 2 +- .../ActSVG/IndexedSurfacesSvgConverter.hpp | 14 ++-- .../ActSVG/src/DetectorVolumeSvgConverter.cpp | 2 +- Plugins/ActSVG/src/PortalSvgConverter.cpp | 14 ++-- .../DetectorVolumeFinderJsonConverter.hpp | 19 +++--- .../Json/IndexedSurfacesJsonConverter.hpp | 16 ++--- .../Acts/Plugins/Json/PortalJsonConverter.hpp | 4 +- Plugins/Json/src/DetectorJsonConverter.cpp | 2 +- .../src/DetectorVolumeFinderJsonConverter.cpp | 16 +++-- .../Json/src/DetectorVolumeJsonConverter.cpp | 4 +- .../Json/src/IndexedSurfacesJsonConverter.cpp | 21 +++--- Plugins/Json/src/PortalJsonConverter.cpp | 25 ++++---- .../CuboidalContainerBuilderTests.cpp | 2 +- .../CuboidalDetectorFromBlueprintTests.cpp | 6 +- .../Detector/CuboidalDetectorHelperTests.cpp | 2 +- .../CylindricalContainerBuilderTests.cpp | 2 +- .../CylindricalDetectorFromBlueprintTests.cpp | 6 +- .../CylindricalDetectorHelperTests.cpp | 2 +- .../Core/Detector/DetectorBuilderTests.cpp | 2 +- .../UnitTests/Core/Detector/DetectorTests.cpp | 4 +- .../Detector/DetectorVolumeBuilderTests.cpp | 2 +- .../DetectorVolumeConsistencyTests.cpp | 2 +- .../Core/Detector/DetectorVolumeTests.cpp | 2 +- .../Detector/GeometryIdGeneratorTests.cpp | 2 +- .../IndexedRootVolumeFinderBuilderTests.cpp | 4 +- .../IndexedSurfaceGridFillerTests.cpp | 26 ++++---- .../IndexedSurfacesGeneratorTests.cpp | 50 +++++++-------- .../MultiWireStructureBuilderTests.cpp | 2 +- .../Core/Detector/PortalGeneratorsTests.cpp | 2 +- Tests/UnitTests/Core/Detector/PortalTests.cpp | 50 +++++++-------- .../IntersectionMaterialAssignerTests.cpp | 2 +- .../PropagatorMaterialAssignerTests.cpp | 2 +- .../UnitTests/Core/Navigation/CMakeLists.txt | 2 +- .../Navigation/DetectorNavigatorTests.cpp | 2 +- .../Navigation/DetectorVolumeFindersTests.cpp | 2 +- .../Navigation/MultiWireNavigationTests.cpp | 2 +- .../NavigationStateUpdatersTests.cpp | 39 +++++------ ...ersTests.cpp => PortalNavigationTests.cpp} | 17 ++--- .../ActSVG/DetectorSvgConverterTests.cpp | 2 +- .../DetectorVolumeSvgConverterTests.cpp | 2 +- .../IndexedSurfacesSvgConverterTests.cpp | 24 +++---- .../ActSVG/PortalSvgConverterTests.cpp | 2 +- .../Json/DetectorJsonConverterTests.cpp | 2 +- ...DetectorVolumeFinderJsonConverterTests.cpp | 7 +- .../Json/DetectorVolumeJsonConverterTests.cpp | 2 +- .../Plugins/Json/PortalJsonConverterTests.cpp | 6 +- docs/core/geometry/layerless/layerless.md | 8 +-- 75 files changed, 528 insertions(+), 496 deletions(-) rename Core/include/Acts/Navigation/{SurfaceCandidatesUpdaters.hpp => InternalNavigation.hpp} (77%) rename Core/include/Acts/Navigation/{MultiLayerSurfacesUpdater.hpp => MultiLayerNavigation.hpp} (91%) rename Core/include/Acts/Navigation/{DetectorVolumeUpdaters.hpp => PortalNavigation.hpp} (75%) rename Tests/UnitTests/Core/Navigation/{DetectorVolumeUpdatersTests.cpp => PortalNavigationTests.cpp} (84%) diff --git a/Core/include/Acts/Detector/Detector.hpp b/Core/include/Acts/Detector/Detector.hpp index ada2ceefe33..4f0a2a6ad23 100644 --- a/Core/include/Acts/Detector/Detector.hpp +++ b/Core/include/Acts/Detector/Detector.hpp @@ -40,21 +40,21 @@ class Detector : public std::enable_shared_from_this { /// /// @param name the detecor name /// @param rootVolumes the volumes contained by this detector - /// @param detectorVolumeUpdater is a Delegate to find the associated volume + /// @param detectorVolumeFinder is a Delegate to find the associated volume /// /// @note will throw an exception if volumes vector is empty /// @note will throw an exception if duplicate volume names exist /// @note will throw an exception if the delegate is not connected Detector(std::string name, std::vector> rootVolumes, - DetectorVolumeUpdater detectorVolumeUpdater) noexcept(false); + ExternalNavigationDelegate detectorVolumeFinder) noexcept(false); public: /// Factory for producing memory managed instances of Detector. static std::shared_ptr makeShared( std::string name, std::vector> rootVolumes, - DetectorVolumeUpdater detectorVolumeUpdater); + ExternalNavigationDelegate detectorVolumeFinder); /// Retrieve a @c std::shared_ptr for this surface (non-const version) /// @@ -213,11 +213,12 @@ class Detector : public std::enable_shared_from_this { /// Update the volume finder /// - /// @param detectorVolumeUpdater the new volume finder - void updateDetectorVolumeFinder(DetectorVolumeUpdater detectorVolumeUpdater); + /// @param detectorVolumeFinder the new volume finder + void updateDetectorVolumeFinder( + ExternalNavigationDelegate detectorVolumeFinder); /// Const access to the volume finder - const DetectorVolumeUpdater& detectorVolumeFinder() const; + const ExternalNavigationDelegate& detectorVolumeFinder() const; /// Return the name of the detector const std::string& name() const; @@ -233,7 +234,7 @@ class Detector : public std::enable_shared_from_this { DetectorVolume::ObjectStore> m_volumes; /// A volume finder delegate - DetectorVolumeUpdater m_detectorVolumeUpdater; + ExternalNavigationDelegate m_volumeFinder; /// Name/index map to find volumes by name and detect duplicates std::unordered_map m_volumeNameIndex; diff --git a/Core/include/Acts/Detector/DetectorComponents.hpp b/Core/include/Acts/Detector/DetectorComponents.hpp index 8fbd4c9acdc..5f6cf73d6e8 100644 --- a/Core/include/Acts/Detector/DetectorComponents.hpp +++ b/Core/include/Acts/Detector/DetectorComponents.hpp @@ -10,8 +10,8 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Detector/PortalGenerators.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include #include @@ -39,7 +39,7 @@ struct RootDetectorVolumes { /// The list of root volumes std::vector> volumes = {}; /// The Root volumes finder - DetectorVolumeUpdater volumeFinder; + ExternalNavigationDelegate volumeFinder; }; /// @brief The currently built detector components @@ -82,9 +82,9 @@ struct InternalStructure { /// Contained volumes of this volume, handled by the volumeUpdater std::vector> volumes = {}; /// Navigation delegate for surfaces - SurfaceCandidatesUpdater surfacesUpdater; + InternalNavigationDelegate surfacesUpdater; // Navigation delegate for volumes - DetectorVolumeUpdater volumeUpdater; + ExternalNavigationDelegate volumeUpdater; }; } // namespace Experimental diff --git a/Core/include/Acts/Detector/DetectorVolume.hpp b/Core/include/Acts/Detector/DetectorVolume.hpp index 1079f3975e6..abbb4fc8775 100644 --- a/Core/include/Acts/Detector/DetectorVolume.hpp +++ b/Core/include/Acts/Detector/DetectorVolume.hpp @@ -102,19 +102,19 @@ class DetectorVolume : public std::enable_shared_from_this { /// @param bounds the volume bounds /// @param surfaces are the contained surfaces of this volume /// @param volumes are the contains volumes of this volume - /// @param detectorVolumeUpdater is a Delegate to find the associated volume - /// @param surfaceCandidateUpdater the navigation state updator for surfaces/portals + /// @param externalNavigation is a Delegate to find the associated volume + /// @param internalNavigation the navigation state updator for surfaces/portals /// /// @note throws exception if misconfigured: no bounds /// @note throws exception if ghe portal general or navigation /// state updator delegates are not connected - DetectorVolume( - const GeometryContext& gctx, std::string name, - const Transform3& transform, std::shared_ptr bounds, - std::vector> surfaces, - std::vector> volumes, - DetectorVolumeUpdater detectorVolumeUpdater, - SurfaceCandidatesUpdater surfaceCandidateUpdater) noexcept(false); + DetectorVolume(const GeometryContext& gctx, std::string name, + const Transform3& transform, + std::shared_ptr bounds, + std::vector> surfaces, + std::vector> volumes, + ExternalNavigationDelegate externalNavigation, + InternalNavigationDelegate internalNavigation) noexcept(false); /// Create a detector volume - empty/gap volume constructor /// @@ -122,15 +122,15 @@ class DetectorVolume : public std::enable_shared_from_this { /// @param name the volume name /// @param transform the transform defining the volume position /// @param bounds the volume bounds - /// @param surfaceCandidateUpdater the navigation state updator for surfaces/portals + /// @param internalNavigation the navigation state updator for surfaces/portals /// /// @note throws exception if misconfigured: no bounds /// @note throws exception if ghe portal general or navigation /// state updator delegates are not connected - DetectorVolume( - const GeometryContext& gctx, std::string name, - const Transform3& transform, std::shared_ptr bounds, - SurfaceCandidatesUpdater surfaceCandidateUpdater) noexcept(false); + DetectorVolume(const GeometryContext& gctx, std::string name, + const Transform3& transform, + std::shared_ptr bounds, + InternalNavigationDelegate internalNavigation) noexcept(false); /// Factory method for producing memory managed instances of DetectorVolume. /// @@ -140,8 +140,8 @@ class DetectorVolume : public std::enable_shared_from_this { const Transform3& transform, std::shared_ptr bounds, std::vector> surfaces, std::vector> volumes, - DetectorVolumeUpdater detectorVolumeUpdater, - SurfaceCandidatesUpdater surfaceCandidateUpdater); + ExternalNavigationDelegate externalNavigation, + InternalNavigationDelegate internalNavigation); /// Factory method for producing memory managed instances of DetectorVolume. /// @@ -149,7 +149,7 @@ class DetectorVolume : public std::enable_shared_from_this { static std::shared_ptr makeShared( const GeometryContext& gctx, std::string name, const Transform3& transform, std::shared_ptr bounds, - SurfaceCandidatesUpdater surfaceCandidateUpdater); + InternalNavigationDelegate internalNavigation); public: /// Retrieve a @c std::shared_ptr for this surface (non-const version) @@ -283,7 +283,7 @@ class DetectorVolume : public std::enable_shared_from_this { const std::vector& volumes() const; /// Const access to the detector volume updator - const DetectorVolumeUpdater& detectorVolumeUpdater() const; + const ExternalNavigationDelegate& externalNavigation() const; /// @brief Visit all reachable surfaces of the detector /// @@ -362,17 +362,17 @@ class DetectorVolume : public std::enable_shared_from_this { /// This method allows to udate the navigation state updator /// module. /// - /// @param surfaceCandidateUpdater the new navigation state updator for surfaces + /// @param internalNavigation the new navigation state updator for surfaces /// @param surfaces the surfaces the new navigation state updator points to /// @param volumes the volumes the new navigation state updator points to /// - void assignSurfaceCandidatesUpdater( - SurfaceCandidatesUpdater surfaceCandidateUpdater, + void assignInternalNavigation( + InternalNavigationDelegate internalNavigation, const std::vector>& surfaces = {}, const std::vector>& volumes = {}); /// Const access to the navigation state updator - const SurfaceCandidatesUpdater& surfaceCandidatesUpdater() const; + const InternalNavigationDelegate& internalNavigation() const; /// Update a portal given a portal index /// @@ -463,10 +463,10 @@ class DetectorVolume : public std::enable_shared_from_this { /// BoundingBox std::shared_ptr m_boundingBox; - DetectorVolumeUpdater m_detectorVolumeUpdater; + ExternalNavigationDelegate m_externalNavigation; /// The navigation state updator - SurfaceCandidatesUpdater m_surfaceCandidatesUpdater; + InternalNavigationDelegate m_internalNavigation; /// Volume material (optional) std::shared_ptr m_volumeMaterial = nullptr; @@ -493,11 +493,11 @@ class DetectorVolumeFactory { std::shared_ptr bounds, const std::vector>& surfaces, const std::vector>& volumes, - DetectorVolumeUpdater detectorVolumeUpdater, - SurfaceCandidatesUpdater surfaceCandidateUpdater, int nSeg = -1) { + ExternalNavigationDelegate externalNavigation, + InternalNavigationDelegate internalNavigation, int nSeg = -1) { auto dVolume = DetectorVolume::makeShared( gctx, name, transform, std::move(bounds), surfaces, volumes, - std::move(detectorVolumeUpdater), std::move(surfaceCandidateUpdater)); + std::move(externalNavigation), std::move(internalNavigation)); dVolume->construct(gctx, portalGenerator); /// Volume extent is constructed from the portals @@ -515,10 +515,10 @@ class DetectorVolumeFactory { const PortalGenerator& portalGenerator, const GeometryContext& gctx, std::string name, const Transform3& transform, std::shared_ptr bounds, - SurfaceCandidatesUpdater surfaceCandidateUpdater) { - auto dVolume = DetectorVolume::makeShared( - gctx, std::move(name), transform, std::move(bounds), - std::move(surfaceCandidateUpdater)); + InternalNavigationDelegate internalNavigation) { + auto dVolume = DetectorVolume::makeShared(gctx, std::move(name), transform, + std::move(bounds), + std::move(internalNavigation)); dVolume->construct(gctx, portalGenerator); return dVolume; } diff --git a/Core/include/Acts/Detector/IndexedRootVolumeFinderBuilder.hpp b/Core/include/Acts/Detector/IndexedRootVolumeFinderBuilder.hpp index 6160216c2d5..f985ea3975e 100644 --- a/Core/include/Acts/Detector/IndexedRootVolumeFinderBuilder.hpp +++ b/Core/include/Acts/Detector/IndexedRootVolumeFinderBuilder.hpp @@ -10,7 +10,7 @@ #include "Acts/Detector/interface/IRootVolumeFinderBuilder.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Utilities/BinningData.hpp" #include @@ -34,7 +34,7 @@ class IndexedRootVolumeFinderBuilder final : public IRootVolumeFinderBuilder { /// @param rootVolumes the root volumes to be used for the finder /// /// @return a shared detector object - DetectorVolumeUpdater construct( + ExternalNavigationDelegate construct( const GeometryContext& gctx, const std::vector>& rootVolumes) const final; diff --git a/Core/include/Acts/Detector/Portal.hpp b/Core/include/Acts/Detector/Portal.hpp index 98ee573ecd9..6ed605544ed 100644 --- a/Core/include/Acts/Detector/Portal.hpp +++ b/Core/include/Acts/Detector/Portal.hpp @@ -50,9 +50,6 @@ class Portal { /// @param surface is the representing surface Portal(std::shared_ptr surface); - /// The volume links forward/backward with respect to the surface normal - using DetectorVolumeUpdaters = std::array; - /// The vector of attached volumes forward/backward, this is useful in the /// geometry building using AttachedDetectorVolumes = @@ -124,27 +121,27 @@ class Portal { /// Update the volume link /// /// @param dir the direction of the link - /// @param dVolumeUpdater is the mangaged volume updator delegate + /// @param portalNavigation is the navigation delegate /// @param attachedVolumes is the list of attached volumes for book keeping /// /// @note this overwrites the existing link - void assignDetectorVolumeUpdater( - Direction dir, DetectorVolumeUpdater dVolumeUpdater, + void assignPortalNavigation( + Direction dir, ExternalNavigationDelegate portalNavigation, std::vector> attachedVolumes); /// Update the volume link, w/o directive, i.e. it relies that there's only /// one remaining link to be set, throws an exception if that's not the case /// - /// @param dVolumeUpdater is the mangaged volume updator delegate + /// @param portalNavigation is the navigation delegate /// @param attachedVolumes is the list of attached volumes for book keeping /// /// @note this overwrites the existing link - void assignDetectorVolumeUpdater(DetectorVolumeUpdater dVolumeUpdater, - std::vector> - attachedVolumes) noexcept(false); + void assignPortalNavigation(ExternalNavigationDelegate portalNavigation, + std::vector> + attachedVolumes) noexcept(false); // Access to the portal targets: opposite/along normal vector - const DetectorVolumeUpdaters& detectorVolumeUpdaters() const; + const std::array& portalNavigation() const; // Access to the attached volumes - non-const access AttachedDetectorVolumes& attachedDetectorVolumes(); @@ -154,8 +151,8 @@ class Portal { std::shared_ptr m_surface; /// The portal targets along/opposite the normal vector - DetectorVolumeUpdaters m_volumeUpdaters = {DetectorVolumeUpdater{}, - DetectorVolumeUpdater{}}; + std::array m_portalNavigation = { + ExternalNavigationDelegate{}, ExternalNavigationDelegate{}}; /// The portal attaches to the following volumes AttachedDetectorVolumes m_attachedVolumes; diff --git a/Core/include/Acts/Detector/detail/IndexedGridFiller.hpp b/Core/include/Acts/Detector/detail/IndexedGridFiller.hpp index 742d733930f..1668f0ce857 100644 --- a/Core/include/Acts/Detector/detail/IndexedGridFiller.hpp +++ b/Core/include/Acts/Detector/detail/IndexedGridFiller.hpp @@ -13,7 +13,7 @@ #include "Acts/Detector/detail/ReferenceGenerators.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/Polyhedron.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Utilities/Delegate.hpp" #include "Acts/Utilities/Enumerate.hpp" #include "Acts/Utilities/GridAccessHelpers.hpp" diff --git a/Core/include/Acts/Detector/detail/IndexedSurfacesGenerator.hpp b/Core/include/Acts/Detector/detail/IndexedSurfacesGenerator.hpp index 598945d3e5d..6d87d9f3a50 100644 --- a/Core/include/Acts/Detector/detail/IndexedSurfacesGenerator.hpp +++ b/Core/include/Acts/Detector/detail/IndexedSurfacesGenerator.hpp @@ -10,7 +10,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Detector/detail/IndexedGridFiller.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Utilities/Enumerate.hpp" #include @@ -21,7 +21,7 @@ namespace Acts::Experimental::detail { /// @brief A templated indexed grid generator. /// -/// This Generator creates a SurfaceCandidatesUpdater delegate +/// This Generator creates a InternalNavigationDelegate delegate /// which can then be used in the DetectorVolume class for updating /// given surface candidates based on an index grid. /// @@ -56,9 +56,9 @@ struct IndexedSurfacesGenerator { /// @param aGenerator the axis generator /// @param rGenerator the reference generataor /// - /// @return a SurfaceCandidateUpdater delegate + /// @return an InternalNavigationDelegate template - SurfaceCandidatesUpdater operator()( + InternalNavigationDelegate operator()( const GeometryContext& gctx, const axis_generator& aGenerator, const reference_generator& rGenerator) const { ACTS_DEBUG("Indexing " << surfaces.size() << " surface, " @@ -81,16 +81,16 @@ struct IndexedSurfacesGenerator { filler.fill(gctx, indexedSurfaces, surfaces, rGenerator, assignToAll); // The portal delegate - AllPortalsImpl allPortals; + AllPortalsNavigation allPortals; // The chained delegate: indexed surfaces and all portals using DelegateType = - IndexedSurfacesAllPortalsImpl; + IndexedSurfacesAllPortalsNavigation; auto indexedSurfacesAllPortals = std::make_unique( std::tie(allPortals, indexedSurfaces)); // Create the delegate and connect it - SurfaceCandidatesUpdater nStateUpdater; + InternalNavigationDelegate nStateUpdater; nStateUpdater.connect<&DelegateType::update>( std::move(indexedSurfacesAllPortals)); return nStateUpdater; diff --git a/Core/include/Acts/Detector/detail/PortalHelper.hpp b/Core/include/Acts/Detector/detail/PortalHelper.hpp index 63eb39ffca6..52245ee4a66 100644 --- a/Core/include/Acts/Detector/detail/PortalHelper.hpp +++ b/Core/include/Acts/Detector/detail/PortalHelper.hpp @@ -44,9 +44,9 @@ namespace detail::PortalHelper { /// @param volume is the volume that is attached to the portal /// @param direction is the direction to which it is attached /// -void attachDetectorVolumeUpdater(Portal& portal, - const std::shared_ptr& volume, - const Direction& direction); +void attachExternalNavigationDelegate( + Portal& portal, const std::shared_ptr& volume, + const Direction& direction); /// @brief Create and attach the multi link updator, the portal will get /// a volume updator attached, that points to the different sub volumes @@ -73,7 +73,7 @@ void attachDetectorVolumesUpdater( /// @param volumes are the volumes that are pointed to /// @param pReplacements are the portal replacements that are newly connected /// -void attachDetectorVolumeUpdaters( +void attachExternalNavigationDelegates( const GeometryContext& gctx, const std::vector>& volumes, std::vector& pReplacements); diff --git a/Core/include/Acts/Detector/interface/IRootVolumeFinderBuilder.hpp b/Core/include/Acts/Detector/interface/IRootVolumeFinderBuilder.hpp index 793c5d8a9b1..aacb5c5dfc3 100644 --- a/Core/include/Acts/Detector/interface/IRootVolumeFinderBuilder.hpp +++ b/Core/include/Acts/Detector/interface/IRootVolumeFinderBuilder.hpp @@ -9,7 +9,7 @@ #pragma once #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include #include @@ -30,7 +30,7 @@ class IRootVolumeFinderBuilder { /// @param rootVolumes the root volumes to be used for the search /// /// @return a shared detector object - virtual DetectorVolumeUpdater construct( + virtual ExternalNavigationDelegate construct( const GeometryContext& gctx, const std::vector>& rootVolumes) const = 0; diff --git a/Core/include/Acts/Navigation/DetectorVolumeFinders.hpp b/Core/include/Acts/Navigation/DetectorVolumeFinders.hpp index afd24ed0e11..11f2f3730b5 100644 --- a/Core/include/Acts/Navigation/DetectorVolumeFinders.hpp +++ b/Core/include/Acts/Navigation/DetectorVolumeFinders.hpp @@ -22,12 +22,12 @@ namespace Acts::Experimental { -struct NoopFinder : public INavigationDelegate { +struct NoopFinder : public IExternalNavigation { inline void update(const GeometryContext& /*gctx*/, NavigationState& /*nState*/) const {} }; -struct RootVolumeFinder : public INavigationDelegate { +struct RootVolumeFinder : public IExternalNavigation { inline void update(const GeometryContext& gctx, NavigationState& nState) const { if (nState.currentDetector == nullptr) { @@ -39,7 +39,7 @@ struct RootVolumeFinder : public INavigationDelegate { for (const auto v : volumes) { if (v->inside(gctx, nState.position)) { nState.currentVolume = v; - v->detectorVolumeUpdater()(gctx, nState); + v->externalNavigation()(gctx, nState); return; } } @@ -47,7 +47,7 @@ struct RootVolumeFinder : public INavigationDelegate { } }; -struct TrialAndErrorVolumeFinder : public INavigationDelegate { +struct TrialAndErrorVolumeFinder : public IExternalNavigation { inline void update(const GeometryContext& gctx, NavigationState& nState) const { if (nState.currentVolume == nullptr) { @@ -59,7 +59,7 @@ struct TrialAndErrorVolumeFinder : public INavigationDelegate { for (const auto v : volumes) { if (v->inside(gctx, nState.position)) { nState.currentVolume = v; - v->detectorVolumeUpdater()(gctx, nState); + v->externalNavigation()(gctx, nState); return; } } @@ -67,24 +67,24 @@ struct TrialAndErrorVolumeFinder : public INavigationDelegate { }; /// Generate a delegate to try the root volumes -inline static DetectorVolumeUpdater tryRootVolumes() { - DetectorVolumeUpdater vFinder; +inline static ExternalNavigationDelegate tryRootVolumes() { + ExternalNavigationDelegate vFinder; vFinder.connect<&RootVolumeFinder::update>( std::make_unique()); return vFinder; } /// Generate a delegate to try all sub volumes -inline static DetectorVolumeUpdater tryAllSubVolumes() { - DetectorVolumeUpdater vFinder; +inline static ExternalNavigationDelegate tryAllSubVolumes() { + ExternalNavigationDelegate vFinder; vFinder.connect<&TrialAndErrorVolumeFinder::update>( std::make_unique()); return vFinder; } /// Generate a delegate to try no volume -inline static DetectorVolumeUpdater tryNoVolumes() { - DetectorVolumeUpdater vFinder; +inline static ExternalNavigationDelegate tryNoVolumes() { + ExternalNavigationDelegate vFinder; vFinder.connect<&NoopFinder::update>(std::make_unique()); return vFinder; } @@ -116,7 +116,7 @@ struct IndexedDetectorVolumeExtractor { /// @tparam grid_type is the grid type used for this template using IndexedDetectorVolumesImpl = - IndexedUpdaterImpl; + IndexedUpdaterImpl; } // namespace Acts::Experimental diff --git a/Core/include/Acts/Navigation/SurfaceCandidatesUpdaters.hpp b/Core/include/Acts/Navigation/InternalNavigation.hpp similarity index 77% rename from Core/include/Acts/Navigation/SurfaceCandidatesUpdaters.hpp rename to Core/include/Acts/Navigation/InternalNavigation.hpp index 3c707fcc731..288025e473c 100644 --- a/Core/include/Acts/Navigation/SurfaceCandidatesUpdaters.hpp +++ b/Core/include/Acts/Navigation/InternalNavigation.hpp @@ -13,7 +13,7 @@ #include "Acts/Detector/DetectorVolume.hpp" #include "Acts/Detector/Portal.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Navigation/MultiLayerSurfacesUpdater.hpp" +#include "Acts/Navigation/MultiLayerNavigation.hpp" #include "Acts/Navigation/NavigationState.hpp" #include "Acts/Navigation/NavigationStateFillers.hpp" #include "Acts/Navigation/NavigationStateUpdaters.hpp" @@ -24,7 +24,7 @@ namespace Acts::Experimental { -struct AllPortalsImpl : public INavigationDelegate { +struct AllPortalsNavigation : public IInternalNavigation { /// A ordered portal provider /// /// @param gctx is the Geometry context of this call @@ -38,7 +38,7 @@ struct AllPortalsImpl : public INavigationDelegate { NavigationState& nState) const { if (nState.currentVolume == nullptr) { throw std::runtime_error( - "AllPortalsImpl: no detector volume set to navigation state."); + "AllPortalsNavigation: no detector volume set to navigation state."); } // Retrieval necessary if (nState.surfaceCandidates.empty()) { @@ -56,7 +56,7 @@ struct AllPortalsImpl : public INavigationDelegate { } }; -struct AllPortalsAndSurfacesImpl : public INavigationDelegate { +struct AllPortalsAndSurfacesNavigation : public IInternalNavigation { /// An ordered list of portals and surfaces provider /// /// @param gctx is the Geometry context of this call @@ -70,7 +70,8 @@ struct AllPortalsAndSurfacesImpl : public INavigationDelegate { NavigationState& nState) const { if (nState.currentDetector == nullptr) { throw std::runtime_error( - "AllPortalsAndSurfacesImpl: no detector volume set to navigation " + "AllPortalsAndSurfacesNavigation: no detector volume set to " + "navigation " "state."); } // A volume switch has happened, update list of portals & surfaces @@ -94,10 +95,10 @@ struct AllPortalsAndSurfacesImpl : public INavigationDelegate { /// Generate a provider for all portals /// /// @return a connected navigationstate updator -inline static SurfaceCandidatesUpdater tryAllPortals() { - auto ap = std::make_unique(); - SurfaceCandidatesUpdater nStateUpdater; - nStateUpdater.connect<&AllPortalsImpl::update>(std::move(ap)); +inline static InternalNavigationDelegate tryAllPortals() { + auto ap = std::make_unique(); + InternalNavigationDelegate nStateUpdater; + nStateUpdater.connect<&AllPortalsNavigation::update>(std::move(ap)); return nStateUpdater; } @@ -107,10 +108,11 @@ inline static SurfaceCandidatesUpdater tryAllPortals() { /// setup with many surfaces /// /// @return a connected navigationstate updator -inline static SurfaceCandidatesUpdater tryAllPortalsAndSurfaces() { - auto aps = std::make_unique(); - SurfaceCandidatesUpdater nStateUpdater; - nStateUpdater.connect<&AllPortalsAndSurfacesImpl::update>(std::move(aps)); +inline static InternalNavigationDelegate tryAllPortalsAndSurfaces() { + auto aps = std::make_unique(); + InternalNavigationDelegate nStateUpdater; + nStateUpdater.connect<&AllPortalsAndSurfacesNavigation::update>( + std::move(aps)); return nStateUpdater; } @@ -118,7 +120,7 @@ inline static SurfaceCandidatesUpdater tryAllPortalsAndSurfaces() { /// checking, this could be e.g. support surfaces for layer structures, /// e.g. /// -struct AdditionalSurfacesImpl : public INavigationDelegate { +struct AdditionalSurfacesNavigation : public IInternalNavigation { /// The volumes held by this collection std::vector surfaces = {}; @@ -137,21 +139,23 @@ struct AdditionalSurfacesImpl : public INavigationDelegate { /// /// @tparam grid_type is the grid type used for this indexed lookup template -using IndexedSurfacesImpl = - IndexedUpdaterImpl; +using IndexedSurfacesNavigation = + IndexedUpdaterImpl; /// @brief An indexed multi layer surface implementation access /// /// @tparam grid_type is the grid type used for this indexed lookup template -using MultiLayerSurfacesImpl = - MultiLayerSurfacesUpdaterImpl; +using MultiLayerSurfacesNavigation = + MultiLayerNavigation; /// @brief An indexed surface implementation with portal access /// ///@tparam inexed_updator is the updator for the indexed surfaces template class indexed_updator> -using IndexedSurfacesAllPortalsImpl = - ChainedUpdaterImpl>; +using IndexedSurfacesAllPortalsNavigation = + ChainedUpdaterImpl>; } // namespace Acts::Experimental diff --git a/Core/include/Acts/Navigation/MultiLayerSurfacesUpdater.hpp b/Core/include/Acts/Navigation/MultiLayerNavigation.hpp similarity index 91% rename from Core/include/Acts/Navigation/MultiLayerSurfacesUpdater.hpp rename to Core/include/Acts/Navigation/MultiLayerNavigation.hpp index ea9a059d44c..a18e8c438cc 100644 --- a/Core/include/Acts/Navigation/MultiLayerSurfacesUpdater.hpp +++ b/Core/include/Acts/Navigation/MultiLayerNavigation.hpp @@ -20,7 +20,7 @@ namespace Acts::Experimental { template -class MultiLayerSurfacesUpdaterImpl : public INavigationDelegate { +class MultiLayerNavigation : public IInternalNavigation { public: /// Broadcast the grid type using grid_type = grid_t; @@ -41,13 +41,16 @@ class MultiLayerSurfacesUpdaterImpl : public INavigationDelegate { /// @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 - MultiLayerSurfacesUpdaterImpl( - grid_type igrid, const std::array& icasts, - const Transform3& itr = Transform3::Identity()) + MultiLayerNavigation(grid_type igrid, + const std::array& icasts, + const Transform3& itr = Transform3::Identity()) : grid(std::move(igrid)), casts(icasts), transform(itr) {} - MultiLayerSurfacesUpdaterImpl() = delete; + MultiLayerNavigation() = delete; + /// Update the navigation state + /// @param gctx is the geometry context + /// @param nState is the navigation state void update(const GeometryContext& gctx, NavigationState& nState) const { // get the local position and direction auto lposition = transform * nState.position; @@ -118,6 +121,8 @@ class MultiLayerSurfacesUpdaterImpl : public INavigationDelegate { } }; +/// A path generator that generates a straight path along a direction +/// in the grid struct PathGridSurfacesGenerator { std::vector operator()(Vector3 startPosition, const Vector3& direction, ActsScalar stepSize, diff --git a/Core/include/Acts/Navigation/NavigationDelegates.hpp b/Core/include/Acts/Navigation/NavigationDelegates.hpp index bcfe8fe4ad5..b0d747de7c8 100644 --- a/Core/include/Acts/Navigation/NavigationDelegates.hpp +++ b/Core/include/Acts/Navigation/NavigationDelegates.hpp @@ -18,13 +18,11 @@ class Surface; namespace Experimental { -/// Base class for navigation delegates -/// This allows to define a common Owning delegate -/// schema, which in turn allows for accessing the holder -/// of the delegate implementation for e.g. I/O or display -class INavigationDelegate { +/// Base class for navigation delegates that handle internal +/// volume navigation updates +class IInternalNavigation { public: - virtual ~INavigationDelegate() = default; + virtual ~IInternalNavigation() = default; }; /// Declare an updator for the local navigation, i.e. the @@ -41,9 +39,16 @@ class INavigationDelegate { /// /// @note it relies on the detector volume to be set to the state /// Memory managed navigation state updator -using SurfaceCandidatesUpdater = +using InternalNavigationDelegate = OwningDelegate; + IInternalNavigation>; + +/// Base class for external navigation delegates that handle external +/// volume navigation updates +class IExternalNavigation { + public: + virtual ~IExternalNavigation() = default; +}; /// Declare a Detctor Volume finding or switching delegate /// @@ -51,9 +56,9 @@ using SurfaceCandidatesUpdater = /// @param nState [in, out] is the navigation state to be updated /// /// @return the new DetectorVolume into which one changes at this switch -using DetectorVolumeUpdater = +using ExternalNavigationDelegate = OwningDelegate; + IExternalNavigation>; } // namespace Experimental } // namespace Acts diff --git a/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp b/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp index 89eebdc4b68..5b6f1412809 100644 --- a/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp +++ b/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp @@ -62,15 +62,23 @@ inline void updateCandidates(const GeometryContext& gctx, nState.surfaceCandidates = std::move(nextSurfaceCandidates); } -/// @brief This sets a single object, e.g. single surface or single volume +/// @brief This sets a single object, e.g. single surface or single volume +/// into the navigation state +/// +/// @tparam navigation_type distinguishes between internal and external navigation /// @tparam object_type the type of the object to be filled /// @tparam filler_type is the helper to fill the object into nState -template -class SingleObjectImpl : public INavigationDelegate { +/// +template +class SingleObjectNavigation : public navigation_type { public: /// Convenience constructor /// @param so the single object - SingleObjectImpl(const object_type* so) : object(so) {} + SingleObjectNavigation(const object_type* so) : m_object(so) { + if (so == nullptr) { + throw std::invalid_argument("SingleObjectNavigation: object is nullptr"); + } + } /// @brief updates the navigation state with a single object that is filled in /// @@ -80,21 +88,27 @@ class SingleObjectImpl : public INavigationDelegate { /// @note this is attaching objects without intersecting nor checking void update([[maybe_unused]] const GeometryContext& gctx, NavigationState& nState) const { - filler_type::fill(nState, object); + filler_type::fill(nState, m_object); } + /// Const Access to the object + const object_type* object() const { return m_object; } + private: // The object to be filled in - const object_type* object = nullptr; + const object_type* m_object = nullptr; }; /// @brief This uses state less extractor and fillers to manipulate /// the navigation state /// +/// @tparam navigation_type distinguishes between internal and external navigation /// @tparam extractor_type the helper to extract the objects from /// @tparam filler_type is the helper to fill the object into nState -template -class StaticUpdaterImpl : public INavigationDelegate { +/// +template +class StaticAccessNavigation : public navigation_type { public: /// @brief updates the navigation state with a single object that is filled in /// @@ -117,11 +131,14 @@ class StaticUpdaterImpl : public INavigationDelegate { /// /// It can be used for volumes, surfaces at convenience /// +/// @tparam navigation_type distinguishes between internal and external navigation /// @tparam grid_t is the type of the grid /// @tparam extractor_type is the helper to extract the object /// @tparam filler_type is the helper to fill the object into the nState -template -class IndexedUpdaterImpl : public INavigationDelegate { +/// +template +class IndexedUpdaterImpl : public navigation_type { public: /// Broadcast the grid type using grid_type = grid_t; @@ -164,7 +181,11 @@ class IndexedUpdaterImpl : public INavigationDelegate { auto extracted = extractor.extract(gctx, nState, entry); filler_type::fill(nState, extracted); - updateCandidates(gctx, nState); + // If the delegate type is of type IInternalNavigation + if constexpr (std::is_base_of_v) { + // Update the candidates + updateCandidates(gctx, nState); + } } }; @@ -172,9 +193,11 @@ class IndexedUpdaterImpl : public INavigationDelegate { /// Since there is no control whether it is a static or /// payload extractor, these have to be provided by a tuple /// +/// @tparam navigation_type distinguishes between internal and external navigation /// @tparam updators_t the updators that will be called in sequence -template -class ChainedUpdaterImpl : public INavigationDelegate { +/// +template +class ChainedUpdaterImpl : public navigation_type { public: /// The stored updators std::tuple updators; diff --git a/Core/include/Acts/Navigation/DetectorVolumeUpdaters.hpp b/Core/include/Acts/Navigation/PortalNavigation.hpp similarity index 75% rename from Core/include/Acts/Navigation/DetectorVolumeUpdaters.hpp rename to Core/include/Acts/Navigation/PortalNavigation.hpp index 94da589eb11..b5d0fbdfbe7 100644 --- a/Core/include/Acts/Navigation/DetectorVolumeUpdaters.hpp +++ b/Core/include/Acts/Navigation/PortalNavigation.hpp @@ -25,7 +25,7 @@ class DetectorVolume; /// @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 -struct EndOfWorldImpl : public INavigationDelegate { +struct EndOfWorld : public IExternalNavigation { /// @brief a null volume link - explicitly /// /// @note the method parameters are ignored @@ -35,33 +35,10 @@ struct EndOfWorldImpl : public INavigationDelegate { } }; -/// @brief Single volume updator, it sets the current navigation -/// volume to the volume in question -/// -struct SingleDetectorVolumeImpl : public INavigationDelegate { - const DetectorVolume* dVolume = nullptr; - - /// @brief Allowed constructor - /// @param sVolume the volume to which it points - SingleDetectorVolumeImpl(const DetectorVolume* sVolume) noexcept(false) - : dVolume(sVolume) { - if (sVolume == nullptr) { - throw std::invalid_argument( - "DetectorVolumeUpdaters: nullptr provided, use EndOfWorld instead."); - } - } - - SingleDetectorVolumeImpl() = delete; - - /// @brief a null volume link - explicitly - /// - /// @note the method parameters are ignored - /// - inline void update(const GeometryContext& /*ignored*/, - NavigationState& nState) const { - nState.currentVolume = dVolume; - } -}; +/// Navigation to a connected single detector volumed +using SingleDetectorVolumeNavigation = + SingleObjectNavigation; using SingleIndex = std::size_t; @@ -96,10 +73,10 @@ struct DetectorVolumesCollection { /// 1-dimensional grid, e.g. a z-spaced array, or an r-spaced array /// of volumes. /// -struct BoundVolumesGrid1Impl : public INavigationDelegate { +struct BoundVolumesGrid1Navigation : public IExternalNavigation { using IndexedUpdater = - IndexedUpdaterImpl; + IndexedUpdaterImpl; // The indexed updator IndexedUpdater indexedUpdater; @@ -109,7 +86,7 @@ struct BoundVolumesGrid1Impl : public INavigationDelegate { /// @param bValue the binning value /// @param cVolumes the contained volumes /// @param bTransform is the optional transform - BoundVolumesGrid1Impl( + BoundVolumesGrid1Navigation( const std::vector& gBoundaries, BinningValue bValue, const std::vector& cVolumes, const Transform3& bTransform = Transform3::Identity()) noexcept(false) @@ -120,7 +97,8 @@ struct BoundVolumesGrid1Impl : public INavigationDelegate { if (gBoundaries.size() != cVolumes.size() + 1u) { throw std::invalid_argument( - "DetectorVolumeUpdaters: mismatching boundaries and volume numbers"); + "ExternalNavigationDelegates: mismatching boundaries and volume " + "numbers"); } // Initialize the grid entries for (std::size_t ib = 1u; ib < gBoundaries.size(); ++ib) { @@ -128,7 +106,7 @@ struct BoundVolumesGrid1Impl : public INavigationDelegate { } } // Deleted default constructor - BoundVolumesGrid1Impl() = delete; + BoundVolumesGrid1Navigation() = delete; /// @brief This updator relies on an 1D single index grid /// diff --git a/Core/src/Detector/Detector.cpp b/Core/src/Detector/Detector.cpp index 96c136117e0..61a5e6b155c 100644 --- a/Core/src/Detector/Detector.cpp +++ b/Core/src/Detector/Detector.cpp @@ -21,14 +21,14 @@ Acts::Experimental::Detector::Detector( std::string name, std::vector> rootVolumes, - DetectorVolumeUpdater detectorVolumeUpdater) + ExternalNavigationDelegate detectorVolumeFinder) : m_name(std::move(name)), m_rootVolumes(std::move(rootVolumes)), - m_detectorVolumeUpdater(std::move(detectorVolumeUpdater)) { + m_volumeFinder(std::move(detectorVolumeFinder)) { if (m_rootVolumes.internal.empty()) { throw std::invalid_argument("Detector: no volume were given."); } - if (!m_detectorVolumeUpdater.connected()) { + if (!m_volumeFinder.connected()) { throw std::invalid_argument( "Detector: volume finder delegate is not connected."); } @@ -128,10 +128,10 @@ Acts::Experimental::Detector::Detector( std::shared_ptr Acts::Experimental::Detector::makeShared( std::string name, std::vector> rootVolumes, - DetectorVolumeUpdater detectorVolumeUpdater) { + ExternalNavigationDelegate detectorVolumeFinder) { return std::shared_ptr( new Detector(std::move(name), std::move(rootVolumes), - std::move(detectorVolumeUpdater))); + std::move(detectorVolumeFinder))); } std::vector>& @@ -155,13 +155,13 @@ Acts::Experimental::Detector::volumes() const { } void Acts::Experimental::Detector::updateDetectorVolumeFinder( - DetectorVolumeUpdater detectorVolumeUpdater) { - m_detectorVolumeUpdater = std::move(detectorVolumeUpdater); + ExternalNavigationDelegate detectorVolumeFinder) { + m_volumeFinder = std::move(detectorVolumeFinder); } -const Acts::Experimental::DetectorVolumeUpdater& +const Acts::Experimental::ExternalNavigationDelegate& Acts::Experimental::Detector::detectorVolumeFinder() const { - return m_detectorVolumeUpdater; + return m_volumeFinder; } const std::string& Acts::Experimental::Detector::name() const { @@ -180,7 +180,7 @@ Acts::Experimental::Detector::getSharedPtr() const { void Acts::Experimental::Detector::updateDetectorVolume( const GeometryContext& gctx, NavigationState& nState) const { - m_detectorVolumeUpdater(gctx, nState); + m_volumeFinder(gctx, nState); } const Acts::Experimental::DetectorVolume* @@ -189,7 +189,7 @@ Acts::Experimental::Detector::findDetectorVolume( NavigationState nState; nState.currentDetector = this; nState.position = position; - m_detectorVolumeUpdater(gctx, nState); + m_volumeFinder(gctx, nState); return nState.currentVolume; } diff --git a/Core/src/Detector/DetectorVolume.cpp b/Core/src/Detector/DetectorVolume.cpp index c3111553cbb..8d5d6d88d6f 100644 --- a/Core/src/Detector/DetectorVolume.cpp +++ b/Core/src/Detector/DetectorVolume.cpp @@ -13,8 +13,8 @@ #include "Acts/Geometry/Polyhedron.hpp" #include "Acts/Geometry/VolumeBounds.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" #include "Acts/Navigation/NavigationState.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Delegate.hpp" #include "Acts/Utilities/Enumerate.hpp" @@ -31,27 +31,27 @@ Acts::Experimental::DetectorVolume::DetectorVolume( std::shared_ptr bounds, std::vector> surfaces, std::vector> volumes, - DetectorVolumeUpdater detectorVolumeUpdater, - SurfaceCandidatesUpdater surfaceCandidateUpdater) + ExternalNavigationDelegate externalNavigation, + InternalNavigationDelegate internalNavigation) : m_name(std::move(name)), m_transform(transform), m_bounds(std::move(bounds)), m_surfaces(std::move(surfaces)), m_volumes(std::move(volumes)), - m_detectorVolumeUpdater(std::move(detectorVolumeUpdater)), - m_surfaceCandidatesUpdater(std::move(surfaceCandidateUpdater)), + m_externalNavigation(std::move(externalNavigation)), + m_internalNavigation(std::move(internalNavigation)), m_volumeMaterial(nullptr) { if (m_bounds == nullptr) { throw std::invalid_argument( "DetectorVolume: construction with nullptr bounds."); } - if (!m_detectorVolumeUpdater.connected()) { + if (!m_externalNavigation.connected()) { throw std::invalid_argument( - "DetectorVolume: navigation state updator delegate is not connected."); + "DetectorVolume: external navigation delegate is not connected."); } - if (!m_surfaceCandidatesUpdater.connected()) { + if (!m_internalNavigation.connected()) { throw std::invalid_argument( - "DetectorVolume: navigation state updator delegate is not connected."); + "DetectorVolume: internal navigaiton delegate is not connected."); } [[maybe_unused]] const auto& gctx_ref = gctx; @@ -60,9 +60,9 @@ Acts::Experimental::DetectorVolume::DetectorVolume( Acts::Experimental::DetectorVolume::DetectorVolume( const GeometryContext& gctx, std::string name, const Transform3& transform, std::shared_ptr bounds, - SurfaceCandidatesUpdater surfaceCandidateUpdater) + InternalNavigationDelegate internalNavigation) : DetectorVolume(gctx, std::move(name), transform, std::move(bounds), {}, - {}, tryNoVolumes(), std::move(surfaceCandidateUpdater)) {} + {}, tryNoVolumes(), std::move(internalNavigation)) {} std::shared_ptr Acts::Experimental::DetectorVolume::makeShared( @@ -70,22 +70,22 @@ Acts::Experimental::DetectorVolume::makeShared( std::shared_ptr bounds, std::vector> surfaces, std::vector> volumes, - DetectorVolumeUpdater detectorVolumeUpdater, - SurfaceCandidatesUpdater surfaceCandidateUpdater) { + ExternalNavigationDelegate externalNavigation, + InternalNavigationDelegate internalNavigation) { return std::shared_ptr(new DetectorVolume( gctx, std::move(name), transform, std::move(bounds), std::move(surfaces), - std::move(volumes), std::move(detectorVolumeUpdater), - std::move(surfaceCandidateUpdater))); + std::move(volumes), std::move(externalNavigation), + std::move(internalNavigation))); } std::shared_ptr Acts::Experimental::DetectorVolume::makeShared( const GeometryContext& gctx, std::string name, const Transform3& transform, std::shared_ptr bounds, - SurfaceCandidatesUpdater surfaceCandidateUpdater) { + InternalNavigationDelegate internalNavigation) { return std::shared_ptr( new DetectorVolume(gctx, std::move(name), transform, std::move(bounds), - std::move(surfaceCandidateUpdater))); + std::move(internalNavigation))); } const Acts::Transform3& Acts::Experimental::DetectorVolume::transform( @@ -133,14 +133,14 @@ Acts::Experimental::DetectorVolume::volumes() const { return m_volumes.external; } -const Acts::Experimental::DetectorVolumeUpdater& -Acts::Experimental::DetectorVolume::detectorVolumeUpdater() const { - return m_detectorVolumeUpdater; +const Acts::Experimental::ExternalNavigationDelegate& +Acts::Experimental::DetectorVolume::externalNavigation() const { + return m_externalNavigation; } -const Acts::Experimental::SurfaceCandidatesUpdater& -Acts::Experimental::DetectorVolume::surfaceCandidatesUpdater() const { - return m_surfaceCandidatesUpdater; +const Acts::Experimental::InternalNavigationDelegate& +Acts::Experimental::DetectorVolume::internalNavigation() const { + return m_internalNavigation; } void Acts::Experimental::DetectorVolume::assignVolumeMaterial( @@ -233,15 +233,15 @@ bool Acts::Experimental::DetectorVolume::exclusivelyInside( void Acts::Experimental::DetectorVolume::updateNavigationState( const GeometryContext& gctx, NavigationState& nState) const { nState.currentVolume = this; - m_surfaceCandidatesUpdater(gctx, nState); + m_internalNavigation(gctx, nState); nState.surfaceCandidateIndex = 0; } -void Acts::Experimental::DetectorVolume::assignSurfaceCandidatesUpdater( - SurfaceCandidatesUpdater surfaceCandidateUpdater, +void Acts::Experimental::DetectorVolume::assignInternalNavigation( + InternalNavigationDelegate internalNavigation, const std::vector>& surfaces, const std::vector>& volumes) { - m_surfaceCandidatesUpdater = std::move(surfaceCandidateUpdater); + m_internalNavigation = std::move(internalNavigation); m_surfaces = ObjectStore>(surfaces); m_volumes = ObjectStore>(volumes); } @@ -288,13 +288,13 @@ bool Acts::Experimental::DetectorVolume::checkContainment( void Acts::Experimental::DetectorVolume::closePortals() { for (auto& p : m_portals.internal) { // Create a null link - for (auto [ivu, vu] : enumerate(p->detectorVolumeUpdaters())) { + for (auto [ivu, vu] : enumerate(p->portalNavigation())) { if (!vu.connected()) { auto eowDir = Direction::fromIndex(ivu); - auto eow = std::make_unique(); - Acts::Experimental::DetectorVolumeUpdater eowLink; - eowLink.connect<&EndOfWorldImpl::update>(std::move(eow)); - p->assignDetectorVolumeUpdater(eowDir, std::move(eowLink), {}); + auto eow = std::make_unique(); + Acts::Experimental::ExternalNavigationDelegate eowLink; + eowLink.connect<&EndOfWorld::update>(std::move(eow)); + p->assignPortalNavigation(eowDir, std::move(eowLink), {}); } } } diff --git a/Core/src/Detector/DetectorVolumeBuilder.cpp b/Core/src/Detector/DetectorVolumeBuilder.cpp index 70407027927..e3615927be3 100644 --- a/Core/src/Detector/DetectorVolumeBuilder.cpp +++ b/Core/src/Detector/DetectorVolumeBuilder.cpp @@ -15,7 +15,7 @@ #include "Acts/Detector/interface/IInternalStructureBuilder.hpp" #include "Acts/Geometry/VolumeBounds.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Utilities/Enumerate.hpp" #include diff --git a/Core/src/Detector/IndexedRootVolumeFinderBuilder.cpp b/Core/src/Detector/IndexedRootVolumeFinderBuilder.cpp index 09501ebb268..759d20c0ca0 100644 --- a/Core/src/Detector/IndexedRootVolumeFinderBuilder.cpp +++ b/Core/src/Detector/IndexedRootVolumeFinderBuilder.cpp @@ -55,7 +55,7 @@ Acts::Experimental::IndexedRootVolumeFinderBuilder:: } } -Acts::Experimental::DetectorVolumeUpdater +Acts::Experimental::ExternalNavigationDelegate Acts::Experimental::IndexedRootVolumeFinderBuilder::construct( const GeometryContext& gctx, const std::vector>& rootVolumes) const { @@ -77,15 +77,15 @@ Acts::Experimental::IndexedRootVolumeFinderBuilder::construct( fillGridIndices2D(gctx, grid, rootVolumes, boundaries, casts); using IndexedDetectorVolumesImpl = - IndexedUpdaterImpl; + IndexedUpdaterImpl; auto indexedDetectorVolumeImpl = std::make_unique(std::move(grid), casts); // Return the root volume finder - DetectorVolumeUpdater rootVolumeFinder; + ExternalNavigationDelegate rootVolumeFinder; rootVolumeFinder.connect<&IndexedDetectorVolumesImpl::update>( std::move(indexedDetectorVolumeImpl)); return rootVolumeFinder; diff --git a/Core/src/Detector/LayerStructureBuilder.cpp b/Core/src/Detector/LayerStructureBuilder.cpp index 09a9d923c30..993dd08e5bf 100644 --- a/Core/src/Detector/LayerStructureBuilder.cpp +++ b/Core/src/Detector/LayerStructureBuilder.cpp @@ -84,17 +84,17 @@ void adaptBinningRange(std::vector& pBinning, /// /// @return a configured surface candidate updators template -Acts::Experimental::SurfaceCandidatesUpdater createUpdater( +Acts::Experimental::InternalNavigationDelegate createUpdater( const Acts::GeometryContext& gctx, std::vector> lSurfaces, std::vector assignToAll, const Acts::Experimental::ProtoBinning& binning) { // The surface candidate updator & a generator for polyhedrons - Acts::Experimental::SurfaceCandidatesUpdater sfCandidates; + Acts::Experimental::InternalNavigationDelegate sfCandidates; Acts::Experimental::detail::PolyhedronReferenceGenerator rGenerator; // Indexed Surface generator for this case Acts::Experimental::detail::IndexedSurfacesGenerator< - decltype(lSurfaces), Acts::Experimental::IndexedSurfacesImpl> + decltype(lSurfaces), Acts::Experimental::IndexedSurfacesNavigation> isg{std::move(lSurfaces), std::move(assignToAll), {binning.binValue}, @@ -126,18 +126,18 @@ Acts::Experimental::SurfaceCandidatesUpdater createUpdater( /// @return a configured surface candidate updators template -Acts::Experimental::SurfaceCandidatesUpdater createUpdater( +Acts::Experimental::InternalNavigationDelegate createUpdater( const Acts::GeometryContext& gctx, const std::vector>& lSurfaces, const std::vector& assignToAll, const Acts::Experimental::ProtoBinning& aBinning, const Acts::Experimental::ProtoBinning& bBinning) { // The surface candidate updator & a generator for polyhedrons - Acts::Experimental::SurfaceCandidatesUpdater sfCandidates; + Acts::Experimental::InternalNavigationDelegate sfCandidates; Acts::Experimental::detail::PolyhedronReferenceGenerator rGenerator; // Indexed Surface generator for this case Acts::Experimental::detail::IndexedSurfacesGenerator< - decltype(lSurfaces), Acts::Experimental::IndexedSurfacesImpl> + decltype(lSurfaces), Acts::Experimental::IndexedSurfacesNavigation> isg{lSurfaces, assignToAll, {aBinning.binValue, bBinning.binValue}, @@ -193,7 +193,7 @@ Acts::Experimental::LayerStructureBuilder::construct( const Acts::GeometryContext& gctx) const { // Trivialities first: internal volumes std::vector> internalVolumes = {}; - DetectorVolumeUpdater internalVolumeUpdater = tryNoVolumes(); + ExternalNavigationDelegate internalVolumeUpdater = tryNoVolumes(); // Print the auxiliary information if (!m_cfg.auxiliary.empty()) { @@ -201,7 +201,7 @@ Acts::Experimental::LayerStructureBuilder::construct( } // Retrieve the layer surfaces - SurfaceCandidatesUpdater internalCandidatesUpdater = + InternalNavigationDelegate internalCandidatesUpdater = tryAllPortalsAndSurfaces(); auto internalSurfaces = m_cfg.surfacesProvider->surfaces(gctx); ACTS_DEBUG("Building internal layer structure from " diff --git a/Core/src/Detector/MultiWireStructureBuilder.cpp b/Core/src/Detector/MultiWireStructureBuilder.cpp index 720b6af2c4b..5069797a28c 100644 --- a/Core/src/Detector/MultiWireStructureBuilder.cpp +++ b/Core/src/Detector/MultiWireStructureBuilder.cpp @@ -20,7 +20,7 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/VolumeBounds.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Utilities/GridAxisGenerators.hpp" #include "Acts/Utilities/Logger.hpp" @@ -63,12 +63,13 @@ class MultiWireInternalStructureBuilder ACTS_DEBUG(m_cfg.auxiliary); } - Acts::Experimental::DetectorVolumeUpdater internalVolumeUpdater = + Acts::Experimental::ExternalNavigationDelegate internalVolumeUpdater = Acts::Experimental::tryNoVolumes(); // Create the indexed surfaces auto internalSurfaces = m_cfg.iSurfaces; Acts::Experimental::detail::IndexedSurfacesGenerator< - decltype(internalSurfaces), Acts::Experimental::MultiLayerSurfacesImpl> + decltype(internalSurfaces), + Acts::Experimental::MultiLayerSurfacesNavigation> isg{internalSurfaces, {}, {m_cfg.binning[0u].binValue, m_cfg.binning[1u].binValue}, diff --git a/Core/src/Detector/Portal.cpp b/Core/src/Detector/Portal.cpp index 4e556d7aaa8..72519d2b0e9 100644 --- a/Core/src/Detector/Portal.cpp +++ b/Core/src/Detector/Portal.cpp @@ -33,8 +33,9 @@ Acts::RegularSurface& Portal::surface() { return *m_surface.get(); } -const Portal::DetectorVolumeUpdaters& Portal::detectorVolumeUpdaters() const { - return m_volumeUpdaters; +const std::array& +Portal::portalNavigation() const { + return m_portalNavigation; } Portal::AttachedDetectorVolumes& Portal::attachedDetectorVolumes() { @@ -52,13 +53,13 @@ std::shared_ptr Portal::fuse(std::shared_ptr& aPortal, } auto bothConnected = [](const auto& p) { - return p.m_volumeUpdaters[0u].connected() && - p.m_volumeUpdaters[1u].connected(); + return p.m_portalNavigation[0u].connected() && + p.m_portalNavigation[1u].connected(); }; auto noneConnected = [](const auto& p) { - return !p.m_volumeUpdaters[0u].connected() && - !p.m_volumeUpdaters[1u].connected(); + return !p.m_portalNavigation[0u].connected() && + !p.m_portalNavigation[1u].connected(); }; if (bothConnected(*aPortal) || bothConnected(*bPortal)) { @@ -77,10 +78,10 @@ std::shared_ptr Portal::fuse(std::shared_ptr& aPortal, std::shared_ptr fused = std::make_shared(aPortal->m_surface); // Get the connection directions - Direction getA = (aPortal->m_volumeUpdaters[0].connected()) + Direction getA = (aPortal->m_portalNavigation[0].connected()) ? Direction::fromIndex(0) : Direction::fromIndex(1); - Direction getB = (bPortal->m_volumeUpdaters[0].connected()) + Direction getB = (bPortal->m_portalNavigation[0].connected()) ? Direction::fromIndex(0) : Direction::fromIndex(1); @@ -107,39 +108,41 @@ std::shared_ptr Portal::fuse(std::shared_ptr& aPortal, setA = setB.invert(); } - fused->m_volumeUpdaters[setA.index()] = - std::move(aPortal->m_volumeUpdaters[getA.index()]); + fused->m_portalNavigation[setA.index()] = + std::move(aPortal->m_portalNavigation[getA.index()]); fused->m_attachedVolumes[setA.index()] = std::move(aPortal->m_attachedVolumes[getA.index()]); - fused->m_volumeUpdaters[setB.index()] = - std::move(bPortal->m_volumeUpdaters[getB.index()]); + fused->m_portalNavigation[setB.index()] = + std::move(bPortal->m_portalNavigation[getB.index()]); fused->m_attachedVolumes[setB.index()] = std::move(bPortal->m_attachedVolumes[getB.index()]); return fused; } -void Portal::assignDetectorVolumeUpdater( - Direction dir, DetectorVolumeUpdater dVolumeUpdater, +void Portal::assignPortalNavigation( + Direction dir, ExternalNavigationDelegate portalNavigation, std::vector> attachedVolumes) { auto idx = dir.index(); - m_volumeUpdaters[idx] = std::move(dVolumeUpdater); + m_portalNavigation[idx] = std::move(portalNavigation); m_attachedVolumes[idx] = std::move(attachedVolumes); } -void Portal::assignDetectorVolumeUpdater( - DetectorVolumeUpdater dVolumeUpdater, +void Portal::assignPortalNavigation( + ExternalNavigationDelegate portalNavigation, std::vector> attachedVolumes) { // Check and throw exceptions - if (!m_volumeUpdaters[0u].connected() && !m_volumeUpdaters[1u].connected()) { + if (!m_portalNavigation[0u].connected() && + !m_portalNavigation[1u].connected()) { throw std::runtime_error("Portal: portal has no link on either side."); } - if (m_volumeUpdaters[0u].connected() && m_volumeUpdaters[1u].connected()) { + if (m_portalNavigation[0u].connected() && + m_portalNavigation[1u].connected()) { throw std::runtime_error("Portal: portal already has links on both sides."); } - std::size_t idx = m_volumeUpdaters[0u].connected() ? 1u : 0u; - m_volumeUpdaters[idx] = std::move(dVolumeUpdater); + std::size_t idx = m_portalNavigation[0u].connected() ? 1u : 0u; + m_portalNavigation[idx] = std::move(portalNavigation); m_attachedVolumes[idx] = std::move(attachedVolumes); } @@ -149,7 +152,7 @@ void Portal::updateDetectorVolume(const GeometryContext& gctx, const auto& direction = nState.direction; const Vector3 normal = surface().normal(gctx, position); Direction dir = Direction::fromScalar(normal.dot(direction)); - const auto& vUpdater = m_volumeUpdaters[dir.index()]; + const auto& vUpdater = m_portalNavigation[dir.index()]; if (vUpdater.connected()) { vUpdater(gctx, nState); } else { diff --git a/Core/src/Detector/PortalGenerators.cpp b/Core/src/Detector/PortalGenerators.cpp index 16d198dcca2..0136c087b9d 100644 --- a/Core/src/Detector/PortalGenerators.cpp +++ b/Core/src/Detector/PortalGenerators.cpp @@ -11,8 +11,8 @@ #include "Acts/Detector/DetectorVolume.hpp" #include "Acts/Detector/Portal.hpp" #include "Acts/Geometry/VolumeBounds.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" #include "Acts/Navigation/NavigationDelegates.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Utilities/Enumerate.hpp" #include @@ -36,13 +36,13 @@ Acts::Experimental::generatePortals( auto portal = std::make_shared(oSurface.surface); // Create a shared link instance & delegate auto singleLinkImpl = - std::make_unique(dVolume.get()); - DetectorVolumeUpdater singleLink; - singleLink.connect<&SingleDetectorVolumeImpl::update>( + std::make_unique(dVolume.get()); + ExternalNavigationDelegate singleLink; + singleLink.connect<&SingleDetectorVolumeNavigation::update>( std::move(singleLinkImpl)); // Update the volume link and the store - portal->assignDetectorVolumeUpdater(oSurface.direction, - std::move(singleLink), {dVolume}); + portal->assignPortalNavigation(oSurface.direction, std::move(singleLink), + {dVolume}); // Portal is prepared portals.push_back(std::move(portal)); } @@ -72,11 +72,11 @@ Acts::Experimental::generatePortalsUpdateInternals( for (auto& pPtr : vPtr->portalPtrs()) { // Creating a link to the mother auto motherLinkImpl = - std::make_unique(dVolume.get()); - DetectorVolumeUpdater motherLink; - motherLink.connect<&SingleDetectorVolumeImpl::update>( + std::make_unique(dVolume.get()); + ExternalNavigationDelegate motherLink; + motherLink.connect<&SingleDetectorVolumeNavigation::update>( std::move(motherLinkImpl)); - pPtr->assignDetectorVolumeUpdater(std::move(motherLink), {dVolume}); + pPtr->assignPortalNavigation(std::move(motherLink), {dVolume}); } } // Return from the standard generator diff --git a/Core/src/Detector/detail/CuboidalDetectorHelper.cpp b/Core/src/Detector/detail/CuboidalDetectorHelper.cpp index 045dc7075da..137654223be 100644 --- a/Core/src/Detector/detail/CuboidalDetectorHelper.cpp +++ b/Core/src/Detector/detail/CuboidalDetectorHelper.cpp @@ -215,7 +215,7 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( } // Attach the new volume updaters - PortalHelper::attachDetectorVolumeUpdaters(gctx, volumes, pReplacements); + PortalHelper::attachExternalNavigationDelegates(gctx, volumes, pReplacements); // Return proto container DetectorComponent::PortalContainer dShell; diff --git a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp index 976ee706c5d..53001faac42 100644 --- a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp +++ b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp @@ -411,7 +411,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInR( } // Attach the new volume multi links - PortalHelper::attachDetectorVolumeUpdaters(gctx, volumes, pReplacements); + PortalHelper::attachExternalNavigationDelegates(gctx, volumes, pReplacements); // Exchange the portals of the volumes ACTS_VERBOSE("Portals of " << volumes.size() << " volumes need updating."); @@ -616,7 +616,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInZ( } // Attach the new volume multi links - PortalHelper::attachDetectorVolumeUpdaters(gctx, volumes, pReplacements); + PortalHelper::attachExternalNavigationDelegates(gctx, volumes, pReplacements); // Exchange the portals of the volumes ACTS_VERBOSE("Portals of " << volumes.size() << " volumes need updating."); @@ -746,7 +746,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInPhi( } // Attach the new volume multi links - PortalHelper::attachDetectorVolumeUpdaters(gctx, volumes, pReplacements); + PortalHelper::attachExternalNavigationDelegates(gctx, volumes, pReplacements); // Exchange the portals of the volumes ACTS_VERBOSE("Portals of " << volumes.size() << " volumes need updating."); for (auto& iv : volumes) { @@ -835,7 +835,8 @@ Acts::Experimental::detail::CylindricalDetectorHelper::wrapInZR( std::vector> zVolumes = { volumes[1u], volumes[0u], volumes[1u]}; // Attach the new volume multi links - PortalHelper::attachDetectorVolumeUpdaters(gctx, zVolumes, pReplacements); + PortalHelper::attachExternalNavigationDelegates(gctx, zVolumes, + pReplacements); auto& [p, i, dir, boundaries, binning] = pReplacements[0u]; // Update the portals volumes[1u]->updatePortal(p, 6u); diff --git a/Core/src/Detector/detail/IndexedGridFiller.cpp b/Core/src/Detector/detail/IndexedGridFiller.cpp index 62091b85f8c..42f313f59a7 100644 --- a/Core/src/Detector/detail/IndexedGridFiller.cpp +++ b/Core/src/Detector/detail/IndexedGridFiller.cpp @@ -13,7 +13,7 @@ #include "Acts/Detector/detail/ReferenceGenerators.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/Polyhedron.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Utilities/Delegate.hpp" #include "Acts/Utilities/Enumerate.hpp" #include "Acts/Utilities/IAxis.hpp" diff --git a/Core/src/Detector/detail/PortalHelper.cpp b/Core/src/Detector/detail/PortalHelper.cpp index 4db3b278189..ec6458aa42e 100644 --- a/Core/src/Detector/detail/PortalHelper.cpp +++ b/Core/src/Detector/detail/PortalHelper.cpp @@ -9,8 +9,8 @@ #include "Acts/Detector/detail/PortalHelper.hpp" #include "Acts/Detector/Portal.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" #include "Acts/Navigation/NavigationDelegates.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Helpers.hpp" @@ -18,19 +18,18 @@ #include #include -void Acts::Experimental::detail::PortalHelper::attachDetectorVolumeUpdater( +void Acts::Experimental::detail::PortalHelper::attachExternalNavigationDelegate( Portal& portal, const std::shared_ptr& volume, const Direction& direction) { // Create a shared link instance & delegate - auto volumeLinkImpl = - std::make_unique( - volume.get()); - Acts::Experimental::DetectorVolumeUpdater volumeLink; - volumeLink.connect<&Acts::Experimental::SingleDetectorVolumeImpl::update>( - std::move(volumeLinkImpl)); + auto volumeLinkImpl = std::make_unique< + const Acts::Experimental::SingleDetectorVolumeNavigation>(volume.get()); + Acts::Experimental::ExternalNavigationDelegate volumeLink; + volumeLink + .connect<&Acts::Experimental::SingleDetectorVolumeNavigation::update>( + std::move(volumeLinkImpl)); // Update the volume link and the store - portal.assignDetectorVolumeUpdater(direction, std::move(volumeLink), - {volume}); + portal.assignPortalNavigation(direction, std::move(volumeLink), {volume}); } void Acts::Experimental::detail::PortalHelper::attachDetectorVolumesUpdater( @@ -41,19 +40,20 @@ void Acts::Experimental::detail::PortalHelper::attachDetectorVolumesUpdater( // Check if the boundaries need a transform const auto pTransform = portal.surface().transform(gctx); // Creating a link to the mother - auto volumes1D = std::make_unique( + auto volumes1D = std::make_unique( boundaries, binning, unpack_shared_const_vector(volumes), pTransform.inverse()); - DetectorVolumeUpdater dVolumeUpdater; - dVolumeUpdater.connect<&BoundVolumesGrid1Impl::update>(std::move(volumes1D)); - portal.assignDetectorVolumeUpdater(direction, std::move(dVolumeUpdater), - volumes); + ExternalNavigationDelegate dVolumeUpdater; + dVolumeUpdater.connect<&BoundVolumesGrid1Navigation::update>( + std::move(volumes1D)); + portal.assignPortalNavigation(direction, std::move(dVolumeUpdater), volumes); } -void Acts::Experimental::detail::PortalHelper::attachDetectorVolumeUpdaters( - const GeometryContext& gctx, - const std::vector>& volumes, - std::vector& pReplacements) { +void Acts::Experimental::detail::PortalHelper:: + attachExternalNavigationDelegates( + const GeometryContext& gctx, + const std::vector>& volumes, + std::vector& pReplacements) { // Unpack to navigation bare points auto cVolumes = unpack_shared_const_vector(volumes); // Set to the constructed portals (p), at index (i), in direction (d) @@ -62,12 +62,12 @@ void Acts::Experimental::detail::PortalHelper::attachDetectorVolumeUpdaters( // 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( + auto volumes1D = std::make_unique( boundaries, binning, cVolumes, pTransform.inverse()); - DetectorVolumeUpdater dVolumeUpdater; - dVolumeUpdater.connect<&BoundVolumesGrid1Impl::update>( + ExternalNavigationDelegate dVolumeUpdater; + dVolumeUpdater.connect<&BoundVolumesGrid1Navigation::update>( std::move(volumes1D)); - p->assignDetectorVolumeUpdater(dir, std::move(dVolumeUpdater), volumes); + p->assignPortalNavigation(dir, std::move(dVolumeUpdater), volumes); } } diff --git a/Core/src/Visualization/GeometryView3D.cpp b/Core/src/Visualization/GeometryView3D.cpp index 26710a4800a..960182a4431 100644 --- a/Core/src/Visualization/GeometryView3D.cpp +++ b/Core/src/Visualization/GeometryView3D.cpp @@ -204,7 +204,7 @@ void Acts::GeometryView3D::drawPortal(IVisualization3D& helper, // color the portal based on if it contains two links(green) // or one link(red) auto surface = &(portal.surface()); - auto links = &(portal.detectorVolumeUpdaters()); + auto links = &(portal.portalNavigation()); if (links->size() == 2) { drawSurface(helper, *surface, gctx, transform, connected); } else { diff --git a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp index da8e3760d22..b9b6e3ec3b1 100644 --- a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp +++ b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp @@ -16,7 +16,7 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/VolumeBounds.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Plugins/Geant4/Geant4Converters.hpp" #include "Acts/Plugins/Geant4/Geant4DetectorElement.hpp" #include "Acts/Plugins/Geant4/Geant4DetectorSurfaceFactory.hpp" diff --git a/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp b/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp index 882612b4787..4596067a828 100644 --- a/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp +++ b/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp @@ -12,8 +12,8 @@ #include "Acts/Geometry/Extent.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/GeometryHierarchyMap.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Navigation/NavigationDelegates.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" #include "Acts/Plugins/ActSVG/GridSvgConverter.hpp" #include "Acts/Plugins/ActSVG/SurfaceSvgConverter.hpp" #include "Acts/Plugins/ActSVG/SvgUtils.hpp" @@ -188,14 +188,14 @@ ProtoIndexedSurfaceGrid convertImpl(const GeometryContext& gctx, template void convert(const GeometryContext& gctx, const surface_container& surfaces, const Options& cOptions, ProtoIndexedSurfaceGrid& sgi, - const Experimental::SurfaceCandidatesUpdater& delegate, + const Experimental::InternalNavigationDelegate& delegate, [[maybe_unused]] const instance_type& refInstance) { using GridType = typename instance_type::template grid_type>; // Defining a Delegate type - using DelegateType = Experimental::IndexedSurfacesAllPortalsImpl< - GridType, Experimental::IndexedSurfacesImpl>; - using SubDelegateType = Experimental::IndexedSurfacesImpl; + using DelegateType = Experimental::IndexedSurfacesAllPortalsNavigation< + GridType, Experimental::IndexedSurfacesNavigation>; + using SubDelegateType = Experimental::IndexedSurfacesNavigation; // Get the instance const auto* instance = delegate.instance(); @@ -218,7 +218,7 @@ template void unrollConvert(const GeometryContext& gctx, const surface_container& surfaces, const Options& cOptions, ProtoIndexedSurfaceGrid& sgi, - const Experimental::SurfaceCandidatesUpdater& delegate, + const Experimental::InternalNavigationDelegate& delegate, TypeList /*unused*/) { (convert(gctx, surfaces, cOptions, sgi, delegate, Args{}), ...); } @@ -237,7 +237,7 @@ void unrollConvert(const GeometryContext& gctx, template ProtoIndexedSurfaceGrid convert( const GeometryContext& gctx, const surface_container& surfaces, - const Experimental::SurfaceCandidatesUpdater& delegate, + const Experimental::InternalNavigationDelegate& delegate, const Options& cOptions) { // Prep work what is to be filled std::vector pSurfaces; diff --git a/Plugins/ActSVG/src/DetectorVolumeSvgConverter.cpp b/Plugins/ActSVG/src/DetectorVolumeSvgConverter.cpp index 359620715ee..db949a2c256 100644 --- a/Plugins/ActSVG/src/DetectorVolumeSvgConverter.cpp +++ b/Plugins/ActSVG/src/DetectorVolumeSvgConverter.cpp @@ -66,7 +66,7 @@ Acts::Svg::DetectorVolumeConverter::convert( pVolume._v_surfaces = pSurfaces; // Make dedicated surface grid sheets - const auto& internalNavigationDelegate = dVolume.surfaceCandidatesUpdater(); + const auto& internalNavigationDelegate = dVolume.internalNavigation(); IndexedSurfacesConverter::Options isOptions; // Use or transfer the surface style diff --git a/Plugins/ActSVG/src/PortalSvgConverter.cpp b/Plugins/ActSVG/src/PortalSvgConverter.cpp index 01c57a3b22c..16ccd30ef17 100644 --- a/Plugins/ActSVG/src/PortalSvgConverter.cpp +++ b/Plugins/ActSVG/src/PortalSvgConverter.cpp @@ -9,7 +9,7 @@ #include "Acts/Plugins/ActSVG/PortalSvgConverter.hpp" #include "Acts/Detector/Portal.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Surfaces/RegularSurface.hpp" namespace { @@ -49,7 +49,7 @@ Acts::Svg::ProtoLink makeProtoLink( /// @return it will return the proto links std::vector convertMultiLink( const Acts::GeometryContext& gctx, - const Acts::Experimental::BoundVolumesGrid1Impl& multiLink, + const Acts::Experimental::BoundVolumesGrid1Navigation& multiLink, const Acts::Surface& surface, const Acts::Vector3& refPosition, const Acts::Svg::PortalConverter::Options& portalOptions, int sign) noexcept(false) { @@ -138,20 +138,22 @@ Acts::Svg::ProtoPortal Acts::Svg::PortalConverter::convert( rDir = surface.normal(gctx, rPos); // Now convert the link objects - const auto& updators = portal.detectorVolumeUpdaters(); + const auto& updators = portal.portalNavigation(); int sign = -1; for (const auto& dvu : updators) { // Get the instance and start the casting const auto* instance = dvu.instance(); auto singleLink = - dynamic_cast(instance); + dynamic_cast( + instance); if (singleLink != nullptr) { pPortal._volume_links.push_back(makeProtoLink( - portalOptions, rPos, Vector3(sign * rDir), singleLink->dVolume)); + portalOptions, rPos, Vector3(sign * rDir), singleLink->object())); } auto multiLink = - dynamic_cast(instance); + dynamic_cast( + instance); if (multiLink != nullptr) { auto pLinks = convertMultiLink(gctx, *multiLink, surface, rPos, portalOptions, sign); diff --git a/Plugins/Json/include/Acts/Plugins/Json/DetectorVolumeFinderJsonConverter.hpp b/Plugins/Json/include/Acts/Plugins/Json/DetectorVolumeFinderJsonConverter.hpp index 67206b9a2c4..6f46b70a2f1 100644 --- a/Plugins/Json/include/Acts/Plugins/Json/DetectorVolumeFinderJsonConverter.hpp +++ b/Plugins/Json/include/Acts/Plugins/Json/DetectorVolumeFinderJsonConverter.hpp @@ -9,7 +9,8 @@ #pragma once #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" +#include "Acts/Navigation/NavigationDelegates.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Plugins/Json/DetrayJsonHelper.hpp" #include "Acts/Plugins/Json/IndexedGridJsonHelper.hpp" #include "Acts/Utilities/Grid.hpp" @@ -29,13 +30,14 @@ namespace Acts::DetectorVolumeFinderJsonConverter { /// @param refInstance is a reference instance of potential type casting template void convert(nlohmann::json& jIndexedVolumes, - const Experimental::DetectorVolumeUpdater& delegate, bool detray, - [[maybe_unused]] const instance_type& refInstance) { + const Experimental::ExternalNavigationDelegate& delegate, + bool detray, [[maybe_unused]] const instance_type& refInstance) { using GridType = typename instance_type::template grid_type; // Defining a Delegate type using DelegateType = Experimental::IndexedUpdaterImpl< - GridType, Acts::Experimental::IndexedDetectorVolumeExtractor, - Acts::Experimental::DetectorVolumeFiller>; + Experimental::IExternalNavigation, GridType, + Experimental::IndexedDetectorVolumeExtractor, + Experimental::DetectorVolumeFiller>; // Get the instance const auto* instance = delegate.instance(); auto castedDelegate = dynamic_cast(instance); @@ -62,7 +64,7 @@ void convert(nlohmann::json& jIndexedVolumes, /// @param detray indicate if this is a detray json to be written out template void unrollConvert(nlohmann::json& jIndexedVolumes, - const Experimental::DetectorVolumeUpdater& delegate, + const Experimental::ExternalNavigationDelegate& delegate, bool detray, TypeList /*unused*/) { (convert(jIndexedVolumes, delegate, detray, Args{}), ...); } @@ -79,7 +81,8 @@ void unrollConvert(nlohmann::json& jIndexedVolumes, /// /// @return a json object static inline nlohmann::json toJson( - const Experimental::DetectorVolumeUpdater& delegate, bool detray = false) { + const Experimental::ExternalNavigationDelegate& delegate, + bool detray = false) { // Convert if dynamic cast happens to work nlohmann::json jIndexedVolumes; unrollConvert(jIndexedVolumes, delegate, detray, @@ -93,7 +96,7 @@ static inline nlohmann::json toJson( /// @param jVolumeFinder the json file to read from /// /// @return the connected navigation delegate -Experimental::DetectorVolumeUpdater fromJson( +Experimental::ExternalNavigationDelegate fromJson( const nlohmann::json& jVolumeFinder); } // namespace Acts::DetectorVolumeFinderJsonConverter diff --git a/Plugins/Json/include/Acts/Plugins/Json/IndexedSurfacesJsonConverter.hpp b/Plugins/Json/include/Acts/Plugins/Json/IndexedSurfacesJsonConverter.hpp index 7518226e19c..d0d9d7081d4 100644 --- a/Plugins/Json/include/Acts/Plugins/Json/IndexedSurfacesJsonConverter.hpp +++ b/Plugins/Json/include/Acts/Plugins/Json/IndexedSurfacesJsonConverter.hpp @@ -11,8 +11,8 @@ #include "Acts/Detector/detail/IndexedSurfacesGenerator.hpp" #include "Acts/Geometry/Extent.hpp" #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Navigation/NavigationDelegates.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" #include "Acts/Plugins/Json/AlgebraJsonConverter.hpp" #include "Acts/Plugins/Json/DetrayJsonHelper.hpp" #include "Acts/Plugins/Json/GridJsonConverter.hpp" @@ -43,14 +43,14 @@ namespace IndexedSurfacesJsonConverter { /// @param refInstance is a reference instance of potential type casting template void convert(nlohmann::json& jIndexedSurfaces, - const Experimental::SurfaceCandidatesUpdater& delegate, + const Experimental::InternalNavigationDelegate& delegate, bool detray, [[maybe_unused]] const instance_type& refInstance) { using GridType = typename instance_type::template grid_type>; // Defining a Delegate type - using DelegateType = Experimental::IndexedSurfacesAllPortalsImpl< - GridType, Experimental::IndexedSurfacesImpl>; - using SubDelegateType = Experimental::IndexedSurfacesImpl; + using DelegateType = Experimental::IndexedSurfacesAllPortalsNavigation< + GridType, Experimental::IndexedSurfacesNavigation>; + using SubDelegateType = Experimental::IndexedSurfacesNavigation; // Get the instance const auto* instance = delegate.instance(); @@ -77,7 +77,7 @@ void convert(nlohmann::json& jIndexedSurfaces, /// @param detray if the detray json format is written template void unrollConvert(nlohmann::json& jIndexedSurfaces, - const Experimental::SurfaceCandidatesUpdater& delegate, + const Experimental::InternalNavigationDelegate& delegate, bool detray, TypeList /*unused*/) { (convert(jIndexedSurfaces, delegate, detray, Args{}), ...); } @@ -92,7 +92,7 @@ void unrollConvert(nlohmann::json& jIndexedSurfaces, /// /// @return a json object representing the surface updator static inline nlohmann::json toJson( - const Experimental::SurfaceCandidatesUpdater& delegate, + const Experimental::InternalNavigationDelegate& delegate, bool detray = false) { // Convert if dynamic cast happens to work nlohmann::json jIndexedSurfaces; @@ -110,7 +110,7 @@ static inline nlohmann::json toJson( /// @param jSurfaceNavigation the json file to read from /// /// @return the surface navigation delegate -Experimental::SurfaceCandidatesUpdater fromJson( +Experimental::InternalNavigationDelegate fromJson( const nlohmann::json& jSurfaceNavigation); } // namespace IndexedSurfacesJsonConverter diff --git a/Plugins/Json/include/Acts/Plugins/Json/PortalJsonConverter.hpp b/Plugins/Json/include/Acts/Plugins/Json/PortalJsonConverter.hpp index 64c28c25f82..3dbdbfb7b8f 100644 --- a/Plugins/Json/include/Acts/Plugins/Json/PortalJsonConverter.hpp +++ b/Plugins/Json/include/Acts/Plugins/Json/PortalJsonConverter.hpp @@ -10,7 +10,7 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/VolumeBounds.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Plugins/Json/ActsJson.hpp" #include "Acts/Plugins/Json/SurfaceJsonConverter.hpp" #include "Acts/Utilities/Logger.hpp" @@ -74,7 +74,7 @@ std::vector toJsonDetray( /// /// @return a json object nlohmann::json toJson( - const Experimental::DetectorVolumeUpdater& updator, + const Experimental::ExternalNavigationDelegate& updator, const std::vector& detectorVolumes); /// @brief convert from json format diff --git a/Plugins/Json/src/DetectorJsonConverter.cpp b/Plugins/Json/src/DetectorJsonConverter.cpp index 48b305cbce3..0cec6ba18bd 100644 --- a/Plugins/Json/src/DetectorJsonConverter.cpp +++ b/Plugins/Json/src/DetectorJsonConverter.cpp @@ -146,7 +146,7 @@ nlohmann::json Acts::DetectorJsonConverter::toJsonDetray( for (const auto [iv, volume] : enumerate(volumes)) { // And its surface navigation delegates nlohmann::json jSurfacesDelegate = IndexedSurfacesJsonConverter::toJson( - volume->surfaceCandidatesUpdater(), true); + volume->internalNavigation(), true); if (jSurfacesDelegate.is_null()) { continue; } diff --git a/Plugins/Json/src/DetectorVolumeFinderJsonConverter.cpp b/Plugins/Json/src/DetectorVolumeFinderJsonConverter.cpp index 6f8c11ab5bb..7f6039f82e0 100644 --- a/Plugins/Json/src/DetectorVolumeFinderJsonConverter.cpp +++ b/Plugins/Json/src/DetectorVolumeFinderJsonConverter.cpp @@ -9,7 +9,8 @@ #include "Acts/Plugins/Json/DetectorVolumeFinderJsonConverter.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" +#include "Acts/Navigation/NavigationDelegates.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Plugins/Json/GridJsonConverter.hpp" #include "Acts/Plugins/Json/UtilitiesJsonConverter.hpp" #include "Acts/Utilities/GridAxisGenerators.hpp" @@ -32,14 +33,15 @@ struct IndexedVolumesGenerator { /// @param bv the bin value array /// @param transform the transform for the indexed volumes inmplementaiton /// - /// @return a connected DetectorVolumeUpdater object + /// @return a connected ExternalNavigationDelegate object template - Acts::Experimental::DetectorVolumeUpdater createUpdater( + Acts::Experimental::ExternalNavigationDelegate createUpdater( grid_type&& grid, const std::array& bv, const Acts::Transform3& transform) { using IndexedDetectorVolumesImpl = Acts::Experimental::IndexedUpdaterImpl< - grid_type, Acts::Experimental::IndexedDetectorVolumeExtractor, + Acts::Experimental::IExternalNavigation, grid_type, + Acts::Experimental::IndexedDetectorVolumeExtractor, Acts::Experimental::DetectorVolumeFiller>; auto indexedDetectorVolumeImpl = @@ -47,7 +49,7 @@ struct IndexedVolumesGenerator { transform); // Create the delegate and connect it - Acts::Experimental::DetectorVolumeUpdater vFinder; + Acts::Experimental::ExternalNavigationDelegate vFinder; vFinder.connect<&IndexedDetectorVolumesImpl::update>( std::move(indexedDetectorVolumeImpl)); return vFinder; @@ -56,12 +58,12 @@ struct IndexedVolumesGenerator { } // namespace -Acts::Experimental::SurfaceCandidatesUpdater +Acts::Experimental::ExternalNavigationDelegate Acts::DetectorVolumeFinderJsonConverter::fromJson( const nlohmann::json& jVolumeFinder) { // The return object auto vFinder = IndexedGridJsonHelper::generateFromJson< - Experimental::DetectorVolumeUpdater, IndexedVolumesGenerator>( + Experimental::ExternalNavigationDelegate, IndexedVolumesGenerator>( jVolumeFinder, "IndexedVolumes"); if (vFinder.connected()) { return vFinder; diff --git a/Plugins/Json/src/DetectorVolumeJsonConverter.cpp b/Plugins/Json/src/DetectorVolumeJsonConverter.cpp index bf1217b65eb..4817e3435b5 100644 --- a/Plugins/Json/src/DetectorVolumeJsonConverter.cpp +++ b/Plugins/Json/src/DetectorVolumeJsonConverter.cpp @@ -12,7 +12,7 @@ #include "Acts/Detector/Portal.hpp" #include "Acts/Detector/PortalGenerators.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Plugins/Json/AlgebraJsonConverter.hpp" #include "Acts/Plugins/Json/DetrayJsonHelper.hpp" #include "Acts/Plugins/Json/IndexedSurfacesJsonConverter.hpp" @@ -63,7 +63,7 @@ nlohmann::json Acts::DetectorVolumeJsonConverter::toJson( jVolume["surfaces"] = jSurfaces; // And its surface navigation delegates nlohmann::json jSurfacesDelegate = - IndexedSurfacesJsonConverter::toJson(volume.surfaceCandidatesUpdater()); + IndexedSurfacesJsonConverter::toJson(volume.internalNavigation()); jVolume["surface_navigation"] = jSurfacesDelegate; // Write the sub volumes diff --git a/Plugins/Json/src/IndexedSurfacesJsonConverter.cpp b/Plugins/Json/src/IndexedSurfacesJsonConverter.cpp index d44baf99c20..d53b15dd5cc 100644 --- a/Plugins/Json/src/IndexedSurfacesJsonConverter.cpp +++ b/Plugins/Json/src/IndexedSurfacesJsonConverter.cpp @@ -25,7 +25,7 @@ namespace { struct IndexedSurfacesGenerator { using value_type = std::vector; - /// @brief Helper function to create and connect the IndexedSurfacesImpl + /// @brief Helper function to create and connect the IndexedSurfacesNavigation /// /// @tparam grid_type the type of the grid, indicates also the dimension /// @@ -33,26 +33,27 @@ struct IndexedSurfacesGenerator { /// @param bv the bin value array /// @param transform the transform for the indexed surfaces inmplementaiton /// - /// @return a connected SurfaceCandidatesUpdater object + /// @return a connected InternalNavigationDelegate object template - Acts::Experimental::SurfaceCandidatesUpdater createUpdater( + Acts::Experimental::InternalNavigationDelegate createUpdater( grid_type&& grid, const std::array& bv, const Acts::Transform3& transform) { - Acts::Experimental::IndexedSurfacesImpl indexedSurfaces( + Acts::Experimental::IndexedSurfacesNavigation indexedSurfaces( std::move(grid), bv, transform); // The portal delegate - Acts::Experimental::AllPortalsImpl allPortals; + Acts::Experimental::AllPortalsNavigation allPortals; // The chained delegate: indexed surfaces and all portals - using DelegateType = Acts::Experimental::IndexedSurfacesAllPortalsImpl< - grid_type, Acts::Experimental::IndexedSurfacesImpl>; + using DelegateType = + Acts::Experimental::IndexedSurfacesAllPortalsNavigation< + grid_type, Acts::Experimental::IndexedSurfacesNavigation>; auto indexedSurfacesAllPortals = std::make_unique( std::tie(allPortals, indexedSurfaces)); // Create the delegate and connect it - Acts::Experimental::SurfaceCandidatesUpdater nStateUpdater; + Acts::Experimental::InternalNavigationDelegate nStateUpdater; nStateUpdater.connect<&DelegateType::update>( std::move(indexedSurfacesAllPortals)); @@ -62,13 +63,13 @@ struct IndexedSurfacesGenerator { } // namespace -Acts::Experimental::SurfaceCandidatesUpdater +Acts::Experimental::InternalNavigationDelegate Acts::IndexedSurfacesJsonConverter::fromJson( const nlohmann::json& jSurfaceNavigation) { if (!jSurfaceNavigation.is_null()) { // The return object auto sfCandidates = IndexedGridJsonHelper::generateFromJson< - Experimental::SurfaceCandidatesUpdater, IndexedSurfacesGenerator>( + Experimental::InternalNavigationDelegate, IndexedSurfacesGenerator>( jSurfaceNavigation, "IndexedSurfaces"); if (sfCandidates.connected()) { return sfCandidates; diff --git a/Plugins/Json/src/PortalJsonConverter.cpp b/Plugins/Json/src/PortalJsonConverter.cpp index 893a6e72963..f47905643e2 100644 --- a/Plugins/Json/src/PortalJsonConverter.cpp +++ b/Plugins/Json/src/PortalJsonConverter.cpp @@ -11,7 +11,7 @@ #include "Acts/Detector/DetectorVolume.hpp" #include "Acts/Detector/Portal.hpp" #include "Acts/Detector/detail/PortalHelper.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Plugins/Json/DetrayJsonHelper.hpp" #include "Acts/Plugins/Json/SurfaceJsonConverter.hpp" #include "Acts/Plugins/Json/UtilitiesJsonConverter.hpp" @@ -58,7 +58,7 @@ nlohmann::json Acts::PortalJsonConverter::toJson( jPortal["surface"] = SurfaceJsonConverter::toJson(gctx, portal.surface(), options.surfaceOptions); // And the portal specific information - const auto& volumeLinks = portal.detectorVolumeUpdaters(); + const auto& volumeLinks = portal.portalNavigation(); nlohmann::json jLinks; for (const auto& vLink : volumeLinks) { nlohmann::json jLink = toJson(vLink, detectorVolumes); @@ -78,7 +78,7 @@ std::vector Acts::PortalJsonConverter::toJsonDetray( // The overall return object std::vector jPortals = {}; const RegularSurface& surface = portal.surface(); - const auto& volumeLinks = portal.detectorVolumeUpdaters(); + const auto& volumeLinks = portal.portalNavigation(); // First assumption for outside link (along direction) std::size_t outside = 1u; @@ -108,7 +108,7 @@ std::vector Acts::PortalJsonConverter::toJsonDetray( const auto* instance = outsideLink.instance(); // Single link cast auto singleLink = - dynamic_cast( + dynamic_cast( instance); auto [surfaceAdjusted, insidePointer] = orientedSurfaces[ip]; @@ -119,7 +119,7 @@ std::vector Acts::PortalJsonConverter::toJsonDetray( // in order to make sure the size is adjusted if (singleLink != nullptr) { // Single link can be written out - std::size_t vLink = findVolume(singleLink->dVolume, detectorVolumes); + std::size_t vLink = findVolume(singleLink->object(), detectorVolumes); auto jPortal = SurfaceJsonConverter::toJsonDetray(gctx, *surfaceAdjusted, surfaceOptions); DetrayJsonHelper::addVolumeLink(jPortal["mask"], vLink); @@ -127,7 +127,8 @@ std::vector Acts::PortalJsonConverter::toJsonDetray( } else { // Multi link detected - 1D auto multiLink1D = - dynamic_cast(instance); + dynamic_cast( + instance); if (multiLink1D != nullptr) { // Resolve the multi link 1D auto boundaries = @@ -254,17 +255,18 @@ std::vector Acts::PortalJsonConverter::toJsonDetray( } nlohmann::json Acts::PortalJsonConverter::toJson( - const Experimental::DetectorVolumeUpdater& updator, + const Experimental::ExternalNavigationDelegate& updator, const std::vector& detectorVolumes) { nlohmann::json jLink; if (updator.connected()) { const auto instance = updator.instance(); // Single link cast auto singleLink = - dynamic_cast(instance); + dynamic_cast( + instance); // Single link detected if (singleLink != nullptr) { - auto vIndex = findVolume(singleLink->dVolume, detectorVolumes); + auto vIndex = findVolume(singleLink->object(), detectorVolumes); if (vIndex < 0) { throw std::runtime_error( "PortalJsonConverter: volume not found in the list of volumes."); @@ -273,7 +275,8 @@ nlohmann::json Acts::PortalJsonConverter::toJson( } // Multi link detected - 1D auto multiLink1D = - dynamic_cast(instance); + dynamic_cast( + instance); if (multiLink1D != nullptr) { nlohmann::json jMultiLink; const auto& volumes = multiLink1D->indexedUpdater.extractor.dVolumes; @@ -315,7 +318,7 @@ std::shared_ptr Acts::PortalJsonConverter::fromJson( for (auto [ivl, vl] : enumerate(jLinks)) { if (vl.contains("single")) { const auto vIndex = vl["single"].get(); - Experimental::detail::PortalHelper::attachDetectorVolumeUpdater( + Experimental::detail::PortalHelper::attachExternalNavigationDelegate( *portal, detectorVolumes[vIndex], normalDirs[ivl]); } else if (vl.contains("multi_1D")) { // Resolve the multi link 1D diff --git a/Tests/UnitTests/Core/Detector/CuboidalContainerBuilderTests.cpp b/Tests/UnitTests/Core/Detector/CuboidalContainerBuilderTests.cpp index e9b3c6e7630..1d26fc7b0eb 100644 --- a/Tests/UnitTests/Core/Detector/CuboidalContainerBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/CuboidalContainerBuilderTests.cpp @@ -20,7 +20,7 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/Surface.hpp" diff --git a/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp b/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp index 2fb8ac15c05..0137d8ffcd9 100644 --- a/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp +++ b/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp @@ -20,7 +20,7 @@ #include "Acts/Detector/interface/IInternalStructureBuilder.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -48,11 +48,11 @@ class SurfaceBuilder : public Acts::Experimental::IInternalStructureBuilder { // Trivialities first: internal volumes std::vector> internalVolumes = {}; - Acts::Experimental::DetectorVolumeUpdater internalVolumeUpdater = + Acts::Experimental::ExternalNavigationDelegate internalVolumeUpdater = Acts::Experimental::tryNoVolumes(); // Retrieve the layer surfaces - Acts::Experimental::SurfaceCandidatesUpdater internalCandidatesUpdater = + Acts::Experimental::InternalNavigationDelegate internalCandidatesUpdater = Acts::Experimental::tryAllPortalsAndSurfaces(); // Return the internal structure diff --git a/Tests/UnitTests/Core/Detector/CuboidalDetectorHelperTests.cpp b/Tests/UnitTests/Core/Detector/CuboidalDetectorHelperTests.cpp index 65a2e9c0a87..dc02f2a894f 100644 --- a/Tests/UnitTests/Core/Detector/CuboidalDetectorHelperTests.cpp +++ b/Tests/UnitTests/Core/Detector/CuboidalDetectorHelperTests.cpp @@ -14,7 +14,7 @@ #include "Acts/Detector/detail/CuboidalDetectorHelper.hpp" #include "Acts/Geometry/CuboidVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Utilities/BinningData.hpp" #include "Acts/Utilities/StringHelpers.hpp" #include "Acts/Visualization/GeometryView3D.hpp" diff --git a/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp b/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp index ed1fbef6f91..b6f196c5057 100644 --- a/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp @@ -20,7 +20,7 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Surfaces/DiscSurface.hpp" diff --git a/Tests/UnitTests/Core/Detector/CylindricalDetectorFromBlueprintTests.cpp b/Tests/UnitTests/Core/Detector/CylindricalDetectorFromBlueprintTests.cpp index c3a7f12ba15..49d4ddfb100 100644 --- a/Tests/UnitTests/Core/Detector/CylindricalDetectorFromBlueprintTests.cpp +++ b/Tests/UnitTests/Core/Detector/CylindricalDetectorFromBlueprintTests.cpp @@ -20,7 +20,7 @@ #include "Acts/Detector/interface/IInternalStructureBuilder.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Utilities/BinningData.hpp" @@ -43,11 +43,11 @@ class SurfaceBuilder : public Acts::Experimental::IInternalStructureBuilder { // Trivialities first: internal volumes std::vector> internalVolumes = {}; - Acts::Experimental::DetectorVolumeUpdater internalVolumeUpdater = + Acts::Experimental::ExternalNavigationDelegate internalVolumeUpdater = Acts::Experimental::tryNoVolumes(); // Retrieve the layer surfaces - Acts::Experimental::SurfaceCandidatesUpdater internalCandidatesUpdater = + Acts::Experimental::InternalNavigationDelegate internalCandidatesUpdater = Acts::Experimental::tryAllPortalsAndSurfaces(); // Return the internal structure diff --git a/Tests/UnitTests/Core/Detector/CylindricalDetectorHelperTests.cpp b/Tests/UnitTests/Core/Detector/CylindricalDetectorHelperTests.cpp index 6b3e7173134..f0a13b368dd 100644 --- a/Tests/UnitTests/Core/Detector/CylindricalDetectorHelperTests.cpp +++ b/Tests/UnitTests/Core/Detector/CylindricalDetectorHelperTests.cpp @@ -20,7 +20,7 @@ #include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Utilities/Enumerate.hpp" #include "Acts/Utilities/Logger.hpp" diff --git a/Tests/UnitTests/Core/Detector/DetectorBuilderTests.cpp b/Tests/UnitTests/Core/Detector/DetectorBuilderTests.cpp index e5732b5f3fa..4e8b9117f91 100644 --- a/Tests/UnitTests/Core/Detector/DetectorBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/DetectorBuilderTests.cpp @@ -20,7 +20,7 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/Surface.hpp" diff --git a/Tests/UnitTests/Core/Detector/DetectorTests.cpp b/Tests/UnitTests/Core/Detector/DetectorTests.cpp index 6d94b9ed742..6f009e42523 100644 --- a/Tests/UnitTests/Core/Detector/DetectorTests.cpp +++ b/Tests/UnitTests/Core/Detector/DetectorTests.cpp @@ -22,9 +22,9 @@ #include "Acts/Material/Material.hpp" #include "Acts/Material/MaterialSlab.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Navigation/NavigationDelegates.hpp" #include "Acts/Navigation/NavigationState.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp" @@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(DetectorConstruction) { BOOST_CHECK_EQUAL(findNull, nullptr); // Misconfigured - unkonnected finder - Acts::Experimental::DetectorVolumeUpdater unconnected; + Acts::Experimental::ExternalNavigationDelegate unconnected; BOOST_CHECK_THROW( Acts::Experimental::Detector::makeShared("Det012_unconnected", volumes012, std::move(unconnected)), diff --git a/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp b/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp index 31ddc69e794..5b2f7e941cb 100644 --- a/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp @@ -20,7 +20,7 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Surfaces/Surface.hpp" diff --git a/Tests/UnitTests/Core/Detector/DetectorVolumeConsistencyTests.cpp b/Tests/UnitTests/Core/Detector/DetectorVolumeConsistencyTests.cpp index 1619b4891e8..26bca183611 100644 --- a/Tests/UnitTests/Core/Detector/DetectorVolumeConsistencyTests.cpp +++ b/Tests/UnitTests/Core/Detector/DetectorVolumeConsistencyTests.cpp @@ -14,7 +14,7 @@ #include "Acts/Detector/detail/DetectorVolumeConsistency.hpp" #include "Acts/Geometry/CuboidVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" auto portalGenerator = Acts::Experimental::defaultPortalGenerator(); auto tContext = Acts::GeometryContext(); diff --git a/Tests/UnitTests/Core/Detector/DetectorVolumeTests.cpp b/Tests/UnitTests/Core/Detector/DetectorVolumeTests.cpp index c93ebd345e8..9b8d8a91203 100644 --- a/Tests/UnitTests/Core/Detector/DetectorVolumeTests.cpp +++ b/Tests/UnitTests/Core/Detector/DetectorVolumeTests.cpp @@ -21,8 +21,8 @@ #include "Acts/Material/Material.hpp" #include "Acts/Material/MaterialSlab.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Navigation/NavigationState.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" diff --git a/Tests/UnitTests/Core/Detector/GeometryIdGeneratorTests.cpp b/Tests/UnitTests/Core/Detector/GeometryIdGeneratorTests.cpp index f06269fcb91..931a55f865d 100644 --- a/Tests/UnitTests/Core/Detector/GeometryIdGeneratorTests.cpp +++ b/Tests/UnitTests/Core/Detector/GeometryIdGeneratorTests.cpp @@ -16,7 +16,7 @@ #include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp" #include "Acts/Utilities/Enumerate.hpp" diff --git a/Tests/UnitTests/Core/Detector/IndexedRootVolumeFinderBuilderTests.cpp b/Tests/UnitTests/Core/Detector/IndexedRootVolumeFinderBuilderTests.cpp index e2713694b0f..50e6cb4f44a 100644 --- a/Tests/UnitTests/Core/Detector/IndexedRootVolumeFinderBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/IndexedRootVolumeFinderBuilderTests.cpp @@ -16,8 +16,8 @@ #include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Utilities/Logger.hpp" using namespace Acts; diff --git a/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp b/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp index 9aacad07fb4..44d8dbbae15 100644 --- a/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp +++ b/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp @@ -12,8 +12,8 @@ #include "Acts/Detector/detail/IndexedGridFiller.hpp" #include "Acts/Detector/detail/ReferenceGenerators.hpp" #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Navigation/NavigationStateUpdaters.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" @@ -126,8 +126,8 @@ BOOST_AUTO_TEST_CASE(IndexGridXYOneSurfaceCenter) { {axisX, axisY}); // Indexed Surface grid - IndexedSurfacesImpl indexedGridXY(std::move(gridXY), - {binX, binY}); + IndexedSurfacesNavigation indexedGridXY(std::move(gridXY), + {binX, binY}); // Create a single surface in the center auto rBounds = std::make_shared(4., 4.); @@ -162,8 +162,8 @@ BOOST_AUTO_TEST_CASE(IndexGridXYOneSurfaceBinValue) { {axisX, axisY}); // Indexed Surface grid - IndexedSurfacesImpl indexedGridXY(std::move(gridXY), - {binX, binY}); + IndexedSurfacesNavigation indexedGridXY(std::move(gridXY), + {binX, binY}); // Create a single surface in the center auto rBounds = std::make_shared(4., 4.); @@ -199,8 +199,8 @@ BOOST_AUTO_TEST_CASE(IndexGridXYOneSurfacePolyhedron) { {axisX, axisY}); // Indexed Surface grid - IndexedSurfacesImpl indexedGridXY(std::move(gridXY), - {binX, binY}); + IndexedSurfacesNavigation indexedGridXY(std::move(gridXY), + {binX, binY}); // Create a single surface in the center auto rBounds = std::make_shared(4., 4.); @@ -236,8 +236,8 @@ BOOST_AUTO_TEST_CASE(IndexGridXYOneSurfacePolyhedronBinExpansion) { {axisX, axisY}); // Indexed Surface grid - IndexedSurfacesImpl indexedGridXY(std::move(gridXY), - {binX, binY}); + IndexedSurfacesNavigation indexedGridXY(std::move(gridXY), + {binX, binY}); // Create a single surface in the center auto rBounds = std::make_shared(4., 4.); @@ -274,8 +274,8 @@ BOOST_AUTO_TEST_CASE(IndexGridZPhiYOneSurfacePolyhedronBinExpansion) { {axisZ, axisPhi}); // Indexed Surface grid - IndexedSurfacesImpl indexedGridZPhi(std::move(gridZPhi), - {binZ, binPhi}); + IndexedSurfacesNavigation indexedGridZPhi( + std::move(gridZPhi), {binZ, binPhi}); auto cBounds = std::make_shared(10, 2., M_PI / 30, 0.); auto cSurface = Surface::makeShared(Transform3::Identity(), @@ -310,8 +310,8 @@ BOOST_AUTO_TEST_CASE(IndexGridZPhiYOneSurfaceMPIPolyhedronBinExpansion) { {axisZ, axisPhi}); // Indexed Surface grid - IndexedSurfacesImpl indexedGridZPhi(std::move(gridZPhi), - {binZ, binPhi}); + IndexedSurfacesNavigation indexedGridZPhi( + std::move(gridZPhi), {binZ, binPhi}); auto cBounds = std::make_shared(10, 2., M_PI / 10, 0.); auto tf = AngleAxis3(M_PI, Vector3::UnitZ()) * Transform3::Identity(); diff --git a/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp b/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp index 0fc224e6fcb..367454ea5e8 100644 --- a/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp +++ b/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp @@ -13,9 +13,9 @@ #include "Acts/Detector/detail/ReferenceGenerators.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/LayerCreator.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Navigation/NavigationDelegates.hpp" #include "Acts/Navigation/NavigationStateUpdaters.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Surfaces/RadialBounds.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -52,8 +52,8 @@ BOOST_AUTO_TEST_CASE(RingDisc1D) { auto rSurfaces = cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0., 55., 0., 2., 22u); - IndexedSurfacesGenerator irSurfaces{ - rSurfaces, {}, {binPhi}}; + IndexedSurfacesGenerator + irSurfaces{rSurfaces, {}, {binPhi}}; GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(RingDisc1D) { using GridType = decltype(aGenerator)::grid_type>; using DelegateType = - IndexedSurfacesAllPortalsImpl; + IndexedSurfacesAllPortalsNavigation; const auto* instance = indexedRing.instance(); auto castedDelegate = dynamic_cast(instance); @@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(RingDisc1D) { const auto& chainedUpdaters = castedDelegate->updators; const auto& indexedSurfaces = - std::get>(chainedUpdaters); + std::get>(chainedUpdaters); const auto& grid = indexedSurfaces.grid; // Check that surfaces 10, 11, 12 build the bins at phi == 0 @@ -97,8 +97,8 @@ BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) { std::move(rBounds)); rSurfaces.push_back(dSurface.get()); - IndexedSurfacesGenerator irSurfaces{ - rSurfaces, {rSurfaces.size() - 1u}, {binPhi}}; + IndexedSurfacesGenerator + irSurfaces{rSurfaces, {rSurfaces.size() - 1u}, {binPhi}}; GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) { using GridType = decltype(aGenerator)::grid_type>; using DelegateType = - IndexedSurfacesAllPortalsImpl; + IndexedSurfacesAllPortalsNavigation; const auto* instance = indexedRing.instance(); auto castedDelegate = dynamic_cast(instance); @@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) { const auto& chainedUpdaters = castedDelegate->updators; const auto& indexedSurfaces = - std::get>(chainedUpdaters); + std::get>(chainedUpdaters); const auto& grid = indexedSurfaces.grid; // Check that surfaces 10, 11, 12 build the bins at phi == 0 @@ -144,8 +144,8 @@ BOOST_AUTO_TEST_CASE(RingDisc2D) { decltype(rSurfacesR0) rSurfaces = rSurfacesR0; rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end()); - IndexedSurfacesGenerator irSurfaces{ - rSurfaces, {}, {binR, binPhi}}; + IndexedSurfacesGenerator + irSurfaces{rSurfaces, {}, {binR, binPhi}}; GridAxisGenerators::VarBoundEqClosed aGenerator{ {24., 74., 110.}, {-M_PI, M_PI}, 44u}; @@ -156,7 +156,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2D) { using GridType = decltype(aGenerator)::grid_type>; using DelegateType = - IndexedSurfacesAllPortalsImpl; + IndexedSurfacesAllPortalsNavigation; const auto* instance = indexedRing.instance(); auto castedDelegate = dynamic_cast(instance); @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2D) { const auto& chainedUpdaters = castedDelegate->updators; const auto& indexedSurfaces = - std::get>(chainedUpdaters); + std::get>(chainedUpdaters); const auto& grid = indexedSurfaces.grid; // Check that now two rows of surfaces are given @@ -190,8 +190,8 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFine) { rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end()); rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end()); - IndexedSurfacesGenerator irSurfaces{ - rSurfaces, {}, {binR, binPhi}}; + IndexedSurfacesGenerator + irSurfaces{rSurfaces, {}, {binR, binPhi}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {24., 152}, 8u, {-M_PI, M_PI}, 88u}; @@ -203,7 +203,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFine) { using GridType = decltype(aGenerator)::grid_type>; using DelegateType = - IndexedSurfacesAllPortalsImpl; + IndexedSurfacesAllPortalsNavigation; const auto* instance = indexedRing.instance(); auto castedDelegate = dynamic_cast(instance); @@ -212,7 +212,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFine) { const auto& chainedUpdaters = castedDelegate->updators; const auto& indexedSurfaces = - std::get>(chainedUpdaters); + std::get>(chainedUpdaters); const auto& grid = indexedSurfaces.grid; // Fine binning created fewer candidates @@ -237,8 +237,8 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) { rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end()); rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end()); - IndexedSurfacesGenerator irSurfaces{ - rSurfaces, {}, {binR, binPhi}, {2u, 4u}}; + IndexedSurfacesGenerator + irSurfaces{rSurfaces, {}, {binR, binPhi}, {2u, 4u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {24., 152}, 8u, {-M_PI, M_PI}, 88u}; @@ -248,7 +248,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) { using GridType = decltype(aGenerator)::grid_type>; using DelegateType = - IndexedSurfacesAllPortalsImpl; + IndexedSurfacesAllPortalsNavigation; const auto* instance = indexedRing.instance(); auto castedDelegate = dynamic_cast(instance); @@ -257,7 +257,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) { const auto& chainedUpdaters = castedDelegate->updators; const auto& indexedSurfaces = - std::get>(chainedUpdaters); + std::get>(chainedUpdaters); const auto& grid = indexedSurfaces.grid; // Bin expansion created again more elements @@ -271,8 +271,8 @@ BOOST_AUTO_TEST_CASE(Cylinder2D) { auto surfaces = cGeometry.surfacesCylinder(dStore, 8.4, 36., 0.15, 0.145, 116., 3., 2., {52, 14}); - IndexedSurfacesGenerator icSurfaces{ - surfaces, {}, {binZ, binPhi}, {1u, 1u}}; + IndexedSurfacesGenerator + icSurfaces{surfaces, {}, {binZ, binPhi}, {1u, 1u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {-500., 500}, 28, {-M_PI, M_PI}, 52u}; @@ -282,7 +282,7 @@ BOOST_AUTO_TEST_CASE(Cylinder2D) { using GridType = decltype(aGenerator)::grid_type>; using DelegateType = - IndexedSurfacesAllPortalsImpl; + IndexedSurfacesAllPortalsNavigation; const auto* instance = indexedCylinder.instance(); auto castedDelegate = dynamic_cast(instance); @@ -291,7 +291,7 @@ BOOST_AUTO_TEST_CASE(Cylinder2D) { const auto& chainedUpdaters = castedDelegate->updators; const auto& indexedSurfaces = - std::get>(chainedUpdaters); + std::get>(chainedUpdaters); const auto& grid = indexedSurfaces.grid; // Bin expansion created again more elements diff --git a/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp b/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp index e784703a77c..b69ffa4194d 100644 --- a/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp @@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(Multi_Wire_Structure_Builder_StrawSurfacesCreation) { BOOST_CHECK_EQUAL(volumes.front()->surfaces().size(), nSurfacesX * nSurfacesY); BOOST_CHECK(volumes.front()->volumes().empty()); - BOOST_CHECK(volumes.front()->surfaceCandidatesUpdater().connected()); + BOOST_CHECK(volumes.front()->internalNavigation().connected()); } BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Core/Detector/PortalGeneratorsTests.cpp b/Tests/UnitTests/Core/Detector/PortalGeneratorsTests.cpp index 4f4403de8b5..98e6a451545 100644 --- a/Tests/UnitTests/Core/Detector/PortalGeneratorsTests.cpp +++ b/Tests/UnitTests/Core/Detector/PortalGeneratorsTests.cpp @@ -15,8 +15,8 @@ #include "Acts/Geometry/CuboidVolumeBounds.hpp" #include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Navigation/NavigationState.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" #include #include diff --git a/Tests/UnitTests/Core/Detector/PortalTests.cpp b/Tests/UnitTests/Core/Detector/PortalTests.cpp index fb710f1307d..286493bdb65 100644 --- a/Tests/UnitTests/Core/Detector/PortalTests.cpp +++ b/Tests/UnitTests/Core/Detector/PortalTests.cpp @@ -18,9 +18,9 @@ #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Material/HomogeneousSurfaceMaterial.hpp" #include "Acts/Material/MaterialSlab.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Navigation/NavigationDelegates.hpp" #include "Acts/Navigation/NavigationState.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -34,7 +34,7 @@ namespace Acts::Experimental { /// a simple link to volume struct -class LinkToVolumeImpl : public INavigationDelegate { +class LinkToVolumeImpl : public IExternalNavigation { public: std::shared_ptr dVolume = nullptr; @@ -86,10 +86,10 @@ BOOST_AUTO_TEST_CASE(PortalTest) { // Create a links to volumes auto linkToAImpl = std::make_unique(volumeA); - DetectorVolumeUpdater linkToA; + ExternalNavigationDelegate linkToA; linkToA.connect<&LinkToVolumeImpl::link>(std::move(linkToAImpl)); - portalA->assignDetectorVolumeUpdater(Acts::Direction::Positive, - std::move(linkToA), {volumeA}); + portalA->assignPortalNavigation(Acts::Direction::Positive, std::move(linkToA), + {volumeA}); auto attachedDetectorVolumes = portalA->attachedDetectorVolumes(); BOOST_CHECK(attachedDetectorVolumes[0u].empty()); @@ -108,11 +108,11 @@ BOOST_AUTO_TEST_CASE(PortalTest) { BOOST_CHECK_EQUAL(nState.currentVolume, nullptr); auto portalB = std::make_shared(surface); - DetectorVolumeUpdater linkToB; + ExternalNavigationDelegate linkToB; auto linkToBImpl = std::make_unique(volumeB); linkToB.connect<&LinkToVolumeImpl::link>(std::move(linkToBImpl)); - portalB->assignDetectorVolumeUpdater(Acts::Direction::Negative, - std::move(linkToB), {volumeB}); + portalB->assignPortalNavigation(Acts::Direction::Negative, std::move(linkToB), + {volumeB}); // Reverse: positive volume nullptr, negative volume volumeB nState.direction = Acts::Vector3(0., 0., 1.); @@ -203,20 +203,20 @@ BOOST_AUTO_TEST_CASE(PortalMaterialTest) { surfaceA->assignSurfaceMaterial(materialA); auto portalA = std::make_shared(surfaceA); - DetectorVolumeUpdater linkToA; + ExternalNavigationDelegate linkToA; auto linkToAImpl = std::make_unique(volumeA); linkToA.connect<&LinkToVolumeImpl::link>(std::move(linkToAImpl)); - portalA->assignDetectorVolumeUpdater(Acts::Direction::Positive, - std::move(linkToA), {volumeA}); + portalA->assignPortalNavigation(Acts::Direction::Positive, std::move(linkToA), + {volumeA}); auto surfaceB = Acts::Surface::makeShared( Acts::Transform3::Identity(), rectangle); auto portalB = std::make_shared(surfaceB); - DetectorVolumeUpdater linkToB; + ExternalNavigationDelegate linkToB; auto linkToBImpl = std::make_unique(volumeB); linkToB.connect<&LinkToVolumeImpl::link>(std::move(linkToBImpl)); - portalB->assignDetectorVolumeUpdater(Acts::Direction::Negative, - std::move(linkToB), {volumeB}); + portalB->assignPortalNavigation(Acts::Direction::Negative, std::move(linkToB), + {volumeB}); // Portal A fuses with B // - has material and keeps it @@ -225,11 +225,11 @@ BOOST_AUTO_TEST_CASE(PortalMaterialTest) { // Remake portal B portalB = std::make_shared(surfaceB); - DetectorVolumeUpdater linkToB2; + ExternalNavigationDelegate linkToB2; auto linkToB2Impl = std::make_unique(volumeB); linkToB2.connect<&LinkToVolumeImpl::link>(std::move(linkToB2Impl)); - portalB->assignDetectorVolumeUpdater(Acts::Direction::Negative, - std::move(linkToB2), {volumeB}); + portalB->assignPortalNavigation(Acts::Direction::Negative, + std::move(linkToB2), {volumeB}); // Portal B fuses with A // - A has material, portal B gets it from A @@ -238,27 +238,27 @@ BOOST_AUTO_TEST_CASE(PortalMaterialTest) { // This fails because A has accumulated volumes on both sides through fusing BOOST_CHECK_THROW(Portal::fuse(portalB, portalA), std::invalid_argument); // Remove Negative volume on A - portalA->assignDetectorVolumeUpdater(Acts::Direction::Negative, - DetectorVolumeUpdater{}, {}); + portalA->assignPortalNavigation(Acts::Direction::Negative, + ExternalNavigationDelegate{}, {}); portalB = Portal::fuse(portalB, portalA); BOOST_CHECK_EQUAL(portalB->surface().surfaceMaterial(), materialA.get()); // Remake portal A and B, this time both with material portalA = std::make_shared(surfaceA); - DetectorVolumeUpdater linkToA2; + ExternalNavigationDelegate linkToA2; auto linkToA2Impl = std::make_unique(volumeA); linkToA2.connect<&LinkToVolumeImpl::link>(std::move(linkToA2Impl)); - portalA->assignDetectorVolumeUpdater(Acts::Direction::Positive, - std::move(linkToA2), {volumeA}); + portalA->assignPortalNavigation(Acts::Direction::Positive, + std::move(linkToA2), {volumeA}); surfaceB->assignSurfaceMaterial(materialB); portalB = std::make_shared(surfaceB); - DetectorVolumeUpdater linkToB3; + ExternalNavigationDelegate linkToB3; auto linkToB3Impl = std::make_unique(volumeB); linkToB3.connect<&LinkToVolumeImpl::link>(std::move(linkToB3Impl)); - portalB->assignDetectorVolumeUpdater(Acts::Direction::Negative, - std::move(linkToB3), {volumeB}); + portalB->assignPortalNavigation(Acts::Direction::Negative, + std::move(linkToB3), {volumeB}); // Portal A fuses with B - both have material, throw exception BOOST_CHECK_THROW(Portal::fuse(portalA, portalB), std::runtime_error); diff --git a/Tests/UnitTests/Core/Material/IntersectionMaterialAssignerTests.cpp b/Tests/UnitTests/Core/Material/IntersectionMaterialAssignerTests.cpp index 0f692efe5ac..42a15a860f8 100644 --- a/Tests/UnitTests/Core/Material/IntersectionMaterialAssignerTests.cpp +++ b/Tests/UnitTests/Core/Material/IntersectionMaterialAssignerTests.cpp @@ -17,7 +17,7 @@ #include "Acts/Geometry/TrackingVolume.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/Material/IntersectionMaterialAssigner.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/Utilities/Enumerate.hpp" diff --git a/Tests/UnitTests/Core/Material/PropagatorMaterialAssignerTests.cpp b/Tests/UnitTests/Core/Material/PropagatorMaterialAssignerTests.cpp index 785e840da3f..105aca93ea6 100644 --- a/Tests/UnitTests/Core/Material/PropagatorMaterialAssignerTests.cpp +++ b/Tests/UnitTests/Core/Material/PropagatorMaterialAssignerTests.cpp @@ -27,7 +27,7 @@ #include "Acts/Material/PropagatorMaterialAssigner.hpp" #include "Acts/Navigation/DetectorNavigator.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/StraightLineStepper.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" diff --git a/Tests/UnitTests/Core/Navigation/CMakeLists.txt b/Tests/UnitTests/Core/Navigation/CMakeLists.txt index 7c045ff1d06..a5785f38006 100644 --- a/Tests/UnitTests/Core/Navigation/CMakeLists.txt +++ b/Tests/UnitTests/Core/Navigation/CMakeLists.txt @@ -1,4 +1,4 @@ -add_unittest(DetectorVolumeUpdaters DetectorVolumeUpdatersTests.cpp) +add_unittest(PortalNavigation PortalNavigationTests.cpp) add_unittest(DetectorVolumeFinders DetectorVolumeFindersTests.cpp) add_unittest(NavigationState NavigationStateTests.cpp) add_unittest(NavigationStateUpdaters NavigationStateUpdatersTests.cpp) diff --git a/Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp b/Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp index 925def3e650..5bf7eb94f2b 100644 --- a/Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp +++ b/Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp @@ -22,7 +22,7 @@ #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/Navigation/DetectorNavigator.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Propagator/AbortList.hpp" #include "Acts/Propagator/ActionList.hpp" #include "Acts/Propagator/Propagator.hpp" diff --git a/Tests/UnitTests/Core/Navigation/DetectorVolumeFindersTests.cpp b/Tests/UnitTests/Core/Navigation/DetectorVolumeFindersTests.cpp index 33778ad6af5..725b6718126 100644 --- a/Tests/UnitTests/Core/Navigation/DetectorVolumeFindersTests.cpp +++ b/Tests/UnitTests/Core/Navigation/DetectorVolumeFindersTests.cpp @@ -16,8 +16,8 @@ #include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Navigation/NavigationState.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Grid.hpp" #include "Acts/Utilities/detail/Axis.hpp" diff --git a/Tests/UnitTests/Core/Navigation/MultiWireNavigationTests.cpp b/Tests/UnitTests/Core/Navigation/MultiWireNavigationTests.cpp index 84712cfb47b..24444c17438 100644 --- a/Tests/UnitTests/Core/Navigation/MultiWireNavigationTests.cpp +++ b/Tests/UnitTests/Core/Navigation/MultiWireNavigationTests.cpp @@ -13,10 +13,10 @@ #include "Acts/Detector/DetectorVolume.hpp" #include "Acts/Detector/MultiWireStructureBuilder.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Navigation/NavigationState.hpp" #include "Acts/Navigation/NavigationStateFillers.hpp" #include "Acts/Navigation/NavigationStateUpdaters.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/StrawSurface.hpp" #include "Acts/Surfaces/Surface.hpp" diff --git a/Tests/UnitTests/Core/Navigation/NavigationStateUpdatersTests.cpp b/Tests/UnitTests/Core/Navigation/NavigationStateUpdatersTests.cpp index 2ecc2afb810..36b6aff1638 100644 --- a/Tests/UnitTests/Core/Navigation/NavigationStateUpdatersTests.cpp +++ b/Tests/UnitTests/Core/Navigation/NavigationStateUpdatersTests.cpp @@ -163,15 +163,17 @@ class MultiGrid2D { }; } // namespace Acts -using SingleVolumeUpdater = Acts::Experimental::SingleObjectImpl< - Acts::Experimental::DetectorVolume, +using SingleVolumeUpdater = Acts::Experimental::SingleObjectNavigation< + Acts::Experimental::IExternalNavigation, Acts::Experimental::DetectorVolume, Acts::Experimental::DetectorVolumeFiller>; -using AllSurfacesProvider = Acts::Experimental::StaticUpdaterImpl< +using AllSurfacesProvider = Acts::Experimental::StaticAccessNavigation< + Acts::Experimental::IInternalNavigation, Acts::Experimental::AllSurfacesExtractor, Acts::Experimental::SurfacesFiller>; -using AllPortalsProvider = Acts::Experimental::StaticUpdaterImpl< +using AllPortalsProvider = Acts::Experimental::StaticAccessNavigation< + Acts::Experimental::IInternalNavigation, Acts::Experimental::AllPortalsExtractor, Acts::Experimental::PortalsFiller>; auto surfaceA = Acts::Surface::makeShared(); @@ -185,7 +187,7 @@ auto portalB = std::make_shared(pSurfaceB); BOOST_AUTO_TEST_SUITE(Experimental) -BOOST_AUTO_TEST_CASE(SingleDetectorVolumeUpdater) { +BOOST_AUTO_TEST_CASE(SingleExternalNavigationDelegate) { Acts::Experimental::NavigationState nState; // Create a single object and a single object updator @@ -237,10 +239,9 @@ BOOST_AUTO_TEST_CASE(AllPortalsAllSurfaces) { AllPortalsProvider allPortals; AllSurfacesProvider allSurfaces; - auto allPortalsAllSurfaces = - Acts::Experimental::ChainedUpdaterImpl( - std::tie(allPortals, allSurfaces)); + auto allPortalsAllSurfaces = Acts::Experimental::ChainedUpdaterImpl< + Acts::Experimental::IInternalNavigation, AllPortalsProvider, + AllSurfacesProvider>(std::tie(allPortals, allSurfaces)); allPortalsAllSurfaces.update(tContext, nState); BOOST_CHECK_EQUAL(nState.surfaceCandidates.size(), 5u); @@ -259,14 +260,14 @@ BOOST_AUTO_TEST_CASE(AllPortalsGrid1DSurfaces) { AllPortalsProvider allPortals; Acts::MultiGrid1D grid; using Grid1DSurfacesProvider = Acts::Experimental::IndexedUpdaterImpl< - decltype(grid), Acts::Experimental::IndexedSurfacesExtractor, + Acts::Experimental::IInternalNavigation, decltype(grid), + Acts::Experimental::IndexedSurfacesExtractor, Acts::Experimental::SurfacesFiller>; auto grid1DSurfaces = Grid1DSurfacesProvider(std::move(grid), {Acts::binR}); - auto allPortalsGrid1DSurfaces = - Acts::Experimental::ChainedUpdaterImpl( - std::tie(allPortals, grid1DSurfaces)); + auto allPortalsGrid1DSurfaces = Acts::Experimental::ChainedUpdaterImpl< + Acts::Experimental::IInternalNavigation, AllPortalsProvider, + Grid1DSurfacesProvider>(std::tie(allPortals, grid1DSurfaces)); allPortalsGrid1DSurfaces.update(tContext, nState); BOOST_CHECK_EQUAL(nState.surfaceCandidates.size(), 4u); @@ -285,15 +286,15 @@ BOOST_AUTO_TEST_CASE(AllPortalsGrid2DSurfaces) { AllPortalsProvider allPortals; Acts::MultiGrid2D grid; using Grid2DSurfacesProvider = Acts::Experimental::IndexedUpdaterImpl< - decltype(grid), Acts::Experimental::IndexedSurfacesExtractor, + Acts::Experimental::IInternalNavigation, decltype(grid), + Acts::Experimental::IndexedSurfacesExtractor, Acts::Experimental::SurfacesFiller>; auto grid2DSurfaces = Grid2DSurfacesProvider(std::move(grid), {Acts::binR, Acts::binZ}); - auto allPortalsGrid2DSurfaces = - Acts::Experimental::ChainedUpdaterImpl( - std::tie(allPortals, grid2DSurfaces)); + auto allPortalsGrid2DSurfaces = Acts::Experimental::ChainedUpdaterImpl< + Acts::Experimental::IInternalNavigation, AllPortalsProvider, + Grid2DSurfacesProvider>(std::tie(allPortals, grid2DSurfaces)); allPortalsGrid2DSurfaces.update(tContext, nState); BOOST_CHECK_EQUAL(nState.surfaceCandidates.size(), 3u); diff --git a/Tests/UnitTests/Core/Navigation/DetectorVolumeUpdatersTests.cpp b/Tests/UnitTests/Core/Navigation/PortalNavigationTests.cpp similarity index 84% rename from Tests/UnitTests/Core/Navigation/DetectorVolumeUpdatersTests.cpp rename to Tests/UnitTests/Core/Navigation/PortalNavigationTests.cpp index abe8ca8a0f3..c5bf26e88dd 100644 --- a/Tests/UnitTests/Core/Navigation/DetectorVolumeUpdatersTests.cpp +++ b/Tests/UnitTests/Core/Navigation/PortalNavigationTests.cpp @@ -10,9 +10,9 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" #include "Acts/Navigation/NavigationDelegates.hpp" #include "Acts/Navigation/NavigationState.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Utilities/BinningType.hpp" #include @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_SUITE(Experimental) // NavigaitonState according to some given information. // BOOST_AUTO_TEST_CASE(UnconnectedUpdate) { - Acts::Experimental::DetectorVolumeUpdater ucUpdater; + Acts::Experimental::ExternalNavigationDelegate ucUpdater; BOOST_CHECK(!ucUpdater.connected()); } @@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE(EndOfWorldUpdate) { nState.currentVolume = volumeA.get(); BOOST_CHECK_EQUAL(nState.currentVolume, volumeA.get()); - Acts::Experimental::EndOfWorldImpl eow; + Acts::Experimental::EndOfWorld eow; eow.update(tContext, nState); BOOST_CHECK_EQUAL(nState.currentVolume, nullptr); @@ -60,12 +60,12 @@ BOOST_AUTO_TEST_CASE(SingleVolumeUpdate) { nState.currentVolume = volumeA.get(); BOOST_CHECK_EQUAL(nState.currentVolume, volumeA.get()); - Acts::Experimental::SingleDetectorVolumeImpl svu(volumeB.get()); + Acts::Experimental::SingleDetectorVolumeNavigation svu(volumeB.get()); svu.update(tContext, nState); BOOST_CHECK_EQUAL(nState.currentVolume, volumeB.get()); - BOOST_CHECK_THROW(Acts::Experimental::SingleDetectorVolumeImpl(nullptr), + BOOST_CHECK_THROW(Acts::Experimental::SingleDetectorVolumeNavigation(nullptr), std::invalid_argument); } @@ -75,7 +75,8 @@ BOOST_AUTO_TEST_CASE(VolumeArrayUpdate) { std::vector volumes = { volumeA.get(), volumeB.get(), volumeC.get(), volumeD.get()}; - Acts::Experimental::BoundVolumesGrid1Impl bvg(zArray, Acts::binZ, volumes); + Acts::Experimental::BoundVolumesGrid1Navigation bvg(zArray, Acts::binZ, + volumes); // Reset the navigation state nState.currentVolume = nullptr; @@ -92,8 +93,8 @@ BOOST_AUTO_TEST_CASE(VolumeArrayUpdate) { Acts::Transform3 shift300 = Acts::Transform3::Identity(); shift300.pretranslate(Acts::Vector3(0, 0, 300)); - Acts::Experimental::BoundVolumesGrid1Impl bvgs(zArray, Acts::binZ, volumes, - shift300.inverse()); + Acts::Experimental::BoundVolumesGrid1Navigation bvgs( + zArray, Acts::binZ, volumes, shift300.inverse()); // 150 (-300) -> transforms to -150, hence it yields A nState.position = Acts::Vector3(0., 0., 150.); diff --git a/Tests/UnitTests/Plugins/ActSVG/DetectorSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/DetectorSvgConverterTests.cpp index ba3c463823d..349f6a77112 100644 --- a/Tests/UnitTests/Plugins/ActSVG/DetectorSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/DetectorSvgConverterTests.cpp @@ -20,7 +20,7 @@ #include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Plugins/ActSVG/DetectorSvgConverter.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" diff --git a/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp index b3451400d7d..ba2b98d720b 100644 --- a/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp @@ -15,8 +15,8 @@ #include "Acts/Detector/VolumeStructureBuilder.hpp" #include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Navigation/NavigationStateUpdaters.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" #include "Acts/Plugins/ActSVG/DetectorVolumeSvgConverter.hpp" #include "Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp" #include "Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp" diff --git a/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp index cf8fc707c09..d51417b3d5a 100644 --- a/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp @@ -74,8 +74,8 @@ BOOST_AUTO_TEST_CASE(RingDisc1D) { auto rSurfaces = cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0., 55., 0., 2., 22u); - IndexedSurfacesGenerator irSurfaces{ - rSurfaces, {}, {binPhi}}; + IndexedSurfacesGenerator + irSurfaces{rSurfaces, {}, {binPhi}}; GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; @@ -99,8 +99,8 @@ BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) { std::move(rBounds)); rSurfaces.push_back(dSurface.get()); - IndexedSurfacesGenerator irSurfaces{ - rSurfaces, {rSurfaces.size() - 1u}, {binPhi}}; + IndexedSurfacesGenerator + irSurfaces{rSurfaces, {rSurfaces.size() - 1u}, {binPhi}}; GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; @@ -125,8 +125,8 @@ BOOST_AUTO_TEST_CASE(RingDisc2D) { decltype(rSurfacesR0) rSurfaces = rSurfacesR0; rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end()); - IndexedSurfacesGenerator irSurfaces{ - rSurfaces, {}, {binR, binPhi}}; + IndexedSurfacesGenerator + irSurfaces{rSurfaces, {}, {binR, binPhi}}; GridAxisGenerators::VarBoundEqClosed aGenerator{ {24., 74., 110.}, {-M_PI, M_PI}, 44u}; @@ -157,8 +157,8 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFine) { rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end()); rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end()); - IndexedSurfacesGenerator irSurfaces{ - rSurfaces, {}, {binR, binPhi}}; + IndexedSurfacesGenerator + irSurfaces{rSurfaces, {}, {binR, binPhi}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {24., 152}, 8u, {-M_PI, M_PI}, 88u}; @@ -189,8 +189,8 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) { rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end()); rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end()); - IndexedSurfacesGenerator irSurfaces{ - rSurfaces, {}, {binR, binPhi}, {2u, 4u}}; + IndexedSurfacesGenerator + irSurfaces{rSurfaces, {}, {binR, binPhi}, {2u, 4u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {24., 152}, 8u, {-M_PI, M_PI}, 88u}; @@ -210,8 +210,8 @@ BOOST_AUTO_TEST_CASE(Cylinder2D) { auto surfaces = cGeometry.surfacesCylinder(dStore, 8.4, 36., 0.15, 0.145, 116., 3., 2., {52, 14}); - IndexedSurfacesGenerator icSurfaces{ - surfaces, {}, {binZ, binPhi}, {1u, 1u}}; + IndexedSurfacesGenerator + icSurfaces{surfaces, {}, {binZ, binPhi}, {1u, 1u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {-500., 500}, 28, {-M_PI, M_PI}, 52u}; diff --git a/Tests/UnitTests/Plugins/ActSVG/PortalSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/PortalSvgConverterTests.cpp index 97110ef0026..9d73ebbc681 100644 --- a/Tests/UnitTests/Plugins/ActSVG/PortalSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/PortalSvgConverterTests.cpp @@ -13,7 +13,7 @@ #include "Acts/Detector/PortalGenerators.hpp" #include "Acts/Detector/detail/CylindricalDetectorHelper.hpp" #include "Acts/Geometry/CylinderVolumeBounds.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Plugins/ActSVG/PortalSvgConverter.hpp" #include "Acts/Plugins/ActSVG/SvgUtils.hpp" #include "Acts/Utilities/Enumerate.hpp" diff --git a/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp index c055d32d69a..5d7336495f1 100644 --- a/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp @@ -21,7 +21,7 @@ #include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Plugins/Json/DetectorJsonConverter.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" diff --git a/Tests/UnitTests/Plugins/Json/DetectorVolumeFinderJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/DetectorVolumeFinderJsonConverterTests.cpp index 43aa8cf5458..a596ecbcade 100644 --- a/Tests/UnitTests/Plugins/Json/DetectorVolumeFinderJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/DetectorVolumeFinderJsonConverterTests.cpp @@ -9,7 +9,7 @@ #include #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/DetectorVolumeUpdaters.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" #include "Acts/Plugins/Json/DetectorVolumeFinderJsonConverter.hpp" #include "Acts/Utilities/GridAxisGenerators.hpp" @@ -54,7 +54,8 @@ BOOST_AUTO_TEST_CASE(RzVolumes) { auto casts = std::array{Acts::binZ, Acts::binR}; using IndexedDetectorVolumesImpl = Acts::Experimental::IndexedUpdaterImpl< - GridType, Acts::Experimental::IndexedDetectorVolumeExtractor, + Acts::Experimental::IExternalNavigation, GridType, + Acts::Experimental::IndexedDetectorVolumeExtractor, Acts::Experimental::DetectorVolumeFiller>; auto indexedDetectorVolumesImpl = @@ -62,7 +63,7 @@ BOOST_AUTO_TEST_CASE(RzVolumes) { casts); // Return the root volume finder - Acts::Experimental::DetectorVolumeUpdater rootVolumeFinder; + Acts::Experimental::ExternalNavigationDelegate rootVolumeFinder; rootVolumeFinder.connect<&IndexedDetectorVolumesImpl::update>( std::move(indexedDetectorVolumesImpl)); diff --git a/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp index 770b9d63588..cc3f15979b0 100644 --- a/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp @@ -18,7 +18,7 @@ #include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Navigation/DetectorVolumeFinders.hpp" -#include "Acts/Navigation/SurfaceCandidatesUpdaters.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" #include "Acts/Plugins/Json/DetectorVolumeJsonConverter.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" diff --git a/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp index 374e81a9c5a..b9405d7e0f4 100644 --- a/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp @@ -73,9 +73,9 @@ BOOST_AUTO_TEST_CASE(PortalSingleConnected) { std::make_shared(std::move(surface)); BOOST_CHECK_NE(portal, nullptr); // Attaching the portals - Acts::Experimental::detail::PortalHelper::attachDetectorVolumeUpdater( + Acts::Experimental::detail::PortalHelper::attachExternalNavigationDelegate( *portal, forwardVolume, Acts::Direction::Forward); - Acts::Experimental::detail::PortalHelper::attachDetectorVolumeUpdater( + Acts::Experimental::detail::PortalHelper::attachExternalNavigationDelegate( *portal, backwardVolume, Acts::Direction::Backward); std::vector detectorVolumes = { @@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(PortalMultiConnected) { BOOST_CHECK_NE(portal, nullptr); // Attaching the portals - Acts::Experimental::detail::PortalHelper::attachDetectorVolumeUpdater( + Acts::Experimental::detail::PortalHelper::attachExternalNavigationDelegate( *portal, backwardVolume, Acts::Direction::Backward); Acts::Experimental::detail::PortalHelper::attachDetectorVolumesUpdater( diff --git a/docs/core/geometry/layerless/layerless.md b/docs/core/geometry/layerless/layerless.md index 18c22c86e1e..b9784ac1f74 100644 --- a/docs/core/geometry/layerless/layerless.md +++ b/docs/core/geometry/layerless/layerless.md @@ -47,8 +47,8 @@ A struct {struct}`Acts::Experimental::NavigationState` holds the current navigat Several navigation delegates built upon the {class}`Acts::Delegate` template class are defined and can be adapted and specialized for dedicated detector layouts. These delegates are called: -- `Acts::Experimental::SurfaceCandidatesDelegate` that is called for updating the information at initialization, within the volume or at a volume switch caused by traversing a portal -- `Acts::Experimental::DetectorVolumeFinder` which allows to find a volume by global position (and is usually only needed at initialization of the navigation) and which is attached to a {class}`Acts::Experimental::Portal` to switch volumes when traversing a portal +- `Acts::Experimental::IInternalNavigation` that is called for updating the information at initialization, within the volume or at a volume switch caused by traversing a portal +- `Acts::Experimental::IExternalNavigation` which allows to find a volume by global position (and is usually only needed at initialization of the navigation) and which is attached to a {class}`Acts::Experimental::Portal` to switch volumes when traversing a portal ## Detailed Description @@ -70,14 +70,14 @@ Illustration of a shared direct portal between two volumes, the arrows indicate Illustration of a shared extended portal between several volumes, the arrows indicate the direction of attachment. ::: -The implementation of a unique, binned or any other volume link can be adapted to the detector geometry by providing a suitable `Acts::Experimental::DetectorVolumeUpdater` delegate. +The implementation of a unique, binned or any other volume link can be adapted to the detector geometry by providing a suitable `Acts::Experimental::ExternalNavigationDelegate` delegate. ### The Detector volume object A detector volume has to contain: - a list of bounding portal objects (that can be shared with other volumes) -- a navigation state updator as a `Acts::Experimental::SurfaceCandidatesUpdater` delegate, that at minimum is able to provide the portal surfaces for leaving the volume again. +- a navigation state updator as a `Acts::Experimental::InternalNavigationDelegate` delegate, that at minimum is able to provide the portal surfaces for leaving the volume again. - a unique name string :::{note} From 2e0ebfed194b7ec337d608707c075c3fc8b946bf Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 21 May 2024 19:15:52 +0200 Subject: [PATCH 05/19] refactor: Refactor Core CKF finalization (#3188) - Drop `filtered` flag since there are no steps afterwards - Unify finalization of branches and finding - Use `end of world` aborter instead `navigation break` flag --- .../CombinatorialKalmanFilter.hpp | 98 +++++++------------ 1 file changed, 35 insertions(+), 63 deletions(-) diff --git a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp index 51817dd1bb6..d7c76a647f8 100644 --- a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp +++ b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp @@ -231,9 +231,6 @@ struct CombinatorialKalmanFilterResult { std::unordered_map> sourcelinkTips; - /// Indicator if filtering has been done - bool filtered = false; - /// Indicator if track finding has been done bool finished = false; @@ -348,30 +345,10 @@ class CombinatorialKalmanFilter { true, logger()); } - if (!result.filtered && - targetReached(state, stepper, navigator, logger())) { - // Bind the parameter to the target surface - auto res = stepper.boundState(state.stepping, *targetReached.surface); - if (!res.ok()) { - ACTS_ERROR("Error while acquiring bound state for target surface: " - << res.error() << " " << res.error().message()); - result.lastError = res.error(); - } else { - const auto& fittedState = *res; - std::size_t currentTip = result.activeTips.back().first; - // Assign the fitted parameters - result.fittedParameters.emplace( - currentTip, std::get(fittedState)); - } - - navigator.navigationBreak(state.navigation, true); - stepper.releaseStepSize(state.stepping, ConstrainedStep::actor); - } - // Update: // - Waiting for a current surface - auto surface = navigator.currentSurface(state.navigation); - if (surface != nullptr && !result.filtered) { + if (auto surface = navigator.currentSurface(state.navigation); + surface != nullptr) { // There are three scenarios: // 1) The surface is in the measurement map // -> Select source links @@ -394,10 +371,37 @@ class CombinatorialKalmanFilter { } } - // Reset propagation state: - // - When navigation breaks and there is still active tip present after - // recording&removing track tips on current surface - if (navigator.navigationBreak(state.navigation) && !result.filtered) { + const bool isEndOfWorldReached = + endOfWorldReached(state, stepper, navigator, logger()); + const bool isPathLimitReached = + result.pathLimitReached(state, stepper, navigator, logger()); + const bool isTargetReached = + targetReached(state, stepper, navigator, logger()); + if (isEndOfWorldReached || isPathLimitReached || isTargetReached) { + if (isEndOfWorldReached) { + ACTS_VERBOSE("End of world reached"); + } else if (isPathLimitReached) { + ACTS_VERBOSE("Path limit reached"); + } else if (isTargetReached) { + ACTS_VERBOSE("Target surface reached"); + + // Bind the parameter to the target surface + auto res = stepper.boundState(state.stepping, *targetReached.surface); + if (!res.ok()) { + ACTS_ERROR("Error while acquiring bound state for target surface: " + << res.error() << " " << res.error().message()); + result.lastError = res.error(); + } else { + const auto& fittedState = *res; + std::size_t currentTip = result.activeTips.back().first; + // Assign the fitted parameters + result.fittedParameters.emplace( + currentTip, std::get(fittedState)); + } + + stepper.releaseStepSize(state.stepping, ConstrainedStep::actor); + } + if (!result.activeTips.empty()) { // Record the active tip as trajectory entry indices and remove it // from the list @@ -410,45 +414,13 @@ class CombinatorialKalmanFilter { if (result.activeTips.empty()) { ACTS_VERBOSE("Kalman filtering finds " << result.lastTrackIndices.size() << " tracks"); - result.filtered = true; + result.finished = true; } else { ACTS_VERBOSE("Propagation jumps to branch with tip = " << result.activeTips.back().first); reset(state, stepper, navigator, result); } } - - bool isEndOfWorldReached = - endOfWorldReached(state, stepper, navigator, logger()); - bool isPathLimitReached = - result.pathLimitReached(state, stepper, navigator, logger()); - if (isEndOfWorldReached || isPathLimitReached) { - if (isEndOfWorldReached) { - ACTS_VERBOSE("End of world reached"); - } - if (isPathLimitReached) { - ACTS_VERBOSE("Path limit reached"); - } - - if (result.activeTips.size() <= 1) { - // this was the last track - we are done - ACTS_VERBOSE("Kalman filtering finds " - << result.lastTrackIndices.size() << " tracks"); - result.filtered = true; - } else { - storeLastActiveTip(result); - // Remove the tip from list of active tips - result.activeTips.erase(result.activeTips.end() - 1); - reset(state, stepper, navigator, result); - } - } - - // Post-processing after filtering phase - if (result.filtered) { - ACTS_VERBOSE("Finish CKF filtering"); - // Remember that track finding is done - result.finished = true; - } // if filtering is done } /// @brief CombinatorialKalmanFilter actor operation: reset propagation @@ -709,7 +681,7 @@ class CombinatorialKalmanFilter { ACTS_VERBOSE("Stop Kalman filtering with " << result.lastMeasurementIndices.size() << " found tracks"); - result.filtered = true; + result.finished = true; } } From 05b2347f0759eb5b5114cec1e0e6701b6c29b3ef Mon Sep 17 00:00:00 2001 From: Benjamin Huth <37871400+benjaminhuth@users.noreply.github.com> Date: Tue, 21 May 2024 22:23:05 +0200 Subject: [PATCH 06/19] fix: Add missing header for compilation with GCC 14 (#3201) In my version of GCC `std::sort` could not be resolved with the provided headers anymore. --- Core/include/Acts/Seeding/HoughTransformUtils.ipp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Core/include/Acts/Seeding/HoughTransformUtils.ipp b/Core/include/Acts/Seeding/HoughTransformUtils.ipp index 9b54f251bc5..a8f2dea2341 100644 --- a/Core/include/Acts/Seeding/HoughTransformUtils.ipp +++ b/Core/include/Acts/Seeding/HoughTransformUtils.ipp @@ -6,6 +6,8 @@ // 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/. +#include + template template void Acts::HoughTransformUtils::HoughPlane::fill( From 210b8979078704af25154b594071826f3dbb2a59 Mon Sep 17 00:00:00 2001 From: Fred <92879080+fredevb@users.noreply.github.com> Date: Wed, 22 May 2024 13:19:56 +0200 Subject: [PATCH 07/19] build: setup covfie, detray, traccc, and shared libraries (#3099) Updated cmake files to fetch covfie, detray, traccc, thrust, algebra-plugins and set the cmake options in the projects to use shared libraries instead of setting them up for themselves. Update dfelibs version to v20211029, vecmem version to v1.4.0, and nlohmanjson to v3.10.5. Added new cmake options: - added ACTS_SETUP_ and ACTS_USE_SYSTEM_ for covfie, detray, tracc, thrust, algebra-plugins, and dfelibs. - added ACTS_BUILD_PLUGIN_COVFIE and ACTS_BUILD_PLUGIN_TRACCC for building plugins that would allow acts to easily make use of covfie and traccc (future work) Added tests for covfie and traccc to check if the libraries and plugins are available. --- CMakeLists.txt | 65 ++++++++++++++++++++--- cmake/ActsExternSources.cmake | 52 ++++++++++++++++++ docs/getting_started.md | 13 +++++ thirdparty/FRNN/CMakeLists.txt | 12 +---- thirdparty/GeoModel/CMakeLists.txt | 13 +---- thirdparty/actsvg/CMakeLists.txt | 11 +--- thirdparty/algebra-plugins/CMakeLists.txt | 47 ++++++++++++++++ thirdparty/algebra-plugins/README.md | 5 ++ thirdparty/boost/CMakeLists.txt | 9 +--- thirdparty/covfie/CMakeLists.txt | 33 ++++++++++++ thirdparty/covfie/README.md | 5 ++ thirdparty/detray/CMakeLists.txt | 59 ++++++++++++++++++++ thirdparty/detray/README.md | 5 ++ thirdparty/dfelibs/CMakeLists.txt | 19 ++++--- thirdparty/dfelibs/README.md | 4 ++ thirdparty/eigen3/CMakeLists.txt | 10 +--- thirdparty/nlohmann_json/CMakeLists.txt | 9 +--- thirdparty/pybind11/CMakeLists.txt | 10 +--- thirdparty/traccc/CMakeLists.txt | 44 +++++++++++++++ thirdparty/traccc/README.md | 5 ++ thirdparty/vecmem/CMakeLists.txt | 16 +++--- 21 files changed, 362 insertions(+), 84 deletions(-) create mode 100644 cmake/ActsExternSources.cmake create mode 100644 thirdparty/algebra-plugins/CMakeLists.txt create mode 100644 thirdparty/algebra-plugins/README.md create mode 100644 thirdparty/covfie/CMakeLists.txt create mode 100644 thirdparty/covfie/README.md create mode 100644 thirdparty/detray/CMakeLists.txt create mode 100644 thirdparty/detray/README.md create mode 100644 thirdparty/dfelibs/README.md create mode 100644 thirdparty/traccc/CMakeLists.txt create mode 100644 thirdparty/traccc/README.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 56e6b2a4502..7947f033ee1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,9 @@ option(ACTS_BUILD_PLUGIN_PODIO "Build Podio plugin" OFF) option(ACTS_BUILD_PLUGIN_EDM4HEP "Build EDM4hep plugin" OFF) option(ACTS_BUILD_PLUGIN_FPEMON "Build FPE monitoring plugin" OFF) option(ACTS_BUILD_PLUGIN_GEOMODEL "Build GeoModel plugin" OFF) +option(ACTS_BUILD_PLUGIN_COVFIE "Build Covfie plugin" OFF) +option(ACTS_BUILD_PLUGIN_DETRAY "Build Detray plugin" OFF) +option(ACTS_BUILD_PLUGIN_TRACCC "Build Traccc plugin" OFF) option(ACTS_USE_SYSTEM_GEOMODEL "Use a system-provided GeoModel installation" ${ACTS_USE_SYSTEM_LIBS}) option(ACTS_BUILD_PLUGIN_GEANT4 "Build Geant4 plugin" OFF) option(ACTS_BUILD_PLUGIN_EXATRKX "Build the Exa.TrkX plugin" OFF) @@ -46,8 +49,18 @@ option(ACTS_BUILD_PLUGIN_JSON "Build json plugin" OFF) option(ACTS_USE_SYSTEM_NLOHMANN_JSON "Use nlohmann::json provided by the system instead of the bundled version" ${ACTS_USE_SYSTEM_LIBS}) option(ACTS_BUILD_PLUGIN_LEGACY "Build legacy plugin" OFF) option(ACTS_BUILD_PLUGIN_ONNX "Build ONNX plugin" OFF) +option(ACTS_SETUP_COVFIE "Explicitly set up covfie for the project" OFF) +option(ACTS_USE_SYSTEM_COVFIE "Use a system-provided covfie installation" ${ACTS_USE_SYSTEM_LIBS}) +option(ACTS_SETUP_DETRAY "Explicitly set up detray for the project" OFF) +option(ACTS_USE_SYSTEM_DETRAY "Use a system-provided detray installation" ${ACTS_USE_SYSTEM_LIBS}) +option(ACTS_SETUP_TRACCC "Explicitly set up traccc for the project" OFF) +option(ACTS_USE_SYSTEM_TRACCC "Use a system-provided traccc installation" ${ACTS_USE_SYSTEM_LIBS}) +option(ACTS_SETUP_DFELIBS "Explicitly set up dfelibs for the project" ON) +option(ACTS_USE_SYSTEM_DFELIBS "Use a system-provided dfelibs installation" ${ACTS_USE_SYSTEM_LIBS}) option(ACTS_SETUP_VECMEM "Explicitly set up vecmem for the project" OFF) option(ACTS_USE_SYSTEM_VECMEM "Use a system-provided vecmem installation" ${ACTS_USE_SYSTEM_LIBS}) +option(ACTS_SETUP_ALGEBRAPLUGINS "Explicitly set up algebra-plugins for the project" OFF) +option(ACTS_USE_SYSTEM_ALGEBRAPLUGINS "Use a system-provided algebra-plugins installation" ${ACTS_USE_SYSTEM_LIBS}) option(ACTS_BUILD_PLUGIN_TGEO "Build TGeo plugin" OFF) # fatras related options option(ACTS_BUILD_FATRAS "Build FAst TRAcking Simulation package" OFF) @@ -118,6 +131,7 @@ set_option_if( OR ACTS_BUILD_EXAMPLES_BINARIES OR ACTS_BUILD_EVERYTHING) # core plugins might be required by examples or depend on each other + set_option_if( ACTS_BUILD_PLUGIN_DD4HEP ACTS_BUILD_EXAMPLES_DD4HEP OR ACTS_BUILD_EVERYTHING OR @@ -184,9 +198,9 @@ set(_acts_boost_version 1.71.0) set(_acts_dd4hep_version 1.21) set(_acts_edm4hep_version 0.7) set(_acts_geomodel_version 4.6.0) +set(_acts_eigen3_version 3.3.7) set(_acts_podio_version 0.16) set(_acts_doxygen_version 1.9.4) -set(_acts_eigen3_version 3.3.7) set(_acts_hepmc3_version 3.2.1) set(_acts_nlohmanjson_version 3.2.0) set(_acts_onnxruntime_version 1.12.0) @@ -197,6 +211,9 @@ set(_acts_tbb_version 2020.1) # this version we will try so. set(_acts_boost_recommended_version 1.78.0) +# Include the sources for the external dependencies. +include(ActsExternSources) + # required packages if (ACTS_SETUP_BOOST) if (ACTS_USE_SYSTEM_BOOST) @@ -227,11 +244,29 @@ if (ACTS_SETUP_EIGEN3) endif() endif() +if (ACTS_SETUP_DFELIBS) + if (ACTS_USE_SYSTEM_DFELIBS) + find_package(dfelibs ${_acts_dfelibs_version} REQUIRED) + else() + add_subdirectory(thirdparty/dfelibs) + endif() +endif() + if (ACTS_SETUP_VECMEM) if (ACTS_USE_SYSTEM_VECMEM) - find_package(vecmem REQUIRED) + find_package(vecmem ${_acts_vecmem_version} REQUIRED) else() add_subdirectory(thirdparty/vecmem) + # Make the "VecMem language code" available for the whole project. + include( "${VECMEM_LANGUAGE_DIR}/vecmem-check-language.cmake" ) + endif() +endif() + +if (ACTS_SETUP_ALGEBRAPLUGINS) + if (ACTS_USE_SYSTEM_ALGEBRAPLUGINS) + find_package(algebra-plugins ${_acts_algebraplugins_version} REQUIRED) + else() + add_subdirectory(thirdparty/algebra-plugins) endif() endif() @@ -269,9 +304,30 @@ endmacro() # when a particular package is actually needed. # plugin dependencies +if(ACTS_SETUP_COVFIE) + if(ACTS_USE_SYSTEM_COVFIE) + find_package(covfie ${_acts_covfie_version} REQUIRED CONFIG) + else() + add_subdirectory(thirdparty/covfie) + endif() +endif() +if(ACTS_SETUP_DETRAY) + if(ACTS_USE_SYSTEM_DETRAY) + find_package(detray ${_acts_detray_version} REQUIRED CONFIG) + else() + add_subdirectory(thirdparty/detray) + endif() +endif() +if(ACTS_SETUP_TRACCC) + if(ACTS_USE_SYSTEM_TRACCC) + find_package(traccc ${_acts_traccc_version} REQUIRED CONFIG) + else() + add_subdirectory(thirdparty/traccc) + endif() +endif() + if(ACTS_BUILD_PLUGIN_ACTSVG) if(ACTS_USE_SYSTEM_ACTSVG) - message(STATUS "Using system installation of actsvg") find_package(actsvg ${_acts_actsvg_version} REQUIRED CONFIG) else() add_subdirectory(thirdparty/actsvg) @@ -287,7 +343,6 @@ if(ACTS_BUILD_PLUGIN_DD4HEP) endif() if(ACTS_BUILD_PLUGIN_JSON) if(ACTS_USE_SYSTEM_NLOHMANN_JSON) - message(STATUS "Using system installation of nlohmann::json") find_package(nlohmann_json ${_acts_nlohmanjson_version} REQUIRED CONFIG) else() add_subdirectory(thirdparty/nlohmann_json) @@ -295,7 +350,6 @@ if(ACTS_BUILD_PLUGIN_JSON) endif() if(ACTS_BUILD_PLUGIN_GEOMODEL) if(ACTS_USE_SYSTEM_GEOMODEL) - message(STATUS "Using system installation of GeoModel") find_package(GeoModel ${_acts_geomodel_version} REQUIRED CONFIG) else() add_subdirectory(thirdparty/GeoModel) @@ -352,7 +406,6 @@ if(ACTS_BUILD_EXAMPLES) # for simplicity always request all potentially required components. find_package(ROOT ${_acts_root_version} REQUIRED CONFIG COMPONENTS Core Geom Graf GenVector Hist Tree TreePlayer) check_root_compatibility() - add_subdirectory(thirdparty/dfelibs) endif() if(ACTS_BUILD_EXAMPLES_PYTHON_BINDINGS) find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development) diff --git a/cmake/ActsExternSources.cmake b/cmake/ActsExternSources.cmake new file mode 100644 index 00000000000..213bdccb6d8 --- /dev/null +++ b/cmake/ActsExternSources.cmake @@ -0,0 +1,52 @@ +set( ACTS_ACTSVG_SOURCE + "URL;https://github.com/acts-project/actsvg/archive/refs/tags/v0.4.40.tar.gz;URL_MD5;c8f3a7ac47db7f39cd4f215a5bbf148d" CACHE STRING "Source to take ACTSVG from") +mark_as_advanced( ACTS_ACTSVG_SOURCE ) + +set( ACTS_VECMEM_SOURCE + "URL;https://github.com/acts-project/vecmem/archive/refs/tags/v1.4.0.tar.gz;URL_MD5;af5434e34ca9c084678c2c043441f174" CACHE STRING "Source to take VECMEM from") +mark_as_advanced( ACTS_VECMEM_SOURCE ) + +set( ACTS_ALGEBRAPLUGINS_SOURCE + "URL;https://github.com/acts-project/algebra-plugins/archive/refs/tags/v0.22.0.tar.gz;URL_MD5;42bcaad8d19a2c773993a974816dfdf5" CACHE STRING "Source to take ALGEBRAPLUGINS from") +mark_as_advanced( ACTS_ALGEBRAPLUGINS_SOURCE ) + +set( ACTS_COVFIE_SOURCE + "URL;https://github.com/acts-project/covfie/archive/refs/tags/v0.10.0.tar.gz;URL_MD5;af59c6e2a1eebfa765b29f0af9fc70f7" CACHE STRING "Source to take COVFIE from") +mark_as_advanced( ACTS_COVFIE_SOURCE ) + +set( ACTS_DETRAY_SOURCE + "URL;https://github.com/acts-project/detray/archive/refs/tags/v0.65.1.tar.gz;URL_MD5;fbf57a881565fa6019d79d13409b588f" CACHE STRING "Source to take DETRAY from") +mark_as_advanced( ACTS_DETRAY_SOURCE ) + +set( ACTS_TRACCC_SOURCE + "URL;https://github.com/acts-project/traccc/archive/refs/tags/v0.10.0.tar.gz;URL_MD5;131399d26e3280c4d7f7ca2995efd256" CACHE STRING "Source to take TRACCC from") +mark_as_advanced( ACTS_TRACCC_SOURCE ) + +set( ACTS_DFELIBS_SOURCE + "URL;https://github.com/acts-project/dfelibs/archive/refs/tags/v20211029.tar.gz;URL_MD5;87fb09c5a11b98250f5e266e9cd501ea" CACHE STRING "Source to take dfelibs from") +mark_as_advanced( ACTS_DFELIBS_SOURCE ) + +set( ACTS_FRNN_SOURCE + "GIT_REPOSITORY;https://github.com/lxxue/FRNN;GIT_TAG;3e370d8d9073d4e130363faf87d2370598b5fbf2" CACHE STRING "Source to take FRNN from") +mark_as_advanced( ACTS_FRNN_SOURCE ) + +set( ACTS_GEOMODEL_SOURCE + "GIT_REPOSITORY;https://gitlab.cern.ch/GeoModelDev/GeoModel;GIT_TAG;4.6.0;PATCH_COMMAND;git am ${CMAKE_CURRENT_SOURCE_DIR}/0001-Add-option-to-skip-setting-up-json-completely.patch" CACHE STRING "Source to take GeoModel from") +mark_as_advanced( ACTS_GEOMODEL_SOURCE ) + +set( ACTS_NLOHMANNJSON_SOURCE + "URL;https://github.com/nlohmann/json/archive/refs/tags/v3.10.5.tar.gz;URL_HASH;SHA1=8969f5ad1a422e01f040ff48dcae9c0e6ad0811d" CACHE STRING "Source to take nlohmann_json from") +mark_as_advanced( ACTS_NLOHMANN_JSON_SOURCE ) + +string(REPLACE "." "_" _acts_boost_recommended_version_ ${_acts_boost_recommended_version}) +set( ACTS_BOOST_SOURCE + "URL;https://boostorg.jfrog.io/artifactory/main/release/${_acts_boost_recommended_version}/source/boost_${_acts_boost_recommended_version_}.tar.gz" CACHE STRING "Source to take boost from") +mark_as_advanced( ACTS_BOOST_SOURCE ) + +set( ACTS_EIGEN3_SOURCE + "URL;https://gitlab.com/libeigen/eigen/-/archive/${_acts_eigen3_version}/${_acts_eigen3_version}.tar.gz" CACHE STRING "Source to take eigen3 from") +mark_as_advanced( ACTS_EIGEN3_SOURCE ) + +set( ACTS_PYBIND11_SOURCE + "GIT_REPOSITORY;https://github.com/pybind/pybind11.git;GIT_TAG;v2.10.1" CACHE STRING "Source to take pybind11 from") +mark_as_advanced( ACTS_PYBIND11_SOURCE ) diff --git a/docs/getting_started.md b/docs/getting_started.md index 6d9aa8a7466..d21392cfa02 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -267,6 +267,9 @@ components. | ACTS_BUILD_PLUGIN_EDM4HEP | Build EDM4hep plugin
type: `bool`, default: `OFF` | | ACTS_BUILD_PLUGIN_FPEMON | Build FPE monitoring plugin
type: `bool`, default: `OFF` | | ACTS_BUILD_PLUGIN_GEOMODEL | Build GeoModel plugin
type: `bool`, default: `OFF` | +| ACTS_BUILD_PLUGIN_COVFIE | Build Covfie plugin
type: `bool`, default: `OFF` | +| ACTS_BUILD_PLUGIN_DETRAY | Build Detray plugin
type: `bool`, default: `OFF` | +| ACTS_BUILD_PLUGIN_TRACCC | Build Traccc plugin
type: `bool`, default: `OFF` | | ACTS_USE_SYSTEM_GEOMODEL | Use a system-provided GeoModel
installation
type: `bool`, default: `ACTS_USE_SYSTEM_LIBS -> OFF` | | ACTS_BUILD_PLUGIN_GEANT4 | Build Geant4 plugin
type: `bool`, default: `OFF` | | ACTS_BUILD_PLUGIN_EXATRKX | Build the Exa.TrkX plugin
type: `bool`, default: `OFF` | @@ -276,8 +279,18 @@ components. | ACTS_USE_SYSTEM_NLOHMANN_JSON | Use nlohmann::json provided by the
system instead of the bundled version
type: `bool`, default: `ACTS_USE_SYSTEM_LIBS -> OFF` | | ACTS_BUILD_PLUGIN_LEGACY | Build legacy plugin
type: `bool`, default: `OFF` | | ACTS_BUILD_PLUGIN_ONNX | Build ONNX plugin
type: `bool`, default: `OFF` | +| ACTS_SETUP_COVFIE | Explicitly set up covfie for the project
type: `bool`, default: `OFF` | +| ACTS_USE_SYSTEM_COVFIE | Use a system-provided covfie
installation
type: `bool`, default: `ACTS_USE_SYSTEM_LIBS -> OFF` | +| ACTS_SETUP_DETRAY | Explicitly set up detray for the project
type: `bool`, default: `OFF` | +| ACTS_USE_SYSTEM_DETRAY | Use a system-provided detray
installation
type: `bool`, default: `ACTS_USE_SYSTEM_LIBS -> OFF` | +| ACTS_SETUP_TRACCC | Explicitly set up traccc for the project
type: `bool`, default: `OFF` | +| ACTS_USE_SYSTEM_TRACCC | Use a system-provided traccc
installation
type: `bool`, default: `ACTS_USE_SYSTEM_LIBS -> OFF` | +| ACTS_SETUP_DFELIBS | Explicitly set up dfelibs for the
project
type: `bool`, default: `ON` | +| ACTS_USE_SYSTEM_DFELIBS | Use a system-provided dfelibs
installation
type: `bool`, default: `ACTS_USE_SYSTEM_LIBS -> OFF` | | ACTS_SETUP_VECMEM | Explicitly set up vecmem for the project
type: `bool`, default: `OFF` | | ACTS_USE_SYSTEM_VECMEM | Use a system-provided vecmem
installation
type: `bool`, default: `ACTS_USE_SYSTEM_LIBS -> OFF` | +| ACTS_SETUP_ALGEBRAPLUGINS | Explicitly set up algebra-plugins for
the project
type: `bool`, default: `OFF` | +| ACTS_USE_SYSTEM_ALGEBRAPLUGINS | Use a system-provided algebra-plugins
installation
type: `bool`, default: `ACTS_USE_SYSTEM_LIBS -> OFF` | | ACTS_BUILD_PLUGIN_TGEO | Build TGeo plugin
type: `bool`, default: `OFF` | | ACTS_BUILD_FATRAS | Build FAst TRAcking Simulation package
type: `bool`, default: `OFF` | | ACTS_BUILD_FATRAS_GEANT4 | Build Geant4 Fatras package
type: `bool`, default: `OFF` | diff --git a/thirdparty/FRNN/CMakeLists.txt b/thirdparty/FRNN/CMakeLists.txt index 9aa70a450aa..30161ebb276 100644 --- a/thirdparty/FRNN/CMakeLists.txt +++ b/thirdparty/FRNN/CMakeLists.txt @@ -11,16 +11,8 @@ include(FetchContent) message(STATUS "Building FRNN as part of the ACTS project") -set(ACTS_FRNN_GIT_REPOSITORY "https://github.com/lxxue/FRNN" - CACHE STRING "Git repository to take FRNN from") -set(ACTS_FRNN_GIT_TAG "3e370d8d9073d4e130363faf87d2370598b5fbf2" - CACHE STRING "Version of FRNN to build") - -mark_as_advanced(ACTS_FRNN_GIT_REPOSITORY ACTS_FRNN_GIT_TAG) - -FetchContent_Declare(frnncontent - GIT_REPOSITORY "${ACTS_FRNN_GIT_REPOSITORY}" - GIT_TAG "${ACTS_FRNN_GIT_TAG}" ) +# Declare where to get frnncontent from +FetchContent_Declare( frnncontent ${ACTS_FRNN_SOURCE} ) # FRNN does not provide a CMakeLists.txt, so we use a custom one. Because of this, # we have to implement the populate step manually diff --git a/thirdparty/GeoModel/CMakeLists.txt b/thirdparty/GeoModel/CMakeLists.txt index dfd85283977..1e243455a05 100644 --- a/thirdparty/GeoModel/CMakeLists.txt +++ b/thirdparty/GeoModel/CMakeLists.txt @@ -17,17 +17,8 @@ set( GEOMODEL_VERSION "${_acts_geomodel_version}") set( GEOMODEL_SETUP_JSON OFF CACHE BOOL "Skip setting up json completely" ) - -# Declare where to get VecMem from. -set( ACTS_GEOMODEL_GIT_REPOSITORY "https://gitlab.cern.ch/GeoModelDev/GeoModel" - CACHE STRING "Git repository to take GeoModel from" ) -set( ACTS_GEOMODEL_GIT_TAG "${GEOMODEL_VERSION}" CACHE STRING "Version of GeoModel to build" ) -mark_as_advanced( ACTS_GEOMODEL_GIT_REPOSITORY ACTS_GEOMODEL_GIT_TAG ) -FetchContent_Declare( geomodel - GIT_REPOSITORY "${ACTS_GEOMODEL_GIT_REPOSITORY}" - GIT_TAG "${ACTS_GEOMODEL_GIT_TAG}" - PATCH_COMMAND git am ${CMAKE_CURRENT_SOURCE_DIR}/0001-Add-option-to-skip-setting-up-json-completely.patch -) +# Declare where to get geomodel from. +FetchContent_Declare( geomodel ${ACTS_GEOMODEL_SOURCE} ) # Now set up its build. FetchContent_MakeAvailable( geomodel ) diff --git a/thirdparty/actsvg/CMakeLists.txt b/thirdparty/actsvg/CMakeLists.txt index 72dc546a202..2da1b0c7aa5 100644 --- a/thirdparty/actsvg/CMakeLists.txt +++ b/thirdparty/actsvg/CMakeLists.txt @@ -13,16 +13,7 @@ include( FetchContent ) # Tell the user what's happening. message( STATUS "Building actsvg as part of the ACTS project" ) -set( ACTS_VERSION "v${_acts_actsvg_version}") - -# Declare where to get VecMem from. -set( ACTS_ACTSVG_GIT_REPOSITORY "https://github.com/acts-project/actsvg.git" - CACHE STRING "Git repository to take actsvg from" ) -set( ACTS_ACTSVG_GIT_TAG "${ACTS_VERSION}" CACHE STRING "Version of actsvg to build" ) -mark_as_advanced( ACTS_ACTSVG_GIT_REPOSITORY ACTS_ACTSVG_GIT_TAG ) -FetchContent_Declare( actsvg - GIT_REPOSITORY "${ACTS_ACTSVG_GIT_REPOSITORY}" - GIT_TAG "${ACTS_ACTSVG_GIT_TAG}" ) +FetchContent_Declare( actsvg ${ACTS_ACTSVG_SOURCE} ) # Now set up its build. FetchContent_MakeAvailable( actsvg ) diff --git a/thirdparty/algebra-plugins/CMakeLists.txt b/thirdparty/algebra-plugins/CMakeLists.txt new file mode 100644 index 00000000000..a0126cece7f --- /dev/null +++ b/thirdparty/algebra-plugins/CMakeLists.txt @@ -0,0 +1,47 @@ +# This file is part of the Acts project. +# +# Copyright (C) 2021 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/. + +# CMake include(s). +cmake_minimum_required(VERSION 3.14) +include(FetchContent) + +# Tell the user what's happening. +message( STATUS "Building algebra-plugins as part of the Acts project" ) + +FetchContent_Declare( AlgebraPlugins ${ACTS_ALGEBRAPLUGINS_SOURCE} ) + +# Options used in the build of Algebra Plugins. +set(ALGEBRA_PLUGINS_BUILD_TESTING FALSE CACHE BOOL + "Turn off the build of the Algebra Plugins unit tests") +set(ALGEBRA_PLUGINS_INCLUDE_EIGEN TRUE CACHE BOOL + "Turn on the build of algebra::eigen") +set(ALGEBRA_PLUGINS_INCLUDE_VC TRUE CACHE BOOL + "Turn on the build of algebra::vc_array") +set(ALGEBRA_PLUGINS_INCLUDE_VECMEM TRUE CACHE BOOL + "Turn on the build of algebra::vecmem_array") + +# Build smatrix plugin only when it needs to be +# ROOT is not provided in native github compilers :/ +set(ALGEBRA_PLUGINS_INCLUDE_SMATRIX ${DETRAY_SMATRIX_PLUGIN} + CACHE BOOL "Turn on/off the build of algebra::smatrix") + +set(ALGEBRA_PLUGINS_SETUP_EIGEN3 OFF CACHE BOOL + "Do not have Algebra Plugins set up Eigen3 for itself") +set(ALGEBRA_PLUGINS_SETUP_VC ON CACHE BOOL + "Have Algebra Plugins set up Vc for itself") +set(ALGEBRA_PLUGINS_USE_SYSTEM_VC OFF CACHE BOOL + "Have Algebra Plugins build Vc itself") +set(ALGEBRA_PLUGINS_SETUP_VECMEM FALSE CACHE BOOL + "Do not set up VecMem in Algebra Plugins") +set(ALGEBRA_PLUGINS_SETUP_GOOGLETEST FALSE CACHE BOOL + "Do not set up GoogleTest in Algebra Plugins") + +set(ALGEBRA_PLUGINS_SETUP_BENCHMARK FALSE CACHE BOOL "Do not setup Algebra Plugins benchmark") + +# Now set up its build. +FetchContent_MakeAvailable( AlgebraPlugins ) \ No newline at end of file diff --git a/thirdparty/algebra-plugins/README.md b/thirdparty/algebra-plugins/README.md new file mode 100644 index 00000000000..6b95916ea75 --- /dev/null +++ b/thirdparty/algebra-plugins/README.md @@ -0,0 +1,5 @@ +# Build Recipe for algebra-plugins + +This directory holds a simple build recipe for the +[algebra-plugins](https://github.com/acts-project/algebra-plugins) project. Used in case +`ACTS_USE_SYSTEM_ALGEBRAPLUGINS` is set to `FALSE` for the build. diff --git a/thirdparty/boost/CMakeLists.txt b/thirdparty/boost/CMakeLists.txt index e802ed9662f..94c51b9dbca 100644 --- a/thirdparty/boost/CMakeLists.txt +++ b/thirdparty/boost/CMakeLists.txt @@ -3,7 +3,6 @@ message(STATUS "Building Boost ${_acts_boost_recommended_version}") include(ExternalProject) string(REPLACE "." "_" _acts_boost_recommended_version_ ${_acts_boost_recommended_version}) -set(Boost_URL "https://boostorg.jfrog.io/artifactory/main/release/${_acts_boost_recommended_version}/source/boost_${_acts_boost_recommended_version_}.tar.gz") set(Boost_LIBRARY_LIST "filesystem,program_options,test") set(Boost_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/boost-prefix/src/boost) set(Boost_INCLUDE_DIR ${Boost_SOURCE_DIR}) @@ -16,13 +15,7 @@ set(Boost_B2_FLAGS variant=release threading=multi runtime-link=shared link=shar # Note: Since all builds below depend on the headers, use this step to # download the boost release -ExternalProject_Add( - boost - URL ${Boost_URL} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" -) +ExternalProject_Add( boost "${ACTS_BOOST_SOURCE};CONFIGURE_COMMAND;;BUILD_COMMAND;;INSTALL_COMMAND;" ) add_library(Boost::boost INTERFACE IMPORTED GLOBAL) add_dependencies(Boost::boost boost) diff --git a/thirdparty/covfie/CMakeLists.txt b/thirdparty/covfie/CMakeLists.txt new file mode 100644 index 00000000000..b74710c587b --- /dev/null +++ b/thirdparty/covfie/CMakeLists.txt @@ -0,0 +1,33 @@ +# This file is part of the Acts project. +# +# Copyright (C) 2021 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/. + +# CMake include(s). +cmake_minimum_required(VERSION 3.14) +include(FetchContent) + +# Tell the user what's happening. +message( STATUS "Building Covfie as part of the Acts project" ) + +set( COVFIE_VERSION "v${_acts_covfie_version}") + +# Declare where to get covfie from. +FetchContent_Declare( covfie ${ACTS_COVFIE_SOURCE} ) + +# Options used for covfie. +set( COVFIE_BUILD_EXAMPLES OFF CACHE BOOL "Build covfie examples") +set( COVFIE_BUILD_TESTS OFF CACHE BOOL "Build covfie tests") +set( COVFIE_BUILD_BENCHMARKS OFF CACHE BOOL "Build covfie benchmarks") + +set( COVFIE_PLATFORM_CPU ON CACHE BOOL "Enable covfie CPU platform") +set( COVFIE_PLATFORM_CUDA ${ACTS_BUILD_PLUGIN_CUDA} CACHE BOOL "Enable covfie CUDA platform") + +set( COVFIE_REQUIRE_CXX20 OFF CACHE BOOL "Enable covfie C++20 requirement") +set( COVFIE_QUIET ON CACHE BOOL "Quiet covfie feature warnings") + +# Now set up its build. +FetchContent_MakeAvailable( covfie ) \ No newline at end of file diff --git a/thirdparty/covfie/README.md b/thirdparty/covfie/README.md new file mode 100644 index 00000000000..dbc48747511 --- /dev/null +++ b/thirdparty/covfie/README.md @@ -0,0 +1,5 @@ +# Build Recipe for covfie + +This directory holds a simple build recipe for the +[covfie](https://github.com/acts-project/covfie) project. Used in case +`ACTS_USE_SYSTEM_COVFIE` is set to `FALSE` for the build. diff --git a/thirdparty/detray/CMakeLists.txt b/thirdparty/detray/CMakeLists.txt new file mode 100644 index 00000000000..961057df933 --- /dev/null +++ b/thirdparty/detray/CMakeLists.txt @@ -0,0 +1,59 @@ +# This file is part of the Acts project. +# +# Copyright (C) 2021 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/. + +# CMake include(s). +cmake_minimum_required( VERSION 3.11 ) +include( FetchContent ) + +# Tell the user what's happening. +message( STATUS "Building Detray as part of the Acts project" ) + +set( DETRAY_VERSION "v${_acts_detray_version}") + +# Declare where to get Detray from. +FetchContent_Declare( Detray ${ACTS_DETRAY_SOURCE} ) + +# Options used in the build of Detray. +set( DETRAY_CUSTOM_SCALARTYPE "float" CACHE STRING + "Scalar type to use in the Detray code" ) + +set( DETRAY_BUILD_TESTING OFF CACHE BOOL + "Turn off the build of the Detray unit tests" ) +set( DETRAY_BUILD_TUTORIALS OFF CACHE BOOL + "Turn off the build of the Detray tutorials" ) +set( DETRAY_EIGEN_PLUGIN ON CACHE BOOL + "Turn on the build of the Detray Eigen code" ) +set( DETRAY_VC_PLUGIN ON CACHE BOOL + "Turn on the build of the Detray Vc code" ) + +set( DETRAY_SETUP_VECMEM OFF CACHE BOOL + "Do not set up VecMem as part of Detray" ) +set( DETRAY_SETUP_ALGEBRA_PLUGINS OFF CACHE BOOL + "Do not set up Algebra Plugins as part of Detray" ) +set( DETRAY_SETUP_GOOGLETEST OFF CACHE BOOL + "Do not set up GoogleTest as part of Detray" ) +set( DETRAY_SETUP_BENCHMARK OFF CACHE BOOL + "Do not set up Google Benchmark as part of Detray" ) +set( DETRAY_SETUP_THRUST ON CACHE BOOL + "Set up Thrust as part of Detray" ) +set( DETRAY_SETUP_COVFIE OFF CACHE BOOL + "Do not set up covfie as part of Detray" ) +set( DETRAY_SETUP_NLOHMANN OFF CACHE BOOL + "Do not set up Nlohmann as part of Detray" ) +set( DETRAY_SETUP_ACTSVG OFF CACHE BOOL + "Do not set up Actsvg as part of Detray" ) +set( DETRAY_SETUP_DFELIBS OFF CACHE BOOL + "Do not set up Dfelibs as part of Detray" ) +#set( DETRAY_VC_PLUGIN OFF CACHE BOOL +# "Do not build Vc based math plugin" ) +#set( DETRAY_SVG_DISPLAY ON CACHE BOOL +# "Build the ActSVG display module" ) + + +#Now set up its build. +FetchContent_MakeAvailable(Detray) \ No newline at end of file diff --git a/thirdparty/detray/README.md b/thirdparty/detray/README.md new file mode 100644 index 00000000000..69c36ad6076 --- /dev/null +++ b/thirdparty/detray/README.md @@ -0,0 +1,5 @@ +# Build Recipe for detray + +This directory holds a simple build recipe for the +[detray](https://github.com/acts-project/detray) project. Used in case +`ACTS_USE_SYSTEM_DETRAY` is set to `FALSE` for the build. diff --git a/thirdparty/dfelibs/CMakeLists.txt b/thirdparty/dfelibs/CMakeLists.txt index 4c0a94a0d73..d95941b8406 100644 --- a/thirdparty/dfelibs/CMakeLists.txt +++ b/thirdparty/dfelibs/CMakeLists.txt @@ -4,15 +4,18 @@ include( FetchContent ) # Tell the user what's happening. message( STATUS "Building dfelibs as part of the ACTS project" ) +set( DFELIBS_VERSION "v${_acts_dfelibs_version}") -# Declare where to get VecMem from. -set( ACTS_DFELIBS_GIT_REPOSITORY "https://github.com/acts-project/dfelibs.git" - CACHE STRING "Git repository to take dfelibs from" ) -set( ACTS_DFELIBS_GIT_TAG "v20200416" CACHE STRING "Version of dfelibs to build" ) -mark_as_advanced( ACTS_DFELIBS_GIT_REPOSITORY ACTS_DFELIBS_GIT_TAG ) -FetchContent_Declare( dfelibs - GIT_REPOSITORY "${ACTS_DFELIBS_GIT_REPOSITORY}" - GIT_TAG "${ACTS_DFELIBS_GIT_TAG}" ) +# Declare where to get dfelibs from. +FetchContent_Declare( dfelibs ${ACTS_DFELIBS_SOURCE} ) + +# Options used in the build of dfelibs. +set( dfelibs_BUILD_EXAMPLES OFF CACHE BOOL + "Turn off the build of the dfelibs examples" ) +set( dfelibs_BUILD_UNITTESTS OFF CACHE BOOL + "Turn off the build of the dfelibs unit tests" ) +set( dfelibs_ENABLE_INSTALL ON CACHE BOOL + "Have dfelibs be installed together with the rest of the project" ) # Now set up its build. FetchContent_MakeAvailable( dfelibs ) diff --git a/thirdparty/dfelibs/README.md b/thirdparty/dfelibs/README.md new file mode 100644 index 00000000000..4b2960be096 --- /dev/null +++ b/thirdparty/dfelibs/README.md @@ -0,0 +1,4 @@ +# Build Recipe for dfelibs + +This directory holds a simple build recipe for the +[dfelibs](https://github.com/acts-project/dfelibs) project. diff --git a/thirdparty/eigen3/CMakeLists.txt b/thirdparty/eigen3/CMakeLists.txt index 26ac8d0b4dd..7aefc97f2bf 100644 --- a/thirdparty/eigen3/CMakeLists.txt +++ b/thirdparty/eigen3/CMakeLists.txt @@ -2,19 +2,11 @@ message(STATUS "Building Eigen ${_acts_eigen3_version}") include(ExternalProject) -set(Eigen3_URL "https://gitlab.com/libeigen/eigen/-/archive/${_acts_eigen3_version}/${_acts_eigen3_version}.tar.gz") set(Eigen3_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/eigen3-prefix/src/eigen3) -ExternalProject_Add( - eigen3 - URL ${Eigen3_URL} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" -) +ExternalProject_Add(eigen3 "${ACTS_EIGEN3_SOURCE};CONFIGURE_COMMAND;;BUILD_COMMAND;;INSTALL_COMMAND;") add_library(Eigen3::Eigen INTERFACE IMPORTED GLOBAL) add_dependencies(Eigen3::Eigen eigen3) target_include_directories(Eigen3::Eigen INTERFACE ${Eigen3_INCLUDE_DIR}) install(DIRECTORY ${Eigen3_INCLUDE_DIR}/Eigen DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - diff --git a/thirdparty/nlohmann_json/CMakeLists.txt b/thirdparty/nlohmann_json/CMakeLists.txt index 52851da85f9..39aedcb2d5c 100644 --- a/thirdparty/nlohmann_json/CMakeLists.txt +++ b/thirdparty/nlohmann_json/CMakeLists.txt @@ -8,13 +8,8 @@ if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) endif() -# Declare where to get VecMem from. -set( ACTS_NLOHMANN_JSON_GIT_TAG "v3.10.5" CACHE STRING "Version of nlohmann_json to build" ) -set( ACTS_NLOHMANN_JSON_SHA1 "8969f5ad1a422e01f040ff48dcae9c0e6ad0811d" CACHE STRING "SHA1 hash of the downloaded zip" ) -mark_as_advanced( ACTS_NLOHMANN_JSON_GIT_REPOSITORY ACTS_NLOHMANN_JSON_GIT_TAG ) -FetchContent_Declare( nlohmann_json - URL "https://github.com/nlohmann/json/archive/refs/tags/${ACTS_NLOHMANN_JSON_GIT_TAG}.tar.gz" - URL_HASH SHA1=${ACTS_NLOHMANN_JSON_SHA1}) +# Declare where to get nlohmann json from. +FetchContent_Declare( nlohmann_json ${ACTS_NLOHMANNJSON_SOURCE} ) # Now set up its build. set(JSON_BuildTests OFF CACHE INTERNAL "") diff --git a/thirdparty/pybind11/CMakeLists.txt b/thirdparty/pybind11/CMakeLists.txt index cfd22447e35..60b95573dfc 100644 --- a/thirdparty/pybind11/CMakeLists.txt +++ b/thirdparty/pybind11/CMakeLists.txt @@ -4,14 +4,8 @@ include( FetchContent ) # Tell the user what's happening. message( STATUS "Building pybind11 as part of the ACTS project" ) -# Declare where to get VecMem from. -set( ACTS_PYBIND11_GIT_REPOSITORY "https://github.com/pybind/pybind11.git" - CACHE STRING "Git repository to take pybind11 from" ) -set( ACTS_PYBIND11_GIT_TAG "v2.10.1" CACHE STRING "Version of pybind11 to build" ) -mark_as_advanced( ACTS_PYBIND11_GIT_REPOSITORY ACTS_PYBIND11_GIT_TAG ) -FetchContent_Declare( pybind11 - GIT_REPOSITORY "${ACTS_PYBIND11_GIT_REPOSITORY}" - GIT_TAG "${ACTS_PYBIND11_GIT_TAG}" ) +# Declare where to get pybind from. +FetchContent_Declare( pybind11 ${ACTS_PYBIND11_SOURCE} ) # Now set up its build. set(PYBIND11_TEST OFF) diff --git a/thirdparty/traccc/CMakeLists.txt b/thirdparty/traccc/CMakeLists.txt new file mode 100644 index 00000000000..b62c9ba35f0 --- /dev/null +++ b/thirdparty/traccc/CMakeLists.txt @@ -0,0 +1,44 @@ +# This file is part of the Acts project. +# +# Copyright (C) 2021 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/. + +# CMake include(s). +cmake_minimum_required(VERSION 3.14) +include(FetchContent) + +# Tell the user what's happening. +message( STATUS "Building tracc as part of the Acts project" ) + +set( TRACCC_VERSION "${_acts_traccc_version}") + +# Declare where to get traccc from. +FetchContent_Declare( traccc ${ACTS_TRACCC_SOURCE} ) + +set( TRACCC_SETUP_VECMEM OFF CACHE BOOL + "Do not set up Actsvg as part of Traccc" ) +set( TRACCC_SETUP_EIGEN3 OFF CACHE BOOL + "Do not set up Eigen3 as part of Traccc" ) +set( TRACCC_SETUP_THRUST OFF CACHE BOOL + "Do not set up Thrust as part of Traccc" ) +set( TRACCC_SETUP_ALGEBRA_PLUGINS OFF CACHE BOOL + "Do not set up Algebra Plugins as part of Traccc" ) +set( TRACCC_SETUP_COVFIE OFF CACHE BOOL + "Do not set up Covfie as part of Traccc" ) +set( TRACCC_SETUP_DFELIBS OFF CACHE BOOL + "Do not set up dfelibs as part of Traccc" ) +set( TRACCC_SETUP_DETRAY OFF CACHE BOOL + "Do not set up Detray as part of Traccc" ) +set( TRACCC_SETUP_ACTS OFF CACHE BOOL + "Do not set up ACTS as part of Traccc" ) + +set( TRACCC_BUILD_TESTING OFF CACHE BOOL + "Turn off the build of the Traccc unit tests" ) +set( TRACCC_BUILD_EXAMPLES OFF CACHE BOOL + "Turn off the build of the Traccc examples" ) + +# Now set up its build. +FetchContent_MakeAvailable( traccc ) \ No newline at end of file diff --git a/thirdparty/traccc/README.md b/thirdparty/traccc/README.md new file mode 100644 index 00000000000..d7d1c3d1a23 --- /dev/null +++ b/thirdparty/traccc/README.md @@ -0,0 +1,5 @@ +# Build Recipe for traccc + +This directory holds a simple build recipe for the +[traccc](https://github.com/acts-project/traccc) project. Used in case +`ACTS_USE_SYSTEM_TRACCC` is set to `FALSE` for the build. diff --git a/thirdparty/vecmem/CMakeLists.txt b/thirdparty/vecmem/CMakeLists.txt index 8b6c80a1d05..b6d74615471 100644 --- a/thirdparty/vecmem/CMakeLists.txt +++ b/thirdparty/vecmem/CMakeLists.txt @@ -13,14 +13,16 @@ include( FetchContent ) # Tell the user what's happening. message( STATUS "Building VecMem as part of the Acts project" ) +set( VECMEM_VERSION "v${_acts_vecmem_version}") + # Declare where to get VecMem from. -set( ACTS_VECMEM_GIT_REPOSITORY "https://github.com/acts-project/vecmem.git" - CACHE STRING "Git repository to take VecMem from" ) -set( ACTS_VECMEM_GIT_TAG "v0.4.0" CACHE STRING "Version of VecMem to build" ) -mark_as_advanced( ACTS_VECMEM_GIT_REPOSITORY ACTS_VECMEM_GIT_TAG ) -FetchContent_Declare( VecMem - GIT_REPOSITORY "${ACTS_VECMEM_GIT_REPOSITORY}" - GIT_TAG "${ACTS_VECMEM_GIT_TAG}" ) +FetchContent_Declare( VecMem ${ACTS_VECMEM_SOURCE} ) + +# Options used in the build of VecMem. +set( VECMEM_BUILD_TESTING FALSE CACHE BOOL + "Turn off the build of the VecMem unit tests" ) +set( VECMEM_BUILD_BENCHMARKING FALSE CACHE BOOL + "Turn off the build of VecMem benchmarking" ) # Now set up its build. FetchContent_MakeAvailable( VecMem ) From 1dfef95402218e61f2b43992a3e35b56baf624e4 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 22 May 2024 15:01:25 +0200 Subject: [PATCH 08/19] fix: Fix Core CKF segfault with fitted params (#3203) This fixes a rare bug in the CKF. During extrapolation to the target surface we expect a previous track state which does not need to exist necessarily. https://github.com/acts-project/acts/pull/3161 also cleans this up by having tracks for each branch instead of last tip states --- Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp index d7c76a647f8..b4b5caf6e2f 100644 --- a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp +++ b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp @@ -391,7 +391,7 @@ class CombinatorialKalmanFilter { ACTS_ERROR("Error while acquiring bound state for target surface: " << res.error() << " " << res.error().message()); result.lastError = res.error(); - } else { + } else if (!result.activeTips.empty()) { const auto& fittedState = *res; std::size_t currentTip = result.activeTips.back().first; // Assign the fitted parameters From fa10f5eb1e76ae70aeb85b6ae2695e513ed76a6c Mon Sep 17 00:00:00 2001 From: Amperiadou Dimitra <63058524+dimitra97@users.noreply.github.com> Date: Wed, 22 May 2024 17:34:17 +0200 Subject: [PATCH 09/19] feat: Smearing for straw surfaces (#3197) This PR introduces the smearing of the` boundParameters` of Straw Surface, that can be used for a fast digitization approach for the MDTs with a Gaussian distribution. It is configures from the json structure that can be used for the creation of a json file for a full propagation-digitization test. Also the option for positive only values is introduced in the `SmearingConfig` as a flag because for the case of the drift radius we want to get only positive values as output. --- .../Digitization/SmearingConfig.hpp | 2 + .../Digitization/UncorrelatedHitSmearer.hpp | 4 + .../Fatras/Digitization/CMakeLists.txt | 2 +- .../UncorrelatedHitSmearerTests.cpp | 89 +++++++++++++++++-- 4 files changed, 88 insertions(+), 9 deletions(-) diff --git a/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/SmearingConfig.hpp b/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/SmearingConfig.hpp index 587e3b54f50..de32254e6d2 100644 --- a/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/SmearingConfig.hpp +++ b/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/SmearingConfig.hpp @@ -21,6 +21,8 @@ struct ParameterSmearingConfig { Acts::BoundIndices index = Acts::eBoundSize; /// The smearing function for this parameter. ActsFatras::SingleParameterSmearFunction smearFunction; + /// A flag to return only positive smeared values + bool forcePositiveValues = false; }; // The configured indices must be unique, i.e. each one can only appear once diff --git a/Fatras/include/ActsFatras/Digitization/UncorrelatedHitSmearer.hpp b/Fatras/include/ActsFatras/Digitization/UncorrelatedHitSmearer.hpp index 565559e01c2..0600006b5f2 100644 --- a/Fatras/include/ActsFatras/Digitization/UncorrelatedHitSmearer.hpp +++ b/Fatras/include/ActsFatras/Digitization/UncorrelatedHitSmearer.hpp @@ -49,6 +49,7 @@ struct BoundParametersSmearer { /// Parameter indices that will be used to create the smeared measurements. std::array indices{}; std::array, kSize> smearFunctions{}; + std::array forcePositive = {}; static constexpr std::size_t size() { return kSize; } @@ -93,6 +94,9 @@ struct BoundParametersSmearer { } auto [value, stddev] = res.value(); par[i] = value; + if (forcePositive[i]) { + par[i] = std::abs(value); + } cov(i, i) = stddev * stddev; } diff --git a/Tests/UnitTests/Fatras/Digitization/CMakeLists.txt b/Tests/UnitTests/Fatras/Digitization/CMakeLists.txt index 8737e163dfc..54f1a7d1cd9 100644 --- a/Tests/UnitTests/Fatras/Digitization/CMakeLists.txt +++ b/Tests/UnitTests/Fatras/Digitization/CMakeLists.txt @@ -1,4 +1,4 @@ -set(unittest_extra_libraries ActsFatras) +set(unittest_extra_libraries ActsExamplesDigitization ActsExamplesIoJson ActsFatras) add_unittest(FatrasChannelMerger ChannelMergerTests.cpp) add_unittest(FatrasChannelizer ChannelizerTests.cpp) diff --git a/Tests/UnitTests/Fatras/Digitization/UncorrelatedHitSmearerTests.cpp b/Tests/UnitTests/Fatras/Digitization/UncorrelatedHitSmearerTests.cpp index fceb680f873..7950c353d80 100644 --- a/Tests/UnitTests/Fatras/Digitization/UncorrelatedHitSmearerTests.cpp +++ b/Tests/UnitTests/Fatras/Digitization/UncorrelatedHitSmearerTests.cpp @@ -18,9 +18,13 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" +#include "Acts/Surfaces/StrawSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/Result.hpp" +#include "ActsExamples/Digitization/DigitizationConfigurator.hpp" +#include "ActsExamples/Digitization/Smearers.hpp" +#include "ActsExamples/Io/Json/JsonDigitizationConfig.hpp" #include "ActsFatras/Digitization/DigitizationError.hpp" #include "ActsFatras/Digitization/UncorrelatedHitSmearer.hpp" #include "ActsFatras/EventData/Barcode.hpp" @@ -37,6 +41,8 @@ #include #include +#include + namespace { namespace bd = boost::unit_test::data; @@ -69,8 +75,9 @@ struct InvalidSmearer { } }; +template struct Fixture { - RandomGenerator rng; + generator_t rng; // identifiers Acts::GeometryIdentifier gid; ActsFatras::Barcode pid; @@ -83,13 +90,12 @@ struct Fixture { // hit information ActsFatras::Hit hit; - Fixture(uint64_t rngSeed) + Fixture(uint64_t rngSeed, std::shared_ptr surf) : rng(rngSeed), gid(Acts::GeometryIdentifier().setVolume(1).setLayer(2).setSensitive( 3)), pid(ActsFatras::Barcode().setVertexPrimary(12).setParticle(23)), - surface(Acts::Surface::makeShared( - Acts::Transform3(Acts::Translation3(3, 2, 1)))) { + surface(std::move(surf)) { using namespace Acts::UnitLiterals; using Acts::VectorHelpers::makeVector4; @@ -99,6 +105,7 @@ struct Fixture { auto [par, cov] = Acts::detail::Test::generateBoundParametersCovariance(rng); boundParams = par; + freeParams = Acts::transformBoundToFreeParameters(*surface, geoCtx, boundParams); @@ -135,7 +142,9 @@ constexpr auto tol = 128 * std::numeric_limits::epsilon(); BOOST_AUTO_TEST_SUITE(FatrasUncorrelatedHitSmearer) BOOST_DATA_TEST_CASE(Bound1, bd::make(boundIndices), index) { - Fixture f(123); + Fixture f( + 123, Acts::Surface::makeShared( + Acts::Transform3(Acts::Translation3(3, 2, 1)))); ActsFatras::BoundParametersSmearer s; s.indices = {index}; @@ -165,7 +174,9 @@ BOOST_DATA_TEST_CASE(Bound1, bd::make(boundIndices), index) { } BOOST_AUTO_TEST_CASE(BoundAll) { - Fixture f(12356); + Fixture f( + 12356, Acts::Surface::makeShared( + Acts::Transform3(Acts::Translation3(3, 2, 1)))); // without q/p ActsFatras::BoundParametersSmearer s; @@ -209,7 +220,9 @@ BOOST_AUTO_TEST_CASE(BoundAll) { } BOOST_DATA_TEST_CASE(Free1, bd::make(freeIndices), index) { - Fixture f(1234); + Fixture f( + 1234, Acts::Surface::makeShared( + Acts::Transform3(Acts::Translation3(3, 2, 1)))); ActsFatras::FreeParametersSmearer s; s.indices = {index}; @@ -239,7 +252,9 @@ BOOST_DATA_TEST_CASE(Free1, bd::make(freeIndices), index) { } BOOST_AUTO_TEST_CASE(FreeAll) { - Fixture f(123567); + Fixture f( + 123567, Acts::Surface::makeShared( + Acts::Transform3(Acts::Translation3(3, 2, 1)))); // without q/p ActsFatras::FreeParametersSmearer s; std::copy(std::begin(freeIndices), std::end(freeIndices), s.indices.begin()); @@ -280,4 +295,62 @@ BOOST_AUTO_TEST_CASE(FreeAll) { } } +BOOST_AUTO_TEST_CASE(GaussianSmearing) { + nlohmann::json djson = nlohmann::json::parse(R"( + { + "acts-geometry-hierarchy-map" : { + "format-version" : 0, + "value-identifier" : "digitization-configuration" + }, + + "entries" + : [ + { + "volume" : 1, + "value" : { + "smearing" : [ + {"index" : 0, "mean" : 0.0, "stddev" : 0.05, "type" : "Gauss", "forcePositiveValues" : true} + + + ] + } + } + ] +})"); + double radius = 5.; + double halfZ = 8.; + Fixture f( + 123567, + Acts::Surface::makeShared( + Acts::Transform3(Acts::Translation3(0., 0., 0.)), radius, halfZ)); + + // Get the smearing configuration from the json object + auto digiConfig = + ActsExamples::DigiConfigConverter("digitization-configuration") + .fromJson(djson); + ActsFatras::BoundParametersSmearer s; + + for (auto& el : digiConfig) { + for (auto& smearing : el.smearingDigiConfig) { + std::fill(std::begin(s.indices), std::end(s.indices), + static_cast(smearing.index)); + std::fill(std::begin(s.smearFunctions), std::end(s.smearFunctions), + smearing.smearFunction); + std::fill(std::begin(s.forcePositive), std::end(s.forcePositive), + smearing.forcePositiveValues); + } + } + + auto ret = s(f.rng, f.hit, *f.surface, f.geoCtx); + + BOOST_CHECK(ret.ok()); + auto [par, cov] = ret.value(); + for (std::size_t i = 0; i < s.indices.size(); i++) { + BOOST_TEST_INFO("Comparing smeared measurement " + << i << " originating from bound parameter " + << s.indices[i]); + CHECK_CLOSE_REL(par[i], f.boundParams[s.indices[i]], 0.15); + } +} + BOOST_AUTO_TEST_SUITE_END() From eb8677409dd91d7455ef606c24649d57c5ce7008 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 22 May 2024 23:10:49 +0200 Subject: [PATCH 10/19] refactor: Move boundary check implementations to `VerticesHelper` (#3205) `computeClosestPointOnPolygon` and `computeEuclideanClosestPointOnRectangle` are generic functions which do not need to be coupled to `BoundaryCheck`. In this PR I move them to `VerticesHelper` and rewire `BoundaryCheck`. Pulled out of https://github.com/acts-project/acts/pull/3170 --- Core/include/Acts/Surfaces/BoundaryCheck.hpp | 130 ++---------------- .../Acts/Surfaces/detail/VerticesHelper.hpp | 124 +++++++++++++++++ 2 files changed, 132 insertions(+), 122 deletions(-) diff --git a/Core/include/Acts/Surfaces/BoundaryCheck.hpp b/Core/include/Acts/Surfaces/BoundaryCheck.hpp index ee93700fbbd..be686b65d3a 100644 --- a/Core/include/Acts/Surfaces/BoundaryCheck.hpp +++ b/Core/include/Acts/Surfaces/BoundaryCheck.hpp @@ -7,6 +7,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #pragma once + #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/detail/VerticesHelper.hpp" @@ -138,11 +139,6 @@ class BoundaryCheck { Vector2 computeClosestPointOnPolygon(const Vector2& point, const Vector2Container& vertices) const; - /// Calculate the closest point on the box - Vector2 computeEuclideanClosestPointOnRectangle( - const Vector2& point, const Vector2& lowerLeft, - const Vector2& upperRight) const; - /// metric weight matrix: identity for absolute mode or inverse covariance SquareMatrix2 m_weight; @@ -246,7 +242,8 @@ inline bool Acts::BoundaryCheck::isInside(const Vector2& point, if (m_type == Type::eNone || m_type == Type::eAbsolute) { // absolute, can calculate directly closestPoint = - computeEuclideanClosestPointOnRectangle(point, lowerLeft, upperRight); + detail::VerticesHelper::computeEuclideanClosestPointOnRectangle( + point, lowerLeft, upperRight); } else /* Type::eChi2 */ { // need to calculate by projection and squarednorm @@ -275,8 +272,9 @@ inline double Acts::BoundaryCheck::distance(const Acts::Vector2& point, const Vector2& upperRight) const { if (m_type == Type::eNone || m_type == Type::eAbsolute) { // compute closest point on box - double d = (point - computeEuclideanClosestPointOnRectangle( - point, lowerLeft, upperRight)) + double d = (point - + detail::VerticesHelper::computeEuclideanClosestPointOnRectangle( + point, lowerLeft, upperRight)) .norm(); return detail::VerticesHelper::isInsideRectangle(point, lowerLeft, upperRight) @@ -311,118 +309,6 @@ inline double Acts::BoundaryCheck::squaredNorm(const Vector2& x) const { template inline Acts::Vector2 Acts::BoundaryCheck::computeClosestPointOnPolygon( const Acts::Vector2& point, const Vector2Container& vertices) const { - // calculate the closest position on the segment between `ll0` and `ll1` to - // the point as measured by the metric induced by the weight matrix - auto closestOnSegment = [&](auto&& ll0, auto&& ll1) { - // normal vector and position of the closest point along the normal - auto n = ll1 - ll0; - auto weighted_n = m_weight * n; - auto f = n.dot(weighted_n); - auto u = std::isnormal(f) - ? (point - ll0).dot(weighted_n) / f - : 0.5; // ll0 and ll1 are so close it doesn't matter - // u must be in [0, 1] to still be on the polygon segment - return ll0 + std::clamp(u, 0.0, 1.0) * n; - }; - - auto iv = std::begin(vertices); - Vector2 l0 = *iv; - Vector2 l1 = *(++iv); - Vector2 closest = closestOnSegment(l0, l1); - auto closestDist = squaredNorm(closest - point); - // Calculate the closest point on other connecting lines and compare distances - for (++iv; iv != std::end(vertices); ++iv) { - l0 = l1; - l1 = *iv; - Vector2 current = closestOnSegment(l0, l1); - auto currentDist = squaredNorm(current - point); - if (currentDist < closestDist) { - closest = current; - closestDist = currentDist; - } - } - // final edge from last vertex back to the first vertex - Vector2 last = closestOnSegment(l1, *std::begin(vertices)); - if (squaredNorm(last - point) < closestDist) { - closest = last; - } - return closest; -} - -inline Acts::Vector2 -Acts::BoundaryCheck::computeEuclideanClosestPointOnRectangle( - const Vector2& point, const Vector2& lowerLeft, - const Vector2& upperRight) const { - /* - * - * | | - * IV | V | I - * | | - * ------------------------------ - * | | - * | | - * VIII | INSIDE | VI - * | | - * | | - * ------------------------------ - * | | - * III | VII | II - * | | - * - */ - - double l0 = point[0], l1 = point[1]; - double loc0Min = lowerLeft[0], loc0Max = upperRight[0]; - double loc1Min = lowerLeft[1], loc1Max = upperRight[1]; - - // check if inside - if (loc0Min <= l0 && l0 < loc0Max && loc1Min <= l1 && l1 < loc1Max) { - // INSIDE - double dist = std::abs(loc0Max - l0); - Vector2 cls(loc0Max, l1); - - double test = std::abs(loc0Min - l0); - if (test <= dist) { - dist = test; - cls = {loc0Min, l1}; - } - - test = std::abs(loc1Max - l1); - if (test <= dist) { - dist = test; - cls = {l0, loc1Max}; - } - - test = std::abs(loc1Min - l1); - if (test <= dist) { - return {l0, loc1Min}; - } - return cls; - } else { - // OUTSIDE, check sectors - if (l0 > loc0Max) { - if (l1 > loc1Max) { // I - return {loc0Max, loc1Max}; - } else if (l1 <= loc1Min) { // II - return {loc0Max, loc1Min}; - } else { // VI - return {loc0Max, l1}; - } - } else if (l0 < loc0Min) { - if (l1 > loc1Max) { // IV - return {loc0Min, loc1Max}; - } else if (l1 <= loc1Min) { // III - return {loc0Min, loc1Min}; - } else { // VIII - return {loc0Min, l1}; - } - } else { - if (l1 > loc1Max) { // V - return {l0, loc1Max}; - } else { // l1 <= loc1Min # VII - return {l0, loc1Min}; - } - // third case not necessary, see INSIDE above - } - } + return detail::VerticesHelper::computeClosestPointOnPolygon(point, vertices, + m_weight); } diff --git a/Core/include/Acts/Surfaces/detail/VerticesHelper.hpp b/Core/include/Acts/Surfaces/detail/VerticesHelper.hpp index d9b06aaadd4..80d16c8c017 100644 --- a/Core/include/Acts/Surfaces/detail/VerticesHelper.hpp +++ b/Core/include/Acts/Surfaces/detail/VerticesHelper.hpp @@ -168,4 +168,128 @@ bool isInsideRectangle(const vertex_t& point, const vertex_t& lowerLeft, bool onHyperPlane(const std::vector& vertices, ActsScalar tolerance = s_onSurfaceTolerance); +/// Calculate the closest point on the polygon. +template +inline Vector2 computeClosestPointOnPolygon(const Vector2& point, + const Vector2Container& vertices, + const SquareMatrix2& metric) { + auto squaredNorm = [&](const Vector2& x) { + return (x.transpose() * metric * x).value(); + }; + + // calculate the closest position on the segment between `ll0` and `ll1` to + // the point as measured by the metric induced by the metric matrix + auto closestOnSegment = [&](auto&& ll0, auto&& ll1) { + // normal vector and position of the closest point along the normal + auto n = ll1 - ll0; + auto n_transformed = metric * n; + auto f = n.dot(n_transformed); + auto u = std::isnormal(f) + ? (point - ll0).dot(n_transformed) / f + : 0.5; // ll0 and ll1 are so close it doesn't matter + // u must be in [0, 1] to still be on the polygon segment + return ll0 + std::clamp(u, 0.0, 1.0) * n; + }; + + auto iv = std::begin(vertices); + Vector2 l0 = *iv; + Vector2 l1 = *(++iv); + Vector2 closest = closestOnSegment(l0, l1); + auto closestDist = squaredNorm(closest - point); + // Calculate the closest point on other connecting lines and compare distances + for (++iv; iv != std::end(vertices); ++iv) { + l0 = l1; + l1 = *iv; + Vector2 current = closestOnSegment(l0, l1); + auto currentDist = squaredNorm(current - point); + if (currentDist < closestDist) { + closest = current; + closestDist = currentDist; + } + } + // final edge from last vertex back to the first vertex + Vector2 last = closestOnSegment(l1, *std::begin(vertices)); + if (squaredNorm(last - point) < closestDist) { + closest = last; + } + return closest; +} + +/// Calculate the closest point on the box +inline Vector2 computeEuclideanClosestPointOnRectangle( + const Vector2& point, const Vector2& lowerLeft, const Vector2& upperRight) { + /* + * + * | | + * IV | V | I + * | | + * ------------------------------ + * | | + * | | + * VIII | INSIDE | VI + * | | + * | | + * ------------------------------ + * | | + * III | VII | II + * | | + * + */ + + double l0 = point[0], l1 = point[1]; + double loc0Min = lowerLeft[0], loc0Max = upperRight[0]; + double loc1Min = lowerLeft[1], loc1Max = upperRight[1]; + + // check if inside + if (loc0Min <= l0 && l0 < loc0Max && loc1Min <= l1 && l1 < loc1Max) { + // INSIDE + double dist = std::abs(loc0Max - l0); + Vector2 cls(loc0Max, l1); + + double test = std::abs(loc0Min - l0); + if (test <= dist) { + dist = test; + cls = {loc0Min, l1}; + } + + test = std::abs(loc1Max - l1); + if (test <= dist) { + dist = test; + cls = {l0, loc1Max}; + } + + test = std::abs(loc1Min - l1); + if (test <= dist) { + return {l0, loc1Min}; + } + return cls; + } else { + // OUTSIDE, check sectors + if (l0 > loc0Max) { + if (l1 > loc1Max) { // I + return {loc0Max, loc1Max}; + } else if (l1 <= loc1Min) { // II + return {loc0Max, loc1Min}; + } else { // VI + return {loc0Max, l1}; + } + } else if (l0 < loc0Min) { + if (l1 > loc1Max) { // IV + return {loc0Min, loc1Max}; + } else if (l1 <= loc1Min) { // III + return {loc0Min, loc1Min}; + } else { // VIII + return {loc0Min, l1}; + } + } else { + if (l1 > loc1Max) { // V + return {l0, loc1Max}; + } else { // l1 <= loc1Min # VII + return {l0, loc1Min}; + } + // third case not necessary, see INSIDE above + } + } +} + } // namespace Acts::detail::VerticesHelper From 72e2720a913e95df4ec21ef386804b86c30b129a Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 23 May 2024 03:01:54 +0200 Subject: [PATCH 11/19] refactor: Early exit for `AnnulusBounds::inside` (#3206) Move code to the left and by leveraging early return statements. Have a clear unconditional return statement at the end of the function. Pulled out of https://github.com/acts-project/acts/pull/3170 --- Core/src/Surfaces/AnnulusBounds.cpp | 288 ++++++++++++++-------------- 1 file changed, 142 insertions(+), 146 deletions(-) diff --git a/Core/src/Surfaces/AnnulusBounds.cpp b/Core/src/Surfaces/AnnulusBounds.cpp index 811a3d77a53..7ee26c92d94 100644 --- a/Core/src/Surfaces/AnnulusBounds.cpp +++ b/Core/src/Surfaces/AnnulusBounds.cpp @@ -178,158 +178,154 @@ bool Acts::AnnulusBounds::inside(const Vector2& lposition, if (bcheck.type() == BoundaryCheck::Type::eAbsolute) { return inside(lposition, bcheck.tolerance()[eBoundLoc0], bcheck.tolerance()[eBoundLoc1]); - } else { - // first check if inside. We don't need to look into the covariance if - // inside - if (inside(lposition, 0., 0.)) { - return true; - } + } - // we need to rotate the locpo - Vector2 locpo_rotated = m_rotationStripPC * lposition; - - // covariance is given in STRIP SYSTEM in PC - // we need to convert the covariance to the MODULE SYSTEM in PC - // via jacobian. - // The following transforms into STRIP XY, does the shift into MODULE XY, - // and then transforms into MODULE PC - double dphi = get(eAveragePhi); - double phi_strip = locpo_rotated[eBoundLoc1]; - double r_strip = locpo_rotated[eBoundLoc0]; - double O_x = m_shiftXY[eBoundLoc0]; - double O_y = m_shiftXY[eBoundLoc1]; - - // For a transformation from cartesian into polar coordinates - // - // [ _________ ] - // [ / 2 2 ] - // [ \/ x + y ] - // [ r' ] [ ] - // v = [ ] = [ / y \] - // [phi'] [2*atan|----------------|] - // [ | _________|] - // [ | / 2 2 |] - // [ \x + \/ x + y /] - // - // Where x, y are polar coordinates that can be rotated by dPhi - // - // [x] [O_x + r*cos(dPhi - phi)] - // [ ] = [ ] - // [y] [O_y - r*sin(dPhi - phi)] - // - // The general jacobian is: - // - // [d d ] - // [--(f_x) --(f_x)] - // [dx dy ] - // Jgen = [ ] - // [d d ] - // [--(f_y) --(f_y)] - // [dx dy ] - // - // which means in this case: - // - // [ d d ] - // [ ----------(rMod) ---------(rMod) ] - // [ dr_{strip} dphiStrip ] - // J = [ ] - // [ d d ] - // [----------(phiMod) ---------(phiMod)] - // [dr_{strip} dphiStrip ] - // - // Performing the derivative one gets: - // - // [B*O_x + C*O_y + rStrip rStrip*(B*O_y + O_x*sin(dPhi - phiStrip))] - // [---------------------- -----------------------------------------] - // [ ___ ___ ] - // [ \/ A \/ A ] - // J = [ ] - // [ -(B*O_y - C*O_x) rStrip*(B*O_x + C*O_y + rStrip) ] - // [ ----------------- ------------------------------- ] - // [ A A ] - // - // where - // 2 2 2 - // A = O_x + 2*O_x*rStrip*cos(dPhi - phiStrip) + O_y - - // 2*O_y*rStrip*sin(dPhi - phiStrip) + rStrip B = cos(dPhi - phiStrip) C = - // -sin(dPhi - phiStrip) - - double cosDPhiPhiStrip = std::cos(dphi - phi_strip); - double sinDPhiPhiStrip = std::sin(dphi - phi_strip); - - double A = O_x * O_x + 2 * O_x * r_strip * cosDPhiPhiStrip + O_y * O_y - - 2 * O_y * r_strip * sinDPhiPhiStrip + r_strip * r_strip; - double sqrtA = std::sqrt(A); - - double B = cosDPhiPhiStrip; - double C = -sinDPhiPhiStrip; - ActsMatrix<2, 2> jacobianStripPCToModulePC; - jacobianStripPCToModulePC(0, 0) = (B * O_x + C * O_y + r_strip) / sqrtA; - jacobianStripPCToModulePC(0, 1) = - r_strip * (B * O_y + O_x * sinDPhiPhiStrip) / sqrtA; - jacobianStripPCToModulePC(1, 0) = -(B * O_y - C * O_x) / A; - jacobianStripPCToModulePC(1, 1) = - r_strip * (B * O_x + C * O_y + r_strip) / A; - - // covariance is given in STRIP PC - auto covStripPC = bcheck.covariance(); - // calculate covariance in MODULE PC using jacobian from above - auto covModulePC = jacobianStripPCToModulePC * covStripPC * - jacobianStripPCToModulePC.transpose(); - - // Mahalanobis distance uses inverse covariance as weights - auto weightStripPC = covStripPC.inverse(); - auto weightModulePC = covModulePC.inverse(); - - double minDist = std::numeric_limits::max(); - - Vector2 currentClosest; - double currentDist = 0; - - // do projection in STRIP PC - - // first: STRIP system. locpo is in STRIP PC already - currentClosest = closestOnSegment(m_inLeftStripPC, m_outLeftStripPC, - locpo_rotated, weightStripPC); - currentDist = squaredNorm(locpo_rotated - currentClosest, weightStripPC); - minDist = currentDist; + // first check if inside. We don't need to look into the covariance if inside + if (inside(lposition, 0., 0.)) { + return true; + } - currentClosest = closestOnSegment(m_inRightStripPC, m_outRightStripPC, - locpo_rotated, weightStripPC); - currentDist = squaredNorm(locpo_rotated - currentClosest, weightStripPC); - if (currentDist < minDist) { - minDist = currentDist; - } + // we need to rotate the locpo + Vector2 locpo_rotated = m_rotationStripPC * lposition; - // now: MODULE system. Need to transform locpo to MODULE PC - // transform is STRIP PC -> STRIP XY -> MODULE XY -> MODULE PC - Vector2 locpoStripXY( - locpo_rotated[eBoundLoc0] * std::cos(locpo_rotated[eBoundLoc1]), - locpo_rotated[eBoundLoc0] * std::sin(locpo_rotated[eBoundLoc1])); - Vector2 locpoModulePC = stripXYToModulePC(locpoStripXY); - - // now check edges in MODULE PC (inner and outer circle) - // assuming Mahalanobis distances are of same unit if covariance - // is correctly transformed - currentClosest = closestOnSegment(m_inLeftModulePC, m_inRightModulePC, - locpoModulePC, weightModulePC); - currentDist = squaredNorm(locpoModulePC - currentClosest, weightModulePC); - if (currentDist < minDist) { - minDist = currentDist; - } + // covariance is given in STRIP SYSTEM in PC we need to convert the covariance + // to the MODULE SYSTEM in PC via jacobian. The following transforms into + // STRIP XY, does the shift into MODULE XY, and then transforms into MODULE PC + double dphi = get(eAveragePhi); + double phi_strip = locpo_rotated[eBoundLoc1]; + double r_strip = locpo_rotated[eBoundLoc0]; + double O_x = m_shiftXY[eBoundLoc0]; + double O_y = m_shiftXY[eBoundLoc1]; + + // For a transformation from cartesian into polar coordinates + // + // [ _________ ] + // [ / 2 2 ] + // [ \/ x + y ] + // [ r' ] [ ] + // v = [ ] = [ / y \] + // [phi'] [2*atan|----------------|] + // [ | _________|] + // [ | / 2 2 |] + // [ \x + \/ x + y /] + // + // Where x, y are polar coordinates that can be rotated by dPhi + // + // [x] [O_x + r*cos(dPhi - phi)] + // [ ] = [ ] + // [y] [O_y - r*sin(dPhi - phi)] + // + // The general jacobian is: + // + // [d d ] + // [--(f_x) --(f_x)] + // [dx dy ] + // Jgen = [ ] + // [d d ] + // [--(f_y) --(f_y)] + // [dx dy ] + // + // which means in this case: + // + // [ d d ] + // [ ----------(rMod) ---------(rMod) ] + // [ dr_{strip} dphiStrip ] + // J = [ ] + // [ d d ] + // [----------(phiMod) ---------(phiMod)] + // [dr_{strip} dphiStrip ] + // + // Performing the derivative one gets: + // + // [B*O_x + C*O_y + rStrip rStrip*(B*O_y + O_x*sin(dPhi - phiStrip))] + // [---------------------- -----------------------------------------] + // [ ___ ___ ] + // [ \/ A \/ A ] + // J = [ ] + // [ -(B*O_y - C*O_x) rStrip*(B*O_x + C*O_y + rStrip) ] + // [ ----------------- ------------------------------- ] + // [ A A ] + // + // where + // 2 2 + // A = O_x + 2*O_x*rStrip*cos(dPhi - phiStrip) + O_y + // 2 + // - 2*O_y*rStrip*sin(dPhi - phiStrip) + rStrip + // B = cos(dPhi - phiStrip) + // C = -sin(dPhi - phiStrip) + + double cosDPhiPhiStrip = std::cos(dphi - phi_strip); + double sinDPhiPhiStrip = std::sin(dphi - phi_strip); + + double A = O_x * O_x + 2 * O_x * r_strip * cosDPhiPhiStrip + O_y * O_y - + 2 * O_y * r_strip * sinDPhiPhiStrip + r_strip * r_strip; + double sqrtA = std::sqrt(A); + + double B = cosDPhiPhiStrip; + double C = -sinDPhiPhiStrip; + ActsMatrix<2, 2> jacobianStripPCToModulePC; + jacobianStripPCToModulePC(0, 0) = (B * O_x + C * O_y + r_strip) / sqrtA; + jacobianStripPCToModulePC(0, 1) = + r_strip * (B * O_y + O_x * sinDPhiPhiStrip) / sqrtA; + jacobianStripPCToModulePC(1, 0) = -(B * O_y - C * O_x) / A; + jacobianStripPCToModulePC(1, 1) = r_strip * (B * O_x + C * O_y + r_strip) / A; + + // covariance is given in STRIP PC + auto covStripPC = bcheck.covariance(); + // calculate covariance in MODULE PC using jacobian from above + auto covModulePC = jacobianStripPCToModulePC * covStripPC * + jacobianStripPCToModulePC.transpose(); + + // Mahalanobis distance uses inverse covariance as weights + auto weightStripPC = covStripPC.inverse(); + auto weightModulePC = covModulePC.inverse(); + + double minDist = std::numeric_limits::max(); + + Vector2 currentClosest; + double currentDist = 0; + + // do projection in STRIP PC + + // first: STRIP system. locpo is in STRIP PC already + currentClosest = closestOnSegment(m_inLeftStripPC, m_outLeftStripPC, + locpo_rotated, weightStripPC); + currentDist = squaredNorm(locpo_rotated - currentClosest, weightStripPC); + minDist = currentDist; + + currentClosest = closestOnSegment(m_inRightStripPC, m_outRightStripPC, + locpo_rotated, weightStripPC); + currentDist = squaredNorm(locpo_rotated - currentClosest, weightStripPC); + if (currentDist < minDist) { + minDist = currentDist; + } - currentClosest = closestOnSegment(m_outLeftModulePC, m_outRightModulePC, - locpoModulePC, weightModulePC); - currentDist = squaredNorm(locpoModulePC - currentClosest, weightModulePC); - if (currentDist < minDist) { - minDist = currentDist; - } + // now: MODULE system. Need to transform locpo to MODULE PC + // transform is STRIP PC -> STRIP XY -> MODULE XY -> MODULE PC + Vector2 locpoStripXY( + locpo_rotated[eBoundLoc0] * std::cos(locpo_rotated[eBoundLoc1]), + locpo_rotated[eBoundLoc0] * std::sin(locpo_rotated[eBoundLoc1])); + Vector2 locpoModulePC = stripXYToModulePC(locpoStripXY); + + // now check edges in MODULE PC (inner and outer circle) assuming Mahalanobis + // distances are of same unit if covariance is correctly transformed + currentClosest = closestOnSegment(m_inLeftModulePC, m_inRightModulePC, + locpoModulePC, weightModulePC); + currentDist = squaredNorm(locpoModulePC - currentClosest, weightModulePC); + if (currentDist < minDist) { + minDist = currentDist; + } - // compare resulting Mahalanobis distance to configured - // "number of sigmas" - // we square it b/c we never took the square root of the distance - return minDist < bcheck.tolerance()[0] * bcheck.tolerance()[0]; + currentClosest = closestOnSegment(m_outLeftModulePC, m_outRightModulePC, + locpoModulePC, weightModulePC); + currentDist = squaredNorm(locpoModulePC - currentClosest, weightModulePC); + if (currentDist < minDist) { + minDist = currentDist; } + + // compare resulting Mahalanobis distance to configured "number of sigmas" we + // square it b/c we never took the square root of the distance + return minDist < bcheck.tolerance()[0] * bcheck.tolerance()[0]; } Acts::Vector2 Acts::AnnulusBounds::stripXYToModulePC( From ccf3dc8f61db7dd21f0e0f10ccae157991d2b09f Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Thu, 23 May 2024 05:05:45 +0200 Subject: [PATCH 12/19] feat: enable simulation from GeoModel (#3202) This PR adds the necessary infrastructure and Python bindings to run simulation (and `material_recording`) from `GeoModel`. The Plugin is activated with the CMake configuration `ACTS_BUILD_PLUGIN_GEOMODEL=ON` It mimics exactly how this is done for DD4hep in terms of Detector construction, etc. It *does not* contain the translation to Gen1/Gen2 reconstruction geometry. The plot attached shows the material recording output starting from ATLAS' `ITK_Sqlite.db`. It has been produced with ```sh python /Examples/Scripts/Python/material_recording.py --input ITK_Sqlite.db ``` ITkG4_ACTS @noemina - this is the first piece for the summer student project to start from. --- Examples/Algorithms/Geant4/CMakeLists.txt | 10 +++ .../GeoModelDetectorConstruction.hpp | 63 +++++++++++++++++++ .../src/GeoModelDetectorConstruction.cpp | 61 ++++++++++++++++++ Examples/Python/CMakeLists.txt | 18 ++++++ .../python/acts/examples/geant4/geomodel.py | 6 ++ .../Python/src/Geant4GeoModelComponent.cpp | 37 +++++++++++ Examples/Python/src/GeoModel.cpp | 33 ++++++++++ Examples/Python/src/GeoModelStub.cpp | 12 ++++ Examples/Python/src/ModuleEntry.cpp | 4 +- Examples/Scripts/Python/material_recording.py | 20 ++++-- Plugins/CMakeLists.txt | 1 + Plugins/GeoModel/CMakeLists.txt | 21 +++++++ .../Acts/Plugins/GeoModel/GeoModelReader.hpp | 24 +++++++ .../Acts/Plugins/GeoModel/GeoModelTree.hpp | 22 +++++++ Plugins/GeoModel/src/GeoModelReader.cpp | 26 ++++++++ thirdparty/GeoModel/CMakeLists.txt | 2 + 16 files changed, 354 insertions(+), 6 deletions(-) create mode 100644 Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp create mode 100644 Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp create mode 100644 Examples/Python/python/acts/examples/geant4/geomodel.py create mode 100644 Examples/Python/src/Geant4GeoModelComponent.cpp create mode 100644 Examples/Python/src/GeoModel.cpp create mode 100644 Examples/Python/src/GeoModelStub.cpp create mode 100644 Plugins/GeoModel/CMakeLists.txt create mode 100644 Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelReader.hpp create mode 100644 Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelTree.hpp create mode 100644 Plugins/GeoModel/src/GeoModelReader.cpp diff --git a/Examples/Algorithms/Geant4/CMakeLists.txt b/Examples/Algorithms/Geant4/CMakeLists.txt index dc11b46f76a..41b23ce1a63 100644 --- a/Examples/Algorithms/Geant4/CMakeLists.txt +++ b/Examples/Algorithms/Geant4/CMakeLists.txt @@ -18,6 +18,10 @@ if (ACTS_BUILD_EXAMPLES_DD4HEP) list(APPEND ACTS_EXAMPLES_G4SOURCES src/DDG4DetectorConstruction.cpp) endif() +if (ACTS_BUILD_PLUGIN_GEOMODEL) + list(APPEND ACTS_EXAMPLES_G4SOURCES src/GeoModelDetectorConstruction.cpp) +endif() + add_library( ActsExamplesGeant4 SHARED ${ACTS_EXAMPLES_G4SOURCES}) target_compile_definitions( @@ -48,6 +52,12 @@ if (ACTS_BUILD_EXAMPLES_DD4HEP) endif() endif() +if (ACTS_BUILD_PLUGIN_GEOMODEL) + target_link_libraries( + ActsExamplesGeant4 + PUBLIC ActsPluginGeoModel GeoModel2G4) +endif() + install( TARGETS ActsExamplesGeant4 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp new file mode 100644 index 00000000000..36e23411f07 --- /dev/null +++ b/Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp @@ -0,0 +1,63 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 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 "ActsExamples/Geant4/DetectorConstructionFactory.hpp" +#include "ActsExamples/Geant4/RegionCreator.hpp" +#include + +#include + +#include + +class G4VPhysicalVolume; + +namespace ActsExamples { + +/// Construct the Geant4 detector from a GeoModel world volume +class GeoModelDetectorConstruction final : public G4VUserDetectorConstruction { + public: + /// @param geoModelTree is the GeoModel tree containing the world volume + /// @param regionCreators are the region creators + GeoModelDetectorConstruction( + const Acts::GeoModelTree& geoModelTree, + std::vector> regionCreators = {}); + + /// Read the file and parse it to construct the Geant4 description + /// + /// @note to simplify further setup withiin the ACTS framework + /// the world is cached when first constructed + G4VPhysicalVolume* Construct() override; + + private: + /// The GeoModel tree + Acts::GeoModelTree m_geoModelTree; + /// Region creators + std::vector> m_regionCreators; + /// The world volume + G4VPhysicalVolume* m_g4World = nullptr; +}; + +class GeoModelDetectorConstructionFactory final + : public DetectorConstructionFactory { + public: + GeoModelDetectorConstructionFactory( + const Acts::GeoModelTree& geoModelTree, + std::vector> regionCreators = {}); + + std::unique_ptr factorize() const override; + + private: + /// The GeoModel tree + Acts::GeoModelTree m_geoModelTree; + /// Region creators + std::vector> m_regionCreators; +}; + +} // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp new file mode 100644 index 00000000000..0447d6acf19 --- /dev/null +++ b/Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp @@ -0,0 +1,61 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 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/. + +#include "ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp" + +#include + +#include +#include +#include +#include +#include +#include + +using namespace ActsExamples; + +GeoModelDetectorConstruction::GeoModelDetectorConstruction( + const Acts::GeoModelTree& geoModelTree, + std::vector> regionCreators) + : G4VUserDetectorConstruction(), + m_geoModelTree(geoModelTree), + m_regionCreators(std::move(regionCreators)) { + if (geoModelTree.worldVolume == nullptr) { + throw std::invalid_argument( + "GeoModelDetectorConstruction: " + "GeoModel world volume is nullptr"); + } +} + +G4VPhysicalVolume* GeoModelDetectorConstruction::Construct() { + if (m_g4World == nullptr) { + ExtParameterisedVolumeBuilder builder(m_geoModelTree.worldVolumeName); + G4LogicalVolume* g4WorldLog = builder.Build(m_geoModelTree.worldVolume); + m_g4World = + new G4PVPlacement(nullptr, G4ThreeVector(), g4WorldLog, + m_geoModelTree.worldVolumeName, nullptr, false, 0); + + // Create regions + for (const auto& regionCreator : m_regionCreators) { + regionCreator->Construct(); + } + } + return m_g4World; +} + +GeoModelDetectorConstructionFactory::GeoModelDetectorConstructionFactory( + const Acts::GeoModelTree& geoModelTree, + std::vector> regionCreators) + : m_geoModelTree(geoModelTree), + m_regionCreators(std::move(regionCreators)) {} + +std::unique_ptr +GeoModelDetectorConstructionFactory::factorize() const { + return std::make_unique(m_geoModelTree, + m_regionCreators); +} diff --git a/Examples/Python/CMakeLists.txt b/Examples/Python/CMakeLists.txt index d376ab0c5a7..9c7708bd9cf 100644 --- a/Examples/Python/CMakeLists.txt +++ b/Examples/Python/CMakeLists.txt @@ -77,6 +77,13 @@ else() target_sources(ActsPythonBindings PRIVATE src/JsonStub.cpp) endif() +if(ACTS_BUILD_PLUGIN_GEOMODEL) + target_link_libraries(ActsPythonBindings PUBLIC ActsPluginGeoModel) + target_sources(ActsPythonBindings PRIVATE src/GeoModel.cpp) +else() + target_sources(ActsPythonBindings PRIVATE src/GeoModelStub.cpp) +endif() + if(ACTS_BUILD_PLUGIN_ACTSVG) target_link_libraries(ActsPythonBindings PUBLIC ActsExamplesIoSvg) target_sources(ActsPythonBindings PRIVATE src/Svg.cpp) @@ -130,6 +137,17 @@ if(ACTS_BUILD_EXAMPLES_GEANT4) list(APPEND py_files examples/geant4/dd4hep.py) endif() + if(ACTS_BUILD_PLUGIN_GEOMODEL) + pybind11_add_module(ActsPythonBindingsGeoModelG4 src/Geant4GeoModelComponent.cpp) + target_link_libraries(ActsPythonBindingsGeoModelG4 PUBLIC + ActsPythonUtilities + ActsExamplesGeant4) + add_dependencies(ActsPythonBindings ActsPythonBindingsGeoModelG4) + install(TARGETS ActsPythonBindingsGeoModelG4 DESTINATION ${_python_install_dir}) + + list(APPEND py_files examples/geant4/geomodel.py) + endif() + if(ACTS_BUILD_EXAMPLES_HEPMC3) target_link_libraries(ActsPythonBindingsGeant4 PUBLIC ActsExamplesEventRecording) target_sources(ActsPythonBindingsGeant4 PRIVATE src/Geant4HepMC3.cpp) diff --git a/Examples/Python/python/acts/examples/geant4/geomodel.py b/Examples/Python/python/acts/examples/geant4/geomodel.py new file mode 100644 index 00000000000..bbc5882eaf3 --- /dev/null +++ b/Examples/Python/python/acts/examples/geant4/geomodel.py @@ -0,0 +1,6 @@ +from acts._adapter import _patch_config +from acts import ActsPythonBindingsGeoModelG4 + +_patch_config(ActsPythonBindingsGeoModelG4) + +from acts.ActsPythonBindingsGeoModelG4 import * diff --git a/Examples/Python/src/Geant4GeoModelComponent.cpp b/Examples/Python/src/Geant4GeoModelComponent.cpp new file mode 100644 index 00000000000..d4e3576b00b --- /dev/null +++ b/Examples/Python/src/Geant4GeoModelComponent.cpp @@ -0,0 +1,37 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 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/. + +#include "Acts/Utilities/TypeTraits.hpp" +#include "ActsExamples/Framework/ProcessCode.hpp" +#include "ActsExamples/Geant4/DetectorConstructionFactory.hpp" +#include "ActsExamples/Geant4/RegionCreator.hpp" +#include "ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp" + +#include +#include +#include + +class GeoVPhysVol; + +namespace py = pybind11; + +using namespace ActsExamples; +using namespace Acts; + +PYBIND11_MODULE(ActsPythonBindingsGeoModelG4, m) { + py::module_::import("acts.ActsPythonBindingsGeant4"); + + py::class_>( + m, "GeoModelDetectorConstructionFactory") + .def(py::init>>(), + py::arg("geoModelTree"), + py::arg("regionCreators") = + std::vector>()); +} diff --git a/Examples/Python/src/GeoModel.cpp b/Examples/Python/src/GeoModel.cpp new file mode 100644 index 00000000000..896f9dd3aed --- /dev/null +++ b/Examples/Python/src/GeoModel.cpp @@ -0,0 +1,33 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 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/. + +#include "Acts/Plugins/GeoModel/GeoModelReader.hpp" +#include "Acts/Plugins/GeoModel/GeoModelTree.hpp" +#include "Acts/Plugins/Python/Utilities.hpp" + +#include + +#include +#include +#include +#include + +namespace py = pybind11; +using namespace pybind11::literals; + +namespace Acts::Python { +void addGeoModel(Context& ctx) { + auto m = ctx.get("main"); + + auto gm = m.def_submodule("geomodel"); + + py::class_(gm, "GeoModelTree").def(py::init<>()); + + gm.def("readFromDb", &Acts::GeoModelReader::readFromDb); +} +} // namespace Acts::Python diff --git a/Examples/Python/src/GeoModelStub.cpp b/Examples/Python/src/GeoModelStub.cpp new file mode 100644 index 00000000000..8ec521b9619 --- /dev/null +++ b/Examples/Python/src/GeoModelStub.cpp @@ -0,0 +1,12 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 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/. + +namespace Acts::Python { +struct Context; +void addGeoModel(Context& /*ctx*/) {} +} // namespace Acts::Python diff --git a/Examples/Python/src/ModuleEntry.cpp b/Examples/Python/src/ModuleEntry.cpp index 68aa575ad77..cc6442fe285 100644 --- a/Examples/Python/src/ModuleEntry.cpp +++ b/Examples/Python/src/ModuleEntry.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-2024 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 @@ -69,6 +69,7 @@ void addAmbiguityResolution(Context& ctx); // Plugins void addDigitization(Context& ctx); void addPythia8(Context& ctx); +void addGeoModel(Context& ctx); void addJson(Context& ctx); void addHepMC3(Context& ctx); void addExaTrkXTrackFinding(Context& ctx); @@ -130,6 +131,7 @@ PYBIND11_MODULE(ActsPythonBindings, m) { addDigitization(ctx); addPythia8(ctx); addJson(ctx); + addGeoModel(ctx); addHepMC3(ctx); addExaTrkXTrackFinding(ctx); addObj(ctx); diff --git a/Examples/Scripts/Python/material_recording.py b/Examples/Scripts/Python/material_recording.py index ddceefc753c..f52bb8b2ab2 100755 --- a/Examples/Scripts/Python/material_recording.py +++ b/Examples/Scripts/Python/material_recording.py @@ -12,6 +12,7 @@ EventGenerator, RandomNumbers, ) + import acts.examples.dd4hep import acts.examples.geant4 import acts.examples.geant4.dd4hep @@ -96,21 +97,30 @@ def main(): "-t", "--tracks", type=int, default=100, help="Particle tracks per event" ) p.add_argument( - "-i", "--input", type=str, default="", help="GDML input file (optional)" + "-i", "--input", type=str, default="", help="input (GDML/SQL) file (optional)" ) args = p.parse_args() detectorConstructionFactory = None - if args.input != "": + if args.input == "": + detector, trackingGeometry, decorators = getOpenDataDetector() + + detectorConstructionFactory = ( + acts.examples.geant4.dd4hep.DDG4DetectorConstructionFactory(detector) + ) + elif args.input.endswith(".gdml"): detectorConstructionFactory = ( acts.examples.geant4.GdmlDetectorConstructionFactory(args.input) ) - else: - detector, trackingGeometry, decorators = getOpenDataDetector() + elif args.input.endswith(".sqlite") or args.input.endswith(".db"): + import acts.examples.geant4.geomodel + geoModelTree = acts.geomodel.readFromDb(args.input) detectorConstructionFactory = ( - acts.examples.geant4.dd4hep.DDG4DetectorConstructionFactory(detector) + acts.examples.geant4.geomodel.GeoModelDetectorConstructionFactory( + geoModelTree + ) ) runMaterialRecording( diff --git a/Plugins/CMakeLists.txt b/Plugins/CMakeLists.txt index 31d487a9a01..93fa92a23e8 100644 --- a/Plugins/CMakeLists.txt +++ b/Plugins/CMakeLists.txt @@ -5,6 +5,7 @@ add_component_if(ActSVG PluginActSVG ACTS_BUILD_PLUGIN_ACTSVG) add_component_if(Cuda PluginCuda ACTS_BUILD_PLUGIN_CUDA) add_component_if(FpeMonitoring PluginFpeMonitoring ACTS_BUILD_PLUGIN_FPEMON) add_component_if(Geant4 PluginGeant4 ACTS_BUILD_PLUGIN_GEANT4) +add_component_if(GeoModel PluginGeoModel ACTS_BUILD_PLUGIN_GEOMODEL) add_component_if(Json PluginJson ACTS_BUILD_PLUGIN_JSON) add_component_if(Legacy PluginLegacy ACTS_BUILD_PLUGIN_LEGACY) add_component_if(Onnx PluginOnnx ACTS_BUILD_PLUGIN_ONNX) diff --git a/Plugins/GeoModel/CMakeLists.txt b/Plugins/GeoModel/CMakeLists.txt new file mode 100644 index 00000000000..a7fc08498f7 --- /dev/null +++ b/Plugins/GeoModel/CMakeLists.txt @@ -0,0 +1,21 @@ +include(FetchContent) + +add_library( + ActsPluginGeoModel SHARED + src/GeoModelReader.cpp) +target_include_directories( + ActsPluginGeoModel + PUBLIC + $ + $) +target_link_libraries( + ActsPluginGeoModel + PUBLIC ActsCore GeoModelKernel GeoModelIO::GeoModelDBManager GeoModelIO::GeoModelRead) + +install( + TARGETS ActsPluginGeoModel + EXPORT ActsPluginGeoModelTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install( + DIRECTORY include/Acts + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelReader.hpp b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelReader.hpp new file mode 100644 index 00000000000..f5eacf4079d --- /dev/null +++ b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelReader.hpp @@ -0,0 +1,24 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 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/Plugins/GeoModel/GeoModelTree.hpp" + +#include + +namespace Acts::GeoModelReader { + +/// @brief Read the GeoModel from the database +/// +/// @param dbPath path to the database +/// +/// @return world/top volume of the GeoModel tree in memory +GeoModelTree readFromDb(const std::string& dbPath); + +} // namespace Acts::GeoModelReader diff --git a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelTree.hpp b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelTree.hpp new file mode 100644 index 00000000000..b3215e8c3be --- /dev/null +++ b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelTree.hpp @@ -0,0 +1,22 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 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 + +class GeoVPhysVol; + +namespace Acts { + +struct GeoModelTree { + std::shared_ptr geoReader = nullptr; + GeoVPhysVol* worldVolume = nullptr; + std::string worldVolumeName = "World"; +}; +} // namespace Acts diff --git a/Plugins/GeoModel/src/GeoModelReader.cpp b/Plugins/GeoModel/src/GeoModelReader.cpp new file mode 100644 index 00000000000..46bd8dba779 --- /dev/null +++ b/Plugins/GeoModel/src/GeoModelReader.cpp @@ -0,0 +1,26 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 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/. + +#include "Acts/Plugins/GeoModel/GeoModelReader.hpp" + +#include +#include +#include + +Acts::GeoModelTree Acts::GeoModelReader::readFromDb(const std::string& dbPath) { + // Data base manager + GMDBManager* db = new GMDBManager(dbPath); + if (!db->checkIsDBOpen()) { + throw std::runtime_error("GeoModelReader: Could not open the database"); + } + // Setup the GeoModel reader + auto geoReader = std::make_shared(db); + // Read the GeoModel + GeoModelTree geoModel{geoReader, geoReader->buildGeoModel()}; + return geoModel; +} diff --git a/thirdparty/GeoModel/CMakeLists.txt b/thirdparty/GeoModel/CMakeLists.txt index 1e243455a05..b841c8c5dea 100644 --- a/thirdparty/GeoModel/CMakeLists.txt +++ b/thirdparty/GeoModel/CMakeLists.txt @@ -17,6 +17,8 @@ set( GEOMODEL_VERSION "${_acts_geomodel_version}") set( GEOMODEL_SETUP_JSON OFF CACHE BOOL "Skip setting up json completely" ) +set ( GEOMODEL_BUILD_GEOMODELG4 "${ACTS_BUILD_PLUGIN_GEANT4}" CACHE BOOL "Build the Geant4 plugin" ) + # Declare where to get geomodel from. FetchContent_Declare( geomodel ${ACTS_GEOMODEL_SOURCE} ) From cb9af28fb24f9a1e18fd522f363de5c075bf568b Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Thu, 23 May 2024 07:01:52 +0200 Subject: [PATCH 13/19] test(gx2f): generalise unit test (#3209) 2 tiny changes to make the unit test more general. --- Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp index a896d7b96a2..fb1adb30c63 100644 --- a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp @@ -98,7 +98,7 @@ std::shared_ptr makeToyDetector( // Create configurations for surfaces std::vector surfaceConfig; - for (unsigned int surfPos = 1; surfPos <= nSurfaces; surfPos++) { + for (std::size_t surfPos = 1; surfPos <= nSurfaces; surfPos++) { // Position of the surfaces CuboidVolumeBuilder::SurfaceConfig cfg; cfg.position = {surfPos * UnitConstants::m, 0., 0.}; @@ -343,7 +343,7 @@ BOOST_AUTO_TEST_CASE(Fit5Iterations) { // Track quantities CHECK_CLOSE_ABS(track.chi2(), 8., 2.); - BOOST_CHECK_EQUAL(track.nDoF(), 10u); + BOOST_CHECK_EQUAL(track.nDoF(), nSurfaces * 2); BOOST_CHECK_EQUAL(track.nHoles(), 0u); BOOST_CHECK_EQUAL(track.nMeasurements(), nSurfaces); BOOST_CHECK_EQUAL(track.nSharedHits(), 0u); @@ -540,7 +540,7 @@ BOOST_AUTO_TEST_CASE(FitWithBfield) { // Track quantities CHECK_CLOSE_ABS(track.chi2(), 7.5, 1.5); - BOOST_CHECK_EQUAL(track.nDoF(), 10u); + BOOST_CHECK_EQUAL(track.nDoF(), nSurfaces * 2); BOOST_CHECK_EQUAL(track.nHoles(), 0u); BOOST_CHECK_EQUAL(track.nMeasurements(), nSurfaces); BOOST_CHECK_EQUAL(track.nSharedHits(), 0u); @@ -636,7 +636,7 @@ BOOST_AUTO_TEST_CASE(relChi2changeCutOff) { // Track quantities CHECK_CLOSE_ABS(track.chi2(), 8., 2.); - BOOST_CHECK_EQUAL(track.nDoF(), 10u); + BOOST_CHECK_EQUAL(track.nDoF(), nSurfaces * 2); BOOST_CHECK_EQUAL(track.nHoles(), 0u); BOOST_CHECK_EQUAL(track.nMeasurements(), nSurfaces); BOOST_CHECK_EQUAL(track.nSharedHits(), 0u); From 8a8e54a57397d97425b6bb047d982dc58f2ea645 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 23 May 2024 10:57:47 +0200 Subject: [PATCH 14/19] refactor: Early exit for `CylinderBounds::inside` (#3207) Move code to the left and by leveraging early return statements. Have a clear unconditional return statement at the end of the function. Pulled out of https://github.com/acts-project/acts/pull/3170 --- Core/src/Surfaces/CylinderBounds.cpp | 76 ++++++++++++++-------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/Core/src/Surfaces/CylinderBounds.cpp b/Core/src/Surfaces/CylinderBounds.cpp index 64d13bb688a..b66ecec9065 100644 --- a/Core/src/Surfaces/CylinderBounds.cpp +++ b/Core/src/Surfaces/CylinderBounds.cpp @@ -48,47 +48,49 @@ bool Acts::CylinderBounds::inside(const Vector2& lposition, double halfLengthZ = get(eHalfLengthZ); double halfPhi = get(eHalfPhiSector); - if (bevelMinZ != 0. && bevelMaxZ != 0.) { - double radius = get(eR); - // Beleved sides will unwrap to a trapezoid - /////////////////////////////////// - // ________ - // /| . . |\ r/phi - // \|______|/ r/phi - // -Z 0 Z - /////////////////////////////////// - float localx = - lposition[0] > radius ? 2 * radius - lposition[0] : lposition[0]; - Vector2 shiftedlposition = shifted(lposition); - if ((std::fabs(shiftedlposition[0]) <= halfPhi && - std::fabs(shiftedlposition[1]) <= halfLengthZ)) { - return true; - } else if ((lposition[1] >= - -(localx * std::tan(bevelMinZ) + halfLengthZ)) && - (lposition[1] <= (localx * std::tan(bevelMaxZ) + halfLengthZ))) { - return true; - } else { - // check within tolerance - auto boundaryCheck = bcheck.transformed(jacobian()); - - Vector2 lowerLeft = {-radius, -halfLengthZ}; - Vector2 middleLeft = {0., -(halfLengthZ + radius * std::tan(bevelMinZ))}; - Vector2 upperLeft = {radius, -halfLengthZ}; - Vector2 upperRight = {radius, halfLengthZ}; - Vector2 middleRight = {0., (halfLengthZ + radius * std::tan(bevelMaxZ))}; - Vector2 lowerRight = {-radius, halfLengthZ}; - Vector2 vertices[] = {lowerLeft, middleLeft, upperLeft, - upperRight, middleRight, lowerRight}; - Vector2 closestPoint = - boundaryCheck.computeClosestPointOnPolygon(lposition, vertices); - - return boundaryCheck.isTolerated(closestPoint - lposition); - } - } else { + + if (bevelMinZ == 0. || bevelMaxZ == 0.) { return bcheck.transformed(jacobian()) .isInside(shifted(lposition), Vector2(-halfPhi, -halfLengthZ), Vector2(halfPhi, halfLengthZ)); } + + double radius = get(eR); + // Beleved sides will unwrap to a trapezoid + /////////////////////////////////// + // ________ + // /| . . |\ r/phi + // \|______|/ r/phi + // -Z 0 Z + /////////////////////////////////// + float localx = + lposition[0] > radius ? 2 * radius - lposition[0] : lposition[0]; + Vector2 shiftedlposition = shifted(lposition); + if ((std::fabs(shiftedlposition[0]) <= halfPhi && + std::fabs(shiftedlposition[1]) <= halfLengthZ)) { + return true; + } + + if ((lposition[1] >= -(localx * std::tan(bevelMinZ) + halfLengthZ)) && + (lposition[1] <= (localx * std::tan(bevelMaxZ) + halfLengthZ))) { + return true; + } + + // check within tolerance + auto boundaryCheck = bcheck.transformed(jacobian()); + + Vector2 lowerLeft = {-radius, -halfLengthZ}; + Vector2 middleLeft = {0., -(halfLengthZ + radius * std::tan(bevelMinZ))}; + Vector2 upperLeft = {radius, -halfLengthZ}; + Vector2 upperRight = {radius, halfLengthZ}; + Vector2 middleRight = {0., (halfLengthZ + radius * std::tan(bevelMaxZ))}; + Vector2 lowerRight = {-radius, halfLengthZ}; + Vector2 vertices[] = {lowerLeft, middleLeft, upperLeft, + upperRight, middleRight, lowerRight}; + Vector2 closestPoint = + boundaryCheck.computeClosestPointOnPolygon(lposition, vertices); + + return boundaryCheck.isTolerated(closestPoint - lposition); } bool Acts::CylinderBounds::inside3D(const Vector3& position, From 36811859790b86bf7729bff2241d52ada0e32e27 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Thu, 23 May 2024 15:31:38 +0200 Subject: [PATCH 15/19] feat: adding some more options to the odd_full_chain (#3179) This PR adds a few more options to the `full_chain` script, in order to steer it a bit better: ```sh options: -h, --help show this help message and exit --output OUTPUT, -o OUTPUT Output directory --events EVENTS, -n EVENTS Number of events --skip SKIP, -s SKIP Number of events --edm4hep EDM4HEP Use edm4hep inputs --geant4 Use Geant4 instead of fatras --ttbar Use Pythia8 (ttbar, pile-up 200) instead of particle gun --ttbar-pu TTBAR_PU Number of pile-up events for ttbar --gun-particles GUN_PARTICLES Multiplicity (no. of particles) of the particle gun --gun-multiplicity GUN_MULTIPLICITY Multiplicity (no. of vertices) of the particle gun --gun-eta-range GUN_ETA_RANGE [GUN_ETA_RANGE ...] Eta range of the particle gun --gun-pt-range GUN_PT_RANGE [GUN_PT_RANGE ...] Pt range of the particle gun (GeV) --digi-config DIGI_CONFIG Digitization configuration file --material-config MATERIAL_CONFIG Material map configuration file --ambi-solver {greedy,scoring,ML} Set which ambiguity solver to use, default is the classical one --ambi-config AMBI_CONFIG Set the configuration file for the Score Based ambiguity resolution --MLSeedFilter Use the Ml seed filter to select seed after the seeding step --reco, --no-reco Switch reco on/off --output-root, --no-output-root Switch root output on/off --output-csv, --no-output-csv Switch csv output on/off ``` Particularly interesting are the configurations for the particle gun (multiplicity, momentum, eta range) and steering of the output. With these modification I dropped the `sim_digi_odd` file again. --- Examples/Scripts/Python/full_chain_odd.py | 293 +++++++++++++--------- Examples/Scripts/Python/sim_digi_odd.py | 245 ------------------ 2 files changed, 176 insertions(+), 362 deletions(-) delete mode 100644 Examples/Scripts/Python/sim_digi_odd.py diff --git a/Examples/Scripts/Python/full_chain_odd.py b/Examples/Scripts/Python/full_chain_odd.py index d4910e1cfc0..c864c116721 100755 --- a/Examples/Scripts/Python/full_chain_odd.py +++ b/Examples/Scripts/Python/full_chain_odd.py @@ -66,12 +66,38 @@ type=int, default=200, ) +parser.add_argument( + "--gun-particles", + help="Multiplicity (no. of particles) of the particle gun", + type=int, + default=4, +) parser.add_argument( "--gun-multiplicity", - help="Multiplicity of the particle gun", + help="Multiplicity (no. of vertices) of the particle gun", type=int, default=200, ) +parser.add_argument( + "--gun-eta-range", + nargs=2, + help="Eta range of the particle gun", + type=float, + default=[-3.0, 3.0], +) +parser.add_argument( + "--gun-pt-range", + nargs=2, + help="Pt range of the particle gun (GeV)", + type=float, + default=[1.0 * u.GeV, 10.0 * u.GeV], +) +parser.add_argument( + "--digi-config", help="Digitization configuration file", type=pathlib.Path +) +parser.add_argument( + "--material-config", help="Material map configuration file", type=pathlib.Path +) parser.add_argument( "--ambi-solver", help="Set which ambiguity solver to use, default is the classical one", @@ -91,21 +117,47 @@ help="Use the Ml seed filter to select seed after the seeding step", action="store_true", ) +parser.add_argument( + "--reco", + help="Switch reco on/off", + default=True, + action=argparse.BooleanOptionalAction, +) +parser.add_argument( + "--output-root", + help="Switch root output on/off", + default=True, + action=argparse.BooleanOptionalAction, +) +parser.add_argument( + "--output-csv", + help="Switch csv output on/off", + default=True, + action=argparse.BooleanOptionalAction, +) -args = vars(parser.parse_args()) +args = parser.parse_args() -outputDir = args["output"] -ttbar = args["ttbar"] -g4_simulation = args["geant4"] -ambi_ML = args["ambi_solver"] == "ML" -ambi_scoring = args["ambi_solver"] == "scoring" -ambi_config = args["ambi_config"] -seedFilter_ML = args["MLSeedFilter"] +outputDir = args.output +ambi_ML = args.ambi_solver == "ML" +ambi_scoring = args.ambi_solver == "scoring" +ambi_config = args.ambi_config +seedFilter_ML = args.MLSeedFilter geoDir = getOpenDataDetectorDirectory() # acts.examples.dump_args_calls(locals()) # show python binding calls -oddMaterialMap = geoDir / "data/odd-material-maps.root" -oddDigiConfig = geoDir / "config/odd-digi-smearing-config.json" +oddMaterialMap = ( + args.material_config + if args.material_config + else geoDir / "data/odd-material-maps.root" +) + +oddDigiConfig = ( + args.digi_config + if args.digi_config + else geoDir / "config/odd-digi-smearing-config.json" +) + oddSeedingSel = geoDir / "config/odd-seeding-config.json" oddMaterialDeco = acts.IMaterialDecorator.fromFile(oddMaterialMap) @@ -116,17 +168,17 @@ rnd = acts.examples.RandomNumbers(seed=42) s = acts.examples.Sequencer( - events=args["events"], - skip=args["skip"], - numThreads=1 if g4_simulation else -1, + events=args.events, + skip=args.skip, + numThreads=1 if args.geant4 else -1, outputDir=str(outputDir), ) -if args["edm4hep"]: +if args.edm4hep: import acts.examples.edm4hep edm4hepReader = acts.examples.edm4hep.EDM4hepReader( - inputPath=str(args["edm4hep"]), + inputPath=str(args.edm4hep), inputSimHits=[ "PixelBarrelReadout", "PixelEndcapReadout", @@ -161,27 +213,33 @@ outputParticles="particles_selected", ) else: - if not ttbar: + if not args.ttbar: addParticleGun( s, - MomentumConfig(1.0 * u.GeV, 10.0 * u.GeV, transverse=True), - EtaConfig(-3.0, 3.0), + MomentumConfig( + args.gun_pt_range[0] * u.GeV, + args.gun_pt_range[1] * u.GeV, + transverse=True, + ), + EtaConfig(args.gun_eta_range[0], args.gun_eta_range[1]), PhiConfig(0.0, 360.0 * u.degree), - ParticleConfig(4, acts.PdgParticle.eMuon, randomizeCharge=True), + ParticleConfig( + args.gun_particles, acts.PdgParticle.eMuon, randomizeCharge=True + ), vtxGen=acts.examples.GaussianVertexGenerator( mean=acts.Vector4(0, 0, 0, 0), stddev=acts.Vector4( 0.0125 * u.mm, 0.0125 * u.mm, 55.5 * u.mm, 1.0 * u.ns ), ), - multiplicity=args["gun_multiplicity"], + multiplicity=args.gun_multiplicity, rnd=rnd, ) else: addPythia8( s, hardProcess=["Top:qqbar2ttbar=on"], - npileup=args["ttbar_pu"], + npileup=args.ttbar_pu, vtxGen=acts.examples.GaussianVertexGenerator( mean=acts.Vector4(0, 0, 0, 0), stddev=acts.Vector4( @@ -189,11 +247,11 @@ ), ), rnd=rnd, - outputDirRoot=outputDir, - # outputDirCsv=outputDir, + outputDirRoot=outputDir if args.output_root else None, + outputDirCsv=outputDir if args.output_csv else None, ) - if g4_simulation: + if args.geant4: if s.config.numThreads != 1: raise ValueError("Geant 4 simulation does not support multi-threading") @@ -212,8 +270,8 @@ pt=(150 * u.MeV, None), removeNeutral=True, ), - outputDirRoot=outputDir, - # outputDirCsv=outputDir, + outputDirRoot=outputDir if args.output_root else None, + outputDirCsv=outputDir if args.output_csv else None, rnd=rnd, killVolume=trackingGeometry.worldVolume, killAfterTime=25 * u.ns, @@ -231,12 +289,12 @@ pt=(150 * u.MeV, None), removeNeutral=True, ) - if ttbar + if args.ttbar else ParticleSelectorConfig() ), enableInteractions=True, - outputDirRoot=outputDir, - # outputDirCsv=outputDir, + outputDirRoot=outputDir if args.output_root else None, + outputDirCsv=outputDir if args.output_csv else None, rnd=rnd, ) @@ -245,107 +303,108 @@ trackingGeometry, field, digiConfigFile=oddDigiConfig, - outputDirRoot=outputDir, - # outputDirCsv=outputDir, + outputDirRoot=outputDir if args.output_root else None, + outputDirCsv=outputDir if args.output_csv else None, rnd=rnd, ) -addSeeding( - s, - trackingGeometry, - field, - ( - TruthSeedRanges(pt=(1.0 * u.GeV, None), eta=(-3.0, 3.0), nHits=(9, None)) - if ttbar - else TruthSeedRanges() - ), - geoSelectionConfigFile=oddSeedingSel, - outputDirRoot=outputDir, - # outputDirCsv=outputDir, -) - -if seedFilter_ML: - addSeedFilterML( +if args.reco: + addSeeding( s, - SeedFilterMLDBScanConfig( - epsilonDBScan=0.03, minPointsDBScan=2, minSeedScore=0.1 + trackingGeometry, + field, + ( + TruthSeedRanges(pt=(1.0 * u.GeV, None), eta=(-3.0, 3.0), nHits=(9, None)) + if args.ttbar + else TruthSeedRanges() ), - onnxModelFile=os.path.dirname(__file__) - + "/MLAmbiguityResolution/seedDuplicateClassifier.onnx", - outputDirRoot=outputDir, - # outputDirCsv=outputDir, + geoSelectionConfigFile=oddSeedingSel, + outputDirRoot=outputDir if args.output_root else None, + outputDirCsv=outputDir if args.output_csv else None, ) -addCKFTracks( - s, - trackingGeometry, - field, - TrackSelectorConfig( - pt=(1.0 * u.GeV if ttbar else 0.0, None), - absEta=(None, 3.0), - loc0=(-4.0 * u.mm, 4.0 * u.mm), - nMeasurementsMin=7, - maxHoles=2, - maxOutliers=2, - ), - CkfConfig( - seedDeduplication=True, - stayOnSeed=True, - ), - outputDirRoot=outputDir, - writeCovMat=True, - # outputDirCsv=outputDir, -) + if seedFilter_ML: + addSeedFilterML( + s, + SeedFilterMLDBScanConfig( + epsilonDBScan=0.03, minPointsDBScan=2, minSeedScore=0.1 + ), + onnxModelFile=os.path.dirname(__file__) + + "/MLAmbiguityResolution/seedDuplicateClassifier.onnx", + outputDirRoot=outputDir if args.output_root else None, + outputDirCsv=outputDir if args.output_csv else None, + ) -if ambi_ML: - addAmbiguityResolutionML( + addCKFTracks( s, - AmbiguityResolutionMLConfig( - maximumSharedHits=3, maximumIterations=1000000, nMeasurementsMin=7 + trackingGeometry, + field, + TrackSelectorConfig( + pt=(1.0 * u.GeV if args.ttbar else 0.0, None), + absEta=(None, 3.0), + loc0=(-4.0 * u.mm, 4.0 * u.mm), + nMeasurementsMin=7, + maxHoles=2, + maxOutliers=2, ), - outputDirRoot=outputDir, - # outputDirCsv=outputDir, - onnxModelFile=os.path.dirname(__file__) - + "/MLAmbiguityResolution/duplicateClassifier.onnx", - ) - -elif ambi_scoring: - addScoreBasedAmbiguityResolution( - s, - ScoreBasedAmbiguityResolutionConfig( - minScore=0, - minScoreSharedTracks=1, - maxShared=2, - maxSharedTracksPerMeasurement=2, - pTMax=1400, - pTMin=0.5, - phiMax=3.14, - phiMin=-3.14, - etaMax=4, - etaMin=-4, - useAmbiguityFunction=False, + CkfConfig( + seedDeduplication=True, + stayOnSeed=True, ), - outputDirRoot=outputDir, - ambiVolumeFile=ambi_config, + outputDirRoot=outputDir if args.output_root else None, + outputDirCsv=outputDir if args.output_csv else None, writeCovMat=True, - # outputDirCsv=outputDir, ) -else: - addAmbiguityResolution( + + if ambi_ML: + addAmbiguityResolutionML( + s, + AmbiguityResolutionMLConfig( + maximumSharedHits=3, maximumIterations=1000000, nMeasurementsMin=7 + ), + outputDirRoot=outputDir if args.output_root else None, + outputDirCsv=outputDir if args.output_csv else None, + onnxModelFile=os.path.dirname(__file__) + + "/MLAmbiguityResolution/duplicateClassifier.onnx", + ) + + elif ambi_scoring: + addScoreBasedAmbiguityResolution( + s, + ScoreBasedAmbiguityResolutionConfig( + minScore=0, + minScoreSharedTracks=1, + maxShared=2, + maxSharedTracksPerMeasurement=2, + pTMax=1400, + pTMin=0.5, + phiMax=3.14, + phiMin=-3.14, + etaMax=4, + etaMin=-4, + useAmbiguityFunction=False, + ), + outputDirRoot=outputDir if args.output_root else None, + outputDirCsv=outputDir if args.output_csv else None, + ambiVolumeFile=ambi_config, + writeCovMat=True, + ) + else: + addAmbiguityResolution( + s, + AmbiguityResolutionConfig( + maximumSharedHits=3, maximumIterations=1000000, nMeasurementsMin=7 + ), + outputDirRoot=outputDir if args.output_root else None, + outputDirCsv=outputDir if args.output_csv else None, + writeCovMat=True, + ) + + addVertexFitting( s, - AmbiguityResolutionConfig( - maximumSharedHits=3, maximumIterations=1000000, nMeasurementsMin=7 - ), - outputDirRoot=outputDir, - writeCovMat=True, - # outputDirCsv=outputDir, + field, + vertexFinder=VertexFinder.Iterative, + outputDirRoot=outputDir if args.output_root else None, ) -addVertexFitting( - s, - field, - vertexFinder=VertexFinder.Iterative, - outputDirRoot=outputDir, -) - s.run() diff --git a/Examples/Scripts/Python/sim_digi_odd.py b/Examples/Scripts/Python/sim_digi_odd.py deleted file mode 100644 index 3309cf222c8..00000000000 --- a/Examples/Scripts/Python/sim_digi_odd.py +++ /dev/null @@ -1,245 +0,0 @@ -#!/usr/bin/env python3 - -import os -import argparse -import pathlib - -import acts -import acts.examples -from acts.examples.simulation import ( - addParticleGun, - MomentumConfig, - EtaConfig, - PhiConfig, - ParticleConfig, - addPythia8, - addFatras, - addGeant4, - ParticleSelectorConfig, - addDigitization, - addParticleSelection, -) - -from acts.examples.dd4hep import ( - DD4hepDetector, - DD4hepDetectorOptions, - DD4hepGeometryService, -) - -from acts.examples.odd import getOpenDataDetector, getOpenDataDetectorDirectory - -u = acts.UnitConstants - -parser = argparse.ArgumentParser(description="Sim-digi chain with the OpenDataDetector") -parser.add_argument( - "--output", - "-o", - help="Output directory", - type=pathlib.Path, - default=pathlib.Path.cwd() / "odd_output", -) -parser.add_argument("--events", "-n", help="Number of events", type=int, default=100) -parser.add_argument("--skip", "-s", help="Number of events", type=int, default=0) -parser.add_argument( - "--geant4", help="Use Geant4 instead of fatras", action="store_true" -) -parser.add_argument( - "--ttbar", - help="Use Pythia8 (ttbar, pile-up 200) instead of particle gun", - action="store_true", -) -parser.add_argument( - "--ttbar-pu", - help="Number of pile-up events for ttbar", - type=int, - default=200, -) -parser.add_argument( - "--gun-particles", - help="Particle multiplicity of the particle gun", - type=int, - default=200, -) -parser.add_argument( - "--gun-vertices", - help="Vertex mulitplicity for the particle gun", - type=int, - default=1, -) -parser.add_argument( - "--gun-eta-range", - nargs="+", - help="Eta range of the particle gun", - type=float, - default=[-3.0, 3.0], -) -parser.add_argument( - "--gun-pt-range", - nargs="+", - help="Pt range of the particle gun (GeV)", - type=float, - default=[0.1 * u.GeV, 100 * u.GeV], -) -parser.add_argument( - "--rnd-seed", - help="Random seed", - type=int, - default=42, -) -parser.add_argument( - "--digi-config", - help="Digitization configuration file", - type=str, - default="", -) - -parser.add_argument( - "--mat-map", - help="Material map file", - type=str, - default="", -) - -parser.add_argument( - "--experimental", - action=argparse.BooleanOptionalAction, - help="Construct experimental geometry", -) - -args = parser.parse_args() - -decorators = None -if args.mat_map != "": - decorators = acts.IMaterialDecorator.fromFile(args.map) - -if args.experimental: - odd_xml = getOpenDataDetectorDirectory() / "xml" / "OpenDataDetector.xml" - - # Create the dd4hep geometry service and detector - dd4hepConfig = DD4hepGeometryService.Config() - dd4hepConfig.logLevel = acts.logging.INFO - dd4hepConfig.xmlFileNames = [str(odd_xml)] - dd4hepGeometryService = DD4hepGeometryService(dd4hepConfig) - detector = DD4hepDetector(dd4hepGeometryService) - - cOptions = DD4hepDetectorOptions(logLevel=acts.logging.INFO, emulateToGraph="") - cOptions.materialDecorator = decorators - - # Context and options - geoContext = acts.GeometryContext() - [recoGeometry, contextors, store] = detector.finalize(geoContext, cOptions) - - -else: - [detector, recoGeometry, decorators] = getOpenDataDetector(decorators) - - -outputDir = args.output -oddDigiConfig = args.digi_config -# Field specifications -field = acts.ConstantBField(acts.Vector3(0.0, 0.0, 2.0 * u.T)) - -rnd = acts.examples.RandomNumbers(seed=args.rnd_seed) - -s = acts.examples.Sequencer( - events=args.events, - skip=args.skip, - numThreads=1 if args.geant4 else -1, - outputDir=str(outputDir), -) - - -if not args.ttbar: - addParticleGun( - s, - MomentumConfig( - args.gun_pt_range[0] * u.GeV, - args.gun_pt_range[1] * u.GeV, - transverse=True, - ), - EtaConfig(args.gun_eta_range[0], args.gun_eta_range[1]), - PhiConfig(0.0, 360.0 * u.degree), - ParticleConfig( - args.gun_particles, acts.PdgParticle.eMuon, randomizeCharge=True - ), - vtxGen=acts.examples.GaussianVertexGenerator( - mean=acts.Vector4(0, 0, 0, 0), - stddev=acts.Vector4(0.0125 * u.mm, 0.0125 * u.mm, 55.5 * u.mm, 1.0 * u.ns), - ), - multiplicity=args.gun_vertices, - rnd=rnd, - ) -else: - addPythia8( - s, - hardProcess=["Top:qqbar2ttbar=on"], - npileup=args.ttbar_pu, - vtxGen=acts.examples.GaussianVertexGenerator( - mean=acts.Vector4(0, 0, 0, 0), - stddev=acts.Vector4(0.0125 * u.mm, 0.0125 * u.mm, 55.5 * u.mm, 5.0 * u.ns), - ), - rnd=rnd, - outputDirRoot=outputDir, - # outputDirCsv=outputDir, - ) - -if args.geant4: - if s.config.numThreads != 1: - raise ValueError("Geant 4 simulation does not support multi-threading") - - # Pythia can sometime simulate particles outside the world volume, a cut on the Z of the track help mitigate this effect - # Older version of G4 might not work, this as has been tested on version `geant4-11-00-patch-03` - # For more detail see issue #1578 - addGeant4( - s, - detector, - recoGeometry, - field, - preSelectParticles=ParticleSelectorConfig( - rho=(0.0, 24 * u.mm), - absZ=(0.0, 1.0 * u.m), - eta=(-3.0, 3.0), - pt=(150 * u.MeV, None), - removeNeutral=True, - ), - outputDirRoot=outputDir, - outputDirCsv=outputDir, - rnd=rnd, - killVolume=recoGeometry.worldVolume - if isinstance(recoGeometry, acts.TrackingGeometry) - else None, - killAfterTime=25 * u.ns, - ) -elif isinstance(recoGeometry, acts.TrackingGeometry): - addFatras( - s, - recoGeometry, - field, - preSelectParticles=ParticleSelectorConfig( - rho=(0.0, 24 * u.mm), - absZ=(0.0, 1.0 * u.m), - eta=(-3.0, 3.0), - pt=(150 * u.MeV, None), - removeNeutral=True, - ) - if args.ttbar - else ParticleSelectorConfig(), - enableInteractions=True, - outputDirRoot=outputDir, - outputDirCsv=outputDir, - rnd=rnd, - ) -else: - raise ValueError("Fatras simulation with Experimental::Detector not yet supported") - -addDigitization( - s, - recoGeometry, - field, - digiConfigFile=oddDigiConfig, - outputDirRoot=outputDir, - outputDirCsv=outputDir, - rnd=rnd, -) - -s.run() From 8b063398fd0bb0ccbfac65b19ba63fdf72d40076 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Thu, 23 May 2024 16:28:16 +0200 Subject: [PATCH 16/19] fix: clang-format Regex (#3211) Copilot suddenly suggested me an include path with `ACTFW` which was our include path years ago for the framework components. That's how I found that. --- .clang-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 90d1b3cc15e..fe441f11a71 100644 --- a/.clang-format +++ b/.clang-format @@ -19,7 +19,7 @@ IncludeCategories: # Acts headers before system headers to ensure that they include what they use - Regex: '^(<|")Acts.*' Priority: 1 - - Regex: '^(<|")ACTFW/.*' + - Regex: '^(<|")ActsExamples/.*' Priority: 1 # standard library includes: '<...>' without any '/' or '.' in the path - Regex: '^<[^/.]*>' From 6e967630f495fe103de96423975e2420b2dd2f9c Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Thu, 23 May 2024 17:25:44 +0200 Subject: [PATCH 17/19] test(gx2f): make eBoundTime-check more readable (#3212) Since we are not fitting the time in the current tests, this value stays untouched. --- Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp index fb1adb30c63..7d81461993f 100644 --- a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp @@ -357,7 +357,8 @@ BOOST_AUTO_TEST_CASE(Fit5Iterations) { BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-5, 1e3); BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); BOOST_CHECK_EQUAL(track.parameters()[eBoundQOverP], 1); - BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], 12591.2832360000, 1e-6); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], + startParametersFit.parameters()[eBoundTime], 1e-6); BOOST_CHECK_CLOSE(track.covariance().determinant(), 1e-27, 4e0); // Convergence @@ -460,7 +461,8 @@ BOOST_AUTO_TEST_CASE(MixedDetector) { BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-5, 1e3); BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); BOOST_CHECK_EQUAL(track.parameters()[eBoundQOverP], 1); - BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], 12591.2832360000, 1e-6); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], + startParametersFit.parameters()[eBoundTime], 1e-6); BOOST_CHECK_CLOSE(track.covariance().determinant(), 2e-28, 1e0); // Convergence @@ -555,7 +557,8 @@ BOOST_AUTO_TEST_CASE(FitWithBfield) { BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-4, 1e3); BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); BOOST_CHECK_CLOSE(track.parameters()[eBoundQOverP], 0.5, 2e-1); - BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], 12591.2832360000, 1e-6); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], + startParametersFit.parameters()[eBoundTime], 1e-6); BOOST_CHECK_CLOSE(track.covariance().determinant(), 8e-35, 4e0); // Convergence @@ -650,7 +653,8 @@ BOOST_AUTO_TEST_CASE(relChi2changeCutOff) { BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-5, 1e3); BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); BOOST_CHECK_EQUAL(track.parameters()[eBoundQOverP], 1); - BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], 12591.2832360000, 1e-6); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], + startParametersFit.parameters()[eBoundTime], 1e-6); BOOST_CHECK_CLOSE(track.covariance().determinant(), 1e-27, 4e0); // Convergence @@ -908,7 +912,8 @@ BOOST_AUTO_TEST_CASE(FindHoles) { BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-5, 1e3); BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); BOOST_CHECK_EQUAL(track.parameters()[eBoundQOverP], 1); - BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], 12591.2832360000, 1e-6); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], + startParametersFit.parameters()[eBoundTime], 1e-6); BOOST_CHECK_CLOSE(track.covariance().determinant(), 4.7e-28, 2e0); ACTS_INFO("*** Test: FindHoles -- Finish"); From 6932aa9126ad2a9d3041d7cee4916fcb8c52a6ef Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Thu, 23 May 2024 18:33:36 +0200 Subject: [PATCH 18/19] test(gx2f): Add test bench for material effects (#3185) This PR creates a test case for material effects (multiple scattering). This should be fulfilled during a future update of the GX2F. ![image](https://github.com/acts-project/acts/assets/70842573/cfb276e3-ac12-4d03-b1ff-882927d146c5) --- .../UnitTests/Core/TrackFitting/Gx2fTests.cpp | 123 +++++++++++++++++- 1 file changed, 119 insertions(+), 4 deletions(-) diff --git a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp index 7d81461993f..ad6f43d7d52 100644 --- a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp @@ -79,7 +79,8 @@ static std::vector prepareSourceLinks( /// @param geoCtx /// @param nSurfaces Number of surfaces std::shared_ptr makeToyDetector( - const Acts::GeometryContext& geoCtx, const std::size_t nSurfaces = 5) { + const Acts::GeometryContext& geoCtx, const std::size_t nSurfaces = 5, + const std::set& surfaceIndexWithMaterial = {}) { if (nSurfaces < 1) { throw std::invalid_argument("At least 1 surfaces needs to be created."); } @@ -112,9 +113,12 @@ std::shared_ptr makeToyDetector( cfg.rBounds = std::make_shared( RectangleBounds(halfSizeSurface, halfSizeSurface)); - // Material of the surfaces - MaterialSlab matProp(makeBeryllium(), 0.5_mm); - cfg.surMat = std::make_shared(matProp); + // Add material only for selected surfaces + if (surfaceIndexWithMaterial.count(surfPos) != 0) { + // Material of the surfaces + MaterialSlab matProp(makeSilicon(), 5_mm); + cfg.surMat = std::make_shared(matProp); + } // Thickness of the detector element cfg.thickness = 1_um; @@ -918,5 +922,116 @@ BOOST_AUTO_TEST_CASE(FindHoles) { ACTS_INFO("*** Test: FindHoles -- Finish"); } + +BOOST_AUTO_TEST_CASE(Material) { + ACTS_INFO("*** Test: Material -- Start"); + + std::default_random_engine rng(42); + + ACTS_DEBUG("Create the detector"); + const std::size_t nSurfaces = 7; + const std::set surfaceIndexWithMaterial = {4}; + Detector detector; + detector.geometry = + makeToyDetector(geoCtx, nSurfaces, surfaceIndexWithMaterial); + + ACTS_DEBUG("Set the start parameters for measurement creation and fit"); + const auto parametersMeasurements = makeParameters(); + const auto startParametersFit = makeParameters( + 7_mm, 11_mm, 15_mm, 42_ns, 10_degree, 80_degree, 1_GeV, 1_e); + + ACTS_DEBUG("Create the measurements"); + using SimPropagator = + Acts::Propagator; + const SimPropagator simPropagator = makeStraightPropagator(detector.geometry); + auto measurements = + createMeasurements(simPropagator, geoCtx, magCtx, parametersMeasurements, + resMapAllPixel, rng); + + const Acts::ActsVector<2> scatterOffset = {100_mm, 100_mm}; + const std::size_t indexMaterialSurface = 3; + for (std::size_t iMeas = indexMaterialSurface; iMeas < nSurfaces; iMeas++) { + // This only works, because our detector is evenly spaced + const std::size_t offsetFactor = iMeas - indexMaterialSurface; + + auto& sl = measurements.sourceLinks[iMeas]; + sl.parameters[0] += scatterOffset[0] * offsetFactor; + sl.parameters[1] += scatterOffset[1] * offsetFactor; + } + + const auto sourceLinks = prepareSourceLinks(measurements.sourceLinks); + ACTS_VERBOSE("sourceLinks.size() = " << sourceLinks.size()); + + BOOST_REQUIRE_EQUAL(sourceLinks.size(), nSurfaces); + + ACTS_DEBUG("Set up the fitter"); + const Surface* rSurface = ¶metersMeasurements.referenceSurface(); + + using RecoStepper = EigenStepper<>; + const auto recoPropagator = + makeConstantFieldPropagator(detector.geometry, 0_T); + + using RecoPropagator = decltype(recoPropagator); + using Gx2Fitter = + Experimental::Gx2Fitter; + const Gx2Fitter fitter(recoPropagator, gx2fLogger->clone()); + + Experimental::Gx2FitterExtensions extensions; + extensions.calibrator + .connect<&testSourceLinkCalibrator>(); + TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; + extensions.surfaceAccessor + .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); + + const Experimental::Gx2FitterOptions gx2fOptions( + geoCtx, magCtx, calCtx, extensions, PropagatorPlainOptions(), rSurface, + false, false, FreeToBoundCorrection(false), 5, true, 0); + + Acts::TrackContainer tracks{Acts::VectorTrackContainer{}, + Acts::VectorMultiTrajectory{}}; + + ACTS_DEBUG("Fit the track"); + ACTS_VERBOSE("startParameter unsmeared:\n" << parametersMeasurements); + ACTS_VERBOSE("startParameter fit:\n" << startParametersFit); + const auto res = fitter.fit(sourceLinks.begin(), sourceLinks.end(), + startParametersFit, gx2fOptions, tracks); + + BOOST_REQUIRE(res.ok()); + + const auto& track = *res; + + BOOST_CHECK_EQUAL(track.tipIndex(), nSurfaces - 1); + BOOST_CHECK(track.hasReferenceSurface()); + + // TODO Add material handling to the gx2f, to pass the 6 commented tests + // Track quantities + // CHECK_CLOSE_ABS(track.chi2(), 8., 2.); + BOOST_CHECK_EQUAL(track.nDoF(), nSurfaces * 2); + BOOST_CHECK_EQUAL(track.nHoles(), 0u); + BOOST_CHECK_EQUAL(track.nMeasurements(), nSurfaces); + BOOST_CHECK_EQUAL(track.nSharedHits(), 0u); + BOOST_CHECK_EQUAL(track.nOutliers(), 0u); + + // Parameters + // We need quite coarse checks here, since on different builds + // the created measurements differ in the randomness + // BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc0], -11., 7e0); + // BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc1], -15., 6e0); + // BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-5, 1e3); + // BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); + BOOST_CHECK_EQUAL(track.parameters()[eBoundQOverP], 1); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], + startParametersFit.parameters()[eBoundTime], 1e-6); + // BOOST_CHECK_CLOSE(track.covariance().determinant(), 1e-27, 4e0); + + // Convergence + BOOST_CHECK_EQUAL( + (track.template component< + std::size_t, + hashString(Experimental::Gx2fConstants::gx2fnUpdateColumn)>()), + 5); + + ACTS_INFO("*** Test: Material -- Finish"); +} BOOST_AUTO_TEST_SUITE_END() } // namespace Acts::Test From 273278b69a99c787a6766bb6b7463bc2f91a62fa Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 23 May 2024 19:39:00 +0200 Subject: [PATCH 19/19] refactor: Use `double` for `CylinderBounds::inside` (#3210) Popped up here https://github.com/acts-project/acts/pull/3207#discussion_r1610599648 I think this can be safely changed to a `double` --- Core/src/Surfaces/CylinderBounds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/Surfaces/CylinderBounds.cpp b/Core/src/Surfaces/CylinderBounds.cpp index b66ecec9065..0ae07759441 100644 --- a/Core/src/Surfaces/CylinderBounds.cpp +++ b/Core/src/Surfaces/CylinderBounds.cpp @@ -63,7 +63,7 @@ bool Acts::CylinderBounds::inside(const Vector2& lposition, // \|______|/ r/phi // -Z 0 Z /////////////////////////////////// - float localx = + double localx = lposition[0] > radius ? 2 * radius - lposition[0] : lposition[0]; Vector2 shiftedlposition = shifted(lposition); if ((std::fabs(shiftedlposition[0]) <= halfPhi &&