Skip to content

Commit

Permalink
Merge branch 'main' into refactor-navigation-options
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand authored May 24, 2024
2 parents e3a2cb4 + 273278b commit 09f5040
Show file tree
Hide file tree
Showing 134 changed files with 2,044 additions and 1,398 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -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: '^<[^/.]*>'
Expand Down
65 changes: 59 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -46,8 +49,18 @@ option(ACTS_BUILD_PLUGIN_JSON "Build json plugin" OFF)
option(ACTS_USE_SYSTEM_NLOHMANN_JSON "Use nlohmann::json provided by the system instead of the bundled version" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_BUILD_PLUGIN_LEGACY "Build legacy plugin" OFF)
option(ACTS_BUILD_PLUGIN_ONNX "Build ONNX plugin" OFF)
option(ACTS_SETUP_COVFIE "Explicitly set up covfie for the project" OFF)
option(ACTS_USE_SYSTEM_COVFIE "Use a system-provided covfie installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_SETUP_DETRAY "Explicitly set up detray for the project" OFF)
option(ACTS_USE_SYSTEM_DETRAY "Use a system-provided detray installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_SETUP_TRACCC "Explicitly set up traccc for the project" OFF)
option(ACTS_USE_SYSTEM_TRACCC "Use a system-provided traccc installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_SETUP_DFELIBS "Explicitly set up dfelibs for the project" ON)
option(ACTS_USE_SYSTEM_DFELIBS "Use a system-provided dfelibs installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_SETUP_VECMEM "Explicitly set up vecmem for the project" OFF)
option(ACTS_USE_SYSTEM_VECMEM "Use a system-provided vecmem installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_SETUP_ALGEBRAPLUGINS "Explicitly set up algebra-plugins for the project" OFF)
option(ACTS_USE_SYSTEM_ALGEBRAPLUGINS "Use a system-provided algebra-plugins installation" ${ACTS_USE_SYSTEM_LIBS})
option(ACTS_BUILD_PLUGIN_TGEO "Build TGeo plugin" OFF)
# fatras related options
option(ACTS_BUILD_FATRAS "Build FAst TRAcking Simulation package" OFF)
Expand Down Expand Up @@ -118,6 +131,7 @@ set_option_if(
OR ACTS_BUILD_EXAMPLES_BINARIES
OR ACTS_BUILD_EVERYTHING)
# core plugins might be required by examples or depend on each other

set_option_if(
ACTS_BUILD_PLUGIN_DD4HEP
ACTS_BUILD_EXAMPLES_DD4HEP OR ACTS_BUILD_EVERYTHING OR
Expand Down Expand Up @@ -184,9 +198,9 @@ set(_acts_boost_version 1.71.0)
set(_acts_dd4hep_version 1.21)
set(_acts_edm4hep_version 0.7)
set(_acts_geomodel_version 4.6.0)
set(_acts_eigen3_version 3.3.7)
set(_acts_podio_version 0.16)
set(_acts_doxygen_version 1.9.4)
set(_acts_eigen3_version 3.3.7)
set(_acts_hepmc3_version 3.2.1)
set(_acts_nlohmanjson_version 3.2.0)
set(_acts_onnxruntime_version 1.12.0)
Expand All @@ -197,6 +211,9 @@ set(_acts_tbb_version 2020.1)
# this version we will try so.
set(_acts_boost_recommended_version 1.78.0)

# Include the sources for the external dependencies.
include(ActsExternSources)

# required packages
if (ACTS_SETUP_BOOST)
if (ACTS_USE_SYSTEM_BOOST)
Expand Down Expand Up @@ -227,11 +244,29 @@ if (ACTS_SETUP_EIGEN3)
endif()
endif()

if (ACTS_SETUP_DFELIBS)
if (ACTS_USE_SYSTEM_DFELIBS)
find_package(dfelibs ${_acts_dfelibs_version} REQUIRED)
else()
add_subdirectory(thirdparty/dfelibs)
endif()
endif()

if (ACTS_SETUP_VECMEM)
if (ACTS_USE_SYSTEM_VECMEM)
find_package(vecmem REQUIRED)
find_package(vecmem ${_acts_vecmem_version} REQUIRED)
else()
add_subdirectory(thirdparty/vecmem)
# Make the "VecMem language code" available for the whole project.
include( "${VECMEM_LANGUAGE_DIR}/vecmem-check-language.cmake" )
endif()
endif()

if (ACTS_SETUP_ALGEBRAPLUGINS)
if (ACTS_USE_SYSTEM_ALGEBRAPLUGINS)
find_package(algebra-plugins ${_acts_algebraplugins_version} REQUIRED)
else()
add_subdirectory(thirdparty/algebra-plugins)
endif()
endif()

Expand Down Expand Up @@ -269,9 +304,30 @@ endmacro()
# when a particular package is actually needed.

# plugin dependencies
if(ACTS_SETUP_COVFIE)
if(ACTS_USE_SYSTEM_COVFIE)
find_package(covfie ${_acts_covfie_version} REQUIRED CONFIG)
else()
add_subdirectory(thirdparty/covfie)
endif()
endif()
if(ACTS_SETUP_DETRAY)
if(ACTS_USE_SYSTEM_DETRAY)
find_package(detray ${_acts_detray_version} REQUIRED CONFIG)
else()
add_subdirectory(thirdparty/detray)
endif()
endif()
if(ACTS_SETUP_TRACCC)
if(ACTS_USE_SYSTEM_TRACCC)
find_package(traccc ${_acts_traccc_version} REQUIRED CONFIG)
else()
add_subdirectory(thirdparty/traccc)
endif()
endif()

if(ACTS_BUILD_PLUGIN_ACTSVG)
if(ACTS_USE_SYSTEM_ACTSVG)
message(STATUS "Using system installation of actsvg")
find_package(actsvg ${_acts_actsvg_version} REQUIRED CONFIG)
else()
add_subdirectory(thirdparty/actsvg)
Expand All @@ -287,15 +343,13 @@ 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)
endif()
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)
Expand Down Expand Up @@ -352,7 +406,6 @@ if(ACTS_BUILD_EXAMPLES)
# for simplicity always request all potentially required components.
find_package(ROOT ${_acts_root_version} REQUIRED CONFIG COMPONENTS Core Geom Graf GenVector Hist Tree TreePlayer)
check_root_compatibility()
add_subdirectory(thirdparty/dfelibs)
endif()
if(ACTS_BUILD_EXAMPLES_PYTHON_BINDINGS)
find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development)
Expand Down
15 changes: 8 additions & 7 deletions Core/include/Acts/Detector/Detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ class Detector : public std::enable_shared_from_this<Detector> {
///
/// @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<std::shared_ptr<DetectorVolume>> rootVolumes,
DetectorVolumeUpdater detectorVolumeUpdater) noexcept(false);
ExternalNavigationDelegate detectorVolumeFinder) noexcept(false);

public:
/// Factory for producing memory managed instances of Detector.
static std::shared_ptr<Detector> makeShared(
std::string name,
std::vector<std::shared_ptr<DetectorVolume>> rootVolumes,
DetectorVolumeUpdater detectorVolumeUpdater);
ExternalNavigationDelegate detectorVolumeFinder);

/// Retrieve a @c std::shared_ptr for this surface (non-const version)
///
Expand Down Expand Up @@ -213,11 +213,12 @@ class Detector : public std::enable_shared_from_this<Detector> {

/// 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;
Expand All @@ -233,7 +234,7 @@ class Detector : public std::enable_shared_from_this<Detector> {
DetectorVolume::ObjectStore<std::shared_ptr<DetectorVolume>> 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<std::string, std::size_t> m_volumeNameIndex;
Expand Down
10 changes: 5 additions & 5 deletions Core/include/Acts/Detector/DetectorComponents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <map>
#include <memory>
Expand Down Expand Up @@ -39,7 +39,7 @@ struct RootDetectorVolumes {
/// The list of root volumes
std::vector<std::shared_ptr<DetectorVolume>> volumes = {};
/// The Root volumes finder
DetectorVolumeUpdater volumeFinder;
ExternalNavigationDelegate volumeFinder;
};

/// @brief The currently built detector components
Expand Down Expand Up @@ -82,9 +82,9 @@ struct InternalStructure {
/// Contained volumes of this volume, handled by the volumeUpdater
std::vector<std::shared_ptr<DetectorVolume>> volumes = {};
/// Navigation delegate for surfaces
SurfaceCandidatesUpdater surfacesUpdater;
InternalNavigationDelegate surfacesUpdater;
// Navigation delegate for volumes
DetectorVolumeUpdater volumeUpdater;
ExternalNavigationDelegate volumeUpdater;
};

} // namespace Experimental
Expand Down
62 changes: 31 additions & 31 deletions Core/include/Acts/Detector/DetectorVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,35 +102,35 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
/// @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<VolumeBounds> bounds,
std::vector<std::shared_ptr<Surface>> surfaces,
std::vector<std::shared_ptr<DetectorVolume>> volumes,
DetectorVolumeUpdater detectorVolumeUpdater,
SurfaceCandidatesUpdater surfaceCandidateUpdater) noexcept(false);
DetectorVolume(const GeometryContext& gctx, std::string name,
const Transform3& transform,
std::shared_ptr<VolumeBounds> bounds,
std::vector<std::shared_ptr<Surface>> surfaces,
std::vector<std::shared_ptr<DetectorVolume>> volumes,
ExternalNavigationDelegate externalNavigation,
InternalNavigationDelegate internalNavigation) noexcept(false);

/// Create a detector volume - empty/gap volume constructor
///
/// @param gctx the geometry context while building - for future contextual store
/// @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<VolumeBounds> bounds,
SurfaceCandidatesUpdater surfaceCandidateUpdater) noexcept(false);
DetectorVolume(const GeometryContext& gctx, std::string name,
const Transform3& transform,
std::shared_ptr<VolumeBounds> bounds,
InternalNavigationDelegate internalNavigation) noexcept(false);

