diff --git a/.clang-format b/.clang-format index 90d1b3cc15ee..fe441f11a713 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: '^<[^/.]*>' diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 30616ac45b17..531985ef9ffb 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -515,48 +515,4 @@ jobs: run: cmake --build build-downstream - name: Downstream run run: ./build-downstream/bin/ShowActsVersion - - - sycl: - runs-on: ubuntu-latest - container: ghcr.io/acts-project/ubuntu2004_oneapi:v41 - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v4 - - - name: Restore ccache - uses: actions/cache/restore@v4 - id: ccache-restore - with: - path: ${{ github.workspace }}/ccache - key: ${{ runner.os }}-ccache-sycl_${{ env.CCACHE_KEY_SUFFIX }}_${{ github.sha }} - restore-keys: | - ${{ runner.os }}-ccache-sycl_${{ env.CCACHE_KEY_SUFFIX }}_ - - - name: Configure - run: > - source /opt/intel/oneapi/setvars.sh - && ccache -z - && cmake -B build -S . - -GNinja - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - -DCMAKE_CXX_COMPILER=/opt/intel/oneapi/compiler/2022.0.2/linux/bin-llvm/clang++ - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_CXX_FLAGS=-Werror - -DACTS_SETUP_VECMEM=ON - -DACTS_BUILD_PLUGIN_SYCL=ON - -DACTS_BUILD_UNITTESTS=ON - - name: Build - run: > - source /opt/intel/oneapi/setvars.sh - && cmake --build build - - name: ccache stats - run: ccache -s - - name: Save ccache - uses: actions/cache/save@v4 - if: always() - with: - path: ${{ github.workspace }}/ccache - key: ${{ steps.ccache-restore.outputs.cache-primary-key }} + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 25a7c4feb257..7947f033ee1e 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,9 +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_BUILD_PLUGIN_SYCL "Build SYCL plugin" OFF) +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) @@ -119,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 @@ -185,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) @@ -198,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) @@ -228,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() @@ -270,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) @@ -288,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) @@ -296,16 +350,11 @@ 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) endif() endif() - -if(ACTS_BUILD_PLUGIN_SYCL) - find_package(SYCL REQUIRED) -endif() if(ACTS_BUILD_PLUGIN_TGEO) find_package(ROOT ${_acts_root_version} REQUIRED CONFIG COMPONENTS Geom Graf) check_root_compatibility() @@ -357,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/Core/include/Acts/Detector/Detector.hpp b/Core/include/Acts/Detector/Detector.hpp index ada2ceefe33d..4f0a2a6ad23a 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 8fbd4c9acdc8..5f6cf73d6e8b 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 1079f3975e6f..abbb4fc87756 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 6160216c2d52..f985ea3975ef 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 98ee573ecd96..6ed605544ed1 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 742d733930f3..1668f0ce8577 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 598945d3e5d2..6d87d9f3a50f 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 63eb39ffca6c..52245ee4a664 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 793c5d8a9b16..aacb5c5dfc38 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/EventData/MultiTrajectory.hpp b/Core/include/Acts/EventData/MultiTrajectory.hpp index d25e1ec72e7a..b0410d522749 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 1940c0cc3446..93592b1afb8f 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 8bcb34d8c9c1..55757e3925dd 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 df70cdabcfa4..9ee0d0996b7f 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/Core/include/Acts/Geometry/TrackingGeometry.hpp b/Core/include/Acts/Geometry/TrackingGeometry.hpp index 974a288ca9f9..31c697fc156d 100644 --- a/Core/include/Acts/Geometry/TrackingGeometry.hpp +++ b/Core/include/Acts/Geometry/TrackingGeometry.hpp @@ -160,6 +160,10 @@ class TrackingGeometry { /// @retval pointer to the found surface otherwise. const Surface* findSurface(GeometryIdentifier id) const; + /// Access to the GeometryIdentifier - Surface association map + const std::unordered_map& + geoIdSurfaceMap() const; + private: // the known world TrackingVolumePtr m_world; diff --git a/Core/include/Acts/Navigation/DetectorVolumeFinders.hpp b/Core/include/Acts/Navigation/DetectorVolumeFinders.hpp index afd24ed0e112..11f2f3730b54 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 3c707fcc731e..288025e473c1 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 ea9a059d44cf..a18e8c438cc6 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 bcfe8fe4ad5f..b0d747de7c87 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 89eebdc4b68c..5b6f14128090 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 94da589eb119..b5d0fbdfbe7b 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/include/Acts/Propagator/Navigator.hpp b/Core/include/Acts/Propagator/Navigator.hpp index 27a4c9148b9d..7ff14b7555a7 100644 --- a/Core/include/Acts/Propagator/Navigator.hpp +++ b/Core/include/Acts/Propagator/Navigator.hpp @@ -163,10 +163,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 @@ -296,8 +298,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) @@ -305,8 +305,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."); @@ -324,12 +322,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 @@ -450,6 +450,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; @@ -478,10 +479,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( @@ -605,8 +607,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) @@ -843,7 +844,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 = @@ -1016,25 +1017,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; @@ -1049,16 +1046,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 @@ -1106,19 +1099,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 @@ -1143,17 +1131,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 diff --git a/Core/include/Acts/Seeding/HoughTransformUtils.ipp b/Core/include/Acts/Seeding/HoughTransformUtils.ipp index 9b54f251bc56..a8f2dea2341a 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( diff --git a/Core/include/Acts/Surfaces/BoundaryCheck.hpp b/Core/include/Acts/Surfaces/BoundaryCheck.hpp index ee93700fbbd0..be686b65d3ae 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 d9b06aaadd47..80d16c8c017f 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 diff --git a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp index 97992902f2b7..8eb8a8e4d58a 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 if (!result.activeTips.empty()) { + 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 @@ -711,7 +683,7 @@ class CombinatorialKalmanFilter { ACTS_VERBOSE("Stop Kalman filtering with " << result.lastMeasurementIndices.size() << " found tracks"); - result.filtered = true; + result.finished = true; } } diff --git a/Core/src/Detector/Detector.cpp b/Core/src/Detector/Detector.cpp index 96c136117e0b..61a5e6b155c9 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 c3111553cbb4..8d5d6d88d6ff 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 70407027927a..e3615927be34 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 09501ebb2681..759d20c0ca05 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 09a9d923c30d..993dd08e5bfc 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 720b6af2c4be..5069797a28c6 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 4e556d7aaa8b..72519d2b0e94 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 16d198dcca22..0136c087b9d8 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 045dc7075da5..137654223bef 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 976ee706c5d8..53001faac42d 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 62091b85f8cc..42f313f59a72 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 4db3b2781892..ec6458aa42e4 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/Geometry/TrackingGeometry.cpp b/Core/src/Geometry/TrackingGeometry.cpp index 1d04db1b6fab..1ccf40ee1a93 100644 --- a/Core/src/Geometry/TrackingGeometry.cpp +++ b/Core/src/Geometry/TrackingGeometry.cpp @@ -93,3 +93,8 @@ const Acts::Surface* Acts::TrackingGeometry::findSurface( } return srf->second; } + +const std::unordered_map& +Acts::TrackingGeometry::geoIdSurfaceMap() const { + return m_surfacesById; +} diff --git a/Core/src/Surfaces/AnnulusBounds.cpp b/Core/src/Surfaces/AnnulusBounds.cpp index 811a3d77a532..7ee26c92d947 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( diff --git a/Core/src/Surfaces/CylinderBounds.cpp b/Core/src/Surfaces/CylinderBounds.cpp index 64d13bb688a7..0ae077594414 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 + /////////////////////////////////// + double 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, diff --git a/Core/src/Visualization/GeometryView3D.cpp b/Core/src/Visualization/GeometryView3D.cpp index 26710a4800aa..960182a44316 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/Algorithms/Digitization/include/ActsExamples/Digitization/DigitizationConfig.hpp b/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/DigitizationConfig.hpp index 726cbb070306..bea136494409 100644 --- a/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/DigitizationConfig.hpp +++ b/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/DigitizationConfig.hpp @@ -12,7 +12,6 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Definitions/Units.hpp" #include "Acts/Geometry/GeometryHierarchyMap.hpp" -#include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/Utilities/BinUtility.hpp" #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Logger.hpp" @@ -26,16 +25,17 @@ #include #include #include +#include #include #include #include #include +#include #include #include namespace Acts { class GeometryIdentifier; -class TrackingGeometry; } // namespace Acts namespace ActsExamples { @@ -145,8 +145,9 @@ class DigitizationConfig { std::string outputMeasurementParticlesMap = "measurement_particles_map"; /// Output collection to map measured hits to simulated hits. std::string outputMeasurementSimHitsMap = "measurement_simhits_map"; - /// Tracking geometry required to access global-to-local transforms. - std::shared_ptr trackingGeometry = nullptr; + /// Map of surface by identifier to allow local - to global + std::unordered_map + surfaceByIdentifier; /// Random numbers tool. std::shared_ptr randomNumbers = nullptr; /// Do we merge hits or not diff --git a/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/SmearingConfig.hpp b/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/SmearingConfig.hpp index 587e3b54f50a..de32254e6d26 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/Examples/Algorithms/Digitization/src/DigitizationAlgorithm.cpp b/Examples/Algorithms/Digitization/src/DigitizationAlgorithm.cpp index 29b652577524..3834645ed7ea 100644 --- a/Examples/Algorithms/Digitization/src/DigitizationAlgorithm.cpp +++ b/Examples/Algorithms/Digitization/src/DigitizationAlgorithm.cpp @@ -57,8 +57,8 @@ ActsExamples::DigitizationAlgorithm::DigitizationAlgorithm( throw std::invalid_argument( "Missing hit-to-simulated-hits map output collection"); } - if (!m_cfg.trackingGeometry) { - throw std::invalid_argument("Missing tracking geometry"); + if (m_cfg.surfaceByIdentifier.empty()) { + throw std::invalid_argument("Missing Surface-GeometryID association map"); } if (!m_cfg.randomNumbers) { throw std::invalid_argument("Missing random numbers tool"); @@ -162,10 +162,9 @@ ActsExamples::ProcessCode ActsExamples::DigitizationAlgorithm::execute( Acts::GeometryIdentifier moduleGeoId = simHitsGroup.first; const auto& moduleSimHits = simHitsGroup.second; - const Acts::Surface* surfacePtr = - m_cfg.trackingGeometry->findSurface(moduleGeoId); + auto surfaceItr = m_cfg.surfaceByIdentifier.find(moduleGeoId); - if (surfacePtr == nullptr) { + if (surfaceItr == m_cfg.surfaceByIdentifier.end()) { // this is either an invalid geometry id or a misconfigured smearer // setup; both cases can not be handled and should be fatal. ACTS_ERROR("Could not find surface " << moduleGeoId @@ -173,6 +172,8 @@ ActsExamples::ProcessCode ActsExamples::DigitizationAlgorithm::execute( return ProcessCode::ABORT; } + const Acts::Surface* surfacePtr = surfaceItr->second; + auto digitizerItr = m_digitizers.find(moduleGeoId); if (digitizerItr == m_digitizers.end()) { ACTS_VERBOSE("No digitizer present for module " << moduleGeoId); diff --git a/Examples/Algorithms/Fatras/src/FatrasSimulation.cpp b/Examples/Algorithms/Fatras/src/FatrasSimulation.cpp index e7857a0ed1bd..a470c28873e2 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; diff --git a/Examples/Algorithms/Geant4/CMakeLists.txt b/Examples/Algorithms/Geant4/CMakeLists.txt index dc11b46f76a3..41b23ce1a633 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 000000000000..36e23411f072 --- /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 000000000000..0447d6acf195 --- /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/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp index da8e3760d227..b9b6e3ec3b13 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/Examples/Io/Json/src/JsonDigitizationConfig.cpp b/Examples/Io/Json/src/JsonDigitizationConfig.cpp index f923b53f72b0..262bd79cd263 100644 --- a/Examples/Io/Json/src/JsonDigitizationConfig.cpp +++ b/Examples/Io/Json/src/JsonDigitizationConfig.cpp @@ -147,8 +147,6 @@ void ActsExamples::from_json(const nlohmann::json& j, gdc.threshold = j["threshold"]; gdc.digital = j["digital"]; if (j.find("variances") != j.end()) { - std::cout << "READING variance map!" << std::endl; - /// Read the variances from the json file auto jvariances = j["variances"]; for (const auto& jvar : jvariances) { diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootMeasurementWriter.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootMeasurementWriter.hpp index 6b9ee3738840..78dcf3e83efc 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootMeasurementWriter.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootMeasurementWriter.hpp @@ -71,8 +71,9 @@ class RootMeasurementWriter final : public WriterT { std::string fileMode = "RECREATE"; ///< file access mode /// The indices for this digitization configurations Acts::GeometryHierarchyMap> boundIndices; - /// Tracking geometry required to access local-to-global transforms. - std::shared_ptr trackingGeometry; + /// Map of the geometry identifier to the surface + std::unordered_map + surfaceByIdentifier; }; struct DigitizationTree { diff --git a/Examples/Io/Root/src/RootMeasurementWriter.cpp b/Examples/Io/Root/src/RootMeasurementWriter.cpp index fc94fb12f4bc..5f71a6a3f8e4 100644 --- a/Examples/Io/Root/src/RootMeasurementWriter.cpp +++ b/Examples/Io/Root/src/RootMeasurementWriter.cpp @@ -8,7 +8,6 @@ #include "ActsExamples/Io/Root/RootMeasurementWriter.hpp" -#include "Acts/Geometry/TrackingGeometry.hpp" #include "ActsExamples/EventData/AverageSimHits.hpp" #include "ActsExamples/EventData/Index.hpp" #include "ActsExamples/EventData/IndexSourceLink.hpp" @@ -45,8 +44,8 @@ ActsExamples::RootMeasurementWriter::RootMeasurementWriter( m_inputMeasurementSimHitsMap.initialize(m_cfg.inputMeasurementSimHitsMap); m_inputClusters.maybeInitialize(m_cfg.inputClusters); - if (!m_cfg.trackingGeometry) { - throw std::invalid_argument("Missing tracking geometry"); + if (m_cfg.surfaceByIdentifier.empty()) { + throw std::invalid_argument("Missing Surface-GeoID association map"); } // Setup ROOT File m_outputFile = TFile::Open(m_cfg.filePath.c_str(), m_cfg.fileMode.c_str()); @@ -122,12 +121,11 @@ ActsExamples::ProcessCode ActsExamples::RootMeasurementWriter::writeT( Acts::GeometryIdentifier geoId = m.sourceLink().template get().geometryId(); // find the corresponding surface - const Acts::Surface* surfacePtr = - m_cfg.trackingGeometry->findSurface(geoId); - if (!surfacePtr) { + auto surfaceItr = m_cfg.surfaceByIdentifier.find(geoId); + if (surfaceItr == m_cfg.surfaceByIdentifier.end()) { return; } - const Acts::Surface& surface = *surfacePtr; + const Acts::Surface& surface = *(surfaceItr->second); // find the corresponding output tree auto dTreeItr = m_outputTrees.find(geoId); if (dTreeItr == m_outputTrees.end()) { diff --git a/Examples/Python/CMakeLists.txt b/Examples/Python/CMakeLists.txt index d376ab0c5a7e..9c7708bd9cfa 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 000000000000..bbc5882eaf3f --- /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/python/acts/examples/simulation.py b/Examples/Python/python/acts/examples/simulation.py index 9fd0074e462c..76cf0685aa83 100644 --- a/Examples/Python/python/acts/examples/simulation.py +++ b/Examples/Python/python/acts/examples/simulation.py @@ -645,7 +645,7 @@ def addGeant4( ---------- s: Sequencer the sequencer module to which we add the Geant4 steps (returned from addGeant4) - trackingGeometry : tracking geometry + trackingGeometry : tracking geometry or detector field : magnetic field rnd : RandomNumbers, None random number generator @@ -766,7 +766,7 @@ def addGeant4( def addDigitization( s: acts.examples.Sequencer, - trackingGeometry: acts.TrackingGeometry, + trackingGeometry: Union[acts.TrackingGeometry, acts.Detector], field: acts.MagneticFieldProvider, digiConfigFile: Union[Path, str], outputDirCsv: Optional[Union[Path, str]] = None, @@ -782,7 +782,7 @@ def addDigitization( ---------- s: Sequencer the sequencer module to which we add the Digitization steps (returned from addDigitization) - trackingGeometry : tracking geometry + trackingGeometry : tracking geometry or detector field : magnetic field digiConfigFile : Path|str, path Configuration (.json) file for digitization or smearing description @@ -804,7 +804,7 @@ def addDigitization( acts.examples.readDigiConfigFromJson( str(digiConfigFile), ), - trackingGeometry=trackingGeometry, + surfaceByIdentifier=trackingGeometry.geoIdSurfaceMap(), randomNumbers=rnd, inputSimHits="simhits", outputSourceLinks="sourcelinks", @@ -832,7 +832,7 @@ def addDigitization( inputSimHits=digiAlg.config.inputSimHits, inputMeasurementSimHitsMap=digiAlg.config.outputMeasurementSimHitsMap, filePath=str(outputDirRoot / f"{digiAlg.config.outputMeasurements}.root"), - trackingGeometry=trackingGeometry, + surfaceByIdentifier=trackingGeometry.geoIdSurfaceMap(), ) rmwConfig.addBoundIndicesFromDigiConfig(digiAlg.config) s.addWriter(acts.examples.RootMeasurementWriter(rmwConfig, customLogLevel())) diff --git a/Examples/Python/src/Digitization.cpp b/Examples/Python/src/Digitization.cpp index b9f225736154..54ec8934ac1d 100644 --- a/Examples/Python/src/Digitization.cpp +++ b/Examples/Python/src/Digitization.cpp @@ -67,7 +67,7 @@ void addDigitization(Context& ctx) { ACTS_PYTHON_MEMBER(outputClusters); ACTS_PYTHON_MEMBER(outputMeasurementParticlesMap); ACTS_PYTHON_MEMBER(outputMeasurementSimHitsMap); - ACTS_PYTHON_MEMBER(trackingGeometry); + ACTS_PYTHON_MEMBER(surfaceByIdentifier); ACTS_PYTHON_MEMBER(randomNumbers); ACTS_PYTHON_MEMBER(doMerge); ACTS_PYTHON_MEMBER(minEnergyDeposit); diff --git a/Examples/Python/src/Geant4GeoModelComponent.cpp b/Examples/Python/src/Geant4GeoModelComponent.cpp new file mode 100644 index 000000000000..d4e3576b00b0 --- /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 000000000000..896f9dd3aed7 --- /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 000000000000..8ec521b9619a --- /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/Geometry.cpp b/Examples/Python/src/Geometry.cpp index ea7440f73083..bb228ba29582 100644 --- a/Examples/Python/src/Geometry.cpp +++ b/Examples/Python/src/Geometry.cpp @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -74,6 +75,14 @@ struct MaterialSurfaceSelector { } }; +struct IdentifierSurfacesCollector { + std::unordered_map surfaces; + /// @param surface is the test surface + void operator()(const Acts::Surface* surface) { + surfaces[surface->geometryId()] = surface; + } +}; + } // namespace namespace Acts::Python { @@ -141,6 +150,7 @@ void addGeometry(Context& ctx) { [](Acts::TrackingGeometry& self, py::function& func) { self.visitSurfaces(func); }) + .def("geoIdSurfaceMap", &Acts::TrackingGeometry::geoIdSurfaceMap) .def("extractMaterialSurfaces", [](Acts::TrackingGeometry& self) { MaterialSurfaceSelector selector; @@ -217,10 +227,16 @@ void addExperimentalGeometry(Context& ctx) { .def("volumePtrs", &Detector::volumePtrs) .def("numberVolumes", [](Detector& self) { return self.volumes().size(); }) - .def("extractMaterialSurfaces", [](Detector& self) { - MaterialSurfaceSelector selector; - self.visitSurfaces(selector); - return selector.surfaces; + .def("extractMaterialSurfaces", + [](Detector& self) { + MaterialSurfaceSelector selector; + self.visitSurfaces(selector); + return selector.surfaces; + }) + .def("geoIdSurfaceMap", [](Detector& self) { + IdentifierSurfacesCollector collector; + self.visitSurfaces(collector); + return collector.surfaces; }); // Portal definition diff --git a/Examples/Python/src/ModuleEntry.cpp b/Examples/Python/src/ModuleEntry.cpp index 68aa575ad778..cc6442fe2856 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/Python/src/Output.cpp b/Examples/Python/src/Output.cpp index 680b2931cd41..767717fb8ddd 100644 --- a/Examples/Python/src/Output.cpp +++ b/Examples/Python/src/Output.cpp @@ -265,7 +265,7 @@ void addOutput(Context& ctx) { ACTS_PYTHON_MEMBER(filePath); ACTS_PYTHON_MEMBER(fileMode); ACTS_PYTHON_MEMBER(boundIndices); - ACTS_PYTHON_MEMBER(trackingGeometry); + ACTS_PYTHON_MEMBER(surfaceByIdentifier); ACTS_PYTHON_STRUCT_END(); } diff --git a/Examples/Python/tests/conftest.py b/Examples/Python/tests/conftest.py index 90162055f39c..b288b51f9b35 100644 --- a/Examples/Python/tests/conftest.py +++ b/Examples/Python/tests/conftest.py @@ -349,7 +349,7 @@ def _factory(s): / "Examples/Algorithms/Digitization/share/default-smearing-config-generic.json" ) ), - trackingGeometry=trk_geo, + surfaceByIdentifier=trk_geo.geoIdSurfaceMap(), randomNumbers=rng, inputSimHits=simAlg.config.outputSimHits, ) diff --git a/Examples/Python/tests/test_writer.py b/Examples/Python/tests/test_writer.py index dcdedbe7975b..18dac96e96f4 100644 --- a/Examples/Python/tests/test_writer.py +++ b/Examples/Python/tests/test_writer.py @@ -163,7 +163,7 @@ def test_root_meas_writer(tmp_path, fatras, trk_geo, assert_root_hash): inputSimHits=simAlg.config.outputSimHits, inputMeasurementSimHitsMap=digiAlg.config.outputMeasurementSimHitsMap, filePath=str(out), - trackingGeometry=trk_geo, + surfaceByIdentifier=trk_geo.geoIdSurfaceMap(), ) config.addBoundIndicesFromDigiConfig(digiAlg.config) s.addWriter(RootMeasurementWriter(level=acts.logging.INFO, config=config)) @@ -280,8 +280,8 @@ def test_root_writer_interface(writer, conf_const, tmp_path, trk_geo): for k, _ in inspect.getmembers(config): if k.startswith("input"): kw[k] = "collection" - if k == "trackingGeometry": - kw[k] = trk_geo + if k == "surfaceByIdentifier": + kw[k] = trk_geo.geoIdSurfaceMap() assert conf_const(writer, **kw) diff --git a/Examples/Scripts/Python/full_chain_odd.py b/Examples/Scripts/Python/full_chain_odd.py index d4910e1cfc08..c864c116721e 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/material_recording.py b/Examples/Scripts/Python/material_recording.py index ddceefc753c9..f52bb8b2ab23 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/Examples/Scripts/Python/sim_digi_odd.py b/Examples/Scripts/Python/sim_digi_odd.py deleted file mode 100644 index 510cedb028d3..000000000000 --- a/Examples/Scripts/Python/sim_digi_odd.py +++ /dev/null @@ -1,234 +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.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("--edm4hep", help="Use edm4hep inputs", type=pathlib.Path) -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-multiplicity", - help="Multiplicity of the particle gun", - type=int, - default=200, -) -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="", -) -args = parser.parse_args() - -outputDir = args.output -geoDir = getOpenDataDetectorDirectory() - -oddDigiConfig = args.digi_config - -detector, trackingGeometry, decorators = getOpenDataDetector( - odd_dir=geoDir, mdecorator=None -) -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 args.edm4hep: - import acts.examples.edm4hep - - edm4hepReader = acts.examples.edm4hep.EDM4hepReader( - inputPath=str(args.edm4hep), - inputSimHits=[ - "PixelBarrelReadout", - "PixelEndcapReadout", - "ShortStripBarrelReadout", - "ShortStripEndcapReadout", - "LongStripBarrelReadout", - "LongStripEndcapReadout", - ], - outputParticlesGenerator="particles_input", - outputParticlesInitial="particles_initial", - outputParticlesFinal="particles_final", - outputSimHits="simhits", - graphvizOutput="graphviz", - dd4hepDetector=detector, - trackingGeometry=trackingGeometry, - sortSimHitsInTime=True, - level=acts.logging.INFO, - ) - s.addReader(edm4hepReader) - s.addWhiteboardAlias("particles", edm4hepReader.config.outputParticlesGenerator) - - addParticleSelection( - s, - config=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, - ), - inputParticles="particles", - outputParticles="particles_selected", - ) -else: - 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(4, 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, - 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, - trackingGeometry, - 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=trackingGeometry.worldVolume, - killAfterTime=25 * u.ns, - ) - else: - addFatras( - s, - trackingGeometry, - 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, - ) - -addDigitization( - s, - trackingGeometry, - field, - digiConfigFile=oddDigiConfig, - outputDirRoot=outputDir, - outputDirCsv=outputDir, - rnd=rnd, -) - -s.run() diff --git a/Fatras/include/ActsFatras/Digitization/UncorrelatedHitSmearer.hpp b/Fatras/include/ActsFatras/Digitization/UncorrelatedHitSmearer.hpp index 565559e01c2e..0600006b5f22 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/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp b/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp index 882612b47878..4596067a8289 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 359620715ee5..db949a2c2563 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 01c57a3b22c2..16ccd30ef175 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/CMakeLists.txt b/Plugins/CMakeLists.txt index 97f612bf8fc5..93fa92a23e89 100644 --- a/Plugins/CMakeLists.txt +++ b/Plugins/CMakeLists.txt @@ -5,10 +5,10 @@ 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) -add_component_if(Sycl PluginSycl ACTS_BUILD_PLUGIN_SYCL) add_component_if(ExaTrkX PluginExaTrkX ACTS_BUILD_PLUGIN_EXATRKX) # dependent plugins. depend either on a independent plugins or on one another diff --git a/Plugins/GeoModel/CMakeLists.txt b/Plugins/GeoModel/CMakeLists.txt new file mode 100644 index 000000000000..a7fc08498f75 --- /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 000000000000..f5eacf4079d1 --- /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 000000000000..b3215e8c3be0 --- /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 000000000000..46bd8dba7795 --- /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/Plugins/Json/include/Acts/Plugins/Json/DetectorVolumeFinderJsonConverter.hpp b/Plugins/Json/include/Acts/Plugins/Json/DetectorVolumeFinderJsonConverter.hpp index 67206b9a2c4c..6f46b70a2f13 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 7518226e19c2..d0d9d7081d49 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 64c28c25f826..3dbdbfb7b8f4 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 48b305cbce37..0cec6ba18bd2 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 6f8c11ab5bbd..7f6039f82e03 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 bf1217b65eb3..4817e3435b51 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 d44baf99c20b..d53b15dd5cc4 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 893a6e729631..f47905643e29 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/Plugins/Podio/include/Acts/Plugins/Podio/PodioDynamicColumns.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioDynamicColumns.hpp index 80d48167814d..39e6ec326df4 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 9393d7fc8a97..1a75473efca0 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 ec2bd7cc4892..1714fe9e7701 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)}); diff --git a/Plugins/Sycl/CMakeLists.txt b/Plugins/Sycl/CMakeLists.txt deleted file mode 100644 index 59190b32f822..000000000000 --- a/Plugins/Sycl/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# This file is part of the Acts project. -# -# Copyright (C) 2020-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/. - -add_library( - ActsPluginSycl SHARED - # header files - include/Acts/Plugins/Sycl/Seeding/detail/Types.hpp - include/Acts/Plugins/Sycl/Seeding/CreateSeedsForGroupSycl.hpp - include/Acts/Plugins/Sycl/Seeding/DeviceExperimentCuts.hpp - include/Acts/Plugins/Sycl/Seeding/SeedFinder.hpp - include/Acts/Plugins/Sycl/Seeding/SeedFinder.ipp - include/Acts/Plugins/Sycl/Utilities/CalculateNdRange.hpp - include/Acts/Plugins/Sycl/Utilities/DeviceSelector.hpp - include/Acts/Plugins/Sycl/Utilities/ListPlatforms.hpp - include/Acts/Plugins/Sycl/Utilities/QueueWrapper.hpp - # implementation files - src/Seeding/CreateSeedsForGroupSycl.cpp - src/Seeding/DupletSearch.hpp - src/Seeding/LinearTransform.hpp - src/Seeding/SpacePointType.hpp - src/Utilities/CalculateNdRange.cpp - src/Utilities/DeviceSelector.cpp - src/Utilities/ListPlatforms.cpp - src/Utilities/QueueWrapper.cpp -) - -target_include_directories( - ActsPluginSycl - PUBLIC - $ - $) - -target_link_libraries( - ActsPluginSycl - PUBLIC ActsCore vecmem::core - PRIVATE vecmem::sycl) - -acts_target_setup_sycl(ActsPluginSycl DEPENDENCY PRIVATE) - -install( - TARGETS ActsPluginSycl - EXPORT ActsPluginSyclTargets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -install( - DIRECTORY include/Acts - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/CreateSeedsForGroupSycl.hpp b/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/CreateSeedsForGroupSycl.hpp deleted file mode 100644 index 4e70d04449f0..000000000000 --- a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/CreateSeedsForGroupSycl.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020-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/. - -#pragma once - -// System include(s) -#include - -// VecMem include(s). -#include "vecmem/containers/jagged_vector.hpp" -#include "vecmem/containers/vector.hpp" -#include "vecmem/memory/memory_resource.hpp" - -// SYCL plugin include(s) -#include "Acts/Plugins/Sycl/Seeding/DeviceExperimentCuts.hpp" -#include "Acts/Plugins/Sycl/Seeding/detail/Types.hpp" -#include "Acts/Plugins/Sycl/Utilities/QueueWrapper.hpp" - -namespace Acts::Sycl { - -/// @brief Seedfinding algorithm implemented in SYCL. -/// -/// @param[in] wrappedQueue is a wrapper object of the SYCL queue -/// @param[in] resource is the host-accessible memory resource to use -/// @param[in] device_resource is the optional device-accessible memory -/// resource, necessary if @c resource is not -/// device-accessible -/// @param[in] seedFinderConfig includes the required configuration -/// parameters for the algorithm -/// @param[in] deviceCuts is an experiment specific object with customizable -/// seed weight altering and seed cutting member functions -/// @param[in] bottomSPs an array of simplified internal space -/// point structures of bottom space points -/// @param[in] middleSPs an array of simplified internal space -/// point structures of middle space points -/// @param[in] topSPs an array of simplified internal space -/// point structures of top space points -/// @param[out] seeds holds of the generated seed indices and weight -void createSeedsForGroupSycl( - QueueWrapper wrappedQueue, vecmem::memory_resource& resource, - vecmem::memory_resource* device_resource, - const detail::DeviceSeedFinderConfig& seedFinderConfig, - const DeviceExperimentCuts& deviceCuts, - vecmem::vector& bottomSPs, - vecmem::vector& middleSPs, - vecmem::vector& topSPs, - std::vector>& seeds); -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/DeviceExperimentCuts.hpp b/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/DeviceExperimentCuts.hpp deleted file mode 100644 index b2a0eba55fe9..000000000000 --- a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/DeviceExperimentCuts.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 - -// SYCL plugin include(s) -#include "Acts/Plugins/Sycl/Seeding/detail/Types.hpp" - -namespace Acts::Sycl { -/// @c DeviceExperimentCuts can be used to increase or decrease seed weights -/// based on the space points used in a seed. Seed weights are also -/// influenced by the SeedFilter default implementation. This tool is also used -/// to decide if a seed passes a seed weight cut. As the weight is stored in -/// seeds, there are two distinct methods. -class DeviceExperimentCuts { - public: - /// Returns seed weight bonus/malus depending on detector considerations. - /// @param bottom bottom space point of the current seed - /// @param middle middle space point of the current seed - /// @param top top space point of the current seed - /// @return seed weight to be added to the seed's weight - float seedWeight(const detail::DeviceSpacePoint& bottom, - const detail::DeviceSpacePoint& /*middle*/, - const detail::DeviceSpacePoint& top) const { - float weight = 0; - if (bottom.r > 150.f) { - weight = 400.f; - } - if (top.r < 150.f) { - weight = 200.f; - } - return weight; - }; - /// @param weight the current seed weight - /// @param bottom bottom space point of the current seed - /// @param middle middle space point of the current seed - /// @param top top space point of the current seed - /// @return true if the seed should be kept, false if the seed should be - /// discarded - bool singleSeedCut(float weight, const detail::DeviceSpacePoint& bottom, - const detail::DeviceSpacePoint& /*middle*/, - const detail::DeviceSpacePoint& /*top*/) const { - return !(bottom.r > 150.f && weight < 380.f); - }; -}; -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/SeedFinder.hpp b/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/SeedFinder.hpp deleted file mode 100644 index a2ae0c46a72d..000000000000 --- a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/SeedFinder.hpp +++ /dev/null @@ -1,80 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020-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 - -// Acts include(s). -#include "Acts/Seeding/SeedFilter.hpp" -#include "Acts/Seeding/SeedFinderConfig.hpp" -#include "Acts/Seeding/SpacePointGrid.hpp" - -// SYCL plugin include(s). -#include "Acts/Plugins/Sycl/Seeding/DeviceExperimentCuts.hpp" -#include "Acts/Plugins/Sycl/Seeding/detail/Types.hpp" -#include "Acts/Plugins/Sycl/Utilities/QueueWrapper.hpp" - -// VecMem include(s). -#include "vecmem/memory/memory_resource.hpp" - -namespace Acts::Sycl { - -template -class SeedFinder { - public: - SeedFinder(Acts::SeedFinderConfig config, - const Acts::SeedFinderOptions& options, - const Acts::Sycl::DeviceExperimentCuts& cuts, - Acts::Sycl::QueueWrapper wrappedQueue, - vecmem::memory_resource& resource, - vecmem::memory_resource* device_resource = nullptr); - - ~SeedFinder() = default; - SeedFinder() = delete; - SeedFinder(const SeedFinder&) = delete; - SeedFinder& operator=( - const SeedFinder&) = delete; - - /// Create all seeds from the space points in the three iterators. - /// Can be used to parallelize the seed creation - /// @param bottomSPs group of space points to be used as innermost SP in a seed. - /// @param middleSPs group of space points to be used as middle SP in a seed. - /// @param topSPs group of space points to be used as outermost SP in a seed. - /// Ranges must return pointers. - /// Ranges must be separate objects for each parallel call. - /// @return vector in which all found seeds for this group are stored. - template - std::vector> createSeedsForGroup( - Acts::SpacePointData& spacePointData, - Acts::CylindricalSpacePointGrid& grid, - const sp_range_t& bottomSPs, const std::size_t middleSPs, - const sp_range_t& topSPs) const; - - private: - Acts::SeedFinderConfig m_config; - Acts::SeedFinderOptions m_options; - - /// Experiment specific cuts - Acts::Sycl::DeviceExperimentCuts m_deviceCuts; - - /// Configuration object for the device side. - Acts::Sycl::detail::DeviceSeedFinderConfig m_deviceConfig; - - /// Wrapper around a SYCL queue object. - QueueWrapper m_wrappedQueue; - - /// host/shared memory resource to use in the seed-finder - vecmem::memory_resource* m_resource; - - /// Device memory resource for use - vecmem::memory_resource* m_device_resource; -}; - -} // namespace Acts::Sycl - -// Include the template implementation. -#include "Acts/Plugins/Sycl/Seeding/SeedFinder.ipp" diff --git a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/SeedFinder.ipp b/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/SeedFinder.ipp deleted file mode 100644 index eefa416a0aea..000000000000 --- a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/SeedFinder.ipp +++ /dev/null @@ -1,157 +0,0 @@ -// 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/. - -// System include(s) -#include -#include -#include - -// VecMem include(s). -#include "vecmem/containers/vector.hpp" - -// Acts include(s). -#include "Acts/Seeding/CandidatesForMiddleSp.hpp" -#include "Acts/Seeding/InternalSeed.hpp" -#include "Acts/Seeding/InternalSpacePoint.hpp" - -// SYCL plugin include(s) -#include "Acts/Plugins/Sycl/Seeding/CreateSeedsForGroupSycl.hpp" -#include "Acts/Plugins/Sycl/Seeding/SeedFinder.hpp" - -namespace Acts::Sycl { -template -SeedFinder::SeedFinder( - Acts::SeedFinderConfig config, - const Acts::SeedFinderOptions& options, - const Acts::Sycl::DeviceExperimentCuts& cuts, - Acts::Sycl::QueueWrapper wrappedQueue, vecmem::memory_resource& resource, - vecmem::memory_resource* device_resource) - : m_config(config), - m_options(options), - m_deviceCuts(cuts), - m_wrappedQueue(std::move(wrappedQueue)), - m_resource(&resource), - m_device_resource(device_resource) { - auto seedFilterConfig = m_config.seedFilter->getSeedFilterConfig(); - - // init m_deviceConfig - m_deviceConfig = Acts::Sycl::detail::DeviceSeedFinderConfig{ - m_config.deltaRMin, - m_config.deltaRMax, - m_config.cotThetaMax, - m_config.collisionRegionMin, - m_config.collisionRegionMax, - m_config.maxScatteringAngle2, - m_config.sigmaScattering, - m_options.minHelixDiameter2, - m_options.pT2perRadius, - seedFilterConfig.deltaInvHelixDiameter, - seedFilterConfig.impactWeightFactor, - seedFilterConfig.deltaRMin, - seedFilterConfig.compatSeedWeight, - m_config.impactMax, - seedFilterConfig.compatSeedLimit, - }; -} - -template -template -std::vector> -SeedFinder::createSeedsForGroup( - Acts::SpacePointData& spacePointData, - Acts::CylindricalSpacePointGrid& grid, - const sp_range_t& bottomSPs, const std::size_t middleSPs, - const sp_range_t& topSPs) const { - std::vector> outputVec; - - // As a first step, we create Arrays of Structures (AoS) - // that are easily comprehensible by the GPU. This allows us - // less memory access operations than with simple (float) arrays. - - // Creating VecMem vectors of the space points, linked to the host/shared - // memory resource They will be filled and passed to CreateSeedsForGroup(). - vecmem::vector deviceBottomSPs(m_resource); - vecmem::vector deviceMiddleSPs(m_resource); - vecmem::vector deviceTopSPs(m_resource); - - std::vector*> bottomSPvec; - std::vector*> middleSPvec; - std::vector*> topSPvec; - - for (std::size_t SPidx : bottomSPs) { - auto& sp_collection = grid.at(SPidx); - for (auto& SP : sp_collection) { - bottomSPvec.push_back(SP.get()); - } - } - deviceBottomSPs.reserve(bottomSPvec.size()); - for (auto SP : bottomSPvec) { - deviceBottomSPs.push_back({SP->x(), SP->y(), SP->z(), SP->radius(), - SP->varianceR(), SP->varianceZ()}); - } - - { - auto& sp_collection = grid.at(middleSPs); - for (auto& SP : sp_collection) { - middleSPvec.push_back(SP.get()); - } - } - deviceMiddleSPs.reserve(middleSPvec.size()); - for (auto SP : middleSPvec) { - deviceMiddleSPs.push_back({SP->x(), SP->y(), SP->z(), SP->radius(), - SP->varianceR(), SP->varianceZ()}); - } - - for (auto SPidx : topSPs) { - auto& sp_collection = grid.at(SPidx); - for (auto& SP : sp_collection) { - topSPvec.push_back(SP.get()); - } - } - deviceTopSPs.reserve(topSPvec.size()); - for (auto SP : topSPvec) { - deviceTopSPs.push_back({SP->x(), SP->y(), SP->z(), SP->radius(), - SP->varianceR(), SP->varianceZ()}); - } - - // std::vector> seeds; - std::vector> seeds; - - // Call the SYCL seeding algorithm - createSeedsForGroupSycl(m_wrappedQueue, *m_resource, m_device_resource, - m_deviceConfig, m_deviceCuts, deviceBottomSPs, - deviceMiddleSPs, deviceTopSPs, seeds); - - // Iterate through seeds returned by the SYCL algorithm and perform the last - // step of filtering for fixed middle SP. - std::vector>::value_type> - candidates; - - for (std::size_t mi = 0; mi < seeds.size(); ++mi) { - candidates.clear(); - for (std::size_t j = 0; j < seeds[mi].size(); ++j) { - auto& bottomSP = *(bottomSPvec[seeds[mi][j].bottom]); - auto& middleSP = *(middleSPvec[mi]); - auto& topSP = *(topSPvec[seeds[mi][j].top]); - float weight = seeds[mi][j].weight; - - candidates.emplace_back(bottomSP, middleSP, topSP, weight, 0, false); - } - std::sort( - candidates.begin(), candidates.end(), - CandidatesForMiddleSp>:: - descendingByQuality); - std::size_t numQualitySeeds = 0; // not used but needs to be fixed - m_config.seedFilter->filterSeeds_1SpFixed(spacePointData, candidates, - numQualitySeeds, - std::back_inserter(outputVec)); - } - return outputVec; -} -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/detail/Types.hpp b/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/detail/Types.hpp deleted file mode 100644 index a90e7b3888a3..000000000000 --- a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/detail/Types.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 - -// System include(s) -#include -#include - -namespace Acts::Sycl::detail { -/// Simplified internal space point object with parameters required for the -/// seeding algorithm on the device side. -struct DeviceSpacePoint { - float x; - float y; - float z; - /// radius - float r; - /// variance R - float varR; - /// variance Z - float varZ; -}; - -/// Simple structure holding information about duplet circles (middle-bottom and -/// middle-top) in linear equation form. -/// They are used on the device side in SYCL kernels. -struct DeviceLinEqCircle { - float zo; - float cotTheta; - float iDeltaR; - float er; - float u; - float v; -}; - -/// Config parameters of SeedFinder and SeedFilter classes -/// needed for the seeding algorithm on the device side. -struct DeviceSeedFinderConfig { - float deltaRMin; - float deltaRMax; - float cotThetaMax; - float collisionRegionMin; - float collisionRegionMax; - float maxScatteringAngle2; - float sigmaScattering; - float minHelixDiameter2; - float pT2perRadius; - float deltaInvHelixDiameter; - float impactWeightFactor; - float filterDeltaRMin; - float compatSeedWeight; - float impactMax; - std::size_t compatSeedLimit; -}; - -/// Struct holding information about triplets that are calculated in the triplet -/// search kernel and needed in the next kernel (triplet filter). -struct DeviceTriplet { - float curvature; - float impact; - int32_t topSPIndex; -}; - -/// Struct returned from the SYCL seeding algorithm to the host -/// -/// Stores the indices of the space points and the weight of the seed. -/// They index arrays on the host side, constructed in -/// @c Acts::Sycl::SeedFinder::createSeedsForGroup(...). -struct SeedData { - uint32_t bottom; - uint32_t top; - uint32_t middle; - float weight; -}; -} // namespace Acts::Sycl::detail diff --git a/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/CalculateNdRange.hpp b/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/CalculateNdRange.hpp deleted file mode 100644 index 3c1a49007f3f..000000000000 --- a/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/CalculateNdRange.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 - -// SYCL include -#include - -namespace Acts::Sycl { -/// @brief Calculate global range of 1 dimensional nd_range for -/// kernel execution -/// -/// @param[in] numThreads is the number of threads globally -/// @param[in] workGroupSize is the number of threads in one work group -/// -/// Calculates the global dimension of the nd_range, which is the smallest -/// multiple of workGroupSize that is not smaller than numThreads. -/// -/// @return a one dimensional nd_range of threads -cl::sycl::nd_range<1> calculate1DimNDRange(const uint32_t numThreads, - const uint32_t workGroupSize); - -/// @brief Calculate global and local range of 2 dimensional nd_range for -/// kernel execution -/// -/// @param[in] numThreadsDim0 is the number of threads globally in the first -/// dimension -/// @param[in] numThreadsDim1 is the number of threads globally in the -/// second dimension -/// @param[in] workGroupSize is the number of threads in one work group -/// -/// Local range is calculated the following way: -/// - local range dimensions multiplied together should be equal to -/// workGroupSize -/// - if workGroupSize > numThreadsDim1: set local range in the second -/// dimension to be equal to the smallest factor of 2, that is not smaller -/// that the number of threads globally in the second dimension -/// - else: local range is {1, workGroupSize} -/// -/// Global range is calculated the following way: -/// - set the number of threads in both dimensions to the smallest multiple -/// of the work group size in that dimension -/// -/// @return a two dimensional nd_range of threads -cl::sycl::nd_range<2> calculate2DimNDRange(const uint32_t numThreadsDim0, - const uint32_t numThreadsDim1, - const uint32_t workGroupSize); - -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/DeviceSelector.hpp b/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/DeviceSelector.hpp deleted file mode 100644 index 161738cd920e..000000000000 --- a/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/DeviceSelector.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 - -// System include(s) -#include - -// SYCL include -#include - -namespace Acts::Sycl { -/// @brief Custom device selector that refuses to select NVIDIA OpenCL backends. -/// -/// It is also possible to the tell the selector explicitly which device we want -/// to use by providing a substring of the preferred device's name. -struct DeviceSelector : public cl::sycl::device_selector { - DeviceSelector(const std::string& deviceName = ""); - - int operator()(const cl::sycl::device& d) const; - - private: - /// Fallback device selector - cl::sycl::default_selector m_defaultSelector; - - /// Substring of the preferred device's name - std::string m_deviceName; -}; -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/ListPlatforms.hpp b/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/ListPlatforms.hpp deleted file mode 100644 index 20c7aafd4976..000000000000 --- a/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/ListPlatforms.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 - -namespace Acts::Sycl { -/// @brief This function allows us to list available SYCL platforms and devices. -/// -/// Available platforms and devices only include previously linked targets by -/// CMake, which can optionally be altered by environment variable SYCL_BE. -void listPlatforms(); - -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/QueueWrapper.hpp b/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/QueueWrapper.hpp deleted file mode 100644 index d19f663ff7ae..000000000000 --- a/Plugins/Sycl/include/Acts/Plugins/Sycl/Utilities/QueueWrapper.hpp +++ /dev/null @@ -1,85 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020-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/. - -#pragma once - -// Acts include(s). -#include "Acts/Utilities/Logger.hpp" - -// System include(s) -#include -#include - -/// Forward declaration of incomplete type cl::sycl::queue -inline namespace cl { -namespace sycl { -class queue; -} -}; // namespace cl - -namespace Acts::Sycl { - -class QueueWrapper { - public: - /// Create queue with default selector or given name - /// Default constructed queue wrappers are owners. - QueueWrapper(const std::string& = "", - std::unique_ptr logger = - getDefaultLogger("Sycl::QueueWrapper", Logging::INFO)); - /// Constructor around an existing queue object - QueueWrapper(cl::sycl::queue& queue, - std::unique_ptr logger = - getDefaultLogger("Sycl::QueueWrapper", Logging::INFO)); - /// Move constructor - /// It takes ownership (if it is given). - QueueWrapper(QueueWrapper&& parent) noexcept; - /// Copy constructor - /// Does not give ownership to the underlying pointer. - QueueWrapper(const QueueWrapper& other); - /// Destructor - /// Destroy the underlying pointer, but only if it is owned. - ~QueueWrapper(); - - /// Move assignment operator - QueueWrapper& operator=(QueueWrapper&& rhs) noexcept; - /// Copy assignment operator - QueueWrapper& operator=(const QueueWrapper& other); - - /// @name Accessor functions/operators - /// @{ - - /// Get stored pointer (const) - const cl::sycl::queue* getQueue() const; - /// Get stored pointer (non-const) - cl::sycl::queue* getQueue(); - - /// Operator implementing smart pointer behaviour (const) - const cl::sycl::queue* operator->() const; - /// Operator implementing smart pointer behaviour (non-const) - cl::sycl::queue* operator->(); - - /// De-referencing operator (const) - const cl::sycl::queue& operator*() const; - /// De-referencing operator (non-const) - cl::sycl::queue& operator*(); - - /// @} - - private: - /// Raw pointer to SYCL queue object - cl::sycl::queue* m_queue; - /// Owns queue - bool m_ownsQueue; - /// The logger object - std::unique_ptr m_logger; - - /// Logger accessor - const Logger& logger() const { return *m_logger; } - -}; // class QueueWrapper -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/src/Seeding/CreateSeedsForGroupSycl.cpp b/Plugins/Sycl/src/Seeding/CreateSeedsForGroupSycl.cpp deleted file mode 100644 index 5f95ee1fdf8b..000000000000 --- a/Plugins/Sycl/src/Seeding/CreateSeedsForGroupSycl.cpp +++ /dev/null @@ -1,641 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020-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/. - -// System include(s) -#include -#include -#include -#include -#include -#include -#include - -// Acts include(s) -#include "Acts/Utilities/Logger.hpp" - -// SYCL plugin include(s) -#include "Acts/Plugins/Sycl/Seeding/CreateSeedsForGroupSycl.hpp" -#include "Acts/Plugins/Sycl/Seeding/detail/Types.hpp" -#include "Acts/Plugins/Sycl/Utilities/CalculateNdRange.hpp" - -#include "../Utilities/Arrays.hpp" -#include "DupletSearch.hpp" -#include "LinearTransform.hpp" -#include "TripletFilter.hpp" -#include "TripletSearch.hpp" - -// VecMem include(s). -#include "vecmem/containers/data/jagged_vector_buffer.hpp" -#include "vecmem/containers/data/vector_buffer.hpp" -#include "vecmem/utils/sycl/copy.hpp" - -// SYCL include -#include - -namespace Acts::Sycl { -// Kernel classes in order of execution. -class ind_copy_bottom_kernel; -class ind_copy_top_kernel; -class triplet_search_kernel; -class filter_2sp_fixed_kernel; - -void createSeedsForGroupSycl( - QueueWrapper wrappedQueue, vecmem::memory_resource& resource, - vecmem::memory_resource* device_resource, - const detail::DeviceSeedFinderConfig& seedFinderConfig, - const DeviceExperimentCuts& deviceCuts, - vecmem::vector& bottomSPs, - vecmem::vector& middleSPs, - vecmem::vector& topSPs, - std::vector>& seeds) { - // Each vector stores data of space points in simplified - // structures of float variables - // M: number of middle space points - // B: number of bottom space points - // T: number of top space points - const uint32_t M = middleSPs.size(); - const uint32_t B = bottomSPs.size(); - const uint32_t T = topSPs.size(); - - // Up to the Nth space point, the sum of compatible bottom/top space points. - // We need these for indexing other vectors later in the algorithm. - // These are prefix sum arrays, with a leading zero. - // Those will be created with either host or shared memory resource - vecmem::vector sumBotMidPrefix(&resource); - sumBotMidPrefix.push_back(0); - vecmem::vector sumTopMidPrefix(&resource); - sumTopMidPrefix.push_back(0); - vecmem::vector sumBotTopCombPrefix(&resource); - sumBotTopCombPrefix.push_back(0); - - // After completing the duplet search, we'll have successfully constructed - // two bipartite graphs for bottom-middle and top-middle space points. - // We store the indices of the middle space points of the corresponding - // edges. - vecmem::vector indMidBotComp(&resource); - vecmem::vector indMidTopComp(&resource); - - try { - auto* q = wrappedQueue.getQueue(); - uint64_t globalBufferSize = - q->get_device().get_info(); - uint64_t maxWorkGroupSize = - q->get_device().get_info(); - vecmem::sycl::copy copy(wrappedQueue.getQueue()); - - // Calculate 2 dimensional range of bottom-middle duplet search kernel - // We'll have a total of M*B threads globally, but we need to give the - // nd_range the global dimensions so that they are an exact multiple of - // the local dimensions. That's why we need this calculation. - - cl::sycl::nd_range<2> bottomDupletNDRange = - calculate2DimNDRange(M, B, maxWorkGroupSize); - cl::sycl::nd_range<2> topDupletNDRange = - calculate2DimNDRange(M, T, maxWorkGroupSize); - - // Create views of the space point vectors. - // They will be constructed differently depending on the number of memory - // resources given. - std::unique_ptr> - deviceBottomSPs, deviceTopSPs, deviceMiddleSPs; - vecmem::data::vector_view bottomSPsView, - topSPsView, middleSPsView; - if (!device_resource) { - bottomSPsView = vecmem::get_data(bottomSPs); - topSPsView = vecmem::get_data(topSPs); - middleSPsView = vecmem::get_data(middleSPs); - } else { - deviceBottomSPs = std::make_unique< - vecmem::data::vector_buffer>( - B, *device_resource); - deviceTopSPs = std::make_unique< - vecmem::data::vector_buffer>( - T, *device_resource); - deviceMiddleSPs = std::make_unique< - vecmem::data::vector_buffer>( - M, *device_resource); - - copy(vecmem::get_data(bottomSPs), *deviceBottomSPs); - copy(vecmem::get_data(topSPs), *deviceTopSPs); - copy(vecmem::get_data(middleSPs), *deviceMiddleSPs); - - bottomSPsView = vecmem::get_data(*deviceBottomSPs); - topSPsView = vecmem::get_data(*deviceTopSPs); - middleSPsView = vecmem::get_data(*deviceMiddleSPs); - } - //*********************************************// - // ********** DUPLET SEARCH - BEGIN ********** // - //*********************************************// - - // Create the output data of the duplet search - jagged vectors. - std::unique_ptr> - midBotDupletBuffer; - std::unique_ptr> - midTopDupletBuffer; - - midBotDupletBuffer = - std::make_unique>( - std::vector(M, 0), std::vector(M, B), - (device_resource ? *device_resource : resource), - (device_resource ? &resource : nullptr)); - midTopDupletBuffer = - std::make_unique>( - std::vector(M, 0), std::vector(M, T), - (device_resource ? *device_resource : resource), - (device_resource ? &resource : nullptr)); - copy.setup(*midBotDupletBuffer); - copy.setup(*midTopDupletBuffer); - - // Perform the middle-bottom duplet search. - auto middleBottomEvent = q->submit([&](cl::sycl::handler& h) { - detail::DupletSearch kernel( - middleSPsView, bottomSPsView, *midBotDupletBuffer, seedFinderConfig); - h.parallel_for(bottomDupletNDRange, - kernel); - }); - - // Perform the middle-top duplet search. - auto middleTopEvent = q->submit([&](cl::sycl::handler& h) { - detail::DupletSearch kernel( - middleSPsView, topSPsView, *midTopDupletBuffer, seedFinderConfig); - h.parallel_for(topDupletNDRange, kernel); - }); - middleBottomEvent.wait_and_throw(); - middleTopEvent.wait_and_throw(); - //*********************************************// - // *********** DUPLET SEARCH - END *********** // - //*********************************************// - - // Get the sizes of the inner vectors of the jagged vector - number of - // compatible bottom/top SPs for each MiddleSP. - auto countBotDuplets = copy.get_sizes(*midBotDupletBuffer); - auto countTopDuplets = copy.get_sizes(*midTopDupletBuffer); - // Construct prefix sum arrays of duplet counts. - // These will later be used to index other arrays based on middle SP - // indices. - for (uint32_t i = 1; i < M + 1; ++i) { - sumBotMidPrefix.push_back(sumBotMidPrefix.at(i - 1) + - countBotDuplets[i - 1]); - sumTopMidPrefix.push_back(sumTopMidPrefix.at(i - 1) + - countTopDuplets[i - 1]); - sumBotTopCombPrefix.push_back(sumBotTopCombPrefix.at(i - 1) + - countBotDuplets[i - 1] * - countTopDuplets[i - 1]); - } - // Number of edges for middle-bottom and middle-top duplet bipartite graphs. - const uint64_t edgesBottom = sumBotMidPrefix[M]; - const uint64_t edgesTop = sumTopMidPrefix[M]; - // Number of possible compatible triplets. This is the sum of the - // combination of the number of compatible bottom and compatible top duplets - // per middle space point. (nb0*nt0 + nb1*nt1 + ... where nbk is the number - // of comp. bot. SPs for the kth middle SP) - const uint64_t edgesComb = sumBotTopCombPrefix[M]; - - indMidBotComp.reserve(edgesBottom); - indMidTopComp.reserve(edgesTop); - - // Fill arrays of middle SP indices of found duplets (bottom and top). - for (uint32_t mid = 0; mid < M; ++mid) { - std::fill_n(std::back_inserter(indMidBotComp), countBotDuplets[mid], mid); - std::fill_n(std::back_inserter(indMidTopComp), countTopDuplets[mid], mid); - } - - if (edgesBottom > 0 && edgesTop > 0) { - // Calculate global and local range of execution for edgesBottom number of - // threads. Local range is the same as block size in CUDA. - cl::sycl::nd_range<1> edgesBotNdRange = - calculate1DimNDRange(edgesBottom, maxWorkGroupSize); - - // Global and local range of execution for edgesTop number of threads. - cl::sycl::nd_range<1> edgesTopNdRange = - calculate1DimNDRange(edgesTop, maxWorkGroupSize); - - // EXPLANATION OF INDEXING (first part) - /* - (for bottom-middle duplets, but it is the same for middle-tops) - In case we have 4 middle SP and 5 bottom SP, our temporary array of - the compatible bottom duplet indices would look like this: - --------------------- - mid0 | 0 | 3 | 4 | 1 | - | Indices in the columns correspond to - mid1 | 3 | 2 | - | - | - | bottom SP indices in the bottomSPs - mid2 | - | - | - | - | - | array. Threads are executed concurrently, - mid3 | 4 | 2 | 1 | - | - | so the order of indices is random. - --------------------- - We will refer to this structure as a bipartite graph, as it can be - described by a graph of nodes for middle and bottom SPs, and edges - between one middle and one bottom SP, but never two middle or two - bottom SPs. - We will flatten this matrix out, and store the indices the - following way (this is indBotDupletBuffer): - ------------------------------------- - | 0 | 3 | 4 | 1 | 3 | 2 | 4 | 2 | 1 | - ------------------------------------- - Also the length of this array is equal to edgesBottom, which is 9 in - this example. It is the number of the edges of the bottom-middle - bipartite graph. - To find out where the indices of bottom SPs start for a particular - middle SP, we use prefix sum arrays. - We know how many duplets were found for each middle SP (this is - countBotDuplets). - ----------------- - | 4 | 2 | 0 | 3 | - ----------------- - We will make a prefix sum array of these counts, with a leading zero: - (this is sumBotMidPrefix) - --------------------- - | 0 | 4 | 6 | 6 | 9 | - --------------------- - If we have the middle SP with index 1, then we know that the indices - of the compatible bottom SPs are in the range (left closed, right - open) [sumBotMidPrefix[1] , sumBotMidPrefix[2] ) of indBotDUpletBuffer. - In this case, these indices are 3 and 2, so we'd use these to index - views of bottomSPs to gather data about the bottom SP. - To be able to get the indices of middle SPs in constant time inside - kernels, we will also prepare arrays that store the indices of the - middleSPs of the edges (indMidBotComp). - ------------------------------------- - | 0 | 0 | 0 | 0 | 1 | 1 | 3 | 3 | 3 | - ------------------------------------- - (For the same purpose, we could also do a binary search on the - sumBotMidPrefix array, and we will do exactly that later, in the triplet - search kernel.) - We will execute the coordinate transformation on edgesBottom threads, - or 9 in our example. - The size of the array storing our transformed coordinates - (linearBotBuffer) is also edgesBottom, the sum of bottom duplets we - found so far. - */ - - // We store the indices of the BOTTOM/TOP space points of the edges of - // the bottom-middle and top-middle bipartite duplet graphs. They index - // the bottomSPs and topSPs vectors. - - // We store the indices of the MIDDLE space points of the edges of the - // bottom-middle and top-middle bipartite duplet graphs. - // They index the middleSP vector. - // indMidBotComp; - // indMidTopComp; - - // Partial sum arrays of deviceNumBot and deviceNum - // Partial sum array of the combinations of compatible bottom and top - // space points per middle space point. - // Allocations for coordinate transformation. - - // Buffers for Flattening the jagged vectors - std::unique_ptr> indBotDupletBuffer; - std::unique_ptr> indTopDupletBuffer; - - indBotDupletBuffer = - std::make_unique>( - edgesBottom, (device_resource ? *device_resource : resource)); - indTopDupletBuffer = - std::make_unique>( - edgesTop, (device_resource ? *device_resource : resource)); - - copy.setup(*indBotDupletBuffer); - copy.setup(*indTopDupletBuffer); - - // Pointers constructed in case the device memory resource was given. - std::unique_ptr> - device_sumBotMidPrefix, device_sumTopMidPrefix, - device_sumBotTopCombPrefix; - // Vecmem views of the prefix sums used throughout the later code. - vecmem::data::vector_view sumBotMidView, sumTopMidView, - sumBotTopCombView; - - // Same behaviour for the vectors of indices - std::unique_ptr> - device_indMidBotComp, device_indMidTopComp; - vecmem::data::vector_view indMidBotCompView, indMidTopCompView; - // Copy indices from temporary matrices to final, optimal size vectors. - // We will use these for easier indexing. - if (!device_resource) { - sumBotMidView = vecmem::get_data(sumBotMidPrefix); - sumTopMidView = vecmem::get_data(sumTopMidPrefix); - sumBotTopCombView = vecmem::get_data(sumBotTopCombPrefix); - - indMidBotCompView = vecmem::get_data(indMidBotComp); - indMidTopCompView = vecmem::get_data(indMidTopComp); - } else { - device_sumBotMidPrefix = - std::make_unique>( - M + 1, *device_resource); - device_sumTopMidPrefix = - std::make_unique>( - M + 1, *device_resource); - device_sumBotTopCombPrefix = - std::make_unique>( - M + 1, *device_resource); - - device_indMidBotComp = - std::make_unique>( - edgesBottom, *device_resource); - device_indMidTopComp = - std::make_unique>( - edgesTop, *device_resource); - - copy(vecmem::get_data(sumBotMidPrefix), *device_sumBotMidPrefix); - copy(vecmem::get_data(sumTopMidPrefix), *device_sumTopMidPrefix); - copy(vecmem::get_data(sumBotTopCombPrefix), - *device_sumBotTopCombPrefix); - - copy(vecmem::get_data(indMidBotComp), *device_indMidBotComp); - copy(vecmem::get_data(indMidTopComp), *device_indMidTopComp); - - sumBotMidView = vecmem::get_data(*device_sumBotMidPrefix); - sumTopMidView = vecmem::get_data(*device_sumTopMidPrefix); - sumBotTopCombView = vecmem::get_data(*device_sumBotTopCombPrefix); - - indMidBotCompView = vecmem::get_data(*device_indMidBotComp); - indMidTopCompView = vecmem::get_data(*device_indMidTopComp); - } - auto midBotDupletView = vecmem::get_data(*midBotDupletBuffer); - auto indBotDupletView = vecmem::get_data(*indBotDupletBuffer); - auto indBotEvent = q->submit([&](cl::sycl::handler& h) { - h.parallel_for( - edgesBotNdRange, [=](cl::sycl::nd_item<1> item) { - auto idx = item.get_global_linear_id(); - if (idx < edgesBottom) { - vecmem::device_vector deviceIndMidBot( - indMidBotCompView), - sumBotMidPrefix(sumBotMidView), - indBotDuplets(indBotDupletView); - vecmem::jagged_device_vector midBotDuplets( - midBotDupletView); - auto mid = deviceIndMidBot[idx]; - auto ind = midBotDuplets[mid][idx - sumBotMidPrefix[mid]]; - indBotDuplets[idx] = ind; - } - }); - }); - auto midTopDupletView = vecmem::get_data(*midTopDupletBuffer); - auto indTopDupletView = vecmem::get_data(*indTopDupletBuffer); - auto indTopEvent = q->submit([&](cl::sycl::handler& h) { - h.parallel_for( - edgesTopNdRange, [=](cl::sycl::nd_item<1> item) { - auto idx = item.get_global_linear_id(); - if (idx < edgesTop) { - vecmem::device_vector deviceIndMidTop( - indMidTopCompView), - sumTopMidPrefix(sumTopMidView), - indTopDuplets(indTopDupletView); - vecmem::jagged_device_vector midTopDuplets( - midTopDupletView); - auto mid = deviceIndMidTop[idx]; - auto ind = midTopDuplets[mid][idx - sumTopMidPrefix[mid]]; - indTopDuplets[idx] = ind; - } - }); - }); - indBotEvent.wait_and_throw(); - indTopEvent.wait_and_throw(); - - // Create the output data of the linear transform - std::unique_ptr> - linearBotBuffer; - std::unique_ptr> - linearTopBuffer; - - linearBotBuffer = std::make_unique< - vecmem::data::vector_buffer>( - edgesBottom, (device_resource ? *device_resource : resource)); - linearTopBuffer = std::make_unique< - vecmem::data::vector_buffer>( - edgesTop, (device_resource ? *device_resource : resource)); - - copy.setup(*linearBotBuffer); - copy.setup(*linearTopBuffer); - - //************************************************// - // *** LINEAR EQUATION TRANSFORMATION - BEGIN *** // - //************************************************// - - // transformation of circle equation (x,y) into linear equation (u,v) - // x^2 + y^2 - 2x_0*x - 2y_0*y = 0 - // is transformed into - // 1 - 2x_0*u - 2y_0*v = 0 - - // coordinate transformation middle-bottom pairs - auto linB = q->submit([&](cl::sycl::handler& h) { - detail::LinearTransform kernel( - middleSPsView, bottomSPsView, indMidBotCompView, - *indBotDupletBuffer, edgesBottom, *linearBotBuffer); - h.parallel_for(edgesBotNdRange, - kernel); - }); - - // coordinate transformation middle-top pairs - auto linT = q->submit([&](cl::sycl::handler& h) { - detail::LinearTransform kernel( - middleSPsView, topSPsView, indMidTopCompView, *indTopDupletBuffer, - edgesTop, *linearTopBuffer); - h.parallel_for(edgesTopNdRange, kernel); - }); - - //************************************************// - // **** LINEAR EQUATION TRANSFORMATION - END **** // - //************************************************// - - //************************************************// - // *********** TRIPLET SEARCH - BEGIN *********** // - //************************************************// - - // EXPLANATION OF INDEXING (second part) - /* - For the triplet search, we calculate the upper limit of constructible - triplets. - - For this, we multiply the number of compatible bottom and compatible - top SPs for each middle SP, and add these together. - (nb0*nt0 + nb1*nt1 + ... where nbk is the number of compatible bottom - SPs for the kth middle SP, similarly ntb is for tops) - - sumBotTopCombPrefix is a prefix sum array (of length M+1) of the - calculated combinations. - - sumBotTopCombPrefix: - ________________________________________________________ - | | | | | M | M = number - | 0 | nb0*nt0 | nb0*nt0 + nb1*nt1 | ... | ∑ nbi+nti | of middle - |_____|_________|___________________|_____|_i=0________| space points - - We will start kernels and reserve memory for these combinations but - only so much we can fit into memory at once. - - We limit our memory usage to globalBufferSize/2, this is currently - hard-coded, but it could be configured. Actually, it would be better - to use a separate object that manages memory allocations and - deallocations and we could ask it to lend us as much memory as it is - happy to give. - - For later, let maxMemoryAllocation be maximum allocatable memory for - triplet search. - - We start by adding up summing the combinations, until we arrive at a - k which for: - - k+1 - ∑ nbi+nti > maxMemoryAllocation - i=0 - (or k == M). - - So we know, that we need to start our first kernel for the first k - middle SPs. - - Inside the triplet search kernel we start with a binary search, to - find out which middle SP the thread corresponds to. Note, that - sumBotTopCombPrefix is a monotone increasing series of values which - allows us to do a binary search on it. - - Inside the triplet search kernel we count the triplets for fixed - bottom and middle SP. This is deviceCountTriplets. - - The triplet filter kernel is calculated on threads equal to all possible - bottom-middle combinations for the first k middle SPs, which are - the sum of bottom-middle duplets. (For the next kernel it would be the - bottom-middle combinations from the (k+1)th middle SP to another jth - middle SP j<=M.) - - This will be numTripletFilterThreads = - sumBotMidPrefix[lastMiddle] - sumBotMidPrefix[firstMiddle] - - If the triplet search and triplet filter kernel finished, we continue - summing up possible triplet combinations from the (k+1)th middle SP. - - Inside the kernels we need to use offset because of this, to be able to - map threads to space point indices. - - This offset is sumCombUptoFirstMiddle. - */ - - const auto maxMemoryAllocation = - std::min(edgesComb, - globalBufferSize / uint64_t((sizeof(detail::DeviceTriplet) + - sizeof(detail::SeedData)) * - 2)); - - std::unique_ptr> - curvImpactBuffer; - std::unique_ptr> - seedArrayBuffer; - - curvImpactBuffer = - std::make_unique>( - maxMemoryAllocation, - (device_resource ? *device_resource : resource)); - seedArrayBuffer = - std::make_unique>( - maxMemoryAllocation, 0, - (device_resource ? *device_resource : resource)); - - copy.setup(*curvImpactBuffer); - copy.setup(*seedArrayBuffer); - // Reserve memory in advance for seed indices and weight - // Other way around would allocate it inside the loop - // -> less memory usage, but more frequent allocation and deallocation - - // Counting the seeds in the second kernel allows us to copy back the - // right number of seeds, and no more. - seeds.resize(M); - vecmem::vector countTriplets(&resource); - countTriplets.resize(edgesBottom, 0); - - std::unique_ptr> - deviceCountTriplets; - vecmem::data::vector_view countTripletsView; - - if (!device_resource) { - countTripletsView = vecmem::get_data(countTriplets); - } else { - deviceCountTriplets = - std::make_unique>( - edgesBottom, *device_resource); - copy(vecmem::get_data(countTriplets), *deviceCountTriplets); - countTripletsView = vecmem::get_data(*deviceCountTriplets); - } - - // Do the triplet search and triplet filter for 2 sp fixed for middle - // space points in the interval [firstMiddle, lastMiddle). - - uint32_t lastMiddle = 0; - for (uint32_t firstMiddle = 0; firstMiddle < M; - firstMiddle = lastMiddle) { - // Determine the interval [firstMiddle, lastMiddle) right end based - // on memory requirements. - while (lastMiddle + 1 <= M && (sumBotTopCombPrefix[lastMiddle + 1] - - sumBotTopCombPrefix[firstMiddle] < - maxMemoryAllocation)) { - ++lastMiddle; - } - - const auto numTripletSearchThreads = - sumBotTopCombPrefix[lastMiddle] - sumBotTopCombPrefix[firstMiddle]; - - if (numTripletSearchThreads == 0) { - ++lastMiddle; - continue; - } - - copy.setup(*seedArrayBuffer); - const auto numTripletFilterThreads = - sumBotMidPrefix[lastMiddle] - sumBotMidPrefix[firstMiddle]; - - // Nd_range with maximum block size for triplet search and filter. - // (global and local range is already given) - cl::sycl::nd_range<1> tripletSearchNDRange = - calculate1DimNDRange(numTripletSearchThreads, maxWorkGroupSize); - - cl::sycl::nd_range<1> tripletFilterNDRange = - calculate1DimNDRange(numTripletFilterThreads, maxWorkGroupSize); - - auto tripletKernel = q->submit([&](cl::sycl::handler& h) { - h.depends_on({linB, linT}); - detail::TripletSearch kernel( - sumBotTopCombView, numTripletSearchThreads, firstMiddle, - lastMiddle, *midTopDupletBuffer, sumBotMidView, sumTopMidView, - *linearBotBuffer, *linearTopBuffer, middleSPsView, - *indTopDupletBuffer, countTripletsView, seedFinderConfig, - *curvImpactBuffer); - h.parallel_for(tripletSearchNDRange, - kernel); - }); - - q->submit([&](cl::sycl::handler& h) { - h.depends_on(tripletKernel); - detail::TripletFilter kernel( - numTripletFilterThreads, sumBotMidView, firstMiddle, - indMidBotCompView, *indBotDupletBuffer, sumBotTopCombView, - *midTopDupletBuffer, *curvImpactBuffer, topSPsView, - middleSPsView, bottomSPsView, countTripletsView, - *seedArrayBuffer, seedFinderConfig, deviceCuts); - h.parallel_for(tripletFilterNDRange, - kernel); - }).wait_and_throw(); - // sync - // Retrieve results from triplet search - std::vector seedArray; - copy(*seedArrayBuffer, seedArray); - - for (auto& t : seedArray) { - seeds[t.middle].push_back(t); - } - } - - //************************************************// - // ************ TRIPLET SEARCH - END ************ // - //************************************************// - } - - } catch (cl::sycl::exception const& e) { - ACTS_LOCAL_LOGGER( - Acts::getDefaultLogger("SyclSeeding", Acts::Logging::INFO)); - ACTS_FATAL("Caught synchronous SYCL exception:\n" << e.what()) - throw; - } -}; -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/src/Seeding/DupletSearch.hpp b/Plugins/Sycl/src/Seeding/DupletSearch.hpp deleted file mode 100644 index 76942b692b84..000000000000 --- a/Plugins/Sycl/src/Seeding/DupletSearch.hpp +++ /dev/null @@ -1,113 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020-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/. - -#pragma once - -// Local include(s). -#include "Acts/Plugins/Sycl/Seeding/detail/Types.hpp" - -#include "../Utilities/Arrays.hpp" -#include "SpacePointType.hpp" - -// VecMem include(s). -#include "vecmem/containers/data/jagged_vector_view.hpp" -#include "vecmem/containers/data/vector_view.hpp" -#include "vecmem/containers/device_vector.hpp" -#include "vecmem/containers/jagged_device_vector.hpp" - -// SYCL include(s). -#include - -// System include(s). -#include - -namespace Acts::Sycl::detail { - -/// Functor taking care of finding viable spacepoint duplets -template -class DupletSearch { - // Sanity check(s). - static_assert((OtherSPType == SpacePointType::Bottom) || - (OtherSPType == SpacePointType::Top), - "Class must be instantiated with either " - "Acts::Sycl::detail::SpacePointType::Bottom or " - "Acts::Sycl::detail::SpacePointType::Top"); - - public: - /// Constructor with all the necessary arguments - DupletSearch(vecmem::data::vector_view middleSPs, - vecmem::data::vector_view otherSPs, - vecmem::data::jagged_vector_view middleOtherSPIndices, - const DeviceSeedFinderConfig& config) - : m_middleSPs(middleSPs), - m_otherSPs(otherSPs), - m_middleOtherSPIndices(middleOtherSPIndices), - m_config(config) {} - - /// Operator performing the duplet search - void operator()(cl::sycl::nd_item<2> item) const { - // Get the indices of the spacepoints to evaluate. - const auto middleIndex = item.get_global_id(0); - const auto otherIndex = item.get_global_id(1); - - // We check whether this thread actually makes sense (within bounds). - // The number of threads is usually a factor of 2, or 3*2^k (k \in N), etc. - // Without this check we may index out of arrays. - if ((middleIndex >= m_middleSPs.size()) || - (otherIndex >= m_otherSPs.size())) { - return; - } - - // Create a copy of the spacepoint objects for the current thread. On - // dedicated GPUs this provides a better performance than accessing - // variables one-by-one from global device memory. - const vecmem::device_vector middleSPs(m_middleSPs); - const DeviceSpacePoint middleSP = middleSPs[middleIndex]; - const vecmem::device_vector otherSPs(m_otherSPs); - const DeviceSpacePoint otherSP = otherSPs[otherIndex]; - - // Calculate the variables that the duplet quality selection are based on. - // Note that the asserts of the functor make sure that 'OtherSPType' must be - // either SpacePointType::Bottom or SpacePointType::Top. - float deltaR = 0.0f, cotTheta = 0.0f; - if constexpr (OtherSPType == SpacePointType::Bottom) { - deltaR = middleSP.r - otherSP.r; - cotTheta = (middleSP.z - otherSP.z) / deltaR; - } else { - deltaR = otherSP.r - middleSP.r; - cotTheta = (otherSP.z - middleSP.z) / deltaR; - } - const float zOrigin = middleSP.z - middleSP.r * cotTheta; - - // Check if the duplet passes our quality requirements. - if ((deltaR >= m_config.deltaRMin) && (deltaR <= m_config.deltaRMax) && - (cl::sycl::abs(cotTheta) <= m_config.cotThetaMax) && - (zOrigin >= m_config.collisionRegionMin) && - (zOrigin <= m_config.collisionRegionMax)) { - // Create device vector based on the view and push to it - vecmem::jagged_device_vector middleOtherSPIndices( - m_middleOtherSPIndices); - middleOtherSPIndices.at(middleIndex).push_back(otherIndex); - } - } - - private: - /// Middle spacepoints - vecmem::data::vector_view m_middleSPs; - /// "Other" (bottom or top) spacepoints - vecmem::data::vector_view m_otherSPs; - - /// The 2D array storing the compatible middle-other spacepoint indices - vecmem::data::jagged_vector_view m_middleOtherSPIndices; - - /// Configuration for the seed finding - DeviceSeedFinderConfig m_config; - -}; // struct DupletSearch - -} // namespace Acts::Sycl::detail diff --git a/Plugins/Sycl/src/Seeding/LinearTransform.hpp b/Plugins/Sycl/src/Seeding/LinearTransform.hpp deleted file mode 100644 index 048751d8ebf6..000000000000 --- a/Plugins/Sycl/src/Seeding/LinearTransform.hpp +++ /dev/null @@ -1,137 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020-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/. - -#pragma once - -// SYCL plugin include(s). -#include "Acts/Plugins/Sycl/Seeding/detail/Types.hpp" - -#include "../Utilities/Arrays.hpp" -#include "SpacePointType.hpp" - -// SYCL include(s). -#include - -// System include(s). -#include -#include - -// VecMem include(s). -#include "vecmem/containers/data/vector_view.hpp" -#include "vecmem/containers/device_vector.hpp" - -namespace Acts::Sycl::detail { - -/// Functor performing a linear coordinate transformation on spacepoint pairs -template -class LinearTransform { - // Sanity check(s). - static_assert((OtherSPType == SpacePointType::Bottom) || - (OtherSPType == SpacePointType::Top), - "Class must be instantiated with either " - "Acts::Sycl::detail::SpacePointType::Bottom or " - "Acts::Sycl::detail::SpacePointType::Top"); - - public: - /// Constructor with all the necessary arguments - LinearTransform( - vecmem::data::vector_view middleSPs, - vecmem::data::vector_view otherSPs, - vecmem::data::vector_view middleIndexLUT, - vecmem::data::vector_view otherIndexLUT, uint32_t nEdges, - vecmem::data::vector_view resultArray) - : m_middleSPs(middleSPs), - m_otherSPs(otherSPs), - m_middleIndexLUT(middleIndexLUT), - m_otherIndexLUT(otherIndexLUT), - m_nEdges(nEdges), - m_resultArray(resultArray) {} - - /// Operator performing the coordinate linear transformation - void operator()(cl::sycl::nd_item<1> item) const { - // Get the index to operate on. - const auto idx = item.get_global_linear_id(); - if (idx >= m_nEdges) { - return; - } - - // Translate this one index into indices in the spacepoint arrays. - // Note that using asserts with the CUDA backend of dpc++ is not working - // quite correctly at the moment. :-( So these checks may need to be - // disabled if you need to build for an NVidia backend in Debug mode. - vecmem::device_vector middleIndexLUT(m_middleIndexLUT); - const uint32_t middleIndex = middleIndexLUT[idx]; - assert(middleIndex < m_middleSPs.size()); - (void)m_middleSPs.size(); - vecmem::device_vector otherIndexLUT(m_otherIndexLUT); - const uint32_t otherIndex = otherIndexLUT[idx]; - assert(otherIndex < m_otherSPs.size()); - (void)m_otherSPs.size(); - - // Create a copy of the spacepoint objects for the current thread. On - // dedicated GPUs this provides a better performance than accessing - // variables one-by-one from global device memory. - const vecmem::device_vector middleSPs(m_middleSPs); - const DeviceSpacePoint middleSP = middleSPs[middleIndex]; - const vecmem::device_vector otherSPs(m_otherSPs); - const DeviceSpacePoint otherSP = otherSPs[otherIndex]; - - // Calculate some "helper variables" for the coordinate linear - // transformation. - const float cosPhiM = middleSP.x / middleSP.r; - const float sinPhiM = middleSP.y / middleSP.r; - - const float deltaX = otherSP.x - middleSP.x; - const float deltaY = otherSP.y - middleSP.y; - const float deltaZ = otherSP.z - middleSP.z; - - const float x = deltaX * cosPhiM + deltaY * sinPhiM; - const float y = deltaY * cosPhiM - deltaX * sinPhiM; - const float iDeltaR2 = 1.f / (deltaX * deltaX + deltaY * deltaY); - - // Create the result object. - DeviceLinEqCircle result; - result.iDeltaR = cl::sycl::sqrt(iDeltaR2); - result.cotTheta = deltaZ * result.iDeltaR; - if constexpr (OtherSPType == SpacePointType::Bottom) { - result.cotTheta = -(result.cotTheta); - } - result.zo = middleSP.z - middleSP.r * result.cotTheta; - result.u = x * iDeltaR2; - result.v = y * iDeltaR2; - result.er = - ((middleSP.varZ + otherSP.varZ) + - (result.cotTheta * result.cotTheta) * (middleSP.varR + otherSP.varR)) * - iDeltaR2; - - // Store the result in the result vector - vecmem::device_vector resultArray(m_resultArray); - resultArray[idx] = result; - return; - } - - private: - /// Pointer to the middle spacepoints (in global device memory) - vecmem::data::vector_view m_middleSPs; - /// Pointer to the "other" (bottom or top) spacepoints (in global device mem.) - vecmem::data::vector_view m_otherSPs; - - /// Look-Up Table from the iteration index to the middle spacepoint index - vecmem::data::vector_view m_middleIndexLUT; - /// Loop-Up Table from the iteration index to the "other" spacepoint index - vecmem::data::vector_view m_otherIndexLUT; - - /// Total number of elements in the result array - uint32_t m_nEdges; - - /// The result array in device global memory - vecmem::data::vector_view m_resultArray; - -}; // class LinearTransform - -} // namespace Acts::Sycl::detail diff --git a/Plugins/Sycl/src/Seeding/SpacePointType.hpp b/Plugins/Sycl/src/Seeding/SpacePointType.hpp deleted file mode 100644 index fb057e197309..000000000000 --- a/Plugins/Sycl/src/Seeding/SpacePointType.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 - -namespace Acts::Sycl::detail { - -/// Type of a space point -enum class SpacePointType : int { - Bottom = 0, //< The referenced type is a "bottom" spacepoint - Middle = 1, //< The referenced type is a "middle" spacepoint - Top = 2 //< The referenced type is a "top" spacepoint -}; - -} // namespace Acts::Sycl::detail diff --git a/Plugins/Sycl/src/Seeding/TripletFilter.hpp b/Plugins/Sycl/src/Seeding/TripletFilter.hpp deleted file mode 100644 index ae6abc998aae..000000000000 --- a/Plugins/Sycl/src/Seeding/TripletFilter.hpp +++ /dev/null @@ -1,167 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020-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/. - -#pragma once - -// Local include(s). -#include "Acts/Plugins/Sycl/Seeding/detail/Types.hpp" - -#include "../Utilities/Arrays.hpp" -#include "SpacePointType.hpp" - -// VecMem include(s). -#include "vecmem/containers/data/jagged_vector_view.hpp" -#include "vecmem/containers/data/vector_view.hpp" -#include "vecmem/containers/device_vector.hpp" -#include "vecmem/containers/jagged_device_vector.hpp" - -// SYCL include(s). -#include - -// System include(s). -#include - -namespace Acts::Sycl::detail { - -/// Functor performing Triplet Filter -class TripletFilter { - public: - /// Constructor - TripletFilter( - const uint32_t numTripletFilterThreads, - vecmem::data::vector_view sumBotMidView, - const uint32_t firstMiddle, - vecmem::data::vector_view indMidBotCompView, - vecmem::data::vector_view indBotDupletView, - vecmem::data::vector_view sumBotTopCombView, - vecmem::data::jagged_vector_view midTopDupletView, - vecmem::data::vector_view curvImpactView, - vecmem::data::vector_view topSPsView, - vecmem::data::vector_view middleSPsView, - vecmem::data::vector_view bottomSPsView, - vecmem::data::vector_view countTripletsView, - vecmem::data::vector_view seedArrayView, - const DeviceSeedFinderConfig& config, const DeviceExperimentCuts& cuts) - : m_numTripletFilterThreads(numTripletFilterThreads), - m_sumBotMidView(sumBotMidView), - m_firstMiddle(firstMiddle), - m_indMidBotCompView(indMidBotCompView), - m_indBotDupletView(indBotDupletView), - m_sumBotTopCombView(sumBotTopCombView), - m_midTopDupletView(midTopDupletView), - m_curvImpactView(curvImpactView), - m_topSPsView(topSPsView), - m_middleSPsView(middleSPsView), - m_bottomSPsView(bottomSPsView), - m_countTripletsView(countTripletsView), - m_seedArrayView(seedArrayView), - m_config(config), - m_cuts(cuts) {} - - /// Operator performing filtering - void operator()(cl::sycl::nd_item<1> item) const { - if (item.get_global_linear_id() < m_numTripletFilterThreads) { - vecmem::device_vector sumBotMidPrefix(m_sumBotMidView), - deviceIndMidBot(m_indMidBotCompView), - deviceIndBotDuplets(m_indBotDupletView), - sumBotTopCombPrefix(m_sumBotTopCombView), - deviceCountTriplets(m_countTripletsView); - vecmem::jagged_device_vector midTopDuplets(m_midTopDupletView); - const auto idx = - sumBotMidPrefix[m_firstMiddle] + item.get_global_linear_id(); - const auto mid = deviceIndMidBot[idx]; - const auto bot = deviceIndBotDuplets[idx]; - const auto sumCombUptoFirstMiddle = sumBotTopCombPrefix[m_firstMiddle]; - const auto tripletBegin = - sumBotTopCombPrefix[mid] - sumCombUptoFirstMiddle + - (idx - sumBotMidPrefix[mid]) * midTopDuplets.at(mid).size(); - const auto tripletEnd = tripletBegin + deviceCountTriplets[idx]; - const vecmem::device_vector deviceCurvImpactConst( - m_curvImpactView); - for (auto i1 = tripletBegin; i1 < tripletEnd; ++i1) { - const auto current = deviceCurvImpactConst[i1]; - const auto top = current.topSPIndex; - - const auto invHelixDiameter = current.curvature; - const auto lowerLimitCurv = - invHelixDiameter - m_config.deltaInvHelixDiameter; - const auto upperLimitCurv = - invHelixDiameter + m_config.deltaInvHelixDiameter; - const vecmem::device_vector topSPs( - m_topSPsView); - const auto currentTop_r = topSPs[top].r; - auto weight = -(current.impact * m_config.impactWeightFactor); - - uint32_t compatCounter = 0; - // By default compatSeedLimit is 2 -> 2 is - // currently hard coded, because variable length - // arrays are not supported in SYCL kernels. - float compatibleSeedR[2]; - for (auto i2 = tripletBegin; - i2 < tripletEnd && compatCounter < m_config.compatSeedLimit; - ++i2) { - const auto other = deviceCurvImpactConst[i2]; - - const auto otherCurv = other.curvature; - const auto otherTop_r = topSPs[other.topSPIndex].r; - const float deltaR = cl::sycl::abs(currentTop_r - otherTop_r); - if (deltaR >= m_config.filterDeltaRMin && - otherCurv >= lowerLimitCurv && otherCurv <= upperLimitCurv) { - uint32_t c = 0; - for (; c < compatCounter && - cl::sycl::abs(compatibleSeedR[c] - otherTop_r) >= - m_config.filterDeltaRMin; - ++c) { - } - if (c == compatCounter) { - compatibleSeedR[c] = otherTop_r; - ++compatCounter; - } - } - } - weight += compatCounter * m_config.compatSeedWeight; - const vecmem::device_vector middleSPs( - m_middleSPsView), - bottomSPs(m_bottomSPsView); - const auto bottomSP = bottomSPs[bot]; - const auto middleSP = middleSPs[mid]; - const auto topSP = topSPs[top]; - - weight += m_cuts.seedWeight(bottomSP, middleSP, topSP); - - if (m_cuts.singleSeedCut(weight, bottomSP, middleSP, topSP)) { - detail::SeedData D; - D.bottom = bot; - D.top = top; - D.middle = mid; - D.weight = weight; - vecmem::device_vector seedArray(m_seedArrayView); - seedArray.push_back(D); - } - } - } - } - - private: - const uint32_t m_numTripletFilterThreads; - vecmem::data::vector_view m_sumBotMidView; - const uint32_t m_firstMiddle; - vecmem::data::vector_view m_indMidBotCompView; - vecmem::data::vector_view m_indBotDupletView; - vecmem::data::vector_view m_sumBotTopCombView; - vecmem::data::jagged_vector_view m_midTopDupletView; - vecmem::data::vector_view m_curvImpactView; - vecmem::data::vector_view m_topSPsView; - vecmem::data::vector_view m_middleSPsView; - vecmem::data::vector_view m_bottomSPsView; - vecmem::data::vector_view m_countTripletsView; - vecmem::data::vector_view m_seedArrayView; - DeviceSeedFinderConfig m_config; - DeviceExperimentCuts m_cuts; -}; // struct TripletFilter -} // namespace Acts::Sycl::detail diff --git a/Plugins/Sycl/src/Seeding/TripletSearch.hpp b/Plugins/Sycl/src/Seeding/TripletSearch.hpp deleted file mode 100644 index aad1a3737591..000000000000 --- a/Plugins/Sycl/src/Seeding/TripletSearch.hpp +++ /dev/null @@ -1,266 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020-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/. - -#pragma once - -// Local include(s). -#include "Acts/Plugins/Sycl/Seeding/detail/Types.hpp" - -#include "../Utilities/Arrays.hpp" -#include "SpacePointType.hpp" - -// VecMem include(s). -#include "vecmem/containers/data/jagged_vector_view.hpp" -#include "vecmem/containers/data/vector_view.hpp" -#include "vecmem/containers/device_vector.hpp" -#include "vecmem/containers/jagged_device_vector.hpp" -#include "vecmem/memory/atomic.hpp" - -// SYCL include(s). -#include - -// System include(s). -#include - -namespace Acts::Sycl::detail { - -/// Functor performing Triplet Search -class TripletSearch { - public: - /// Constructor - TripletSearch( - vecmem::data::vector_view sumBotTopCombView, - const uint32_t numTripletSearchThreads, const uint32_t firstMiddle, - const uint32_t lastMiddle, - vecmem::data::jagged_vector_view midTopDupletView, - vecmem::data::vector_view sumBotMidView, - vecmem::data::vector_view sumTopMidView, - vecmem::data::vector_view linearBotView, - vecmem::data::vector_view linearTopView, - vecmem::data::vector_view middleSPsView, - vecmem::data::vector_view indTopDupletview, - vecmem::data::vector_view countTripletsView, - const DeviceSeedFinderConfig& config, - vecmem::data::vector_view curvImpactView) - : m_sumBotTopCombView(sumBotTopCombView), - m_numTripletSearchThreads(numTripletSearchThreads), - m_firstMiddle(firstMiddle), - m_lastMiddle(lastMiddle), - m_midTopDupletView(midTopDupletView), - m_sumBotMidView(sumBotMidView), - m_sumTopMidView(sumTopMidView), - m_linearBotView(linearBotView), - m_linearTopView(linearTopView), - m_middleSPsView(middleSPsView), - m_indTopDupletView(indTopDupletview), - m_countTripletsView(countTripletsView), - m_config(config), - m_curvImpactView(curvImpactView) {} - - /// Operator performing the triplet search - void operator()(cl::sycl::nd_item<1> item) const { - // Get the index - const uint32_t idx = item.get_global_linear_id(); - if (idx < m_numTripletSearchThreads) { - // Retrieve the index of the corresponding middle - // space point by binary search - vecmem::device_vector sumBotTopCombPrefix(m_sumBotTopCombView); - const auto sumCombUptoFirstMiddle = sumBotTopCombPrefix[m_firstMiddle]; - auto L = m_firstMiddle; - auto R = m_lastMiddle; - auto mid = L; - while (L < R - 1) { - mid = (L + R) / 2; - // To be able to search in sumBotTopCombPrefix, we need - // to use an offset (sumCombUptoFirstMiddle). - if (idx + sumCombUptoFirstMiddle < sumBotTopCombPrefix[mid]) { - R = mid; - } else { - L = mid; - } - } - mid = L; - vecmem::jagged_device_vector midTopDuplets( - m_midTopDupletView); - const auto numT = midTopDuplets.at(mid).size(); - const auto threadIdxForMiddleSP = - (idx - sumBotTopCombPrefix[mid] + sumCombUptoFirstMiddle); - /* - NOTES ON THREAD MAPPING TO SPACE POINTS - - We need to map bottom and top SP indices to this - thread. - - So we are mapping one bottom and one top SP to this thread - (we already have a middle SP) which gives us a tiplet. - - This is done in the following way: We - calculated the number of possible triplet - combinations for this middle SP (let it be - num_comp_bot*num_comp_top). Let num_comp_bot = 2 - and num_comp_top=3 in this example. So we have 2 - compatible bottom and 3 compatible top SP for this - middle SP. - - That gives us 6 threads altogether: - =========================================== - thread: | 0 | 1 | 2 | 3 | 4 | 5 | - bottom id: | bot0 | bot0 | bot0 | bot1 | bot1 | bot1 | - top id: | top0 | top1 | top2 | top0 | top1 | top2 | - =========================================== - - If we divide 6 by the number of compatible top SP - for this middle SP, or deviceNumTopDuplets[mid] - which is 3 now, we get the id for the bottom SP. - Similarly, if we take modulo - deviceNumTopDuplets[mid], we get the id for the - top SP. - - So if threadIdxForMiddleSP = 3, then ib = 1 and it = 0. - - We can use these ids together with - sumBotMidPrefix[mid] and deviceSumTop[mid] to be able - to index our other arrays. - - These other arrays are deviceIndBot and deviceIndTop. - - So to retrieve the bottom SP index for this thread, we'd - have to index the deviceIndBot array at - sumBotMidPrefix[mid] + ib - which is the id for the bottom SP that we just calculated - (ib = 1 in the example). - */ - - vecmem::device_vector sumBotMidPrefix(m_sumBotMidView), - sumTopMidPrefix(m_sumTopMidView); - const auto ib = sumBotMidPrefix[mid] + (threadIdxForMiddleSP / numT); - const auto it = sumTopMidPrefix[mid] + (threadIdxForMiddleSP % numT); - vecmem::device_vector deviceLinBot( - m_linearBotView), - deviceLinTop(m_linearTopView); - const auto linBotEq = deviceLinBot[ib]; - const auto linTopEq = deviceLinTop[it]; - const vecmem::device_vector middleSPs( - m_middleSPsView); - const auto midSP = middleSPs[mid]; - - const auto Vb = linBotEq.v; - const auto Ub = linBotEq.u; - const auto Erb = linBotEq.er; - const auto cotThetab = linBotEq.cotTheta; - const auto iDeltaRb = linBotEq.iDeltaR; - - const auto Vt = linTopEq.v; - const auto Ut = linTopEq.u; - const auto Ert = linTopEq.er; - const auto cotThetat = linTopEq.cotTheta; - const auto iDeltaRt = linTopEq.iDeltaR; - - const auto rM = midSP.r; - const auto varianceRM = midSP.varR; - const auto varianceZM = midSP.varZ; - - auto iSinTheta2 = (1.f + cotThetab * cotThetab); - auto scatteringInRegion2 = m_config.maxScatteringAngle2 * iSinTheta2; - scatteringInRegion2 *= - m_config.sigmaScattering * m_config.sigmaScattering; - auto error2 = Ert + Erb + - 2.f * (cotThetab * cotThetat * varianceRM + varianceZM) * - iDeltaRb * iDeltaRt; - auto deltaCotTheta = cotThetab - cotThetat; - auto deltaCotTheta2 = deltaCotTheta * deltaCotTheta; - - deltaCotTheta = cl::sycl::abs(deltaCotTheta); - auto error = cl::sycl::sqrt(error2); - auto dCotThetaMinusError2 = - deltaCotTheta2 + error2 - 2.f * deltaCotTheta * error; - auto dU = Ut - Ub; - - if ((!(deltaCotTheta2 - error2 > 0.f) || - !(dCotThetaMinusError2 > scatteringInRegion2)) && - !(dU == 0.f)) { - auto A = (Vt - Vb) / dU; - auto S2 = 1.f + A * A; - auto B = Vb - A * Ub; - auto B2 = B * B; - - auto iHelixDiameter2 = B2 / S2; - auto pT2scatter = 4.f * iHelixDiameter2 * m_config.pT2perRadius; - auto p2scatter = pT2scatter * iSinTheta2; - auto Im = cl::sycl::abs((A - B * rM) * rM); - - if (!(S2 < B2 * m_config.minHelixDiameter2) && - !((deltaCotTheta2 - error2 > 0.f) && - (dCotThetaMinusError2 > p2scatter * m_config.sigmaScattering * - m_config.sigmaScattering)) && - !(Im > m_config.impactMax)) { - vecmem::device_vector deviceIndTopDuplets( - m_indTopDupletView); - const auto top = deviceIndTopDuplets[it]; - // this will be the t-th top space point for - // fixed middle and bottom SP - vecmem::device_vector deviceCountTriplets( - m_countTripletsView); - vecmem::atomic obj(&deviceCountTriplets[ib]); - auto t = obj.fetch_add(1); - /* - sumBotTopCombPrefix[mid] - sumCombUptoFirstMiddle: - gives the memory location reserved for this - middle SP - - (idx-sumBotTopCombPrefix[mid]+sumCombUptoFirstMiddle: - this is the nth thread for this middle SP - - (idx-sumBotTopCombPrefix[mid]+sumCombUptoFirstMiddle)/numT: - this is the mth bottom SP for this middle SP - - multiplying this by numT gives the memory - location for this middle and bottom SP - - and by adding t to it, we will end up storing - compatible triplet candidates for this middle - and bottom SP right next to each other - starting from the given memory - */ - const auto tripletIdx = - sumBotTopCombPrefix[mid] - sumCombUptoFirstMiddle + - (((idx - sumBotTopCombPrefix[mid] + sumCombUptoFirstMiddle) / - numT) * - numT) + - t; - - detail::DeviceTriplet T; - T.curvature = B / cl::sycl::sqrt(S2); - T.impact = Im; - T.topSPIndex = top; - vecmem::device_vector deviceCurvImpact( - m_curvImpactView); - deviceCurvImpact[tripletIdx] = T; - } - } - } - } - - private: - vecmem::data::vector_view m_sumBotTopCombView; - const uint32_t m_numTripletSearchThreads; - const uint32_t m_firstMiddle; - const u_int32_t m_lastMiddle; - vecmem::data::jagged_vector_view m_midTopDupletView; - vecmem::data::vector_view m_sumBotMidView; - vecmem::data::vector_view m_sumTopMidView; - vecmem::data::vector_view m_linearBotView; - vecmem::data::vector_view m_linearTopView; - vecmem::data::vector_view m_middleSPsView; - vecmem::data::vector_view m_indTopDupletView; - vecmem::data::vector_view m_countTripletsView; - DeviceSeedFinderConfig m_config; - vecmem::data::vector_view m_curvImpactView; -}; // struct TripletSearch - -} // namespace Acts::Sycl::detail diff --git a/Plugins/Sycl/src/Utilities/Arrays.hpp b/Plugins/Sycl/src/Utilities/Arrays.hpp deleted file mode 100644 index 0c4f141d7448..000000000000 --- a/Plugins/Sycl/src/Utilities/Arrays.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 - -// SYCL include(s). -#include - -// System include(s). -#include -#include - -namespace Acts::Sycl { - -namespace detail { - -/// Deleter functor for the smart pointer type(s) -class DeviceArrayDeleter { - public: - /// Constructor, with the queue that the memory was allocated on/with - DeviceArrayDeleter(cl::sycl::queue& queue) : m_queue(&queue) {} - /// Operator performing the deletion of the memory - void operator()(void* ptr) { - if (ptr != nullptr) { - cl::sycl::free(ptr, *m_queue); - } - } - - private: - /// The queue that manages the memory area in question - cl::sycl::queue* m_queue; -}; // class DeviceArrayDeleter - -} // namespace detail - -/// Convenience type for using (primitive) variable arrays on a SYCL device -template -using device_array = std::unique_ptr; - -/// Function creating a primitive array in SYCL device memory -template -device_array make_device_array(std::size_t size, cl::sycl::queue& queue) { - return device_array(cl::sycl::malloc_device(size, queue), - detail::DeviceArrayDeleter(queue)); -} - -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/src/Utilities/CalculateNdRange.cpp b/Plugins/Sycl/src/Utilities/CalculateNdRange.cpp deleted file mode 100644 index 89e1ad9d8e6b..000000000000 --- a/Plugins/Sycl/src/Utilities/CalculateNdRange.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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/. - -// SYCL plugin include(s) -#include "Acts/Plugins/Sycl/Utilities/CalculateNdRange.hpp" - -namespace Acts::Sycl { -cl::sycl::nd_range<1> calculate1DimNDRange(const uint32_t numThreads, - const uint32_t workGroupSize) { - auto q = (numThreads + workGroupSize - 1) / workGroupSize; - return cl::sycl::nd_range<1>{cl::sycl::range<1>(q * workGroupSize), - cl::sycl::range<1>(workGroupSize)}; -} - -cl::sycl::nd_range<2> calculate2DimNDRange(const uint32_t numThreadsDim0, - const uint32_t numThreadsDim1, - const uint32_t workGroupSize) { - uint32_t wgSizeDim0 = 1; - uint32_t wgSizeDim1 = workGroupSize; - - while (numThreadsDim1 < wgSizeDim1 && 1 < wgSizeDim1 && wgSizeDim1 % 2 == 0) { - wgSizeDim1 /= 2; - wgSizeDim0 *= 2; - } - auto q1 = (numThreadsDim0 + wgSizeDim0 + 1) / wgSizeDim0; - auto q2 = (numThreadsDim1 + wgSizeDim1 + 1) / wgSizeDim1; - return cl::sycl::nd_range<2>{ - cl::sycl::range<2>(q1 * wgSizeDim0, q2 * wgSizeDim1), - cl::sycl::range<2>(wgSizeDim0, wgSizeDim1)}; -} -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/src/Utilities/DeviceSelector.cpp b/Plugins/Sycl/src/Utilities/DeviceSelector.cpp deleted file mode 100644 index 5c2a70a7a5dc..000000000000 --- a/Plugins/Sycl/src/Utilities/DeviceSelector.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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/. - -// SYCL plugin include(s) -#include "Acts/Plugins/Sycl/Utilities/DeviceSelector.hpp" - -// SYCL include -#include - -namespace Acts::Sycl { -DeviceSelector::DeviceSelector(const std::string& deviceName) - : m_defaultSelector(cl::sycl::default_selector()), - m_deviceName(deviceName) {} - -int DeviceSelector::operator()(const cl::sycl::device& d) const { - // Under no circumstances do we accept any NVidia OpenCL devices. - const std::string vendor = d.get_info(); - const std::string version = d.get_info(); - if ((vendor.find("NVIDIA") != std::string::npos) && - (version.find("OpenCL") != std::string::npos)) { - return -1; - } - - // If the user provided a substring of the device name, look for that device - if (!m_deviceName.empty()) { - if (d.get_info().find(m_deviceName) != - std::string::npos) { - return 1; - } else { - return -1; - } - } - - // Otherwise return the value defined by the default selector - return m_defaultSelector(d); -}; -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/src/Utilities/ListPlatforms.cpp b/Plugins/Sycl/src/Utilities/ListPlatforms.cpp deleted file mode 100644 index ee36ace67aa6..000000000000 --- a/Plugins/Sycl/src/Utilities/ListPlatforms.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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/. - -// System include(s) -#include - -// SYCL plugin include(s) -#include "Acts/Plugins/Sycl/Utilities/ListPlatforms.hpp" - -// SYCL include -#include - -namespace Acts::Sycl { -/// @brief This function allows us to list available SYCL platforms and devices. -void listPlatforms() { - for (const sycl::platform& platform : sycl::platform::get_platforms()) { - // Print some information about the platform. - std::cout << "============ Platform ============" << std::endl; - std::cout << " Name : " << platform.get_info() - << std::endl; - std::cout << " Vendor : " - << platform.get_info() << std::endl; - std::cout << " Version: " - << platform.get_info() - << std::endl; - - // Loop over all devices available from this platform. - for (const sycl::device& device : platform.get_devices()) { - // Print some information about the device. - std::cout << "------------- Device -------------" << std::endl; - std::cout << " Name : " << device.get_info() - << std::endl; - std::cout << " Vendor : " << device.get_info() - << std::endl; - std::cout << " Version: " - << device.get_info() << std::endl; - } - } -} -} // namespace Acts::Sycl diff --git a/Plugins/Sycl/src/Utilities/QueueWrapper.cpp b/Plugins/Sycl/src/Utilities/QueueWrapper.cpp deleted file mode 100644 index 5ecc983e1b07..000000000000 --- a/Plugins/Sycl/src/Utilities/QueueWrapper.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020-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/. - -// System include(s) -#include - -// Acts include(s) -#include "Acts/Utilities/Logger.hpp" - -// SYCL plugin include(s) -#include "Acts/Plugins/Sycl/Utilities/DeviceSelector.hpp" -#include "Acts/Plugins/Sycl/Utilities/QueueWrapper.hpp" - -// SYCL include -#include - -namespace Acts::Sycl { - -QueueWrapper::QueueWrapper(const std::string& deviceNameSubstring, - std::unique_ptr incomingLogger) - : m_queue(nullptr), m_ownsQueue(true), m_logger(std::move(incomingLogger)) { - // SYCL kernel exceptions are asynchronous - auto exception_handler = [this](cl::sycl::exception_list exceptions) { - for (std::exception_ptr const& e : exceptions) { - try { - std::rethrow_exception(e); - } catch (std::exception& e) { - ACTS_FATAL("Caught asynchronous (kernel) SYCL exception:\n" << e.what()) - } - } - }; - - // Create queue with custom device selector - m_queue = new cl::sycl::queue(DeviceSelector(deviceNameSubstring), - exception_handler); - m_ownsQueue = true; - - // See which device we are running on. - ACTS_INFO("Running on: " - << m_queue->get_device().get_info()); -} - -QueueWrapper::QueueWrapper(cl::sycl::queue& queue, - std::unique_ptr incomingLogger) - : m_queue(&queue), - m_ownsQueue(false), - m_logger(std::move(incomingLogger)) {} - -QueueWrapper::QueueWrapper(QueueWrapper&& parent) noexcept - : m_queue(parent.m_queue), - m_ownsQueue(parent.m_ownsQueue), - m_logger(std::move(parent.m_logger)) { - parent.m_queue = nullptr; - parent.m_ownsQueue = false; -} - -QueueWrapper::QueueWrapper(const QueueWrapper& other) - : m_queue(other.m_queue), - m_ownsQueue(false), - m_logger(getDefaultLogger("Sycl::QueueWrapper", Logging::INFO)) {} - -QueueWrapper::~QueueWrapper() { - if (m_ownsQueue && (m_queue != nullptr)) { - delete m_queue; - } -} - -QueueWrapper& QueueWrapper::operator=(QueueWrapper&& rhs) noexcept { - // Check whether we have to do anything - if (this == &rhs) { - return *this; - } - - // Destroy this queue, - if (m_ownsQueue && (m_queue != nullptr)) { - delete m_queue; - } - - // Perform the move - m_queue = rhs.m_queue; - m_ownsQueue = rhs.m_ownsQueue; - m_logger = std::move(rhs.m_logger); - rhs.m_queue = nullptr; - rhs.m_ownsQueue = false; - - // Return this object. - return *this; -} - -QueueWrapper& QueueWrapper::operator=(const QueueWrapper& other) { - // Check whether we have to do anything - if (this == &other) { - return *this; - } - - m_queue = other.m_queue; - m_ownsQueue = false; - return *this; -} - -const cl::sycl::queue* QueueWrapper::getQueue() const { - return m_queue; -} - -cl::sycl::queue* QueueWrapper::getQueue() { - return m_queue; -} - -const cl::sycl::queue* QueueWrapper::operator->() const { - return m_queue; -} - -cl::sycl::queue* QueueWrapper::operator->() { - return m_queue; -} - -const cl::sycl::queue& QueueWrapper::operator*() const { - return *m_queue; -} - -cl::sycl::queue& QueueWrapper::operator*() { - return *m_queue; -} - -} // namespace Acts::Sycl diff --git a/Tests/UnitTests/Core/Detector/CuboidalContainerBuilderTests.cpp b/Tests/UnitTests/Core/Detector/CuboidalContainerBuilderTests.cpp index e9b3c6e76302..1d26fc7b0ebc 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 2fb8ac15c053..0137d8ffcd91 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 65a2e9c0a871..dc02f2a894f4 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 ed1fbef6f919..b6f196c5057e 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 c3a7f12ba15b..49d4ddfb1007 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 6b3e71731346..f0a13b368dd5 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 e5732b5f3fa9..4e8b9117f917 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 6d94b9ed7423..6f009e42523c 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 31ddc69e7943..5b2f7e941cb2 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 1619b4891e8a..26bca183611f 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 c93ebd345e81..9b8d8a91203f 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 f06269fcb916..931a55f865de 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 e2713694b0f1..50e6cb4f44ab 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 9aacad07fb4c..44d8dbbae155 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 0fc224e6fcb1..367454ea5e89 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 e784703a77ca..b69ffa4194d6 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 4f4403de8b5d..98e6a4515453 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 fb710f1307d8..286493bdb65f 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 0f692efe5ac4..42a15a860f80 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 785e840da3f1..105aca93ea6e 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 7c045ff1d067..a5785f38006e 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 70b628dee969..cf7ec1fa0e03 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 33778ad6af50..725b67181263 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 84712cfb47bd..24444c17438f 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 2ecc2afb810f..36b6aff16388 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 abe8ca8a0f3d..c5bf26e88dd3 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/Core/TrackFitting/Gx2fTests.cpp b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp index a896d7b96a2d..ad6f43d7d528 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."); } @@ -98,7 +99,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.}; @@ -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; @@ -343,7 +347,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); @@ -357,7 +361,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 +465,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 @@ -540,7 +546,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); @@ -555,7 +561,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 @@ -636,7 +643,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); @@ -650,7 +657,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,10 +916,122 @@ 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"); } + +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 diff --git a/Tests/UnitTests/Fatras/Digitization/CMakeLists.txt b/Tests/UnitTests/Fatras/Digitization/CMakeLists.txt index 8737e163dfce..54f1a7d1cd99 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 fceb680f8733..7950c353d803 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() diff --git a/Tests/UnitTests/Plugins/ActSVG/DetectorSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/DetectorSvgConverterTests.cpp index ba3c463823df..349f6a771128 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 b3451400d7d4..ba2b98d720b2 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 cf8fc707c09b..d51417b3d5ad 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 97110ef00268..9d73ebbc6817 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/CMakeLists.txt b/Tests/UnitTests/Plugins/CMakeLists.txt index 0bbeeaa5f518..1df68a519a5e 100644 --- a/Tests/UnitTests/Plugins/CMakeLists.txt +++ b/Tests/UnitTests/Plugins/CMakeLists.txt @@ -4,7 +4,6 @@ add_subdirectory_if(DD4hep ACTS_BUILD_PLUGIN_DD4HEP) add_subdirectory_if(ExaTrkX ACTS_BUILD_PLUGIN_EXATRKX) add_subdirectory_if(Geant4 ACTS_BUILD_PLUGIN_GEANT4) add_subdirectory_if(Json ACTS_BUILD_PLUGIN_JSON) -add_subdirectory_if(Sycl ACTS_BUILD_PLUGIN_SYCL) add_subdirectory_if(TGeo ACTS_BUILD_PLUGIN_TGEO) add_subdirectory_if(EDM4hep ACTS_BUILD_PLUGIN_EDM4HEP) add_subdirectory_if(FpeMonitoring ACTS_BUILD_PLUGIN_FPEMON) diff --git a/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp index c055d32d69af..5d7336495f13 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 43aa8cf5458e..a596ecbcade0 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 770b9d635886..cc3f15979b0f 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 374e81a9c5aa..b9405d7e0f4c 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/Tests/UnitTests/Plugins/Sycl/CMakeLists.txt b/Tests/UnitTests/Plugins/Sycl/CMakeLists.txt deleted file mode 100644 index ee2583ade9f5..000000000000 --- a/Tests/UnitTests/Plugins/Sycl/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -set(unittest_extra_libraries ActsPluginSycl) -add_subdirectory(Seeding) diff --git a/Tests/UnitTests/Plugins/Sycl/Seeding/ATLASCuts.hpp b/Tests/UnitTests/Plugins/Sycl/Seeding/ATLASCuts.hpp deleted file mode 100644 index ace87b02a55f..000000000000 --- a/Tests/UnitTests/Plugins/Sycl/Seeding/ATLASCuts.hpp +++ /dev/null @@ -1,97 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2023 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once - -#include "Acts/Seeding/IExperimentCuts.hpp" - -#include - -namespace Acts { -template -class ATLASCuts : public IExperimentCuts { - public: - /// Returns seed weight bonus/malus depending on detector considerations. - /// @param bottom bottom space point of the current seed - /// @param middle middle space point of the current seed - /// @param top top space point of the current seed - /// @return seed weight to be added to the seed's weight - float seedWeight(const InternalSpacePoint& bottom, - const InternalSpacePoint& middle, - const InternalSpacePoint& top) const override; - /// @param weight the current seed weight - /// @param bottom bottom space point of the current seed - /// @param middle middle space point of the current seed - /// @param top top space point of the current seed - /// @return true if the seed should be kept, false if the seed should be - /// discarded - bool singleSeedCut(float weight, const InternalSpacePoint& bottom, - const InternalSpacePoint&, - const InternalSpacePoint&) const override; - - /// @param seedCandidates contains collection of seed candidates created for one middle - /// space point in a std::tuple format - /// @return vector of seed candidates that pass the cut - std::vector>::value_type> - cutPerMiddleSP(std::vector>::value_type> - seedCandidates) const override; -}; - -template -float ATLASCuts::seedWeight( - const InternalSpacePoint& bottom, - const InternalSpacePoint&, - const InternalSpacePoint& top) const { - float weight = 0; - if (bottom.radius() > 150) { - weight = 400; - } - if (top.radius() < 150) { - weight = 200; - } - return weight; -} - -template -bool ATLASCuts::singleSeedCut( - float weight, const InternalSpacePoint& b, - const InternalSpacePoint&, - const InternalSpacePoint&) const { - return !(b.radius() > 150. && weight < 380.); -} - -template -std::vector>::value_type> -ATLASCuts::cutPerMiddleSP( - std::vector>::value_type> - seedCandidates) const { - std::vector>::value_type> - newSeedsVector; - - if (seedCandidates.size() <= 1) { - return seedCandidates; - } - - newSeedsVector.push_back(std::move(seedCandidates[0])); - std::size_t itLength = std::min(seedCandidates.size(), std::size_t{5}); - // don't cut first element - for (std::size_t i(1); i < itLength; i++) { - float weight = seedCandidates[i].weight; - const auto& bottom = seedCandidates[i].bottom; - if (weight > 200. || bottom->radius() > 43.) { - newSeedsVector.push_back(std::move(seedCandidates[i])); - } - } - return newSeedsVector; -} -} // namespace Acts diff --git a/Tests/UnitTests/Plugins/Sycl/Seeding/CMakeLists.txt b/Tests/UnitTests/Plugins/Sycl/Seeding/CMakeLists.txt deleted file mode 100644 index 48991b390b2e..000000000000 --- a/Tests/UnitTests/Plugins/Sycl/Seeding/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# This file is part of the Acts project. -# -# Copyright (C) 2020-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/. - -add_executable(ActsUnitTestSeedFinderSycl - SeedFinderSyclTest.cpp - CommandLineArguments.h - CommandLineArguments.cpp - ATLASCuts.hpp - SpacePoint.hpp) -target_link_libraries(ActsUnitTestSeedFinderSycl - PRIVATE Boost::program_options ActsCore ActsPluginSycl - vecmem::core vecmem::sycl) diff --git a/Tests/UnitTests/Plugins/Sycl/Seeding/CommandLineArguments.cpp b/Tests/UnitTests/Plugins/Sycl/Seeding/CommandLineArguments.cpp deleted file mode 100644 index f8b3c4611926..000000000000 --- a/Tests/UnitTests/Plugins/Sycl/Seeding/CommandLineArguments.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 "CommandLineArguments.h" - -#include "Acts/Plugins/Sycl/Utilities/ListPlatforms.hpp" - -#include -#include - -#include -#include - -namespace po = boost::program_options; - -void CommandLineArguments::parse(int argc, char** argv) { - po::options_description optionsDescription("Allowed options"); - optionsDescription.add_options()("help,h", "Print usage message.")( - "FILE,f", po::value()->default_value(""), - "Provide path for input file.")( - "NUM,n", po::value()->default_value(500), - "Number of groups to iterate in seed finding.")( - "DEVICE,d", po::value()->default_value(""), - "Provide a substring of the preferred device.")( - "LIST,l", "List available SYCL platforms and devices.")( - "GPU,G", po::bool_switch(), "Execute code only on gpu. Default is 0.")( - "ALL,a", po::bool_switch(), "Analyze all groups. Default is 0.")( - "MATCH,m", po::bool_switch(), "Count seed matches. Default is 0.")( - "CSV,c", po::bool_switch(), "Output results in csv format"); - - po::variables_map vm; - po::store(po::parse_command_line(argc, argv, optionsDescription), vm); - po::notify(vm); - - if (vm.count("help") != 0) { - std::cout << optionsDescription << "\n"; - exit(0); - } - - if (vm.count("LIST") != 0) { - Acts::Sycl::listPlatforms(); - exit(0); - } - - onlyGpu = vm["GPU"].as(); - matches = vm["MATCH"].as(); - groups = vm["NUM"].as(); - deviceName = vm["DEVICE"].as(); - allgroup = vm["ALL"].as(); - csvFormat = vm["CSV"].as(); - inpFileName = vm["FILE"].as(); - std::ifstream s(inpFileName); - inpFileExists = s.good(); -} diff --git a/Tests/UnitTests/Plugins/Sycl/Seeding/CommandLineArguments.h b/Tests/UnitTests/Plugins/Sycl/Seeding/CommandLineArguments.h deleted file mode 100644 index 2410fd02f831..000000000000 --- a/Tests/UnitTests/Plugins/Sycl/Seeding/CommandLineArguments.h +++ /dev/null @@ -1,25 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020-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/. - -#pragma once - -#include - -struct CommandLineArguments { - void parse(int argc, char** argv); - bool allgroup = false; - bool onlyGpu = false; - bool matches = false; - unsigned int groups = 500; - bool inpFileExists = false; - bool dirExists = false; - bool outFileExists = false; - std::string deviceName = ""; - std::string inpFileName = ""; - bool csvFormat = false; -}; diff --git a/Tests/UnitTests/Plugins/Sycl/Seeding/SeedFinderSyclTest.cpp b/Tests/UnitTests/Plugins/Sycl/Seeding/SeedFinderSyclTest.cpp deleted file mode 100644 index 7d54c77cc9fd..000000000000 --- a/Tests/UnitTests/Plugins/Sycl/Seeding/SeedFinderSyclTest.cpp +++ /dev/null @@ -1,369 +0,0 @@ -// 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/EventData/SpacePointData.hpp" -#include "Acts/Plugins/Sycl/Seeding/SeedFinder.hpp" -#include "Acts/Plugins/Sycl/Utilities/QueueWrapper.hpp" -#include "Acts/Seeding/BinnedGroup.hpp" -#include "Acts/Seeding/InternalSeed.hpp" -#include "Acts/Seeding/InternalSpacePoint.hpp" -#include "Acts/Seeding/Seed.hpp" -#include "Acts/Seeding/SeedFilter.hpp" -#include "Acts/Seeding/SeedFinder.hpp" -#include "Acts/Seeding/SeedFinderConfig.hpp" -#include "Acts/Seeding/SpacePointGrid.hpp" -#include "Acts/Utilities/GridBinFinder.hpp" -#include "Acts/Utilities/Logger.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "ATLASCuts.hpp" -#include "CommandLineArguments.h" -#include "SpacePoint.hpp" -#include "vecmem/memory/sycl/device_memory_resource.hpp" -#include "vecmem/memory/sycl/host_memory_resource.hpp" - -using namespace Acts::UnitLiterals; - -auto readFile(const std::string& filename) -> std::vector { - std::string line; - std::vector readSP; - - std::ifstream spFile(filename); - if (spFile.is_open()) { - int id = 0; - while (std::getline(spFile, line)) { - std::stringstream ss(line); - std::string linetype; - ss >> linetype; - if (linetype == "lxyz") { - float x; - float y; - float z; - float r; - float varianceR; - float varianceZ; - int layer; - ss >> layer >> x >> y >> z >> varianceR >> varianceZ; - r = std::hypot(x, y); - float f22 = varianceR; - float wid = varianceZ; - float cov = wid * wid * .08333; - if (cov < f22) - cov = f22; - if (std::abs(z) > 450.) { - varianceZ = 9. * cov; - varianceR = .06; - } else { - varianceR = 9. * cov; - varianceZ = .06; - } - readSP.emplace_back( - new SpacePoint(x, y, z, r, layer, varianceR, varianceZ, id)); - ++id; - } - } - } - return readSP; -} - -template -auto setupSeedFinderConfiguration() - -> Acts::SeedFinderConfig { - Acts::SeedFinderConfig config; - // silicon detector max - config.rMax = 160._mm; - config.deltaRMin = 5._mm; - config.deltaRMax = 160._mm; - config.deltaRMinTopSP = config.deltaRMin; - config.deltaRMinBottomSP = config.deltaRMin; - config.deltaRMaxTopSP = config.deltaRMax; - config.deltaRMaxBottomSP = config.deltaRMax; - config.collisionRegionMin = -250._mm; - config.collisionRegionMax = 250._mm; - config.zMin = -2800._mm; - config.zMax = 2800._mm; - config.maxSeedsPerSpM = 5; - // 2.7 eta - config.cotThetaMax = 7.40627; - config.sigmaScattering = 1.00000; - config.minPt = 500._MeV; - config.impactMax = 10._mm; - // for sycl - config.nTrplPerSpBLimit = 100; - config.nAvgTrplPerSpBLimit = 6; - return config; -} - -auto setupSeedFinderOptions() { - Acts::SeedFinderOptions options; - options.bFieldInZ = 2_T; - options.beamPos = {-.5_mm, -.5_mm}; - return options; -} - -template -auto setupSpacePointGridConfig( - const Acts::SeedFinderConfig& config, - const Acts::SeedFinderOptions& options) - -> std::pair { - Acts::CylindricalSpacePointGridConfig gridConf{}; - gridConf.minPt = config.minPt; - gridConf.rMax = config.rMax; - gridConf.zMax = config.zMax; - gridConf.zMin = config.zMin; - gridConf.deltaRMax = config.deltaRMax; - gridConf.cotThetaMax = config.cotThetaMax; - - Acts::CylindricalSpacePointGridOptions gridOpts{}; - gridOpts.bFieldInZ = options.bFieldInZ; - return std::make_pair(gridConf, gridOpts); -} - -auto main(int argc, char** argv) -> int { - auto start_prep = std::chrono::system_clock::now(); - - CommandLineArguments cmdlTool; - cmdlTool.parse(argc, argv); - - if (!cmdlTool.inpFileName.empty() && !cmdlTool.inpFileExists) { - std::cerr << "Input file not found\n"; - return -1; - } - - auto spVec = readFile(cmdlTool.inpFileName); - - int numPhiNeighbors = 1; - - // extent used to store r range for middle spacepoint - Acts::Extent rRangeSPExtent; - - const Acts::Range1D rMiddleSPRange; - - std::vector> zBinNeighborsTop; - std::vector> zBinNeighborsBottom; - - auto bottomBinFinder = std::make_unique>( - Acts::GridBinFinder<2ul>(numPhiNeighbors, zBinNeighborsBottom)); - auto topBinFinder = std::make_unique>( - Acts::GridBinFinder<2ul>(numPhiNeighbors, zBinNeighborsTop)); - auto config = setupSeedFinderConfiguration(); - config = config.toInternalUnits().calculateDerivedQuantities(); - auto options = setupSeedFinderOptions(); - options = options.toInternalUnits().calculateDerivedQuantities(config); - - Acts::ATLASCuts atlasCuts = Acts::ATLASCuts(); - Acts::Sycl::DeviceExperimentCuts deviceAtlasCuts; - config.seedFilter = std::make_unique>( - Acts::SeedFilter(Acts::SeedFilterConfig(), &atlasCuts)); - - const Acts::Logging::Level logLvl = - cmdlTool.csvFormat ? Acts::Logging::WARNING : Acts::Logging::INFO; - Acts::Sycl::QueueWrapper queue( - cmdlTool.deviceName, - Acts::getDefaultLogger("Sycl::QueueWrapper", logLvl)); - vecmem::sycl::host_memory_resource resource(queue.getQueue()); - vecmem::sycl::device_memory_resource device_resource(queue.getQueue()); - Acts::Sycl::SeedFinder syclSeedFinder( - config, options, deviceAtlasCuts, queue, resource, &device_resource); - Acts::SeedFinder> - normalSeedFinder(config); - auto globalTool = [=](const SpacePoint& sp, float /*unused*/, - float /*unused*/, float /*unused*/) - -> std::tuple> { - Acts::Vector3 position(sp.x(), sp.y(), sp.z()); - Acts::Vector2 covariance(sp.varianceR, sp.varianceZ); - return std::make_tuple(position, covariance, std::nullopt); - }; - auto [gridConfig, gridOpts] = setupSpacePointGridConfig(config, options); - gridConfig = gridConfig.toInternalUnits(); - gridOpts = gridOpts.toInternalUnits(); - Acts::CylindricalSpacePointGrid grid = - Acts::CylindricalSpacePointGridCreator::createGrid(gridConfig, - gridOpts); - Acts::CylindricalSpacePointGridCreator::fillGrid(config, options, grid, - spVec.begin(), spVec.end(), - globalTool, rRangeSPExtent); - - std::array, 2ul> navigation; - auto spGroup = Acts::CylindricalBinnedGroup( - std::move(grid), *bottomBinFinder, *topBinFinder, std::move(navigation)); - - auto end_prep = std::chrono::system_clock::now(); - - std::chrono::duration elapsec_prep = end_prep - start_prep; - double prepTime = elapsec_prep.count(); - - if (!cmdlTool.csvFormat) { - std::cout << "read " << spVec.size() << " SP from file " - << cmdlTool.inpFileName << std::endl; - std::cout << "Preparation time: " << std::to_string(prepTime) << std::endl; - } - - // -------------------------------------- // - // ----------- EXECUTE ON CPU ----------- // - // -------------------------------------- // - - auto start_cpu = std::chrono::system_clock::now(); - uint group_count = 0; - std::vector>> seedVector_cpu; - - if (!cmdlTool.onlyGpu) { - decltype(normalSeedFinder)::SeedingState state; - for (auto [bottom, middle, top] : spGroup) { - normalSeedFinder.createSeedsForGroup( - options, state, spGroup.grid(), - std::back_inserter(seedVector_cpu.emplace_back()), bottom, middle, - top, rMiddleSPRange); - group_count++; - if (!cmdlTool.allgroup && group_count >= cmdlTool.groups) { - break; - } - } - } - - auto end_cpu = std::chrono::system_clock::now(); - - if (!cmdlTool.csvFormat) { - std::cout << "Analyzed " << group_count << " groups for CPU" << std::endl; - } - - // -------------------------------------- // - // -------- EXECUTE ON GPU - SYCL ------- // - // -------------------------------------- // - - auto start_sycl = std::chrono::system_clock::now(); - - group_count = 0; - std::vector>> seedVector_sycl; - - Acts::SpacePointData spacePointData; - spacePointData.resize(spVec.size()); - - for (auto [bottom, middle, top] : spGroup) { - seedVector_sycl.push_back(syclSeedFinder.createSeedsForGroup( - spacePointData, spGroup.grid(), bottom, middle, top)); - group_count++; - if (!cmdlTool.allgroup && group_count >= cmdlTool.groups) { - break; - } - } - auto end_sycl = std::chrono::system_clock::now(); - - if (!cmdlTool.csvFormat) { - std::cout << "Analyzed " << group_count << " groups for SYCL" << std::endl; - } - - std::chrono::duration elapsec_cpu = end_cpu - start_cpu; - double cpuTime = elapsec_cpu.count(); - - std::chrono::duration elapsec_sycl = end_sycl - start_sycl; - double syclTime = elapsec_sycl.count(); - - auto textWidth = 20; - auto numWidth = 11; - - int nSeed_cpu = 0; - int nSeed_sycl = 0; - int nMatch = 0; - - if (cmdlTool.matches && !cmdlTool.onlyGpu) { - for (auto& outVec : seedVector_cpu) { - nSeed_cpu += outVec.size(); - } - - for (auto& outVec : seedVector_sycl) { - nSeed_sycl += outVec.size(); - } - - for (std::size_t i = 0; i < seedVector_cpu.size(); i++) { - auto regionVec_cpu = seedVector_cpu[i]; - auto regionVec_sycl = seedVector_sycl[i]; - - std::vector> seeds_cpu; - std::vector> seeds_sycl; - - for (const auto& sd : regionVec_cpu) { - std::vector seed_cpu; - seed_cpu.push_back(*(sd.sp()[0])); - seed_cpu.push_back(*(sd.sp()[1])); - seed_cpu.push_back(*(sd.sp()[2])); - seeds_cpu.push_back(seed_cpu); - } - for (const auto& sd : regionVec_sycl) { - std::vector seed_sycl; - seed_sycl.push_back(*(sd.sp()[0])); - seed_sycl.push_back(*(sd.sp()[1])); - seed_sycl.push_back(*(sd.sp()[2])); - seeds_sycl.push_back(seed_sycl); - } - - for (auto seed : seeds_cpu) { - for (auto other : seeds_sycl) { - if (seed[0] == other[0] && seed[1] == other[1] && - seed[2] == other[2]) { - nMatch++; - break; - } - } - } - } - } - - if (!cmdlTool.csvFormat) { - std::cout << std::endl; - std::cout - << "------------------------- Time Metric -------------------------" - << std::endl; - std::cout << std::setw(textWidth) << " Device:"; - std::cout << std::setw(numWidth) << "CPU"; - std::cout << std::setw(numWidth) << "SYCL"; - std::cout << std::setw(textWidth) << "Speedup/ Agreement" << std::endl; - std::cout << std::setw(textWidth) << " Time (s):"; - std::cout << std::setw(numWidth) << std::to_string(cpuTime); - std::cout << std::setw(numWidth) << std::to_string(syclTime); - std::cout << std::setw(textWidth) << std::to_string(cpuTime / syclTime); - std::cout << std::endl; - - if (cmdlTool.matches && !cmdlTool.onlyGpu) { - std::cout << std::setw(textWidth) << " Seeds found:"; - std::cout << std::setw(numWidth) << std::to_string(nSeed_cpu); - std::cout << std::setw(numWidth) << std::to_string(nSeed_sycl); - std::cout << std::setw(textWidth) - << std::to_string(static_cast(nMatch) / nSeed_cpu * 100); - std::cout << std::endl; - } - - std::cout - << "---------------------------------------------------------------" - << std::endl; - std::cout << std::endl; - } else { - std::cout << cpuTime << ',' << syclTime << ',' << cpuTime / syclTime << ',' - << nSeed_cpu << ',' << nSeed_sycl << ',' << nMatch << '\n'; - } - - for (const auto* S : spVec) { - delete[] S; - } - - return 0; -} diff --git a/Tests/UnitTests/Plugins/Sycl/Seeding/SpacePoint.hpp b/Tests/UnitTests/Plugins/Sycl/Seeding/SpacePoint.hpp deleted file mode 100644 index f268bbef7096..000000000000 --- a/Tests/UnitTests/Plugins/Sycl/Seeding/SpacePoint.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 - -struct SpacePoint { - SpacePoint() = default; - ; - SpacePoint(float p_x, float p_y, float p_z, float p_r, int p_surface, - float p_varianceR, float p_varianceZ, int p_id) - : varianceR(p_varianceR), - varianceZ(p_varianceZ), - m_surface(p_surface), - m_id(p_id), - m_x(p_x), - m_y(p_y), - m_z(p_z), - m_r(p_r) {} - - float x() const { return m_x; } - float y() const { return m_y; } - float z() const { return m_z; } - float r() const { return m_r; } - int id() const { return m_id; } - int surface() const { return m_surface; } - friend bool operator==(const SpacePoint &a, const SpacePoint &b); - float varianceR; - float varianceZ; - int m_surface; - - private: - int m_id; - float m_x; - float m_y; - float m_z; - float m_r; -}; - -bool operator==(const SpacePoint &a, const SpacePoint &b) { - return a.m_id == b.m_id; -} diff --git a/cmake/ActsConfig.cmake.in b/cmake/ActsConfig.cmake.in index b82fd8bf7a78..0233e09c74a7 100644 --- a/cmake/ActsConfig.cmake.in +++ b/cmake/ActsConfig.cmake.in @@ -88,11 +88,6 @@ if(NOT @ACTS_USE_SYSTEM_EIGEN3@) target_include_directories(Eigen3::Eigen INTERFACE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") endif() -# dependencies which cannot be searched in CONFIG mode -if(PluginSycl IN_LIST Acts_COMPONENTS) - find_package(SYCL REQUIRED) -endif() - if(PluginPodio IN_LIST Acts_COMPONENTS) include(${CMAKE_CURRENT_LIST_DIR}/ActsPodioEdmTargets.cmake) endif() diff --git a/cmake/ActsCreatePackageConfig.cmake b/cmake/ActsCreatePackageConfig.cmake index 6fd6e543bb6c..6cfbd570f072 100644 --- a/cmake/ActsCreatePackageConfig.cmake +++ b/cmake/ActsCreatePackageConfig.cmake @@ -27,7 +27,6 @@ install( install( FILES ${CMAKE_CURRENT_LIST_DIR}/FindOnnxRuntime.cmake - ${CMAKE_CURRENT_LIST_DIR}/FindSYCL.cmake DESTINATION ${install_package_config_dir}/Modules) # install target configs for all available components diff --git a/cmake/ActsExternSources.cmake b/cmake/ActsExternSources.cmake new file mode 100644 index 000000000000..213bdccb6d8f --- /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/cmake/FindSYCL.cmake b/cmake/FindSYCL.cmake deleted file mode 100644 index eb1cc30feabe..000000000000 --- a/cmake/FindSYCL.cmake +++ /dev/null @@ -1,192 +0,0 @@ -# This file is part of the Acts project. -# -# Copyright (C) 2020 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/. -# -# This module is used to find out whether the C++ compiler set up to build the -# project is able to compile SYCL code. If so, it provides helper variables -# to the project configuration to set up the build of SYCL -# libraries/executables. -# -# Variable(s) set up by the module: -# - SYCL_FOUND: Boolean, set to TRUE when SYCL compilation is available. -# - acts_target_setup_sycl( [DEPENDENCY PUBLIC|PRIVATE|INTERFACE] ): -# Helper function for setting up a target (library or executable) for -# "SYCL compilation". Provides an optional argument for specifying -# how/whether the target exposes this SYCL dependency. -# -# Technical/internal variable(s) set up by the module: -# - SYCL_builtin_FOUND: Boolean, set to TRUE when the C++ compiler can itself -# understand/build SYCL code. -# - SYCL_builtin_TARGETS: List of strings with the target platforms that the -# compiler can generate code for. -# - SYCL_INCLUDE_DIR: Directory holding the (try)SYCL header(s). -# -# Variable(s) used to control the module's behaviour: -# - SYCL_FLAGS: A list of compiler options that triggers a "SYCL build" from -# the configured C++ compiler. Can be used to pass extra flags -# to the SYCL compilation, if needed. -# - SYCL_SEARCH_SUPPORT_LIBRARIES: A list of library (object file) names (more -# like "name fragments") to include in linking SYCL binaries. By default -# the code only looks for libsycl-glibc.o (or libsycl-msvc.o on Windows), -# and libsycl-cmath.o. But one may need to use other object files (for -# complex or 64-bit mathematics) coming with the Intel compiler as well. -# -# A typical use of the module would look like: -# -# find_package( SYCL ) -# if( SYCL_FOUND ) -# atlas_add_library( SYCLAidedLibrary ... ) -# acts_target_setup_sycl( SYCLAidedLibrary DEPENDENCY PRIVATE ) -# endif() -# - -# This module needs at least CMake 3.13. -cmake_minimum_required( VERSION 3.13 ) - -# We use CMake's built-in modules, used to look for SYCL capabilities. -include( CheckIncludeFileCXX ) -include( CheckCXXSourceCompiles ) -include( CMakeParseArguments ) -include( FindPackageHandleStandardArgs ) -set( CMAKE_REQUIRED_QUIET TRUE ) - -# Greet the user. -if( NOT SYCL_FIND_QUIETLY ) - message( STATUS "Checking if ${CMAKE_CXX_COMPILER} is SYCL capable..." ) -endif() - -# Set up the flag(s) needed for SYCL code compilation. -set( SYCL_FLAGS "-fsycl" CACHE STRING - "Compiler flags to use for SYCL compilation" ) -mark_as_advanced( SYCL_FLAGS ) - -# First check if the compiler is able to compile code using on -# its own, without any additional headers. -check_include_file_cxx( "CL/sycl.hpp" SYCL_builtin_FOUND "${SYCL_FLAGS}" ) - -# If that worked, we must be using a Clang version that understands sycl -# natively. -if( SYCL_builtin_FOUND ) - # Mark that SYCL is found. - if( NOT SYCL_FIND_QUIETLY ) - message( STATUS - "Checking if ${CMAKE_CXX_COMPILER} is SYCL capable... success" ) - message( STATUS "Checking for available SYCL target(s)..." ) - endif() - set( SYCL_FOUND TRUE ) - # Figure out which SYCL target platforms are available. - set( SYCL_POSSIBLE_TARGETS "spir64-unknown-unknown-sycldevice" - CACHE STRING "List of targets to check the availability of" ) - mark_as_advanced( SYCL_POSSIBLE_TARGETS ) - set( SYCL_builtin_TARGETS ) - foreach( _target ${SYCL_POSSIBLE_TARGETS} ) - set( CMAKE_REQUIRED_FLAGS "-fsycl -fsycl-targets=${_target}" ) - check_cxx_source_compiles( " - #include - int main() { - cl::sycl::platform::get_platforms(); - return 0; - } - " _syclTarget${_target}Found ) - if( _syclTarget${_target}Found ) - if( NOT SYCL_FIND_QUIETLY ) - message( STATUS " - Found target: ${_target}" ) - endif() - list( APPEND SYCL_builtin_TARGETS ${_target} ) - endif() - unset( _syclTarget${_target}Found ) - endforeach() - if( NOT SYCL_FIND_QUIETLY ) - message( STATUS "Checking for available SYCL target(s)... done" ) - endif() - if( NOT "${SYCL_builtin_TARGETS}" STREQUAL "" ) - string( REPLACE ";" "," _targets "${SYCL_builtin_TARGETS}" ) - list( APPEND SYCL_FLAGS "-fsycl-targets=${_targets}" ) - unset( _targets ) - endif() - # Look for object files holding SYCL device code, which would be needed for - # the final binaries. - set( SYCL_SEARCH_SUPPORT_LIBRARIES "" CACHE STRING - "List of support libraries / object files to look for and link" ) - mark_as_advanced( SYCL_SEARCH_SUPPORT_LIBRARIES ) - get_filename_component( _compilerDir "${CMAKE_CXX_COMPILER}" DIRECTORY ) - set( SYCL_SUPPORT_LIBRARIES ) - foreach( _supportLib ${SYCL_SEARCH_SUPPORT_LIBRARIES} ) - find_file( SYCL_${_supportLib}_OBJECT_FILE - NAMES "libsycl-${_supportLib}${CMAKE_CXX_OUTPUT_EXTENSION}" - PATHS "${_compilerDir}" - PATH_SUFFIXES "../lib" "../lib64" ) - if( SYCL_${_supportLib}_OBJECT_FILE ) - list( APPEND SYCL_SUPPORT_LIBRARIES - "${SYCL_${_supportLib}_OBJECT_FILE}" ) - endif() - endforeach() - unset( _compilerDir ) - # Set up the acts_target_setup_sycl function. - if( NOT COMMAND acts_target_setup_sycl ) - function( acts_target_setup_sycl targetName ) - cmake_parse_arguments( ARG "" "DEPENDENCY" "" ${ARGN} ) - if( NOT ARG_DEPENDENCY ) - set( ARG_DEPENDENCY "PRIVATE" ) - endif() - target_compile_options( ${targetName} ${ARG_DEPENDENCY} ${SYCL_FLAGS} ) - target_link_options( ${targetName} ${ARG_DEPENDENCY} ${SYCL_FLAGS} ) - target_sources( ${targetName} ${ARG_DEPENDENCY} - ${SYCL_SUPPORT_LIBRARIES} ) - endfunction( acts_target_setup_sycl ) - endif() -else() - if( NOT SYCL_FIND_QUIETLY ) - message( STATUS - "Checking if ${CMAKE_CXX_COMPILER} is SYCL capable... failure" ) - message( STATUS "Looking for the (tri)SYCL header(s)..." ) - endif() - # If the compiler is not providing SYCL capabilities itself, check if we - # have the (tri)SYCL headers available somewhere. - find_path( SYCL_INCLUDE_DIR - NAMES "CL/sycl.hpp" "SYCL/sycl.hpp" "triSYCL/sycl.hpp" - PATH_SUFFIXES include ${CMAKE_INSTALL_INCLUDEDIR} include/triSYCL - ${CMAKE_INSTALL_INCLUDEDIR}/triSYCL - DOC "Location of the (tri)SYCL header(s)" ) - # Look for Boost as well, as these headers need it. - if( SYCL_FIND_QUIETLY ) - find_package( Boost QUIET ) - else() - find_package( Boost ) - endif() - # Check if we found everything. - if( SYCL_INCLUDE_DIR AND Boost_FOUND ) - # Mark that SYCL is found. - if( NOT SYCL_FIND_QUIETLY ) - message( STATUS "Found (tri)SYCL headers: ${SYCL_INCLUDE_DIR}" ) - endif() - set( SYCL_FOUND TRUE ) - # Set up the acts_target_setup_sycl function. - if( NOT COMMAND acts_target_setup_sycl ) - function( acts_target_setup_sycl targetName ) - cmake_parse_arguments( ARG "" "DEPENDENCY" "" ${ARGN} ) - if( NOT ARG_DEPENDENCY ) - set( ARG_DEPENDENCY "PRIVATE" ) - endif() - target_include_directories( ${targetName} SYSTEM ${ARG_DEPENDENCY} - ${Boost_INCLUDE_DIRS} ${SYCL_INCLUDE_DIR} ) - target_link_libraries( ${targetName} ${ARG_DEPENDENCY} - ${Boost_LIBRARIES} ) - endfunction( acts_target_setup_sycl ) - endif() - else() - # We did not find a viable SYCL version. - if( NOT SYCL_FIND_QUIETLY ) - message( STATUS "Looking for the (tri)SYCL header(s)... failure" ) - endif() - set( SYCL_FOUND FALSE ) - endif() -endif() - -# Handle the standard find_package(...) arguments explicitly. -find_package_handle_standard_args( SYCL - REQUIRED_VARS CMAKE_CXX_COMPILER SYCL_FOUND ) diff --git a/docs/core/geometry/layerless/layerless.md b/docs/core/geometry/layerless/layerless.md index 18c22c86e1e0..b9784ac1f74e 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} diff --git a/docs/getting_started.md b/docs/getting_started.md index c24fca751e44..d21392cfa021 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -41,7 +41,6 @@ components: - [Pythia8](https://pythia.org) for some examples - [ROOT](https://root.cern.ch) >= 6.20 for the TGeo plugin and the examples - [Sphinx](https://www.sphinx-doc.org) >= 2.0 with [Breathe](https://breathe.readthedocs.io/en/latest/), [Exhale](https://exhale.readthedocs.io/en/latest/), and [recommonmark](https://recommonmark.readthedocs.io/en/latest/index.html) extensions for the documentation -- [SYCL](https://www.khronos.org/sycl/) for the SYCL plugin - [cugraph](https://github.com/rapidsai/cugraph) for the Exa.TrkX plugin - [libtorch](https://pytorch.org/cppdocs/installing.html) for the Exa.TrkX plugin - [Pybind11](https://github.com/pybind/pybind11) for the Python bindings of the examples @@ -268,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` | @@ -277,9 +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_BUILD_PLUGIN_SYCL | Build SYCL plugin
type: `bool`, default: `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 9aa70a450aa8..30161ebb2769 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 dfd85283977c..b841c8c5dea1 100644 --- a/thirdparty/GeoModel/CMakeLists.txt +++ b/thirdparty/GeoModel/CMakeLists.txt @@ -17,17 +17,10 @@ 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 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 72dc546a202c..2da1b0c7aa54 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 000000000000..a0126cece7ff --- /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 000000000000..6b95916ea757 --- /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 e802ed9662f0..94c51b9dbca0 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 000000000000..b74710c587be --- /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 000000000000..dbc48747511a --- /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 000000000000..961057df9339 --- /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 000000000000..69c36ad60767 --- /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 4c0a94a0d732..d95941b84062 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 000000000000..4b2960be0967 --- /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 26ac8d0b4ddd..7aefc97f2bf1 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 52851da85f93..39aedcb2d5cf 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 cfd22447e356..60b95573dfcb 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 000000000000..b62c9ba35f06 --- /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 000000000000..d7d1c3d1a23f --- /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 8b6c80a1d05f..b6d746154713 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 )