Skip to content

Commit

Permalink
Merge branch 'main' into feat-gen3-proto-axis
Browse files Browse the repository at this point in the history
  • Loading branch information
asalzburger authored Feb 14, 2025
2 parents 9b6934e + e4606c6 commit 1142bce
Show file tree
Hide file tree
Showing 107 changed files with 908 additions and 1,239 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Checks: >
readability-inconsistent-declaration-parameter-name,
readability-named-parameter,
readability-operators-representation,
readability-redundant-smartptr-get
HeaderFilterRegex: '.*(?<!nlohmann\/json)\.(hpp|cpp|ipp)$'
CheckOptions:
readability-operators-representation.BinaryOperators: '&&;&=;&;|;~;!;!=;||;|=;^;^='
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ repos:
- id: type_t
name: type_t
language: system
entry: CI/check_type_t.py
entry: CI/check_type_t.py --fix
files: \.(cpp|hpp|ipp|cu|cuh)$

- repo: local
Expand Down
1 change: 1 addition & 0 deletions CI/clang_tidy/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ limits:
"readability-inconsistent-declaration-parameter-name": 0
"readability-named-parameter": 0
"readability-operators-representation": 0
"readability-redundant-smartptr-get": 0
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ else()
set(_default_examples_unit_tests OFF)
endif()
option(ACTS_BUILD_EXAMPLES_UNITTESTS "Build unit tests" ${_default_examples_unit_tests}) # default: ACTS_BUILD_UNITTESTS AND ACTS_BUILD_EXAMPLES
option(ACTS_BUILD_NONCOMPILE_TESTS "Build tests that check build failure invariants" OFF)
option(ACTS_RUN_CLANG_TIDY "Run clang-tidy static analysis" OFF)
# other options
option(ACTS_BUILD_DOCS "Build documentation" OFF)
Expand All @@ -128,6 +127,7 @@ set(ACTS_GPERF_INSTALL_DIR "" CACHE STRING "Hint to help find gperf if profiling

option(ACTS_ENABLE_LOG_FAILURE_THRESHOLD "Enable failing on log messages with level above certain threshold" OFF)
set(ACTS_LOG_FAILURE_THRESHOLD "" CACHE STRING "Log level above which an exception should be automatically thrown. If ACTS_ENABLE_LOG_FAILURE_THRESHOLD is set and this is unset, this will enable a runtime check of the log level.")
option(ACTS_COMPILE_HEADERS "Generate targets to compile header files" ON)
# gersemi: on

# handle option inter-dependencies and the everything flag
Expand Down Expand Up @@ -280,6 +280,9 @@ set(_acts_annoy_version 1.17.3)
# this version we will try so.
set(_acts_boost_recommended_version 1.78.0)

# Help with compiler flags discovery
include(ActsFunctions)

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

Expand Down Expand Up @@ -440,7 +443,7 @@ if(ACTS_BUILD_PLUGIN_EXATRKX)
endif()
endif()
if(ACTS_BUILD_PLUGIN_ONNX OR ACTS_EXATRKX_ENABLE_ONNX)
find_package(OnnxRuntime ${_acts_onnxruntime_version} REQUIRED)
find_package(onnxruntime ${_acts_onnxruntime_version} CONFIG REQUIRED)
endif()
if(ACTS_BUILD_PLUGIN_EDM4HEP OR ACTS_BUILD_PLUGIN_PODIO)
find_package(podio ${_acts_podio_version} CONFIG)
Expand Down
4 changes: 4 additions & 0 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,7 @@ add_subdirectory(src/Utilities)
add_subdirectory(src/Vertexing)
add_subdirectory(src/Visualization)
add_subdirectory(src/AmbiguityResolution)

acts_compile_headers(ActsCore GLOB
include/Acts/**/*.hpp
)
2 changes: 1 addition & 1 deletion Core/include/Acts/Geometry/BoundarySurfaceT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class BoundarySurfaceT {
template <class volume_t>
inline const RegularSurface& BoundarySurfaceT<volume_t>::surfaceRepresentation()
const {
return (*(m_surface.get()));
return *m_surface;
}

template <class volume_t>
Expand Down
187 changes: 128 additions & 59 deletions Core/include/Acts/Geometry/ProtoLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

namespace Acts {

/// @struct ProtoLayer
///
/// Encapsulates min/max boundaries that will be turned into a layer.
/// The struct allows this information to be obtained in a consistent
/// way, or be caller provided.
namespace detail {

struct ProtoLayer {
/// @class ProtoLayerBase
///
/// Base class containing common functionality for ProtoLayer implementations
/// @note This will go away once we remove the Gen1 geometry which assumes this only takes const pointers.
struct ProtoLayerBase {
public:
/// The extent of the ProtoLayer
Extent extent;
Expand All @@ -37,6 +37,52 @@ struct ProtoLayer {
/// The local transform
Transform3 transform = Transform3::Identity();

/// Get the parameters : min
/// @param aDir The accessed axis direction
/// @param addenv The steering if enevlope is added or not
double min(AxisDirection aDir, bool addenv = true) const;

// Get the parameters : max
/// @param aDir The accessed axis direction
/// @param addenv The steering if enevlope is added or not
double max(AxisDirection aDir, bool addenv = true) const;

// Get the parameters : medium
/// @param aDir The accessed axis direction
/// @param addenv The steering if enevlope is added or not
double medium(AxisDirection aDir, bool addenv = true) const;

// Get the parameters : range
/// @param aDir The accessed axis direction
/// @param addenv The steering if enevlope is added or not
double range(AxisDirection aDir, bool addenv = true) const;

/// Output to ostream
/// @param sl the input ostream
std::ostream& toStream(std::ostream& sl) const;

protected:
/// Helper method which performs the actual min/max calculation
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param surfaces The surfaces to build this protolayer out of
/// @param extent The extent to modify
/// @param transform The transform to use
static void measureImpl(const GeometryContext& gctx,
const std::vector<const Surface*>& surfaces,
Extent& extent, const Transform3& transform);
};

/// @struct ProtoLayerT
///
/// Encapsulates min/max boundaries that will be turned into a layer.
/// The struct allows this information to be obtained in a consistent
/// way, or be caller provided.
template <bool IsConst>
struct ProtoLayerT : public ProtoLayerBase {
using SurfacePtr = std::conditional_t<IsConst, const Surface*, Surface*>;
using SurfaceType = std::conditional_t<IsConst, const Surface, Surface>;

/// Constructor
///
/// Loops over a provided vector of surface and calculates the various
Expand All @@ -46,9 +92,22 @@ struct ProtoLayer {
/// @param gctx The current geometry context object, e.g. alignment
/// @param surfaces The vector of surfaces to consider
/// @param transformIn The local transform to evaluate the sizing in
ProtoLayer(const GeometryContext& gctx,
const std::vector<const Surface*>& surfaces,
const Transform3& transformIn = Transform3::Identity());
ProtoLayerT(const GeometryContext& gctx,
const std::vector<SurfacePtr>& surfaces,
const Transform3& transformIn = Transform3::Identity())
: m_surfaces(surfaces) {
transform = transformIn;
std::vector<const Surface*> constSurfaces;
if constexpr (!IsConst) {
constSurfaces.reserve(surfaces.size());
for (auto* sf : surfaces) {
constSurfaces.push_back(sf);
}
measureImpl(gctx, constSurfaces, extent, transform);
} else {
measureImpl(gctx, surfaces, extent, transform);
}
}

/// Constructor
///
Expand All @@ -59,79 +118,89 @@ struct ProtoLayer {
/// @param gctx The current geometry context object, e.g. alignment
/// @param surfaces The vector of surfaces to consider
/// @param transformIn The local transform to evaluate the sizing in
ProtoLayer(const GeometryContext& gctx,
const std::vector<std::shared_ptr<const Surface>>& surfaces,
const Transform3& transformIn = Transform3::Identity());
ProtoLayerT(const GeometryContext& gctx,
const std::vector<std::shared_ptr<SurfaceType>>& surfaces,
const Transform3& transformIn = Transform3::Identity()) {
transform = transformIn;
m_surfaces.reserve(surfaces.size());
for (const auto& sf : surfaces) {
m_surfaces.push_back(sf.get());
}
std::vector<const Surface*> constSurfaces;
if constexpr (!IsConst) {
constSurfaces.reserve(surfaces.size());
for (auto* sf : m_surfaces) {
constSurfaces.push_back(sf);
}
measureImpl(gctx, constSurfaces, extent, transform);
} else {
measureImpl(gctx, m_surfaces, extent, transform);
}
}

/// Constructor
///
/// Loops over a provided vector of surface and calculates the various
/// min/max values in one go. Also takes into account the thickness
/// of an associated DetectorElement, if it exists.
/// Constructor that accepts non-const shared pointers even when IsConst is
/// true
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param surfaces The vector of surfaces to consider
/// @param transformIn The local transform to evaluate the sizing in
ProtoLayer(const GeometryContext& gctx,
const std::vector<std::shared_ptr<Surface>>& surfaces,
const Transform3& transformIn = Transform3::Identity());

ProtoLayer() = default;

/// Get the parameters : min
/// @param aDir The accessed axis direction
/// @param addenv The steering if enevlope is added or not
double min(AxisDirection aDir, bool addenv = true) const;

// Get the parameters : max
/// @param aDir The accessed axis direction
/// @param addenv The steering if enevlope is added or not
double max(AxisDirection aDir, bool addenv = true) const;

// Get the parameters : max
/// @param aDir The accessed axis direction
/// @param addenv The steering if enevlope is added or not
double medium(AxisDirection aDir, bool addenv = true) const;

// Get the parameters : max
/// @param aDir The accessed axis direction
/// @param addenv The steering if enevlope is added or not
double range(AxisDirection aDir, bool addenv = true) const;
ProtoLayerT(const GeometryContext& gctx,
const std::vector<std::shared_ptr<Surface>>& surfaces,
const Transform3& transformIn = Transform3::Identity())
requires IsConst
{
transform = transformIn;
m_surfaces.reserve(surfaces.size());
for (const auto& sf : surfaces) {
m_surfaces.push_back(sf.get());
}
measureImpl(gctx, m_surfaces, extent, transform);
}

/// Output to ostream
/// @param sl the input ostream
std::ostream& toStream(std::ostream& sl) const;
ProtoLayerT() = default;

/// Output stream operator
/// @param sl the input ostream
/// @param pl the ProtoLayer to be printed
/// @return the output ostream
friend std::ostream& operator<<(std::ostream& sl, const ProtoLayer& pl) {
friend std::ostream& operator<<(std::ostream& sl, const ProtoLayerT& pl) {
return pl.toStream(sl);
}

/// Give access to the surfaces used/assigned to the ProtoLayer
const std::vector<const Surface*>& surfaces() const;
const std::vector<SurfacePtr>& surfaces() const { return m_surfaces; }

/// Add a surface, this will also increase the extent
/// @param gctx The current geometry context object, e.g. alignment
/// @param surface The surface which is added to the ProtoLayer
void add(const GeometryContext& gctx, const Surface& surface);
void add(const GeometryContext& gctx, SurfaceType& surface) {
m_surfaces.push_back(&surface);
std::vector<const Surface*> constSurfaces;
if constexpr (!IsConst) {
constSurfaces.reserve(m_surfaces.size());
for (auto* sf : m_surfaces) {
constSurfaces.push_back(sf);
}
measureImpl(gctx, constSurfaces, extent, transform);
} else {
measureImpl(gctx, m_surfaces, extent, transform);
}
}

private:
/// Helper method which performs the actual min/max calculation
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param surfaces The surfaces to build this protolayer out of
void measure(const GeometryContext& gctx,
const std::vector<const Surface*>& surfaces);

/// Store the list of surfaces used for this proto layer
std::vector<const Surface*> m_surfaces = {};
std::vector<SurfacePtr> m_surfaces = {};
};

inline const std::vector<const Surface*>& ProtoLayer::surfaces() const {
return m_surfaces;
}
} // namespace detail

// Forward-declaration friendly class for backward compatibility
struct ProtoLayer : public detail::ProtoLayerT<true> {
using detail::ProtoLayerT<true>::ProtoLayerT;
};

struct MutableProtoLayer : public detail::ProtoLayerT<false> {
using detail::ProtoLayerT<false>::ProtoLayerT;
};

} // namespace Acts
Loading

0 comments on commit 1142bce

Please sign in to comment.