/// Factory method for producing memory managed instances of DetectorVolume.
///
Expand All @@ -140,16 +140,16 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
const Transform3& transform, std::shared_ptr<VolumeBounds> bounds,
std::vector<std::shared_ptr<Surface>> surfaces,
std::vector<std::shared_ptr<DetectorVolume>> volumes,
DetectorVolumeUpdater detectorVolumeUpdater,
SurfaceCandidatesUpdater surfaceCandidateUpdater);
ExternalNavigationDelegate externalNavigation,
InternalNavigationDelegate internalNavigation);

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

public:
/// Retrieve a @c std::shared_ptr for this surface (non-const version)
Expand Down Expand Up @@ -283,7 +283,7 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
const std::vector<const DetectorVolume*>& 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
///
Expand Down Expand Up @@ -362,17 +362,17 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
/// 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<std::shared_ptr<Surface>>& surfaces = {},
const std::vector<std::shared_ptr<DetectorVolume>>& volumes = {});

/// Const access to the navigation state updator
const SurfaceCandidatesUpdater& surfaceCandidatesUpdater() const;
const InternalNavigationDelegate& internalNavigation() const;

/// Update a portal given a portal index
///
Expand Down Expand Up @@ -463,10 +463,10 @@ class DetectorVolume : public std::enable_shared_from_this<DetectorVolume> {
/// BoundingBox
std::shared_ptr<const BoundingBox> m_boundingBox;

DetectorVolumeUpdater m_detectorVolumeUpdater;
ExternalNavigationDelegate m_externalNavigation;

/// The navigation state updator
SurfaceCandidatesUpdater m_surfaceCandidatesUpdater;
InternalNavigationDelegate m_internalNavigation;

/// Volume material (optional)
std::shared_ptr<const IVolumeMaterial> m_volumeMaterial = nullptr;
Expand All @@ -493,11 +493,11 @@ class DetectorVolumeFactory {
std::shared_ptr<VolumeBounds> bounds,
const std::vector<std::shared_ptr<Surface>>& surfaces,
const std::vector<std::shared_ptr<DetectorVolume>>& 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
Expand All @@ -515,10 +515,10 @@ class DetectorVolumeFactory {
const PortalGenerator& portalGenerator, const GeometryContext& gctx,
std::string name, const Transform3& transform,
std::shared_ptr<VolumeBounds> 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;
}
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Detector/IndexedRootVolumeFinderBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <memory>
Expand All @@ -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<std::shared_ptr<DetectorVolume>>& rootVolumes)
const final;
Expand Down
Loading

0 comments on commit 09f5040

Please sign in to comment.