diff --git a/.clang-tidy b/.clang-tidy index 8411466091e..86a2022c1bf 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,6 +5,7 @@ Checks: > cppcoreguidelines-init-variables, cppcoreguidelines-pro-type-member-init, google-readability-casting, + google-explicit-constructor, modernize-concat-nested-namespaces, modernize-use-equals-default, modernize-use-default-member-init, diff --git a/Alignment/include/ActsAlignment/Kernel/Alignment.hpp b/Alignment/include/ActsAlignment/Kernel/Alignment.hpp index 2a14da18476..195898edfb8 100644 --- a/Alignment/include/ActsAlignment/Kernel/Alignment.hpp +++ b/Alignment/include/ActsAlignment/Kernel/Alignment.hpp @@ -136,9 +136,10 @@ struct Alignment { Alignment() = delete; /// Constructor from arguments - Alignment(fitter_t fitter, - std::unique_ptr _logger = - Acts::getDefaultLogger("Alignment", Acts::Logging::INFO)) + explicit Alignment(fitter_t fitter, + std::unique_ptr _logger = + Acts::getDefaultLogger("Alignment", + Acts::Logging::INFO)) : m_fitter(std::move(fitter)), m_logger{std::move(_logger)} {} /// @brief evaluate alignment state for a single track diff --git a/CI/clang_tidy/limits.yml b/CI/clang_tidy/limits.yml index 7fe44effc2e..470e5912363 100644 --- a/CI/clang_tidy/limits.yml +++ b/CI/clang_tidy/limits.yml @@ -4,6 +4,7 @@ limits: "cppcoreguidelines-init-variables": 0 "cppcoreguidelines-pro-type-member-init": 0 "google-readability-casting": 0 + "google-explicit-constructor": 0 "modernize-concat-nested-namespaces": 0 "modernize-use-equals-default": 0 "modernize-use-default-member-init": 0 diff --git a/Core/include/Acts/AmbiguityResolution/AmbiguityResolutionML.hpp b/Core/include/Acts/AmbiguityResolution/AmbiguityResolutionML.hpp index 66717e3f8ee..c16d191cbb6 100644 --- a/Core/include/Acts/AmbiguityResolution/AmbiguityResolutionML.hpp +++ b/Core/include/Acts/AmbiguityResolution/AmbiguityResolutionML.hpp @@ -38,9 +38,10 @@ class AmbiguityResolutionML { /// /// @param cfg is the algorithm configuration /// @param logger is the logging instance - AmbiguityResolutionML(const Config& cfg, - std::unique_ptr logger = getDefaultLogger( - "AmbiguityResolutionML", Logging::INFO)) + explicit AmbiguityResolutionML(const Config& cfg, + std::unique_ptr logger = + getDefaultLogger("AmbiguityResolutionML", + Logging::INFO)) : m_cfg{cfg}, m_duplicateClassifier(m_cfg.inputDuplicateNN.c_str()), m_logger{std::move(logger)} {} diff --git a/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp b/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp index 13bd9822c86..51926b9a0ce 100644 --- a/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp +++ b/Core/include/Acts/AmbiguityResolution/GreedyAmbiguityResolution.hpp @@ -64,10 +64,10 @@ class GreedyAmbiguityResolution { boost::container::flat_set selectedTracks; }; - GreedyAmbiguityResolution(const Config& cfg, - std::unique_ptr logger = - getDefaultLogger("GreedyAmbiguityResolution", - Logging::INFO)) + explicit GreedyAmbiguityResolution( + const Config& cfg, + std::unique_ptr logger = + getDefaultLogger("GreedyAmbiguityResolution", Logging::INFO)) : m_cfg{cfg}, m_logger{std::move(logger)} {} /// Computes the initial state for the input data. This function accumulates diff --git a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.hpp b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.hpp index 60e81c0a8db..fff9d7314b0 100644 --- a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.hpp +++ b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.hpp @@ -151,7 +151,7 @@ class ScoreBasedAmbiguityResolution { std::vector hitSelections = {}; }; - ScoreBasedAmbiguityResolution( + explicit ScoreBasedAmbiguityResolution( const Config& cfg, std::unique_ptr logger = getDefaultLogger("ScoreBasedAmbiguityResolution", Logging::INFO)) diff --git a/Core/include/Acts/Clusterization/TimedClusterization.hpp b/Core/include/Acts/Clusterization/TimedClusterization.hpp index a53e7793f56..441515d7a5b 100644 --- a/Core/include/Acts/Clusterization/TimedClusterization.hpp +++ b/Core/include/Acts/Clusterization/TimedClusterization.hpp @@ -25,7 +25,7 @@ struct TimedConnect : public Acts::Ccl::DefaultConnect { double timeTolerance{std::numeric_limits::max()}; TimedConnect() = default; - TimedConnect(double time); + explicit TimedConnect(double time); TimedConnect(double time, bool commonCorner) requires(N == 2); ~TimedConnect() override = default; diff --git a/Core/include/Acts/Detector/CuboidalContainerBuilder.hpp b/Core/include/Acts/Detector/CuboidalContainerBuilder.hpp index ecf1f2c778c..00409c999f6 100644 --- a/Core/include/Acts/Detector/CuboidalContainerBuilder.hpp +++ b/Core/include/Acts/Detector/CuboidalContainerBuilder.hpp @@ -65,10 +65,10 @@ class CuboidalContainerBuilder : public IDetectorComponentBuilder { /// /// @param cfg is the configuration struct /// @param logger logging instance for screen output - CuboidalContainerBuilder(const Config& cfg, - std::unique_ptr logger = - getDefaultLogger("CuboidalContainerBuilder", - Logging::INFO)); + explicit CuboidalContainerBuilder( + const Config& cfg, + std::unique_ptr logger = + getDefaultLogger("CuboidalContainerBuilder", Logging::INFO)); /// Constructor from blueprint and logging level /// @@ -84,7 +84,7 @@ class CuboidalContainerBuilder : public IDetectorComponentBuilder { /// @note that the naming of the builders is taken from the bluprint nodes /// /// @return a cylindrical container builder representing this blueprint - CuboidalContainerBuilder( + explicit CuboidalContainerBuilder( const Acts::Experimental::Gen2Blueprint::Node& bpNode, Acts::Logging::Level logLevel = Acts::Logging::INFO); diff --git a/Core/include/Acts/Detector/CylindricalContainerBuilder.hpp b/Core/include/Acts/Detector/CylindricalContainerBuilder.hpp index 69b32e790c1..aa134cf7d98 100644 --- a/Core/include/Acts/Detector/CylindricalContainerBuilder.hpp +++ b/Core/include/Acts/Detector/CylindricalContainerBuilder.hpp @@ -67,7 +67,7 @@ class CylindricalContainerBuilder : public IDetectorComponentBuilder { /// /// @param cfg is the configuration struct /// @param logger logging instance for screen output - CylindricalContainerBuilder( + explicit CylindricalContainerBuilder( const Config& cfg, std::unique_ptr logger = getDefaultLogger("CylindricalContainerBuilder", Logging::INFO)); @@ -86,7 +86,7 @@ class CylindricalContainerBuilder : public IDetectorComponentBuilder { /// @note that the naming of the builders is taken from the bluprint nodes /// /// @return a cylindrical container builder representing this blueprint - CylindricalContainerBuilder( + explicit CylindricalContainerBuilder( const Acts::Experimental::Gen2Blueprint::Node& bpNode, Acts::Logging::Level logLevel = Acts::Logging::INFO); diff --git a/Core/include/Acts/Detector/DetectorBuilder.hpp b/Core/include/Acts/Detector/DetectorBuilder.hpp index d5e0ab7e16b..8ea1b8f00bb 100644 --- a/Core/include/Acts/Detector/DetectorBuilder.hpp +++ b/Core/include/Acts/Detector/DetectorBuilder.hpp @@ -50,9 +50,10 @@ class DetectorBuilder final : public IDetectorBuilder { /// /// @param cfg is the configuration struct /// @param mlogger logging instance for screen output - DetectorBuilder(const Config& cfg, - std::unique_ptr mlogger = - getDefaultLogger("DetectorBuilder", Logging::INFO)); + explicit DetectorBuilder(const Config& cfg, + std::unique_ptr mlogger = + getDefaultLogger("DetectorBuilder", + Logging::INFO)); /// Final implementation of a volume builder that is purely defined /// by an internal and external structure builder diff --git a/Core/include/Acts/Detector/DetectorVolume.hpp b/Core/include/Acts/Detector/DetectorVolume.hpp index 903532361f7..6cd98fc1837 100644 --- a/Core/include/Acts/Detector/DetectorVolume.hpp +++ b/Core/include/Acts/Detector/DetectorVolume.hpp @@ -84,7 +84,7 @@ class DetectorVolume : public std::enable_shared_from_this { /// Store constructor /// /// @param objects are the ones copied into the internal store - ObjectStore(std::vector objects) + explicit ObjectStore(std::vector objects) : internal(std::move(objects)) { external = unpack_shared_const_vector(internal); } diff --git a/Core/include/Acts/Detector/DetectorVolumeBuilder.hpp b/Core/include/Acts/Detector/DetectorVolumeBuilder.hpp index 4360f19c2ac..f088072f4fe 100644 --- a/Core/include/Acts/Detector/DetectorVolumeBuilder.hpp +++ b/Core/include/Acts/Detector/DetectorVolumeBuilder.hpp @@ -54,10 +54,10 @@ class DetectorVolumeBuilder : public IDetectorComponentBuilder { /// /// @param cfg is the configuration struct /// @param mlogger logging instance for screen output - DetectorVolumeBuilder(const Config& cfg, - std::unique_ptr mlogger = - getDefaultLogger("DetectorVolumeBuilder", - Logging::INFO)); + explicit DetectorVolumeBuilder(const Config& cfg, + std::unique_ptr mlogger = + getDefaultLogger("DetectorVolumeBuilder", + Logging::INFO)); /// Final implementation of a volume builder that is purely defined /// by an internal and external structure builder diff --git a/Core/include/Acts/Detector/GeometryIdGenerator.hpp b/Core/include/Acts/Detector/GeometryIdGenerator.hpp index ff8e36cc451..fabcca8c4e6 100644 --- a/Core/include/Acts/Detector/GeometryIdGenerator.hpp +++ b/Core/include/Acts/Detector/GeometryIdGenerator.hpp @@ -70,9 +70,10 @@ class GeometryIdGenerator final : public IGeometryIdGenerator { /// /// @param cfg is the geometry configuration object /// @param mlogger is the logging instance - GeometryIdGenerator(const Config& cfg, - std::unique_ptr mlogger = getDefaultLogger( - "GeometryIdGenerator", Logging::INFO)) + explicit GeometryIdGenerator(const Config& cfg, + std::unique_ptr mlogger = + getDefaultLogger("GeometryIdGenerator", + Logging::INFO)) : m_cfg(cfg), m_logger(std::move(mlogger)) {} ~GeometryIdGenerator() override = default; @@ -142,10 +143,10 @@ class ChainedGeometryIdGenerator : public IGeometryIdGenerator { /// /// @param gens the updators to be called in chain /// @param mlogger is the logging instance - ChainedGeometryIdGenerator(const std::tuple&& gens, - std::unique_ptr mlogger = - getDefaultLogger("ChainedGeometryIdGenerator", - Logging::INFO)) + explicit ChainedGeometryIdGenerator( + const std::tuple&& gens, + std::unique_ptr mlogger = + getDefaultLogger("ChainedGeometryIdGenerator", Logging::INFO)) : generators(std::move(gens)), m_logger(std::move(mlogger)) {} /// @brief Interface method to generate a geometry id cache diff --git a/Core/include/Acts/Detector/GeometryIdMapper.hpp b/Core/include/Acts/Detector/GeometryIdMapper.hpp index 0b9215011e2..00427c9a548 100644 --- a/Core/include/Acts/Detector/GeometryIdMapper.hpp +++ b/Core/include/Acts/Detector/GeometryIdMapper.hpp @@ -52,9 +52,10 @@ class GeometryIdMapper final : public IGeometryIdGenerator { /// /// @param cfg is the geometry configuration object /// @param mlogger is the logging instance - GeometryIdMapper(const Config& cfg, - std::unique_ptr mlogger = - getDefaultLogger("GeometryIdMapper", Logging::INFO)) + explicit GeometryIdMapper(const Config& cfg, + std::unique_ptr mlogger = + getDefaultLogger("GeometryIdMapper", + Logging::INFO)) : m_cfg(cfg), m_logger(std::move(mlogger)) {} ~GeometryIdMapper() override = default; diff --git a/Core/include/Acts/Detector/IndexedRootVolumeFinderBuilder.hpp b/Core/include/Acts/Detector/IndexedRootVolumeFinderBuilder.hpp index ba67d3bd10e..4b2efa54c2e 100644 --- a/Core/include/Acts/Detector/IndexedRootVolumeFinderBuilder.hpp +++ b/Core/include/Acts/Detector/IndexedRootVolumeFinderBuilder.hpp @@ -26,7 +26,8 @@ class IndexedRootVolumeFinderBuilder final : public IRootVolumeFinderBuilder { public: /// @brief Constructor with binning casts /// @param binning the cast values for the grid binning - IndexedRootVolumeFinderBuilder(std::vector binning); + explicit IndexedRootVolumeFinderBuilder( + std::vector binning); /// The virtual interface definition for root volume finder builders /// diff --git a/Core/include/Acts/Detector/LayerStructureBuilder.hpp b/Core/include/Acts/Detector/LayerStructureBuilder.hpp index e0d70ffee65..acce3584191 100644 --- a/Core/include/Acts/Detector/LayerStructureBuilder.hpp +++ b/Core/include/Acts/Detector/LayerStructureBuilder.hpp @@ -57,7 +57,7 @@ class LayerStructureBuilder : public IInternalStructureBuilder { public: /// Constructor with predefined surfaces /// @param isurfaces is the vector of surfaces - SurfacesHolder(std::vector> isurfaces) + explicit SurfacesHolder(std::vector> isurfaces) : m_surfaces(std::move(isurfaces)) {} /// Return the surfaces from the holder @@ -101,9 +101,10 @@ class LayerStructureBuilder : public IInternalStructureBuilder { /// /// @param cfg is the configuration struct /// @param logger logging instance for screen output - LayerStructureBuilder(const Config& cfg, - std::unique_ptr logger = getDefaultLogger( - "LayerStructureBuilder", Logging::INFO)); + explicit LayerStructureBuilder(const Config& cfg, + std::unique_ptr logger = + getDefaultLogger("LayerStructureBuilder", + Logging::INFO)); /// The interface definition for internal structure creation /// diff --git a/Core/include/Acts/Detector/MultiWireStructureBuilder.hpp b/Core/include/Acts/Detector/MultiWireStructureBuilder.hpp index 86c48cc2a30..80063019215 100644 --- a/Core/include/Acts/Detector/MultiWireStructureBuilder.hpp +++ b/Core/include/Acts/Detector/MultiWireStructureBuilder.hpp @@ -52,7 +52,7 @@ class MultiWireStructureBuilder { /// @param config The configure of the MultiWireStructureBuilder /// @param logger logging instance for screen output - MultiWireStructureBuilder( + explicit MultiWireStructureBuilder( const Config& config, std::unique_ptr logger = Acts::getDefaultLogger( "MultiWireStructureBuilder", Acts::Logging::VERBOSE)); diff --git a/Core/include/Acts/Detector/Portal.hpp b/Core/include/Acts/Detector/Portal.hpp index 3cdfce02dc4..5425d3cdc5b 100644 --- a/Core/include/Acts/Detector/Portal.hpp +++ b/Core/include/Acts/Detector/Portal.hpp @@ -47,7 +47,7 @@ class Portal { /// Constructor from surface w/o portal links /// /// @param surface is the representing surface - Portal(std::shared_ptr surface); + explicit Portal(std::shared_ptr surface); /// The vector of attached volumes forward/backward, this is useful in the /// geometry building diff --git a/Core/include/Acts/Detector/VolumeStructureBuilder.hpp b/Core/include/Acts/Detector/VolumeStructureBuilder.hpp index bf236349b31..a107193b574 100644 --- a/Core/include/Acts/Detector/VolumeStructureBuilder.hpp +++ b/Core/include/Acts/Detector/VolumeStructureBuilder.hpp @@ -53,10 +53,10 @@ class VolumeStructureBuilder : public IExternalStructureBuilder { /// /// @param cfg is the configuration struct /// @param mlogger logging instance for screen output - VolumeStructureBuilder(const Config& cfg, - std::unique_ptr mlogger = - getDefaultLogger("VolumeStructureBuilder", - Logging::INFO)); + explicit VolumeStructureBuilder(const Config& cfg, + std::unique_ptr mlogger = + getDefaultLogger("VolumeStructureBuilder", + Logging::INFO)); /// The interface definition for internal structure creation /// diff --git a/Core/include/Acts/EventData/Charge.hpp b/Core/include/Acts/EventData/Charge.hpp index 64073538a3f..75d32d8f59f 100644 --- a/Core/include/Acts/EventData/Charge.hpp +++ b/Core/include/Acts/EventData/Charge.hpp @@ -60,7 +60,7 @@ struct Neutral { /// Construct and verify the input charge magnitude (in debug builds). /// /// This constructor is only provided to allow consistent construction. - constexpr Neutral(float absQ) noexcept { + constexpr explicit Neutral(float absQ) noexcept { assert((absQ == 0) && "Input charge must be zero"); (void)absQ; } @@ -102,7 +102,7 @@ struct SinglyCharged { /// Construct and verify the input charge magnitude (in debug builds). /// /// This constructor is only provided to allow consistent construction. - constexpr SinglyCharged(float absQ) noexcept { + constexpr explicit SinglyCharged(float absQ) noexcept { assert((absQ == UnitConstants::e) && "Input charge magnitude must be e"); (void)absQ; } @@ -141,10 +141,10 @@ static_assert(ChargeConcept, class NonNeutralCharge { public: /// Construct with the magnitude of the input charge. - constexpr NonNeutralCharge(float absQ) noexcept : m_absQ{absQ} { + constexpr explicit NonNeutralCharge(float absQ) noexcept : m_absQ{absQ} { assert((0 < absQ) && "Input charge magnitude must be positive"); } - constexpr NonNeutralCharge(SinglyCharged /*unused*/) noexcept + constexpr explicit NonNeutralCharge(SinglyCharged /*unused*/) noexcept : m_absQ{UnitConstants::e} {} constexpr float absQ() const noexcept { return m_absQ; } @@ -182,12 +182,12 @@ static_assert(ChargeConcept, class AnyCharge { public: /// Construct with the magnitude of the input charge. - constexpr AnyCharge(float absQ) noexcept : m_absQ{absQ} { + constexpr explicit AnyCharge(float absQ) noexcept : m_absQ{absQ} { assert((0 <= absQ) && "Input charge magnitude must be zero or positive"); } - constexpr AnyCharge(SinglyCharged /*unused*/) noexcept + constexpr explicit AnyCharge(SinglyCharged /*unused*/) noexcept : m_absQ{UnitConstants::e} {} - constexpr AnyCharge(Neutral /*unused*/) noexcept {} + constexpr explicit AnyCharge(Neutral /*unused*/) noexcept {} constexpr float absQ() const noexcept { return m_absQ; } diff --git a/Core/include/Acts/EventData/GenericBoundTrackParameters.hpp b/Core/include/Acts/EventData/GenericBoundTrackParameters.hpp index bd2d2063831..07f4b4df521 100644 --- a/Core/include/Acts/EventData/GenericBoundTrackParameters.hpp +++ b/Core/include/Acts/EventData/GenericBoundTrackParameters.hpp @@ -9,6 +9,7 @@ #pragma once #include "Acts/Definitions/Tolerance.hpp" +#include "Acts/EventData/ParticleHypothesis.hpp" #include "Acts/EventData/TrackParameterHelpers.hpp" #include "Acts/EventData/TransformationHelpers.hpp" #include "Acts/EventData/detail/PrintParameters.hpp" @@ -69,11 +70,17 @@ class GenericBoundTrackParameters { /// Converts a bound track parameter with a different hypothesis. template - GenericBoundTrackParameters( + explicit GenericBoundTrackParameters( const GenericBoundTrackParameters& other) - : GenericBoundTrackParameters(other.referenceSurface().getSharedPtr(), - other.parameters(), other.covariance(), - other.particleHypothesis()) {} + : GenericBoundTrackParameters( + other.referenceSurface().getSharedPtr(), other.parameters(), + other.covariance(), + ParticleHypothesis{other.particleHypothesis()}) {} + + /// Convert this track parameter object to the general type-erased one + GenericBoundTrackParameters toBound() const { + return GenericBoundTrackParameters{*this}; + } /// Factory to construct from four-position, direction, absolute momentum, and /// charge. diff --git a/Core/include/Acts/EventData/GenericCurvilinearTrackParameters.hpp b/Core/include/Acts/EventData/GenericCurvilinearTrackParameters.hpp index 9764ad68cfc..06d5d5f47cb 100644 --- a/Core/include/Acts/EventData/GenericCurvilinearTrackParameters.hpp +++ b/Core/include/Acts/EventData/GenericCurvilinearTrackParameters.hpp @@ -70,7 +70,7 @@ class GenericCurvilinearTrackParameters /// Converts a bound track parameter with a different hypothesis. template - GenericCurvilinearTrackParameters( + explicit GenericCurvilinearTrackParameters( const GenericCurvilinearTrackParameters& other) : GenericCurvilinearTrackParameters(other.fourPosition(), diff --git a/Core/include/Acts/EventData/GenericFreeTrackParameters.hpp b/Core/include/Acts/EventData/GenericFreeTrackParameters.hpp index b0499dd3137..f64f21b7643 100644 --- a/Core/include/Acts/EventData/GenericFreeTrackParameters.hpp +++ b/Core/include/Acts/EventData/GenericFreeTrackParameters.hpp @@ -111,7 +111,7 @@ class GenericFreeTrackParameters { /// Converts a free track parameter with a different hypothesis. template - GenericFreeTrackParameters( + explicit GenericFreeTrackParameters( const GenericFreeTrackParameters& other) : GenericFreeTrackParameters(other.parameters(), other.particleHypothesis(), diff --git a/Core/include/Acts/EventData/GenericParticleHypothesis.hpp b/Core/include/Acts/EventData/GenericParticleHypothesis.hpp index 46ebe4ff298..70342c22792 100644 --- a/Core/include/Acts/EventData/GenericParticleHypothesis.hpp +++ b/Core/include/Acts/EventData/GenericParticleHypothesis.hpp @@ -45,7 +45,7 @@ class GenericParticleHypothesis { /// If the lookup fails an exception is thrown. /// /// @param absPdg the absolute PDG - GenericParticleHypothesis(PdgParticle absPdg) + explicit GenericParticleHypothesis(PdgParticle absPdg) : m_absPdg{absPdg}, m_mass{findMass(absPdg).value()}, m_chargeType{std::abs(findCharge(absPdg).value())} { @@ -57,7 +57,7 @@ class GenericParticleHypothesis { /// /// @note This enables implicit conversion. template - constexpr GenericParticleHypothesis( + explicit constexpr GenericParticleHypothesis( const GenericParticleHypothesis& other) : m_absPdg{other.absolutePdg()}, m_mass{other.mass()}, diff --git a/Core/include/Acts/EventData/MultiComponentTrackParameters.hpp b/Core/include/Acts/EventData/MultiComponentTrackParameters.hpp index 5e079af0df7..bf9dea6fa61 100644 --- a/Core/include/Acts/EventData/MultiComponentTrackParameters.hpp +++ b/Core/include/Acts/EventData/MultiComponentTrackParameters.hpp @@ -121,6 +121,9 @@ class MultiComponentBoundTrackParameters { MultiComponentBoundTrackParameters& operator=( MultiComponentBoundTrackParameters&&) = default; + /// Comply with bound convertible, in this case return a copy + MultiComponentBoundTrackParameters toBound() const { return *this; } + /// Access the parameters const auto& components() const { return m_components; } diff --git a/Core/include/Acts/EventData/MultiTrajectory.hpp b/Core/include/Acts/EventData/MultiTrajectory.hpp index 1951d558ee7..0aabe5dd04c 100644 --- a/Core/include/Acts/EventData/MultiTrajectory.hpp +++ b/Core/include/Acts/EventData/MultiTrajectory.hpp @@ -108,13 +108,13 @@ class TrackStateRange { ProxyType operator*() { return *proxy; } }; - TrackStateRange(ProxyType _begin) : m_begin{_begin} {} + explicit TrackStateRange(ProxyType _begin) : m_begin{_begin} {} TrackStateRange() : m_begin{std::nullopt} {} - Iterator begin() { return m_begin; } + Iterator begin() { return Iterator{m_begin}; } Iterator end() { return Iterator{std::nullopt}; } - Iterator cbegin() const { return m_begin; } + Iterator cbegin() const { return Iterator{m_begin}; } Iterator cend() const { return Iterator{std::nullopt}; } private: diff --git a/Core/include/Acts/EventData/ParticleHypothesis.hpp b/Core/include/Acts/EventData/ParticleHypothesis.hpp index f236441ede6..d2b474bb149 100644 --- a/Core/include/Acts/EventData/ParticleHypothesis.hpp +++ b/Core/include/Acts/EventData/ParticleHypothesis.hpp @@ -27,11 +27,12 @@ class SinglyChargedParticleHypothesis public: constexpr SinglyChargedParticleHypothesis(PdgParticle absPdg, float mass) : GenericParticleHypothesis(absPdg, mass, {}) {} - SinglyChargedParticleHypothesis(PdgParticle absPdg) + + explicit SinglyChargedParticleHypothesis(PdgParticle absPdg) : GenericParticleHypothesis(absPdg) {} template - constexpr SinglyChargedParticleHypothesis( + explicit constexpr SinglyChargedParticleHypothesis( const GenericParticleHypothesis& other) : GenericParticleHypothesis(other) {} @@ -70,11 +71,11 @@ class NeutralParticleHypothesis : public GenericParticleHypothesis { public: constexpr NeutralParticleHypothesis(PdgParticle absPdg, float mass) : GenericParticleHypothesis(absPdg, mass, {}) {} - NeutralParticleHypothesis(PdgParticle absPdg) + explicit NeutralParticleHypothesis(PdgParticle absPdg) : GenericParticleHypothesis(absPdg) {} template - constexpr NeutralParticleHypothesis( + explicit constexpr NeutralParticleHypothesis( const GenericParticleHypothesis& other) : GenericParticleHypothesis(other) {} @@ -102,33 +103,38 @@ class NonNeutralChargedParticleHypothesis constexpr NonNeutralChargedParticleHypothesis(PdgParticle absPdg, float mass, NonNeutralCharge chargeType) : GenericParticleHypothesis(absPdg, mass, chargeType) {} - NonNeutralChargedParticleHypothesis(PdgParticle absPdg) + explicit NonNeutralChargedParticleHypothesis(PdgParticle absPdg) : GenericParticleHypothesis(absPdg) {} template - constexpr NonNeutralChargedParticleHypothesis( + explicit constexpr NonNeutralChargedParticleHypothesis( const GenericParticleHypothesis& other) : GenericParticleHypothesis(other) {} static NonNeutralChargedParticleHypothesis muon() { - return SinglyChargedParticleHypothesis::muon(); + return NonNeutralChargedParticleHypothesis{ + SinglyChargedParticleHypothesis::muon()}; } static NonNeutralChargedParticleHypothesis pion() { - return SinglyChargedParticleHypothesis::pion(); + return NonNeutralChargedParticleHypothesis{ + SinglyChargedParticleHypothesis::pion()}; } static NonNeutralChargedParticleHypothesis electron() { - return SinglyChargedParticleHypothesis::electron(); + return NonNeutralChargedParticleHypothesis{ + SinglyChargedParticleHypothesis::electron()}; } static NonNeutralChargedParticleHypothesis kaon() { - return SinglyChargedParticleHypothesis::kaon(); + return NonNeutralChargedParticleHypothesis{ + SinglyChargedParticleHypothesis::kaon()}; } static NonNeutralChargedParticleHypothesis proton() { - return SinglyChargedParticleHypothesis::proton(); + return NonNeutralChargedParticleHypothesis{ + SinglyChargedParticleHypothesis::proton()}; } static NonNeutralChargedParticleHypothesis pionLike(float absQ) { - return NonNeutralChargedParticleHypothesis(pion().absolutePdg(), - pion().mass(), absQ); + return NonNeutralChargedParticleHypothesis( + pion().absolutePdg(), pion().mass(), NonNeutralCharge{absQ}); } static NonNeutralChargedParticleHypothesis chargedGeantino() { @@ -136,7 +142,8 @@ class NonNeutralChargedParticleHypothesis return cache; } static NonNeutralChargedParticleHypothesis chargedGeantino(float absQ) { - return NonNeutralChargedParticleHypothesis(PdgParticle::eInvalid, 0, absQ); + return NonNeutralChargedParticleHypothesis(PdgParticle::eInvalid, 0, + NonNeutralCharge{absQ}); } }; @@ -148,49 +155,51 @@ class ParticleHypothesis : public GenericParticleHypothesis { constexpr ParticleHypothesis(PdgParticle absPdg, float mass, AnyCharge chargeType) : GenericParticleHypothesis(absPdg, mass, chargeType) {} - ParticleHypothesis(PdgParticle absPdg) : GenericParticleHypothesis(absPdg) {} + explicit ParticleHypothesis(PdgParticle absPdg) + : GenericParticleHypothesis(absPdg) {} template - constexpr ParticleHypothesis( + explicit constexpr ParticleHypothesis( const GenericParticleHypothesis& other) : GenericParticleHypothesis(other) {} static ParticleHypothesis muon() { - return SinglyChargedParticleHypothesis::muon(); + return ParticleHypothesis{SinglyChargedParticleHypothesis::muon()}; } static ParticleHypothesis pion() { - return SinglyChargedParticleHypothesis::pion(); + return ParticleHypothesis{SinglyChargedParticleHypothesis::pion()}; } static ParticleHypothesis electron() { - return SinglyChargedParticleHypothesis::electron(); + return ParticleHypothesis{SinglyChargedParticleHypothesis::electron()}; } static ParticleHypothesis kaon() { - return SinglyChargedParticleHypothesis::kaon(); + return ParticleHypothesis{SinglyChargedParticleHypothesis::kaon()}; } static ParticleHypothesis proton() { - return SinglyChargedParticleHypothesis::proton(); + return ParticleHypothesis{SinglyChargedParticleHypothesis::proton()}; } static ParticleHypothesis photon() { - return NeutralParticleHypothesis::photon(); + return ParticleHypothesis{NeutralParticleHypothesis::photon()}; } static ParticleHypothesis pion0() { - return NeutralParticleHypothesis::pion0(); + return ParticleHypothesis{NeutralParticleHypothesis::pion0()}; } static ParticleHypothesis pionLike(float absQ) { - return ParticleHypothesis(pion().absolutePdg(), pion().mass(), absQ); + return ParticleHypothesis(pion().absolutePdg(), pion().mass(), + AnyCharge{absQ}); } static ParticleHypothesis geantino() { - return NeutralParticleHypothesis::geantino(); + return ParticleHypothesis{NeutralParticleHypothesis::geantino()}; } static ParticleHypothesis chargedGeantino() { static const auto cache = chargedGeantino(Acts::UnitConstants::e); return cache; } static ParticleHypothesis chargedGeantino(float absQ) { - return ParticleHypothesis(PdgParticle::eInvalid, 0, absQ); + return ParticleHypothesis(PdgParticle::eInvalid, 0, AnyCharge{absQ}); } }; diff --git a/Core/include/Acts/EventData/ProxyAccessor.hpp b/Core/include/Acts/EventData/ProxyAccessor.hpp index d6a9a3497ce..bf0a068d85b 100644 --- a/Core/include/Acts/EventData/ProxyAccessor.hpp +++ b/Core/include/Acts/EventData/ProxyAccessor.hpp @@ -70,11 +70,11 @@ struct ProxyAccessorBase { /// Create the accessor from an already-hashed string key /// @param _key the key - constexpr ProxyAccessorBase(HashedString _key) : key{_key} {} + explicit constexpr ProxyAccessorBase(HashedString _key) : key{_key} {} /// Create the accessor from a string key /// @param _key the key - constexpr ProxyAccessorBase(const std::string& _key) + explicit constexpr ProxyAccessorBase(const std::string& _key) : key{hashStringDynamic(_key)} {} /// Access the stored key on the proxy given as an argument. Mutable version diff --git a/Core/include/Acts/EventData/TrackParametersConcept.hpp b/Core/include/Acts/EventData/TrackParametersConcept.hpp index 4369fe57141..488193e57f3 100644 --- a/Core/include/Acts/EventData/TrackParametersConcept.hpp +++ b/Core/include/Acts/EventData/TrackParametersConcept.hpp @@ -66,4 +66,11 @@ concept BoundTrackParametersConcept = }; }; +namespace Concepts { +template +concept BoundConvertibleTrackParameters = requires(const Parameters &p) { + { p.toBound() } -> BoundTrackParametersConcept; +}; +} // namespace Concepts + } // namespace Acts diff --git a/Core/include/Acts/EventData/TrackProxy.hpp b/Core/include/Acts/EventData/TrackProxy.hpp index 722c69afba1..d3d5b4ce9ae 100644 --- a/Core/include/Acts/EventData/TrackProxy.hpp +++ b/Core/include/Acts/EventData/TrackProxy.hpp @@ -111,16 +111,29 @@ class TrackProxy { /// /// @{ - /// Copy constructor from a mutable track proxy. This is always valid, either - /// mutable to mutable or mutable to const - /// @param other the other track state proxy - TrackProxy(const MutableTrackProxy& other) + /// Copy constructor: const to const or mutable to mutable + /// @param other the other track proxy + TrackProxy(const TrackProxy& other) = default; + + /// Copy assignment operator: const to const or mutable to mutable + /// @param other the other track proxy + /// @return reference to this track proxy + TrackProxy& operator=(const TrackProxy& other) = default; + + /// Constructor from mutable track proxy + /// @note Only available if the track proxy is read-only + /// @param other the other track proxy + explicit TrackProxy(const MutableTrackProxy& other) + requires ReadOnly : m_container{other.m_container}, m_index{other.m_index} {} - /// Copy assignment operator from mutable track proxy. This is always valid, - /// either mutable to mutable or mutable to const - /// @param other the other track state proxy - TrackProxy& operator=(const MutableTrackProxy& other) { + /// Copy assignment operator from mutable track proxy + /// @note Only available if the track proxy is read-only + /// @param other the other track proxy + /// @return reference to this track proxy + TrackProxy& operator=(const MutableTrackProxy& other) + requires ReadOnly + { m_container = other.m_container; m_index = other.m_index; return *this; diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index 3d91547c725..7d861721260 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -42,10 +42,10 @@ template class TransitiveConstPointer { public: TransitiveConstPointer() = default; - TransitiveConstPointer(T* ptr) : m_ptr{ptr} {} + explicit TransitiveConstPointer(T* ptr) : m_ptr{ptr} {} template - TransitiveConstPointer(const TransitiveConstPointer& other) + explicit TransitiveConstPointer(const TransitiveConstPointer& other) : m_ptr{other.ptr()} {} template @@ -214,17 +214,29 @@ class TrackStateProxy { /// /// @{ - /// Constructor and assignment operator to construct TrackStateProxy - /// from mutable + /// Copy constructor: const to const or mutable to mutable /// @param other The other TrackStateProxy to construct from - TrackStateProxy(const TrackStateProxy& other) + TrackStateProxy(const TrackStateProxy& other) = default; + + /// Copy assignment operator: const to const or mutable to mutable + /// @param other The other TrackStateProxy to assign from + /// @return Reference to this TrackStateProxy + TrackStateProxy& operator=(const TrackStateProxy& other) = default; + + /// Constructor from mutable TrackStateProxy + /// @note Only available if the track state proxy is read-only + /// @param other The other TrackStateProxy to construct from + explicit TrackStateProxy(const TrackStateProxy& other) + requires ReadOnly : m_traj{other.m_traj}, m_istate{other.m_istate} {} /// Assignment operator to from mutable @c TrackStateProxy - /// @param other The other TrackStateProxy to construct from + /// @param other The other TrackStateProxy to assign from + /// @note Only available if the track state proxy is read-only /// @return Reference to this TrackStateProxy - TrackStateProxy& operator=( - const TrackStateProxy& other) { + TrackStateProxy& operator=(const TrackStateProxy& other) + requires ReadOnly + { m_traj = other.m_traj; m_istate = other.m_istate; diff --git a/Core/include/Acts/EventData/TrackStateType.hpp b/Core/include/Acts/EventData/TrackStateType.hpp index 4820ffe6e19..d697b9111ea 100644 --- a/Core/include/Acts/EventData/TrackStateType.hpp +++ b/Core/include/Acts/EventData/TrackStateType.hpp @@ -46,7 +46,9 @@ class TrackStateType { /// Constructor from a reference to the underlying value container /// @param raw the value container - TrackStateType(raw_type& raw) : m_raw{&raw} { assert(m_raw != nullptr); } + explicit TrackStateType(raw_type& raw) : m_raw{&raw} { + assert(m_raw != nullptr); + } // Delete copy constructor TrackStateType(const TrackStateType&) = delete; @@ -114,7 +116,7 @@ class ConstTrackStateType { /// Constructor from a reference to the underlying value container /// @param raw the value container - ConstTrackStateType(const raw_type& raw) : m_raw{&raw} { + explicit ConstTrackStateType(const raw_type& raw) : m_raw{&raw} { assert(m_raw != nullptr); } diff --git a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp index 4238afd88f6..ee5a3b1729b 100644 --- a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp +++ b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp @@ -569,10 +569,10 @@ class ConstVectorMultiTrajectory final ConstVectorMultiTrajectory(const ConstVectorMultiTrajectory& other) : VectorMultiTrajectoryBase{other} {} - ConstVectorMultiTrajectory(const VectorMultiTrajectory& other) + explicit ConstVectorMultiTrajectory(const VectorMultiTrajectory& other) : VectorMultiTrajectoryBase{other} {} - ConstVectorMultiTrajectory(VectorMultiTrajectory&& other) + explicit ConstVectorMultiTrajectory(VectorMultiTrajectory&& other) : VectorMultiTrajectoryBase{std::move(other)} {} ConstVectorMultiTrajectory(ConstVectorMultiTrajectory&&) = default; diff --git a/Core/include/Acts/EventData/VectorTrackContainer.hpp b/Core/include/Acts/EventData/VectorTrackContainer.hpp index d0ce9cf402d..4f062376461 100644 --- a/Core/include/Acts/EventData/VectorTrackContainer.hpp +++ b/Core/include/Acts/EventData/VectorTrackContainer.hpp @@ -204,7 +204,7 @@ class VectorTrackContainer final : public detail_vtc::VectorTrackContainerBase { VectorTrackContainer(const VectorTrackContainer& other) = default; VectorTrackContainer(VectorTrackContainer&&) = default; - VectorTrackContainer(const ConstVectorTrackContainer& other); + explicit VectorTrackContainer(const ConstVectorTrackContainer& other); public: // BEGIN INTERFACE @@ -282,13 +282,13 @@ class ConstVectorTrackContainer final ConstVectorTrackContainer() : VectorTrackContainerBase{} {} ConstVectorTrackContainer(const ConstVectorTrackContainer& other) = default; - ConstVectorTrackContainer(const VectorTrackContainer& other) + explicit ConstVectorTrackContainer(const VectorTrackContainer& other) : VectorTrackContainerBase{other} { assert(checkConsistency()); } ConstVectorTrackContainer(ConstVectorTrackContainer&&) = default; - ConstVectorTrackContainer(VectorTrackContainer&& other) + explicit ConstVectorTrackContainer(VectorTrackContainer&& other) : VectorTrackContainerBase{std::move(other)} { assert(checkConsistency()); } diff --git a/Core/include/Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp b/Core/include/Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp index 42b480482ec..94413db5dad 100644 --- a/Core/include/Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp +++ b/Core/include/Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp @@ -50,7 +50,7 @@ struct FreeToBoundCorrection { explicit FreeToBoundCorrection(bool apply_); /// Return boolean for applying correction or not - operator bool() const; + explicit operator bool() const; }; namespace detail { @@ -72,7 +72,7 @@ struct CorrectedFreeToBoundTransformer { /// Construct from a FreeToBoundCorrection /// /// @param freeToBoundCorrection The freeToBoundCorrection object - CorrectedFreeToBoundTransformer( + explicit CorrectedFreeToBoundTransformer( const FreeToBoundCorrection& freeToBoundCorrection); /// Default constructors diff --git a/Core/include/Acts/EventData/detail/DynamicKeyIterator.hpp b/Core/include/Acts/EventData/detail/DynamicKeyIterator.hpp index df0f1ceeaf2..3462b84c896 100644 --- a/Core/include/Acts/EventData/detail/DynamicKeyIterator.hpp +++ b/Core/include/Acts/EventData/detail/DynamicKeyIterator.hpp @@ -26,7 +26,7 @@ class DynamicKeyIterator { using pointer = void; using reference = void; - DynamicKeyIterator(typename map_t::const_iterator it) : m_it{it} {} + explicit DynamicKeyIterator(typename map_t::const_iterator it) : m_it{it} {} DynamicKeyIterator() = default; DynamicKeyIterator& operator++() { @@ -56,9 +56,16 @@ static_assert(std::forward_iterator>, template class DynamicKeyRange { public: + using map_t = std::unordered_map>; + DynamicKeyRange(DynamicKeyIterator begin, DynamicKeyIterator end) : m_begin{begin}, m_end{end} {} + DynamicKeyRange(typename map_t::const_iterator begin, + typename map_t::const_iterator end) + : m_begin{DynamicKeyIterator{begin}}, + m_end{DynamicKeyIterator{end}} {} + DynamicKeyIterator begin() const { return m_begin; } DynamicKeyIterator end() const { return m_end; } diff --git a/Core/include/Acts/EventData/detail/MultiTrajectoryTestsCommon.hpp b/Core/include/Acts/EventData/detail/MultiTrajectoryTestsCommon.hpp index 1668642e867..33ce2acb643 100644 --- a/Core/include/Acts/EventData/detail/MultiTrajectoryTestsCommon.hpp +++ b/Core/include/Acts/EventData/detail/MultiTrajectoryTestsCommon.hpp @@ -1013,8 +1013,10 @@ class MultiTrajectoryTestsCommon { auto i0 = t.addTrackState(kMask); typename trajectory_t::TrackStateProxy tp = t.getTrackState(i0); // mutable - typename trajectory_t::TrackStateProxy tp2{tp}; // mutable to mutable + typename trajectory_t::TrackStateProxy tp2{tp}; // mutable to mutable + static_cast(tp2); typename trajectory_t::ConstTrackStateProxy tp3{tp}; // mutable to const + static_cast(tp3); // const to mutable: this won't compile // MultiTrajectory::TrackStateProxy tp4{tp3}; } diff --git a/Core/include/Acts/EventData/detail/TestTrackState.hpp b/Core/include/Acts/EventData/detail/TestTrackState.hpp index 26ef78d8084..49ef5c0150d 100644 --- a/Core/include/Acts/EventData/detail/TestTrackState.hpp +++ b/Core/include/Acts/EventData/detail/TestTrackState.hpp @@ -49,8 +49,8 @@ struct TestTrackState { pathLength(std::uniform_real_distribution( 1 * Acts::UnitConstants::mm, 10 * Acts::UnitConstants::mm)(rng)) { // set a random geometry identifier to uniquely identify each surface - auto geoId = - std::uniform_int_distribution()(rng); + Acts::GeometryIdentifier geoId{ + std::uniform_int_distribution()(rng)}; surface->assignGeometryId(geoId); // create source link w/ inline 1d or 2d measurement data diff --git a/Core/include/Acts/Geometry/BlueprintNode.hpp b/Core/include/Acts/Geometry/BlueprintNode.hpp index 71495b493dd..fee4e7f0cb0 100644 --- a/Core/include/Acts/Geometry/BlueprintNode.hpp +++ b/Core/include/Acts/Geometry/BlueprintNode.hpp @@ -10,6 +10,8 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Geometry/BlueprintOptions.hpp" +#include "Acts/Geometry/CuboidVolumeBounds.hpp" +#include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/NavigationPolicyFactory.hpp" #include "Acts/Utilities/AxisDefinitions.hpp" @@ -30,11 +32,13 @@ class PortalShellBase; namespace Experimental { -class CylinderContainerBlueprintNode; class MaterialDesignatorBlueprintNode; class StaticBlueprintNode; class LayerBlueprintNode; +class CylinderContainerBlueprintNode; +class CuboidContainerBlueprintNode; + /// Base class for all nodes in the blueprint tree. This class defines the /// three-phase construction process. The three phases are /// @@ -44,9 +48,9 @@ class LayerBlueprintNode; /// structures /// /// During the *build* phase, the `build` method of all nodes in the tree are -/// called recursively. Some nodes, like @ref Acts::Experimental::CylinderContainerBlueprintNode, +/// called recursively. Some nodes, like @ref Acts::Experimental::ContainerBlueprintNode, /// will take action on the volumes returns from its children, and perform -/// sizing to connect them. See the @ref Acts::Experimental::CylinderContainerBlueprintNode +/// sizing to connect them. See the @ref Acts::Experimental::ContainerBlueprintNode /// and @ref Acts::CylinderVolumeStack documentation for details on how the /// sizing is carried out. class BlueprintNode { @@ -92,7 +96,7 @@ class BlueprintNode { /// Each boundary surface is then turned into a @ref Acts::TrivialPortalLink, which /// in turn produces a one-sided portal (see @ref Acts::Portal documentation) /// - /// Some nodes (like @ref Acts::Experimental::CylinderContainerBlueprintNode) will take action on + /// Some nodes (like @ref Acts::Experimental::ContainerBlueprintNode) will take action on /// their children, and unify the connected portals. /// /// After a node's processing has completed, it returns a reference to a @ref @@ -187,7 +191,7 @@ class BlueprintNode { const std::string& volumeName = "undefined", const std::function& callback = {}); - /// Convenience method for creating a @ref Acts::Experimental::CylinderContainerBlueprintNode. + /// Convenience method for creating a cylinder specialization of @ref Acts::Experimental::ContainerBlueprintNode. /// @param name The name of the container node. This name is only reflected /// in the node tree for debugging, as no extra volumes is created /// for the container. @@ -199,6 +203,18 @@ class BlueprintNode { const std::function& callback = {}); + /// Convenience method for creating a cuboid specialization of @ref Acts::Experimental::ContainerBlueprintNode. + /// @param name The name of the container node. This name is only reflected + /// in the node tree for debugging, as no extra volumes is created + /// for the container. + /// @param direction The direction of the stack configuration. See + /// @ref Acts::CuboidVolumeStack for details. + /// @param callback An optional callback that receives the node as an argument + CuboidContainerBlueprintNode& addCuboidContainer( + const std::string& name, AxisDirection direction, + const std::function& + callback = {}); + /// Convenience method for creating a @ref Acts::Experimental::MaterialDesignatorBlueprintNode. /// @param name The name of the material designator node. Used for debugging /// the node tree only. diff --git a/Core/include/Acts/Geometry/ConeVolumeBounds.hpp b/Core/include/Acts/Geometry/ConeVolumeBounds.hpp index e3f0c36a25c..c9020f70ac1 100644 --- a/Core/include/Acts/Geometry/ConeVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/ConeVolumeBounds.hpp @@ -78,7 +78,8 @@ class ConeVolumeBounds : public VolumeBounds { /// Constructor - from a fixed size array /// /// @param values The bound values - ConeVolumeBounds(const std::array& values) noexcept(false) + explicit ConeVolumeBounds(const std::array& values) noexcept( + false) : m_values(values) { checkConsistency(); buildSurfaceBounds(); diff --git a/Core/include/Acts/Geometry/ContainerBlueprintNode.hpp b/Core/include/Acts/Geometry/ContainerBlueprintNode.hpp new file mode 100644 index 00000000000..1ad55765874 --- /dev/null +++ b/Core/include/Acts/Geometry/ContainerBlueprintNode.hpp @@ -0,0 +1,277 @@ +// This file is part of the ACTS project. +// +// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. + +#pragma once + +#include "Acts/Geometry/BlueprintNode.hpp" +#include "Acts/Geometry/BlueprintOptions.hpp" +#include "Acts/Geometry/TrackingVolume.hpp" +#include "Acts/Geometry/VolumeAttachmentStrategy.hpp" +#include "Acts/Geometry/VolumeResizeStrategy.hpp" +#include "Acts/Geometry/VolumeStack.hpp" +#include "Acts/Utilities/AxisDefinitions.hpp" +#include "Acts/Utilities/GraphViz.hpp" +#include "Acts/Utilities/Logger.hpp" +#include "Acts/Utilities/ThrowAssert.hpp" + +#include + +namespace Acts::Experimental { + +/// @class ContainerBlueprintNode +/// +/// A blueprint node that can contain multiple child volumes. It is responsible +/// for managing the child volumes and their shells. The child volumes can be +/// either gap volumes or volumes from child nodes. +/// +/// The container node is responsible for: +/// 1. Managing the child volumes and their shells +/// 2. Creating gap volumes between child volumes +/// 3. Collecting shells from child nodes and gap volumes +/// 4. Building the volume stack +/// +/// The container node is an abstract base class. Derived classes must +/// implement: +/// 1. makeStack - to create the appropriate volume stack +/// 2. typeName - to provide the type name for debug output +/// +class ContainerBlueprintNode : public BlueprintNode { + public: + /// Main constructor for the container node. + /// @param name The name of the node (for debug only) + /// @param axis The stacking axis direction in local reference frame + /// @param attachmentStrategy The attachment strategy for the stack + /// @param resizeStrategy The resize strategy + ContainerBlueprintNode( + const std::string& name, AxisDirection axis, + VolumeAttachmentStrategy attachmentStrategy = + VolumeAttachmentStrategy::Midpoint, + VolumeResizeStrategy resizeStrategy = VolumeResizeStrategy::Expand); + + /// @copydoc BlueprintNode::name + const std::string& name() const override; + + /// This participates in the construction of the geometry via the blueprint + /// tree. The steps are approximately as follows: + /// -# Collect all child volumes + /// -# Package them into a VolumeStack (cuboid or cylinder), which performs + /// sizing and/or gap creation + /// -# Return the VolumeStack as a volume up the tree + /// + /// @param options The global blueprint options + /// @param gctx The geometry context (nominal usually) + /// @param logger The logger to use + /// @return The combined VolumeStack + Volume& build(const Experimental::BlueprintOptions& options, + const GeometryContext& gctx, + const Logger& logger = Acts::getDummyLogger()) override; + + /// This participates in the construction of the geometry via the blueprint + /// tree. The steps are approximately as follows: + /// -# Register portals created for gap volumes, as they're not handled by + /// dedicated nodes + /// -# Register gap volumes in the @p parent volume + /// -# Create a configured @ref Acts::INavigationPolicy for the gap + /// -# Call `finalize` on all children while passing through @p parent. + /// + /// @param options The global blueprint options + /// @param gctx The geometry context (nominal usually) + /// @param parent The parent volume + /// @param logger The logger to use + void finalize(const Experimental::BlueprintOptions& options, + const GeometryContext& gctx, TrackingVolume& parent, + const Logger& logger) override; + + /// Setter for the stacking direction + /// @param direction The stacking direction + /// @return This node for chaining + ContainerBlueprintNode& setDirection(AxisDirection direction); + + /// Setter for the attachment strategy + /// @param attachmentStrategy The attachment strategy + /// @return This node for chaining + ContainerBlueprintNode& setAttachmentStrategy( + VolumeAttachmentStrategy attachmentStrategy); + + /// Setter for the resize strategy + /// @param resizeStrategy The resize strategy + /// @return This node for chaining + ContainerBlueprintNode& setResizeStrategy( + VolumeResizeStrategy resizeStrategy); + + /// Accessor to the stacking direction + /// @return The stacking direction + AxisDirection direction() const; + + /// Accessor to the attachment strategy + /// @return The attachment strategy + VolumeAttachmentStrategy attachmentStrategy() const; + + /// Accessor to the resize strategy + /// @return The resize strategy + VolumeResizeStrategy resizeStrategy() const; + + /// @copydoc BlueprintNode::addToGraphviz + void addToGraphviz(std::ostream& os) const override; + + protected: + /// Make the volume stack for the container. This is called by the build + /// method and is implemented by the derived classes. + /// @param volumes The volumes to stack + /// @param logger The logger to use + /// @return The volume stack + virtual std::unique_ptr makeStack(std::vector& volumes, + const Logger& logger) = 0; + + /// Get the type name of the container. This is used for the debug output + /// of the container and encoding the volume shape in the dot graph. + /// @return The type name + virtual const std::string& typeName() const = 0; + + /// Collect shells from child nodes and gap volumes + /// + /// This function is responsible for collecting shells from child nodes and + /// creating shells for gap volumes. It is used by the connect method to + /// prepare the shells for the volume stack. + /// + /// The function processes each volume in m_childVolumes in two ways: + /// 1. For gap volumes: + /// - Creates a TrackingVolume from the gap volume + /// - Assigns a unique name (ContainerName::GapN) + /// - Creates a single shell for the gap volume + /// - Stores both the shell and gap volume in m_gaps for later use + /// + /// 2. For child volumes: + /// - Looks up the corresponding child node in m_volumeToNode + /// - Calls connect() on the child node to get its shell + /// - Validates that the shell type matches the expected type + /// - Ensures the shell is valid + /// + /// The function maintains the order of volumes as they appear in + /// m_childVolumes, which is important for the final stack shell construction. + /// + /// @tparam BaseShell The base shell type (e.g. CylinderPortalShell) + /// @tparam SingleShell The single shell type (e.g. SingleCylinderPortalShell) + /// @param options The blueprint options + /// @param gctx The geometry context + /// @param stack The volume stack + /// @param prefix The prefix for debug output + /// @param logger The logger to use + /// @return A vector of shells in the same order as m_childVolumes + template + std::vector collectChildShells( + const Experimental::BlueprintOptions& options, + const GeometryContext& gctx, VolumeStack& stack, + const std::string& prefix, const Logger& logger); + + /// Implementation of the connect method for container nodes + /// + /// This method is responsible for: + /// 1. Collecting shells from child nodes and gap volumes + /// 2. Validating that the number of shells matches the number of child + /// volumes + /// 3. Ensuring all shells are valid + /// 4. Creating a merged stack shell from all collected shells + /// + /// @tparam BaseShell The base shell type (e.g. CylinderPortalShell) + /// @tparam SingleShell The single shell type (e.g. SingleCylinderPortalShell) + /// @tparam ShellStack The stack shell type (e.g. StackCylinderPortalShell) + /// @param options The blueprint options + /// @param gctx The geometry context + /// @param stack The volume stack + /// @param prefix The prefix for debug output + /// @param logger The logger to use + /// @return The merged stack shell + template + PortalShellBase& connectImpl(const Experimental::BlueprintOptions& options, + const GeometryContext& gctx, VolumeStack* stack, + const std::string& prefix, const Logger& logger); + + std::string m_name; + AxisDirection m_direction = AxisDirection::AxisZ; + VolumeAttachmentStrategy m_attachmentStrategy{ + VolumeAttachmentStrategy::Midpoint}; + VolumeResizeStrategy m_resizeStrategy{VolumeResizeStrategy::Expand}; + + std::vector m_childVolumes; + // This is going to be an instance of a *stack* of volumes, which is created + // by the derived classes + std::unique_ptr m_stack{nullptr}; + std::map m_volumeToNode; + + std::unique_ptr m_shell{nullptr}; + std::vector, + std::unique_ptr>> + m_gaps; +}; + +class CylinderContainerBlueprintNode final : public ContainerBlueprintNode { + public: + using ContainerBlueprintNode::ContainerBlueprintNode; + + /// This participates in the construction of the geometry via the blueprint + /// tree. The steps are approximately as follows: + /// -# Walk through all volumes that were created by the build phase + /// -# Check if they are: *real* child volumes or gap volumes + /// - If gap volume: produce a @ref Acts::TrackingVolume, and wrap it in a single use shell + /// - If child volume: locate the right child node it came from, call + /// ` connect` and collect the returned shell + /// -# Produce a combined StackPortalShell (cuboid or cylinder) from all the + /// shells + /// -# Return that shell representation + /// + /// @param options The global blueprint options + /// @param gctx The geometry context (nominal usually) + /// @param logger The logger to use + /// @return The combined StackPortalShell (cuboid or cylinder) + PortalShellBase& connect( + const Experimental::BlueprintOptions& options, + const GeometryContext& gctx, + const Logger& logger = Acts::getDummyLogger()) override; + + std::unique_ptr makeStack(std::vector& volumes, + const Logger& logger) override; + + protected: + inline static const std::string s_typeName = "Cylinder"; + const std::string& typeName() const override; +}; + +class CuboidContainerBlueprintNode final : public ContainerBlueprintNode { + public: + using ContainerBlueprintNode::ContainerBlueprintNode; + + /// This participates in the construction of the geometry via the blueprint + /// tree. The steps are approximately as follows: + /// -# Walk through all volumes that were created by the build phase + /// -# Check if they are: *real* child volumes or gap volumes + /// - If gap volume: produce a @ref Acts::TrackingVolume, and wrap it in a single use shell + /// - If child volume: locate the right child node it came from, call + /// ` connect` and collect the returned shell + /// -# Produce a combined StackPortalShell (cuboid or cylinder) from all the + /// shells + /// -# Return that shell representation + /// + /// @param options The global blueprint options + /// @param gctx The geometry context (nominal usually) + /// @param logger The logger to use + /// @return The combined StackPortalShell (cuboid or cylinder) + PortalShellBase& connect( + const Experimental::BlueprintOptions& options, + const GeometryContext& gctx, + const Logger& logger = Acts::getDummyLogger()) override; + + std::unique_ptr makeStack(std::vector& volumes, + const Logger& logger) override; + + protected: + inline static const std::string s_typeName = "Cuboid"; + const std::string& typeName() const override; +}; + +} // namespace Acts::Experimental diff --git a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp index 7c80a1f8f1f..04bfbc02de4 100644 --- a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp @@ -83,7 +83,7 @@ class CuboidVolumeBounds : public VolumeBounds { /// Constructor - from a fixed size array /// /// @param values iw the bound values - CuboidVolumeBounds(const std::array& values); + explicit CuboidVolumeBounds(const std::array& values); CuboidVolumeBounds( std::initializer_list> keyValues); diff --git a/Core/include/Acts/Geometry/CuboidVolumeBuilder.hpp b/Core/include/Acts/Geometry/CuboidVolumeBuilder.hpp index c0eb1695302..18fda76f9e9 100644 --- a/Core/include/Acts/Geometry/CuboidVolumeBuilder.hpp +++ b/Core/include/Acts/Geometry/CuboidVolumeBuilder.hpp @@ -124,7 +124,7 @@ class CuboidVolumeBuilder : public ITrackingVolumeBuilder { /// @brief Constructor that sets the config /// /// @param [in] cfg Configuration of the detector - CuboidVolumeBuilder(Config& cfg) : m_cfg(cfg) {} + explicit CuboidVolumeBuilder(Config& cfg) : m_cfg(cfg) {} /// @brief Setter of the config /// diff --git a/Core/include/Acts/Geometry/CuboidVolumeStack.hpp b/Core/include/Acts/Geometry/CuboidVolumeStack.hpp index 43b507853e4..fb74660a077 100644 --- a/Core/include/Acts/Geometry/CuboidVolumeStack.hpp +++ b/Core/include/Acts/Geometry/CuboidVolumeStack.hpp @@ -12,6 +12,7 @@ #include "Acts/Geometry/Volume.hpp" #include "Acts/Geometry/VolumeAttachmentStrategy.hpp" #include "Acts/Geometry/VolumeResizeStrategy.hpp" +#include "Acts/Geometry/VolumeStack.hpp" #include "Acts/Utilities/AxisDefinitions.hpp" #include "Acts/Utilities/Logger.hpp" @@ -31,7 +32,7 @@ namespace Acts { /// the input volumes are either extended or gap volumes are created. /// /// @note The size adjustment convention is that volumes are never shrunk -class CuboidVolumeStack : public Volume { +class CuboidVolumeStack : public VolumeStack { public: /// Constructor from a vector of volumes and direction /// @param volumes is the vector of volumes @@ -69,10 +70,6 @@ class CuboidVolumeStack : public Volume { std::optional transform = std::nullopt, const Logger& logger = getDummyLogger()) override; - /// Access the gap volume that were created during attachment or resizing. - /// @return the vector of gap volumes - const std::vector>& gaps() const; - /// Convert axis direction to an array index according to /// stack convention. For example, AxisX --> 0 /// @param direction is the axis direction to convert @@ -85,12 +82,6 @@ class CuboidVolumeStack : public Volume { AxisDirection direction); private: - /// Helper to get the first volume in the input, and throw an exception if - /// there is not one. - /// @param volumes is the vector of volumes - /// @return the first volume - static Volume& initialVolume(const std::vector& volumes); - /// Helper function called during construction that performs the /// internal attachment and produces the overall outer volume bounds. /// @param strategy is the attachment strategy @@ -139,27 +130,13 @@ class CuboidVolumeStack : public Volume { std::pair synchronizeBounds(std::vector& volumes, const Logger& logger); - /// Helper function to create a gap volume with given bounds and register it. - /// @param transform is the transform of the gap volume - /// @param bounds is the bounds of the gap volume - /// @return the shared pointer to the gap volume - std::shared_ptr addGapVolume( - const Transform3& transform, const std::shared_ptr& bounds); - - /// Merging direction of the stack - /// in local group coordinates - AxisDirection m_direction{}; - /// Directions orthogonal to the /// merging direction of the stack /// in local group coordinates AxisDirection m_dirOrth1{}; AxisDirection m_dirOrth2{}; - VolumeResizeStrategy m_resizeStrategy{}; Transform3 m_groupTransform{}; - std::vector> m_gaps{}; - std::vector& m_volumes; }; } // namespace Acts diff --git a/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp b/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp index c90791e376a..a11dc025fdd 100644 --- a/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp @@ -64,8 +64,8 @@ class CutoutCylinderVolumeBounds : public VolumeBounds { /// Constructor - from a fixed size array /// /// @param values The bound values - CutoutCylinderVolumeBounds(const std::array& values) noexcept( - false) + explicit CutoutCylinderVolumeBounds( + const std::array& values) noexcept(false) : m_values(values) { checkConsistency(); buildSurfaceBounds(); diff --git a/Core/include/Acts/Geometry/CylinderContainerBlueprintNode.hpp b/Core/include/Acts/Geometry/CylinderContainerBlueprintNode.hpp deleted file mode 100644 index 5a85aeef8c0..00000000000 --- a/Core/include/Acts/Geometry/CylinderContainerBlueprintNode.hpp +++ /dev/null @@ -1,157 +0,0 @@ -// This file is part of the ACTS project. -// -// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. - -#pragma once - -#include "Acts/Geometry/BlueprintNode.hpp" -#include "Acts/Geometry/CylinderPortalShell.hpp" -#include "Acts/Geometry/CylinderVolumeStack.hpp" -#include "Acts/Geometry/VolumeAttachmentStrategy.hpp" -#include "Acts/Geometry/VolumeResizeStrategy.hpp" -#include "Acts/Utilities/AxisDefinitions.hpp" -#include "Acts/Utilities/Logger.hpp" - -#include - -namespace Acts::Experimental { - -/// This class handles the case of wrapping a set of cylinder-shaped children -/// and stacking them in a configured direction. -/// The stacking is done using @ref CylinderVolumeStack. -/// The container does not result in an extra volume in the hierarchy, as all -/// input volumes and any gap volumes produced are directly registered in the -/// volume of the parent of this node. -/// @note This node assumes all children produce only cylinder volumes! It throws -/// if this is not the case. -class CylinderContainerBlueprintNode final : public BlueprintNode { - public: - /// Main constructor for the cylinder container node. - /// @param name The name of the node (for debug only) - /// @param direction The stacking direction - /// @param attachmentStrategy The attachment strategy for the stack - /// @param resizeStrategy The resize strategy - /// @note The parameters are passed through to @ref CylinderVolumeStack, - /// see documentation of that class for more information - CylinderContainerBlueprintNode( - const std::string& name, AxisDirection direction, - VolumeAttachmentStrategy attachmentStrategy = - VolumeAttachmentStrategy::Midpoint, - VolumeResizeStrategy resizeStrategy = VolumeResizeStrategy::Expand); - - /// @copydoc BlueprintNode::name - const std::string& name() const override; - - /// This participates in the construction of the geometry via the blueprint - /// tree. The steps are approximately as follows: - /// -# Collect all child volumes - /// -# Package them into a @ref Acts::CylinderVolumeStack, which performs - /// sizing and/or gap creation - /// -# Return the @ref Acts::CylinderVolumeStack as a volume up the tree - /// - /// @param options The global blueprint options - /// @param gctx The geometry context (nominal usually) - /// @param logger The logger to use - /// @return The combined @ref Acts::CylinderVolumeStack - Volume& build(const BlueprintOptions& options, const GeometryContext& gctx, - const Logger& logger = Acts::getDummyLogger()) override; - - /// This participates in the construction of the geometry via the blueprint - /// tree. The steps are approximately as follows: - /// -# Walk through all volumes that were created by the build phase - /// -# Check if they are: *real* child volumes or gap volumes - /// - If gap volume: produce a @ref Acts::TrackingVolume, and wrap it in a single use shell - /// - If child volume: locate the right child node it came from, call - /// ` connect` and collect the returned shell - /// -# Produce a combined @ref Acts::CylinderStackPortalShell from all the shells - /// -# Return that shell representation - /// - /// @param options The global blueprint options - /// @param gctx The geometry context (nominal usually) - /// @param logger The logger to use - /// @return The combined @ref Acts::CylinderStackPortalShell - CylinderStackPortalShell& connect( - const BlueprintOptions& options, const GeometryContext& gctx, - const Logger& logger = Acts::getDummyLogger()) override; - - /// This participates in the construction of the geometry via the blueprint - /// tree. The steps are approximately as follows: - /// -# Register portals created for gap volumes, as they're not handled by - /// dedicated nodes - /// -# Register gap volumes in the @p parent volume - /// -# Create a configured @ref Acts::INavigationPolicy for the gap - /// -# Call `finalize` on all children while passing through @p parent. - /// - /// @param options The global blueprint options - /// @param gctx The geometry context (nominal usually) - /// @param parent The parent volume - /// @param logger The logger to use - void finalize(const BlueprintOptions& options, const GeometryContext& gctx, - TrackingVolume& parent, const Logger& logger) override; - - /// Setter for the stacking direction - /// @param direction The stacking direction - /// @return This node for chaining - CylinderContainerBlueprintNode& setDirection(AxisDirection direction); - - /// Setter for the attachment strategy - /// @param attachmentStrategy The attachment strategy - /// @return This node for chaining - CylinderContainerBlueprintNode& setAttachmentStrategy( - VolumeAttachmentStrategy attachmentStrategy); - - /// Setter for the resize strategy - /// @param resizeStrategy The resize strategy - /// @return This node for chaining - CylinderContainerBlueprintNode& setResizeStrategy( - VolumeResizeStrategy resizeStrategy); - - /// Accessor to the stacking direction - /// @return The stacking direction - AxisDirection direction() const; - - /// Accessor to the attachment strategy - /// @return The attachment strategy - VolumeAttachmentStrategy attachmentStrategy() const; - - /// Accessor to the resize strategy - /// @return The resize strategy - VolumeResizeStrategy resizeStrategy() const; - - private: - /// @copydoc BlueprintNode::addToGraphviz - void addToGraphviz(std::ostream& os) const override; - - /// Helper function to check if a volume was created as a gap volume. - /// @param volume The volume to check - /// @return True if the volume is a gap volume, false otherwise - bool isGapVolume(const Volume& volume) const; - - std::vector collectChildShells( - const BlueprintOptions& options, const GeometryContext& gctx, - const Logger& logger); - - std::string m_name; - - AxisDirection m_direction = AxisDirection::AxisZ; - - VolumeAttachmentStrategy m_attachmentStrategy{ - VolumeAttachmentStrategy::Midpoint}; - - VolumeResizeStrategy m_resizeStrategy{VolumeResizeStrategy::Expand}; - - // Is only initialized during `build` - std::vector m_childVolumes; - std::unique_ptr m_stack{nullptr}; - std::map m_volumeToNode; - std::vector, - std::unique_ptr>> - m_gaps; - std::unique_ptr m_shell{nullptr}; -}; - -} // namespace Acts::Experimental diff --git a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp index 79916c84083..1477ebf667c 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp @@ -112,7 +112,7 @@ class CylinderVolumeBounds : public VolumeBounds { /// Constructor - from a fixed size array /// /// @param values The bound values - CylinderVolumeBounds(const std::array& values); + explicit CylinderVolumeBounds(const std::array& values); /// Constructor - extruded from cylinder bounds and thickness /// diff --git a/Core/include/Acts/Geometry/CylinderVolumeBuilder.hpp b/Core/include/Acts/Geometry/CylinderVolumeBuilder.hpp index 4356e26f313..3ff67dbdd0a 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeBuilder.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeBuilder.hpp @@ -509,9 +509,10 @@ class CylinderVolumeBuilder : public ITrackingVolumeBuilder { /// /// @param [in] cvbConfig is the configuration struct to steer the builder /// @param [in] logger logging instance - CylinderVolumeBuilder(const Config& cvbConfig, - std::unique_ptr logger = getDefaultLogger( - "CylinderVolumeBuilder", Logging::INFO)); + explicit CylinderVolumeBuilder(const Config& cvbConfig, + std::unique_ptr logger = + getDefaultLogger("CylinderVolumeBuilder", + Logging::INFO)); /// Destructor ~CylinderVolumeBuilder() override; diff --git a/Core/include/Acts/Geometry/CylinderVolumeHelper.hpp b/Core/include/Acts/Geometry/CylinderVolumeHelper.hpp index 85f20ee8ea9..aafc0d96a27 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeHelper.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeHelper.hpp @@ -56,9 +56,10 @@ class CylinderVolumeHelper : public ITrackingVolumeHelper { /// Constructor /// @param cvhConfig is the configuration struct for this builder /// @param logger logging instance - CylinderVolumeHelper(const Config& cvhConfig, - std::unique_ptr logger = getDefaultLogger( - "CylinderVolumeHelper", Logging::INFO)); + explicit CylinderVolumeHelper(const Config& cvhConfig, + std::unique_ptr logger = + getDefaultLogger("CylinderVolumeHelper", + Logging::INFO)); /// Create a TrackingVolume* from a set of layers and (optional) parameters /// diff --git a/Core/include/Acts/Geometry/CylinderVolumeStack.hpp b/Core/include/Acts/Geometry/CylinderVolumeStack.hpp index 44fa11b5ecf..8fdda18ef39 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeStack.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeStack.hpp @@ -13,6 +13,7 @@ #include "Acts/Geometry/Volume.hpp" #include "Acts/Geometry/VolumeAttachmentStrategy.hpp" #include "Acts/Geometry/VolumeResizeStrategy.hpp" +#include "Acts/Geometry/VolumeStack.hpp" #include "Acts/Utilities/AxisDefinitions.hpp" #include "Acts/Utilities/Logger.hpp" @@ -32,7 +33,7 @@ namespace Acts { /// /// @note The volumes are never shrunk, because this would potentially /// result in overlaps of the resulting volumes bounds. -class CylinderVolumeStack : public Volume { +class CylinderVolumeStack : public VolumeStack { public: /// Constructor from a vector of volumes and direction /// @param volumes is the vector of volumes @@ -71,17 +72,7 @@ class CylinderVolumeStack : public Volume { std::optional transform = std::nullopt, const Logger& logger = getDummyLogger()) override; - /// Access the gap volume that were created during attachment or resizing. - /// @return the vector of gap volumes - const std::vector>& gaps() const; - private: - /// Helper to get the first volume in the input, and throw an exception if - /// there is not one. - /// @param volumes is the vector of volumes - /// @return the first volume - static Volume& initialVolume(const std::vector& volumes); - /// Helper function called during construction that performs the /// internal attachment and produces the overall outer volume bounds. /// @param direction is the binning direction @@ -155,18 +146,7 @@ class CylinderVolumeStack : public Volume { static void checkNoPhiOrBevel(const CylinderVolumeBounds& bounds, const Logger& logger); - /// Helper function to create a gap volume with given bounds and register it. - /// @param transform is the transform of the gap volume - /// @param bounds is the bounds of the gap volume - /// @return the shared pointer to the gap volume - std::shared_ptr addGapVolume( - const Transform3& transform, const std::shared_ptr& bounds); - - AxisDirection m_direction{}; - VolumeResizeStrategy m_resizeStrategy{}; Transform3 m_groupTransform{}; - std::vector> m_gaps{}; - std::vector& m_volumes; }; } // namespace Acts diff --git a/Core/include/Acts/Geometry/GenericApproachDescriptor.hpp b/Core/include/Acts/Geometry/GenericApproachDescriptor.hpp index e4c855fe762..c79fd55538e 100644 --- a/Core/include/Acts/Geometry/GenericApproachDescriptor.hpp +++ b/Core/include/Acts/Geometry/GenericApproachDescriptor.hpp @@ -35,7 +35,7 @@ class GenericApproachDescriptor : public ApproachDescriptor { /// passing ownership /// /// @param aSurfaces are the approach surfaces - GenericApproachDescriptor( + explicit GenericApproachDescriptor( std::vector> aSurfaces) : ApproachDescriptor(), m_surfaces(std::move(aSurfaces)), diff --git a/Core/include/Acts/Geometry/GenericCuboidVolumeBounds.hpp b/Core/include/Acts/Geometry/GenericCuboidVolumeBounds.hpp index 93ebeaa828b..202f0e801a1 100644 --- a/Core/include/Acts/Geometry/GenericCuboidVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/GenericCuboidVolumeBounds.hpp @@ -39,13 +39,13 @@ class GenericCuboidVolumeBounds : public VolumeBounds { /// - the first 4 vertices are the "top" face /// - the second 4 vertices are the "bottom" face /// - both faces are given in counter clock wise order - GenericCuboidVolumeBounds( + explicit GenericCuboidVolumeBounds( const std::array& vertices) noexcept(false); /// Constructor from a fixed size array /// /// @param values The input values - GenericCuboidVolumeBounds( + explicit GenericCuboidVolumeBounds( const std::array& values) noexcept(false); ~GenericCuboidVolumeBounds() override = default; diff --git a/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp b/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp index 0c2e6f996aa..459ab393503 100644 --- a/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp +++ b/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp @@ -69,7 +69,7 @@ class GeometryHierarchyMap { /// Construct the container from the given elements. /// /// @param elements input elements (must be unique with respect to identifier) - GeometryHierarchyMap(std::vector elements); + explicit GeometryHierarchyMap(std::vector elements); /// Construct the container from an initializer list. /// @@ -99,7 +99,9 @@ class GeometryHierarchyMap { /// Access the geometry identifier for the i-th element with bounds check. /// /// @throws std::out_of_range for invalid indices - GeometryIdentifier idAt(std::size_t index) const { return m_ids.at(index); } + GeometryIdentifier idAt(std::size_t index) const { + return GeometryIdentifier(m_ids.at(index)); + } /// Access the value of the i-th element in the container with bounds check. /// @@ -255,7 +257,8 @@ inline void GeometryHierarchyMap::fill( for (const auto& element : elements) { m_ids.push_back(element.first.value()); - m_masks.push_back(makeLeadingLevelsMask(element.first.value())); + m_masks.push_back( + makeLeadingLevelsMask(GeometryIdentifier(element.first.value()))); m_values.push_back(std::move(element.second)); } } diff --git a/Core/include/Acts/Geometry/GeometryIdentifier.hpp b/Core/include/Acts/Geometry/GeometryIdentifier.hpp index ca76b05592c..5802c38561c 100644 --- a/Core/include/Acts/Geometry/GeometryIdentifier.hpp +++ b/Core/include/Acts/Geometry/GeometryIdentifier.hpp @@ -33,7 +33,7 @@ class GeometryIdentifier { using Value = std::uint64_t; /// Construct from an already encoded value. - constexpr GeometryIdentifier(Value encoded) : m_value(encoded) {} + explicit constexpr GeometryIdentifier(Value encoded) : m_value(encoded) {} /// Construct default GeometryIdentifier with all values set to zero. GeometryIdentifier() = default; GeometryIdentifier(GeometryIdentifier&&) = default; diff --git a/Core/include/Acts/Geometry/GeometryObject.hpp b/Core/include/Acts/Geometry/GeometryObject.hpp index e76b27b4bfb..ed6c9373605 100644 --- a/Core/include/Acts/Geometry/GeometryObject.hpp +++ b/Core/include/Acts/Geometry/GeometryObject.hpp @@ -34,7 +34,7 @@ class GeometryObject { /// Constructor from a value /// /// @param geometryId the geometry identifier of the object - GeometryObject(const GeometryIdentifier& geometryId) + explicit GeometryObject(const GeometryIdentifier& geometryId) : m_geometryId(geometryId) {} /// Assignment operator diff --git a/Core/include/Acts/Geometry/GlueVolumesDescriptor.hpp b/Core/include/Acts/Geometry/GlueVolumesDescriptor.hpp index 11f0197b891..32486b4fc88 100644 --- a/Core/include/Acts/Geometry/GlueVolumesDescriptor.hpp +++ b/Core/include/Acts/Geometry/GlueVolumesDescriptor.hpp @@ -38,7 +38,7 @@ class GlueVolumesDescriptor { /// Constructor - with arguments /// /// @param gvs are the glue volume arrays mapped to the volume faces - GlueVolumesDescriptor( + explicit GlueVolumesDescriptor( const std::map>& gvs); diff --git a/Core/include/Acts/Geometry/GridPortalLink.hpp b/Core/include/Acts/Geometry/GridPortalLink.hpp index d94ba5fc749..d39d4f2a834 100644 --- a/Core/include/Acts/Geometry/GridPortalLink.hpp +++ b/Core/include/Acts/Geometry/GridPortalLink.hpp @@ -310,6 +310,10 @@ class GridPortalLink : public PortalLinkBase { /// @return The grid virtual const IGrid& grid() const = 0; + /// Return the associated grid in a type-erased form + /// @return The grid + virtual IGrid& grid() = 0; + /// Set the volume on all grid bins /// @param volume The volume to set virtual void setVolume(TrackingVolume* volume) = 0; @@ -401,23 +405,6 @@ class GridPortalLink : public PortalLinkBase { static void fillGrid1dTo2d(FillDirection dir, const GridPortalLink& grid1d, GridPortalLink& grid2d); - /// Index type for type earsed (**slow**) bin access - using IndexType = boost::container::static_vector; - - /// Helper function to get grid bin count in type-eraased way. - /// @return The number of bins in each direction - virtual IndexType numLocalBins() const = 0; - - /// Helper function to get grid bin content in type-eraased way. - /// @param indices The bin indices - /// @return The tracking volume at the bin - virtual const TrackingVolume*& atLocalBins(IndexType indices) = 0; - - /// Helper function to get grid bin content in type-eraased way. - /// @param indices The bin indices - /// @return The tracking volume at the bin - virtual const TrackingVolume* atLocalBins(IndexType indices) const = 0; - private: AxisDirection m_direction; }; @@ -491,7 +478,7 @@ class GridPortalLinkT : public GridPortalLink { /// Get the grid /// @return The grid - GridType& grid() { return m_grid; } + GridType& grid() override { return m_grid; } /// Get the number of dimensions of the grid /// @return The number of dimensions @@ -575,41 +562,6 @@ class GridPortalLinkT : public GridPortalLink { return m_grid.atPosition(m_projection(position)); } - /// Type erased access to the number of bins - /// @return The number of bins in each direction - IndexType numLocalBins() const override { - typename GridType::index_t idx = m_grid.numLocalBins(); - IndexType result; - for (std::size_t i = 0; i < DIM; i++) { - result.push_back(idx[i]); - } - return result; - } - - /// Type erased local bin access - /// @param indices The bin indices - /// @return The tracking volume at the bin - const TrackingVolume*& atLocalBins(IndexType indices) override { - throw_assert(indices.size() == DIM, "Invalid number of indices"); - typename GridType::index_t idx; - for (std::size_t i = 0; i < DIM; i++) { - idx[i] = indices[i]; - } - return m_grid.atLocalBins(idx); - } - - /// Type erased local bin access - /// @param indices The bin indices - /// @return The tracking volume at the bin - const TrackingVolume* atLocalBins(IndexType indices) const override { - throw_assert(indices.size() == DIM, "Invalid number of indices"); - typename GridType::index_t idx; - for (std::size_t i = 0; i < DIM; i++) { - idx[i] = indices[i]; - } - return m_grid.atLocalBins(idx); - } - private: /// Helper function that's assigned to project from the 2D local position to a /// possible 1D grid. diff --git a/Core/include/Acts/Geometry/KDTreeTrackingGeometryBuilder.hpp b/Core/include/Acts/Geometry/KDTreeTrackingGeometryBuilder.hpp index 4a7a01e214d..dec1cb38ff7 100644 --- a/Core/include/Acts/Geometry/KDTreeTrackingGeometryBuilder.hpp +++ b/Core/include/Acts/Geometry/KDTreeTrackingGeometryBuilder.hpp @@ -64,7 +64,7 @@ class KDTreeTrackingGeometryBuilder : public ITrackingGeometryBuilder { /// /// @param [in] cfg is the configuration struct for this builder /// @param [in] logger logging instance - KDTreeTrackingGeometryBuilder( + explicit KDTreeTrackingGeometryBuilder( const Config& cfg, std::unique_ptr logger = getDefaultLogger("KDTreeTrackingGeometryBuilder", Logging::INFO)); diff --git a/Core/include/Acts/Geometry/Layer.hpp b/Core/include/Acts/Geometry/Layer.hpp index e975fe3cf4b..7cc41cef575 100644 --- a/Core/include/Acts/Geometry/Layer.hpp +++ b/Core/include/Acts/Geometry/Layer.hpp @@ -219,9 +219,10 @@ class Layer : public virtual GeometryObject { /// @param thickness is the normal thickness of the Layer /// @param ades oapproach descriptor /// @param laytyp is the layer type if active or passive - Layer(std::unique_ptr surfaceArray, double thickness = 0., - std::unique_ptr ades = nullptr, - LayerType laytyp = passive); + explicit Layer(std::unique_ptr surfaceArray, + double thickness = 0., + std::unique_ptr ades = nullptr, + LayerType laytyp = passive); /// private method to set enclosing TrackingVolume, called by friend class /// only diff --git a/Core/include/Acts/Geometry/LayerArrayCreator.hpp b/Core/include/Acts/Geometry/LayerArrayCreator.hpp index dfccc615f3d..ba3c73a7177 100644 --- a/Core/include/Acts/Geometry/LayerArrayCreator.hpp +++ b/Core/include/Acts/Geometry/LayerArrayCreator.hpp @@ -39,9 +39,10 @@ class LayerArrayCreator : public ILayerArrayCreator { /// Constructor /// /// @param logger logging instance - LayerArrayCreator(const Config& /*cfg*/, - std::unique_ptr logger = - getDefaultLogger("LayerArrayCreator", Logging::INFO)) + explicit LayerArrayCreator(const Config& /*cfg*/, + std::unique_ptr logger = + getDefaultLogger("LayerArrayCreator", + Logging::INFO)) : m_logger(std::move(logger)) {} /// Destructor diff --git a/Core/include/Acts/Geometry/LayerCreator.hpp b/Core/include/Acts/Geometry/LayerCreator.hpp index 7895e161346..540ea6bd4bf 100644 --- a/Core/include/Acts/Geometry/LayerCreator.hpp +++ b/Core/include/Acts/Geometry/LayerCreator.hpp @@ -61,9 +61,9 @@ class LayerCreator { /// /// @param lcConfig is the configuration object /// @param logger logging instance - LayerCreator(const Config& lcConfig, - std::unique_ptr logger = - getDefaultLogger("LayerCreator", Logging::INFO)); + explicit LayerCreator(const Config& lcConfig, + std::unique_ptr logger = + getDefaultLogger("LayerCreator", Logging::INFO)); /// Destructor ~LayerCreator() = default; diff --git a/Core/include/Acts/Geometry/PassiveLayerBuilder.hpp b/Core/include/Acts/Geometry/PassiveLayerBuilder.hpp index b274c638846..1e4da9d50d2 100644 --- a/Core/include/Acts/Geometry/PassiveLayerBuilder.hpp +++ b/Core/include/Acts/Geometry/PassiveLayerBuilder.hpp @@ -54,9 +54,10 @@ class PassiveLayerBuilder : public ILayerBuilder { /// /// @param plConfig is the ocnfiguration struct that steers behavior /// @param logger logging instance - PassiveLayerBuilder(const Config& plConfig, - std::unique_ptr logger = getDefaultLogger( - "PassiveLayerBuilder", Logging::INFO)); + explicit PassiveLayerBuilder(const Config& plConfig, + std::unique_ptr logger = + getDefaultLogger("PassiveLayerBuilder", + Logging::INFO)); /// Destructor ~PassiveLayerBuilder() override = default; diff --git a/Core/include/Acts/Geometry/ProtoLayerHelper.hpp b/Core/include/Acts/Geometry/ProtoLayerHelper.hpp index fe187954903..f2464dacf74 100644 --- a/Core/include/Acts/Geometry/ProtoLayerHelper.hpp +++ b/Core/include/Acts/Geometry/ProtoLayerHelper.hpp @@ -37,9 +37,10 @@ class ProtoLayerHelper { /// Constructor with explicit config /// /// @param logger logging instance - ProtoLayerHelper(const Config& /*config*/, - std::unique_ptr logger = - getDefaultLogger("ProtoLayerHelper", Logging::INFO)) + explicit ProtoLayerHelper(const Config& /*config*/, + std::unique_ptr logger = + getDefaultLogger("ProtoLayerHelper", + Logging::INFO)) : m_logger(std::move(logger)) {} ~ProtoLayerHelper() = default; diff --git a/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp b/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp index a1076f8c6ba..ea338fcee3c 100644 --- a/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp +++ b/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp @@ -95,16 +95,18 @@ class SurfaceArrayCreator { /// Constructor with default config /// /// @param logger logging instance - SurfaceArrayCreator(std::unique_ptr logger = getDefaultLogger( - "SurfaceArrayCreator", Logging::INFO)) + explicit SurfaceArrayCreator(std::unique_ptr logger = + getDefaultLogger("SurfaceArrayCreator", + Logging::INFO)) : m_cfg(Config()), m_logger(std::move(logger)) {} /// Constructor with explicit config /// /// @param cfg Explicit config struct /// @param logger logging instance - SurfaceArrayCreator(const Config& cfg, - std::unique_ptr logger = getDefaultLogger( - "SurfaceArrayCreator", Logging::INFO)) + explicit SurfaceArrayCreator(const Config& cfg, + std::unique_ptr logger = + getDefaultLogger("SurfaceArrayCreator", + Logging::INFO)) : m_cfg(cfg), m_logger(std::move(logger)) {} /// Destructor diff --git a/Core/include/Acts/Geometry/SurfaceBinningMatcher.hpp b/Core/include/Acts/Geometry/SurfaceBinningMatcher.hpp index 3dae7b47932..8dcb59e2ba6 100644 --- a/Core/include/Acts/Geometry/SurfaceBinningMatcher.hpp +++ b/Core/include/Acts/Geometry/SurfaceBinningMatcher.hpp @@ -25,7 +25,7 @@ struct SurfaceBinningMatcher { SurfaceBinningMatcher() = default; - SurfaceBinningMatcher(const std::vector& tolpars) + explicit SurfaceBinningMatcher(const std::vector& tolpars) : tolerances(tolpars) {} /// Check function for surface equivalent diff --git a/Core/include/Acts/Geometry/TrackingGeometry.hpp b/Core/include/Acts/Geometry/TrackingGeometry.hpp index 33af38b2a56..45f290237f3 100644 --- a/Core/include/Acts/Geometry/TrackingGeometry.hpp +++ b/Core/include/Acts/Geometry/TrackingGeometry.hpp @@ -55,10 +55,11 @@ class TrackingGeometry { /// @param hook Identifier hook to be applied to surfaces /// @param logger instance of a logger (defaulting to the "silent" one) /// @param close If true, run the Gen1 geometry closure - TrackingGeometry(const std::shared_ptr& highestVolume, - const IMaterialDecorator* materialDecorator = nullptr, - const GeometryIdentifierHook& hook = {}, - const Logger& logger = getDummyLogger(), bool close = true); + explicit TrackingGeometry( + const std::shared_ptr& highestVolume, + const IMaterialDecorator* materialDecorator = nullptr, + const GeometryIdentifierHook& hook = {}, + const Logger& logger = getDummyLogger(), bool close = true); /// Destructor ~TrackingGeometry(); diff --git a/Core/include/Acts/Geometry/TrackingGeometryBuilder.hpp b/Core/include/Acts/Geometry/TrackingGeometryBuilder.hpp index 66eb55c4c86..d65836c2d80 100644 --- a/Core/include/Acts/Geometry/TrackingGeometryBuilder.hpp +++ b/Core/include/Acts/Geometry/TrackingGeometryBuilder.hpp @@ -59,10 +59,10 @@ class TrackingGeometryBuilder : public ITrackingGeometryBuilder { /// /// @param [in] cgbConfig is the configuration struct for this builder /// @param [in] logger logging instance - TrackingGeometryBuilder(const Config& cgbConfig, - std::unique_ptr logger = - getDefaultLogger("TrackingGeometryBuilder", - Logging::INFO)); + explicit TrackingGeometryBuilder( + const Config& cgbConfig, + std::unique_ptr logger = + getDefaultLogger("TrackingGeometryBuilder", Logging::INFO)); /// Destructor ~TrackingGeometryBuilder() override = default; diff --git a/Core/include/Acts/Geometry/TrackingVolume.hpp b/Core/include/Acts/Geometry/TrackingVolume.hpp index de50642c8a1..18e7f8f725d 100644 --- a/Core/include/Acts/Geometry/TrackingVolume.hpp +++ b/Core/include/Acts/Geometry/TrackingVolume.hpp @@ -153,7 +153,8 @@ class TrackingVolume : public Volume { /// Constructor from a regular volume /// @param volume is the volume to be converted /// @param volumeName is a string identifier - TrackingVolume(Volume& volume, const std::string& volumeName = "undefined"); + explicit TrackingVolume(Volume& volume, + const std::string& volumeName = "undefined"); /// Return the associated sub Volume, returns THIS if no subVolume exists /// @param gctx The current geometry context object, e.g. alignment diff --git a/Core/include/Acts/Geometry/TrackingVolumeArrayCreator.hpp b/Core/include/Acts/Geometry/TrackingVolumeArrayCreator.hpp index be59b61e3ec..6a45746840a 100644 --- a/Core/include/Acts/Geometry/TrackingVolumeArrayCreator.hpp +++ b/Core/include/Acts/Geometry/TrackingVolumeArrayCreator.hpp @@ -35,10 +35,10 @@ class TrackingVolumeArrayCreator : public ITrackingVolumeArrayCreator { /// Constructor /// /// @param logger logging instance - TrackingVolumeArrayCreator(const Config& /*cfg*/, - std::unique_ptr logger = - getDefaultLogger("LayerArrayCreator", - Logging::INFO)) + explicit TrackingVolumeArrayCreator(const Config& /*cfg*/, + std::unique_ptr logger = + getDefaultLogger("LayerArrayCreator", + Logging::INFO)) : m_logger(std::move(logger)) {} /// create a tracking volume array diff --git a/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp b/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp index d8c35d83d8b..e3aff76222e 100644 --- a/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/TrapezoidVolumeBounds.hpp @@ -138,7 +138,8 @@ class TrapezoidVolumeBounds : public VolumeBounds { /// Constructor - from a fixed size array /// /// @param values The bound values - TrapezoidVolumeBounds(const std::array& values) noexcept(false) + explicit TrapezoidVolumeBounds( + const std::array& values) noexcept(false) : m_values(values) { checkConsistency(); buildSurfaceBounds(); diff --git a/Core/include/Acts/Geometry/VolumeStack.hpp b/Core/include/Acts/Geometry/VolumeStack.hpp new file mode 100644 index 00000000000..4fa5e1f95a2 --- /dev/null +++ b/Core/include/Acts/Geometry/VolumeStack.hpp @@ -0,0 +1,60 @@ +// This file is part of the ACTS project. +// +// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. + +#pragma once + +#include "Acts/Geometry/Volume.hpp" +#include "Acts/Geometry/VolumeResizeStrategy.hpp" +#include "Acts/Utilities/AxisDefinitions.hpp" + +#include +#include + +namespace Acts { + +/// @class VolumeStack +/// @brief A stack of volumes +/// @note This is a base class for the different types of volume stacks +class VolumeStack : public Volume { + public: + /// @param volumes is the vector of volumes + /// @param direction is the direction of the stack + /// @param resizeStrategy is the resize strategy + VolumeStack(std::vector& volumes, AxisDirection direction, + VolumeResizeStrategy resizeStrategy); + + /// Access the gap volume that were created during attachment or resizing. + /// @return the vector of gap volumes + const std::vector>& gaps() const; + + /// Check if a volume is a gap volume + /// @param volume is the volume to check + /// @return true if the volume is a gap volume, false otherwise + bool isGapVolume(const Volume& volume) const; + + private: + /// Helper to get the first volume in the input, and throw an exception if + /// there is not one. + /// @param volumes is the vector of volumes + /// @return the first volume + static Volume& initialVolume(std::span volumes); + + protected: + /// @param transform is the transform of the gap volume + /// @param bounds is the bounds of the gap volume + /// @return the shared pointer to the gap volume + std::shared_ptr addGapVolume( + const Transform3& transform, const std::shared_ptr& bounds); + + AxisDirection m_direction{}; + VolumeResizeStrategy m_resizeStrategy{}; + + std::vector> m_gaps{}; + std::vector& m_volumes; +}; +} // namespace Acts diff --git a/Core/include/Acts/MagneticField/ConstantBField.hpp b/Core/include/Acts/MagneticField/ConstantBField.hpp index eeb0f74c875..c931c557667 100644 --- a/Core/include/Acts/MagneticField/ConstantBField.hpp +++ b/Core/include/Acts/MagneticField/ConstantBField.hpp @@ -23,7 +23,7 @@ class ConstantBField final : public MagneticFieldProvider { public: struct Cache { /// @brief constructor with context - Cache(const MagneticFieldContext& /*mcfg*/) {} + explicit Cache(const MagneticFieldContext& /*mcfg*/) {} }; /// Construct constant magnetic field from field vector. diff --git a/Core/include/Acts/MagneticField/InterpolatedBFieldMap.hpp b/Core/include/Acts/MagneticField/InterpolatedBFieldMap.hpp index 545893f24f0..58025f580f6 100644 --- a/Core/include/Acts/MagneticField/InterpolatedBFieldMap.hpp +++ b/Core/include/Acts/MagneticField/InterpolatedBFieldMap.hpp @@ -145,7 +145,7 @@ class InterpolatedBFieldMap : public InterpolatedMagneticField { struct Cache { /// @brief Constructor with magnetic field context - Cache(const MagneticFieldContext& /*mctx*/) {} + explicit Cache(const MagneticFieldContext& /*mctx*/) {} std::optional fieldCell; bool initialized = false; @@ -174,7 +174,7 @@ class InterpolatedBFieldMap : public InterpolatedMagneticField { /// @brief default constructor /// - InterpolatedBFieldMap(Config cfg) : m_cfg{std::move(cfg)} { + explicit InterpolatedBFieldMap(Config cfg) : m_cfg{std::move(cfg)} { typename Grid::index_t minBin{}; minBin.fill(1); m_lowerLeft = m_cfg.grid.lowerLeftBinEdge(minBin); diff --git a/Core/include/Acts/MagneticField/NullBField.hpp b/Core/include/Acts/MagneticField/NullBField.hpp index 524841e785a..286140e3675 100644 --- a/Core/include/Acts/MagneticField/NullBField.hpp +++ b/Core/include/Acts/MagneticField/NullBField.hpp @@ -20,7 +20,7 @@ class NullBField final : public MagneticFieldProvider { public: struct Cache { /// @brief constructor with context - Cache(const MagneticFieldContext& /*mcfg*/) {} + explicit Cache(const MagneticFieldContext& /*mcfg*/) {} }; /// @brief Default constructor diff --git a/Core/include/Acts/MagneticField/SolenoidBField.hpp b/Core/include/Acts/MagneticField/SolenoidBField.hpp index d020dbc9fa0..5c565464d9a 100644 --- a/Core/include/Acts/MagneticField/SolenoidBField.hpp +++ b/Core/include/Acts/MagneticField/SolenoidBField.hpp @@ -70,7 +70,7 @@ class SolenoidBField final : public MagneticFieldProvider { public: struct Cache { /// @brief Constructor with magnetic field context - Cache(const MagneticFieldContext& /*mctx*/) {} + explicit Cache(const MagneticFieldContext& /*mctx*/) {} }; /// Config struct for the SolenoidBfield. @@ -90,7 +90,7 @@ class SolenoidBField final : public MagneticFieldProvider { /// @brief the constructor with a shared pointer /// @note since it is a shared field, we enforce it to be const /// @tparam bField is the shared BField to be stored - SolenoidBField(Config config); + explicit SolenoidBField(Config config); /// @brief Retrieve magnetic field value in local (r,z) coordinates /// diff --git a/Core/include/Acts/Material/AccumulatedSurfaceMaterial.hpp b/Core/include/Acts/Material/AccumulatedSurfaceMaterial.hpp index 7107410bfec..b2d014d801c 100644 --- a/Core/include/Acts/Material/AccumulatedSurfaceMaterial.hpp +++ b/Core/include/Acts/Material/AccumulatedSurfaceMaterial.hpp @@ -37,7 +37,7 @@ class AccumulatedSurfaceMaterial { /// Default Constructor - for homogeneous material /// /// @param splitFactor is the pre/post splitting directive - AccumulatedSurfaceMaterial(double splitFactor = 0.); + explicit AccumulatedSurfaceMaterial(double splitFactor = 0.); /// Explicit constructor with only full MaterialSlab, /// for one-dimensional binning. @@ -49,8 +49,8 @@ class AccumulatedSurfaceMaterial { /// /// @param binUtility defines the binning structure on the surface /// @param splitFactor is the pre/post splitting directive - AccumulatedSurfaceMaterial(const BinUtility& binUtility, - double splitFactor = 0.); + explicit AccumulatedSurfaceMaterial(const BinUtility& binUtility, + double splitFactor = 0.); /// Copy Constructor /// diff --git a/Core/include/Acts/Material/BinnedSurfaceMaterialAccumulater.hpp b/Core/include/Acts/Material/BinnedSurfaceMaterialAccumulater.hpp index f7f5c24bdae..e0488422cbf 100644 --- a/Core/include/Acts/Material/BinnedSurfaceMaterialAccumulater.hpp +++ b/Core/include/Acts/Material/BinnedSurfaceMaterialAccumulater.hpp @@ -45,7 +45,7 @@ class BinnedSurfaceMaterialAccumulater final /// /// @param cfg the configuration struct /// @param mlogger the logger - BinnedSurfaceMaterialAccumulater( + explicit BinnedSurfaceMaterialAccumulater( const Config& cfg, std::unique_ptr mlogger = getDefaultLogger("BinnedSurfaceMaterialAccumulater", Logging::INFO)); diff --git a/Core/include/Acts/Material/HomogeneousSurfaceMaterial.hpp b/Core/include/Acts/Material/HomogeneousSurfaceMaterial.hpp index 10a561b6a8f..1951222186c 100644 --- a/Core/include/Acts/Material/HomogeneousSurfaceMaterial.hpp +++ b/Core/include/Acts/Material/HomogeneousSurfaceMaterial.hpp @@ -30,8 +30,9 @@ class HomogeneousSurfaceMaterial : public ISurfaceMaterial { /// @param full are the full material properties /// @param splitFactor is the split for pre/post update /// @param mappingType is the type of surface mapping associated to the surface - HomogeneousSurfaceMaterial(const MaterialSlab& full, double splitFactor = 1., - MappingType mappingType = MappingType::Default); + explicit HomogeneousSurfaceMaterial( + const MaterialSlab& full, double splitFactor = 1., + MappingType mappingType = MappingType::Default); /// Copy Constructor /// diff --git a/Core/include/Acts/Material/HomogeneousVolumeMaterial.hpp b/Core/include/Acts/Material/HomogeneousVolumeMaterial.hpp index 2034387e764..ddb2a0fabc2 100644 --- a/Core/include/Acts/Material/HomogeneousVolumeMaterial.hpp +++ b/Core/include/Acts/Material/HomogeneousVolumeMaterial.hpp @@ -25,7 +25,7 @@ class HomogeneousVolumeMaterial : public IVolumeMaterial { /// Explicit constructor /// /// @param material is the material held by this - HomogeneousVolumeMaterial(const Material& material); + explicit HomogeneousVolumeMaterial(const Material& material); /// Copy Constructor /// diff --git a/Core/include/Acts/Material/ISurfaceMaterial.hpp b/Core/include/Acts/Material/ISurfaceMaterial.hpp index 283d67e7db4..b29afaa70e7 100644 --- a/Core/include/Acts/Material/ISurfaceMaterial.hpp +++ b/Core/include/Acts/Material/ISurfaceMaterial.hpp @@ -35,13 +35,13 @@ class ISurfaceMaterial { /// Constructor /// /// @param splitFactor is the splitting ratio between pre/post update - ISurfaceMaterial(double splitFactor) : m_splitFactor(splitFactor) {} + explicit ISurfaceMaterial(double splitFactor) : m_splitFactor(splitFactor) {} /// Constructor /// /// @param splitFactor is the splitting ratio between pre/post update /// @param mappingType is the type of surface mapping associated to the surface - ISurfaceMaterial(double splitFactor, Acts::MappingType mappingType) + explicit ISurfaceMaterial(double splitFactor, Acts::MappingType mappingType) : m_splitFactor(splitFactor), m_mappingType(mappingType) {} /// Destructor diff --git a/Core/include/Acts/Material/InterpolatedMaterialMap.hpp b/Core/include/Acts/Material/InterpolatedMaterialMap.hpp index eb792539871..5c0f1014fe9 100644 --- a/Core/include/Acts/Material/InterpolatedMaterialMap.hpp +++ b/Core/include/Acts/Material/InterpolatedMaterialMap.hpp @@ -247,7 +247,8 @@ class InterpolatedMaterialMap : public IVolumeMaterial { /// @brief Create interpolated map /// /// @param [in] mapper Material map - InterpolatedMaterialMap(Mapper_t&& mapper) : m_mapper(std::move(mapper)) {} + explicit InterpolatedMaterialMap(Mapper_t&& mapper) + : m_mapper(std::move(mapper)) {} /// @brief Create interpolated map /// diff --git a/Core/include/Acts/Material/IntersectionMaterialAssigner.hpp b/Core/include/Acts/Material/IntersectionMaterialAssigner.hpp index 036b3de982a..3d2819a379f 100644 --- a/Core/include/Acts/Material/IntersectionMaterialAssigner.hpp +++ b/Core/include/Acts/Material/IntersectionMaterialAssigner.hpp @@ -47,7 +47,7 @@ class IntersectionMaterialAssigner final : public IAssignmentFinder { /// /// @param cfg is the configuration struct /// @param mlogger is the logger - IntersectionMaterialAssigner( + explicit IntersectionMaterialAssigner( const Config& cfg, std::unique_ptr mlogger = getDefaultLogger("IntersectionMaterialAssigner", Logging::INFO)) diff --git a/Core/include/Acts/Material/Material.hpp b/Core/include/Acts/Material/Material.hpp index 3ffba4385e7..1c5f7aeac1d 100644 --- a/Core/include/Acts/Material/Material.hpp +++ b/Core/include/Acts/Material/Material.hpp @@ -10,6 +10,7 @@ #include #include +#include #include @@ -50,6 +51,20 @@ class Material { // construction from separate material parameters must happen through the // following named constructors. + /// Construct from material parameters using the molar density. + /// + /// @param x0 is the radiation length + /// @param l0 is the nuclear interaction length + /// @param ar is the relative atomic mass + /// @param z is the nuclear charge number + /// @param molarRho is the molar density + /// @param molarElectronRho is the molar electron density + /// @param meanExcitationEnergy is the mean electron excitation energy. + /// If not provided it will be approximated. + static Material fromMolarDensity(float x0, float l0, float ar, float z, + float molarRho, float molarElectronRho, + std::optional meanExcitationEnergy); + /// Construct from material parameters using the molar density. /// /// @param x0 is the radiation length @@ -91,11 +106,13 @@ class Material { /// Return the molar density. constexpr float molarDensity() const { return m_molarRho; } /// Return the molar electron density. - constexpr float molarElectronDensity() const { return m_z * m_molarRho; } + constexpr float molarElectronDensity() const { return m_molarElectronRho; } /// Return the mass density. float massDensity() const; /// Return the mean electron excitation energy. - float meanExcitationEnergy() const; + constexpr float meanExcitationEnergy() const { + return m_meanExcitationEnergy; + } /// Encode the properties into an opaque parameters vector. ParametersVector parameters() const; @@ -106,6 +123,8 @@ class Material { float m_ar = 0.0f; float m_z = 0.0f; float m_molarRho = 0.0f; + float m_molarElectronRho = 0.0f; + float m_meanExcitationEnergy = 0.0f; constexpr Material() = default; @@ -121,7 +140,9 @@ class Material { friend constexpr bool operator==(const Material& lhs, const Material& rhs) { return (lhs.m_x0 == rhs.m_x0) && (lhs.m_l0 == rhs.m_l0) && (lhs.m_ar == rhs.m_ar) && (lhs.m_z == rhs.m_z) && - (lhs.m_molarRho == rhs.m_molarRho); + (lhs.m_molarRho == rhs.m_molarRho) && + (lhs.m_molarElectronRho == rhs.m_molarElectronRho) && + (lhs.m_meanExcitationEnergy == rhs.m_meanExcitationEnergy); } }; diff --git a/Core/include/Acts/Material/MaterialComposition.hpp b/Core/include/Acts/Material/MaterialComposition.hpp index 843736ebd58..b4beb2383ea 100644 --- a/Core/include/Acts/Material/MaterialComposition.hpp +++ b/Core/include/Acts/Material/MaterialComposition.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include namespace Acts { @@ -86,6 +87,13 @@ class ElementFraction { return lhs.m_fraction < rhs.m_fraction; } friend class MaterialComposition; + + /// Stream operator for ElementFraction + friend std::ostream& operator<<(std::ostream& os, const ElementFraction& ef) { + os << "ElementFraction(Z=" << static_cast(ef.m_element) + << ", f=" << ef.fraction() << ")"; + return os; + } }; /// Material composed from multiple elements with varying factions. @@ -98,7 +106,7 @@ class MaterialComposition { /// Constructor from element fractions. /// /// Rescales the fractions so they all add up to unity within the accuracy. - MaterialComposition(std::vector elements) + explicit MaterialComposition(std::vector elements) : m_elements(std::move(elements)) { std::ranges::sort(m_elements, std::less{}); // compute the total weight first @@ -125,7 +133,7 @@ class MaterialComposition { auto end() const { return m_elements.end(); } /// Check if the composed material is valid, i.e. it is not vacuum. - operator bool() const { return !m_elements.empty(); } + explicit operator bool() const { return !m_elements.empty(); } /// Return the number of elements. std::size_t size() const { return m_elements.size(); } @@ -134,7 +142,21 @@ class MaterialComposition { friend inline bool operator==(const MaterialComposition& lhs, const MaterialComposition& rhs) { - return (lhs.m_elements == rhs.m_elements); + return lhs.m_elements == rhs.m_elements; + } + + /// Stream operator for MaterialComposition + friend std::ostream& operator<<(std::ostream& os, + const MaterialComposition& mc) { + os << "MaterialComposition(elements=["; + for (std::size_t i = 0; i < mc.m_elements.size(); ++i) { + if (i > 0) { + os << ", "; + } + os << mc.m_elements[i]; + } + os << "])"; + return os; } }; diff --git a/Core/include/Acts/Material/MaterialInteraction.hpp b/Core/include/Acts/Material/MaterialInteraction.hpp index 42cbc22fa4a..f4e0f970890 100644 --- a/Core/include/Acts/Material/MaterialInteraction.hpp +++ b/Core/include/Acts/Material/MaterialInteraction.hpp @@ -32,11 +32,11 @@ struct InteractionVolume { /// Constructor from tracking volume /// @param tv The tracking volume - InteractionVolume(const TrackingVolume* tv) : trackingVolume(tv) {} + explicit InteractionVolume(const TrackingVolume* tv) : trackingVolume(tv) {} /// Constructor from detector volume /// @param dv The detector volume - InteractionVolume(const Experimental::DetectorVolume* dv) + explicit InteractionVolume(const Experimental::DetectorVolume* dv) : detectorVolume(dv) {} /// Forward the geometry identifier diff --git a/Core/include/Acts/Material/MaterialMapper.hpp b/Core/include/Acts/Material/MaterialMapper.hpp index 6e2d02e6cd7..53f8b99bf69 100644 --- a/Core/include/Acts/Material/MaterialMapper.hpp +++ b/Core/include/Acts/Material/MaterialMapper.hpp @@ -60,9 +60,10 @@ class MaterialMapper { /// /// @param cfg the configuration struct /// @param mlogger the logger instance - MaterialMapper(const Config& cfg, - std::unique_ptr mlogger = getDefaultLogger( - "BinnedSurfaceMaterialAccumulater", Logging::INFO)); + explicit MaterialMapper( + const Config& cfg, + std::unique_ptr mlogger = + getDefaultLogger("BinnedSurfaceMaterialAccumulater", Logging::INFO)); /// @brief Factory for creating the state std::unique_ptr createState() const; diff --git a/Core/include/Acts/Material/MaterialValidater.hpp b/Core/include/Acts/Material/MaterialValidater.hpp index fcfff9b7d93..fd6daa69f69 100644 --- a/Core/include/Acts/Material/MaterialValidater.hpp +++ b/Core/include/Acts/Material/MaterialValidater.hpp @@ -35,9 +35,10 @@ class MaterialValidater { /// Constructor /// @param cfg The configuration struct carrying the used tools /// @param mlogger The logging object - MaterialValidater(const Config& cfg, - std::unique_ptr mlogger = - getDefaultLogger("MaterialValidater", Logging::INFO)); + explicit MaterialValidater(const Config& cfg, + std::unique_ptr mlogger = + getDefaultLogger("MaterialValidater", + Logging::INFO)); /// Method to record the material along a ray /// @param gctx the geometry context diff --git a/Core/include/Acts/Material/PropagatorMaterialAssigner.hpp b/Core/include/Acts/Material/PropagatorMaterialAssigner.hpp index 5c3c0fa0339..0f4d3275545 100644 --- a/Core/include/Acts/Material/PropagatorMaterialAssigner.hpp +++ b/Core/include/Acts/Material/PropagatorMaterialAssigner.hpp @@ -98,7 +98,7 @@ class PropagatorMaterialAssigner final : public IAssignmentFinder { public: /// @brief Construct with propagator /// @param propagator - PropagatorMaterialAssigner(propagator_t propagator) + explicit PropagatorMaterialAssigner(propagator_t propagator) : m_propagator(std::move(propagator)) {} /// @brief Method for generating assignment candidates for the diff --git a/Core/include/Acts/Material/ProtoSurfaceMaterial.hpp b/Core/include/Acts/Material/ProtoSurfaceMaterial.hpp index f0750b02e4f..0be89084910 100644 --- a/Core/include/Acts/Material/ProtoSurfaceMaterial.hpp +++ b/Core/include/Acts/Material/ProtoSurfaceMaterial.hpp @@ -37,8 +37,8 @@ class ProtoSurfaceMaterialT : public ISurfaceMaterial { /// Constructor with BinningType /// @param binning a binning description for the material map binning /// @param mappingType is the type of surface mapping associated to the surface - ProtoSurfaceMaterialT(const BinningType& binning, - MappingType mappingType = MappingType::Default) + explicit ProtoSurfaceMaterialT(const BinningType& binning, + MappingType mappingType = MappingType::Default) : ISurfaceMaterial(1., mappingType), m_binning(binning) {} /// Copy constructor diff --git a/Core/include/Acts/Material/ProtoVolumeMaterial.hpp b/Core/include/Acts/Material/ProtoVolumeMaterial.hpp index d9435974ecc..f56b3bc78dd 100644 --- a/Core/include/Acts/Material/ProtoVolumeMaterial.hpp +++ b/Core/include/Acts/Material/ProtoVolumeMaterial.hpp @@ -35,7 +35,7 @@ class ProtoVolumeMaterial : public IVolumeMaterial { /// /// @param binUtility a BinUtility determining the granularity /// and binning of the material on the volume - ProtoVolumeMaterial(const BinUtility& binUtility); + explicit ProtoVolumeMaterial(const BinUtility& binUtility); /// Copy constructor /// diff --git a/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp b/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp index 664c9c99166..fda6d350113 100644 --- a/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp +++ b/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp @@ -86,7 +86,7 @@ class SingleObjectNavigation : public navigation_type { public: /// Convenience constructor /// @param so the single object - SingleObjectNavigation(const object_type* so) : m_object(so) { + explicit SingleObjectNavigation(const object_type* so) : m_object(so) { if (so == nullptr) { throw std::invalid_argument("SingleObjectNavigation: object is nullptr"); } @@ -262,7 +262,7 @@ class ChainedNavigation : public navigation_type { /// the tuple and call them in sequence /// /// @param upts the updators to be called in chain - ChainedNavigation(const std::tuple&& upts) + explicit ChainedNavigation(const std::tuple&& upts) : updators(std::move(upts)) {} /// A combined navigation state updated to fill the candidates from diff --git a/Core/include/Acts/Propagator/ActorList.hpp b/Core/include/Acts/Propagator/ActorList.hpp index 89de8799a0d..904bf7f7d13 100644 --- a/Core/include/Acts/Propagator/ActorList.hpp +++ b/Core/include/Acts/Propagator/ActorList.hpp @@ -67,12 +67,14 @@ struct ActorList { /// Constructor from tuple /// /// @param actors Source extensions tuple - ActorList(const std::tuple& actors) : m_actors(actors) {} + explicit ActorList(const std::tuple& actors) + : m_actors(actors) {} /// Constructor from tuple move /// /// @param actors Source extensions tuple - ActorList(std::tuple&& actors) : m_actors(std::move(actors)) {} + explicit ActorList(std::tuple&& actors) + : m_actors(std::move(actors)) {} /// Const retrieval of an actor of a specific type /// diff --git a/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp b/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp index 6ecdeeb5d7b..c094b1aea52 100644 --- a/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp +++ b/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp @@ -231,16 +231,17 @@ class MultiEigenStepperLoop : public EigenStepper { }; /// Constructor from a magnetic field and a optionally provided Logger - MultiEigenStepperLoop(std::shared_ptr bField, - std::unique_ptr logger = - getDefaultLogger("GSF", Logging::INFO)) + explicit MultiEigenStepperLoop( + std::shared_ptr bField, + std::unique_ptr logger = getDefaultLogger("GSF", + Logging::INFO)) : EigenStepper(std::move(bField)), m_logger(std::move(logger)) {} /// Constructor from a configuration and optionally provided Logger - MultiEigenStepperLoop(const Config& config, - std::unique_ptr logger = - getDefaultLogger("GSF", Logging::INFO)) + explicit MultiEigenStepperLoop(const Config& config, + std::unique_ptr logger = + getDefaultLogger("GSF", Logging::INFO)) : EigenStepper(config), m_logger(std::move(logger)) {} State makeState(const Options& options) const { diff --git a/Core/include/Acts/Propagator/Propagator.ipp b/Core/include/Acts/Propagator/Propagator.ipp index fbeb79df36a..1b13152d3d1 100644 --- a/Core/include/Acts/Propagator/Propagator.ipp +++ b/Core/include/Acts/Propagator/Propagator.ipp @@ -299,7 +299,7 @@ Acts::Result Acts::Propagator::initialize( static_assert(BoundTrackParametersConcept, "Parameters do not fulfill bound parameters concept."); - m_stepper.initialize(state.stepping, start); + m_stepper.initialize(state.stepping, start.toBound()); state.position = m_stepper.position(state.stepping); state.direction = diff --git a/Core/include/Acts/Propagator/PropagatorOptions.hpp b/Core/include/Acts/Propagator/PropagatorOptions.hpp index 234283a4ce9..aa5e516e424 100644 --- a/Core/include/Acts/Propagator/PropagatorOptions.hpp +++ b/Core/include/Acts/Propagator/PropagatorOptions.hpp @@ -106,7 +106,7 @@ struct PropagatorOptions : public detail::PurePropagatorPlainOptions { navigation(gctx) {} /// PropagatorOptions with context and plain options - PropagatorOptions(const PropagatorPlainOptions& pOptions) + explicit PropagatorOptions(const PropagatorPlainOptions& pOptions) : geoContext(pOptions.geoContext), magFieldContext(pOptions.magFieldContext), stepping(pOptions.geoContext, pOptions.magFieldContext), @@ -115,7 +115,7 @@ struct PropagatorOptions : public detail::PurePropagatorPlainOptions { } /// @brief Convert to plain options - operator PropagatorPlainOptions() const { + explicit operator PropagatorPlainOptions() const { PropagatorPlainOptions pOptions(geoContext, magFieldContext); static_cast(pOptions) = static_cast(*this); diff --git a/Core/include/Acts/Propagator/RiddersPropagator.hpp b/Core/include/Acts/Propagator/RiddersPropagator.hpp index 32df1e09387..e9f4136074f 100644 --- a/Core/include/Acts/Propagator/RiddersPropagator.hpp +++ b/Core/include/Acts/Propagator/RiddersPropagator.hpp @@ -88,7 +88,7 @@ class RiddersPropagator { /// /// @param [in] propagator Underlying propagator that will be used /// @param [in] config Config for the Ridders propagation - RiddersPropagator(propagator_t propagator, Config config = {}) + explicit RiddersPropagator(propagator_t propagator, Config config = {}) : m_propagator(std::move(propagator)), m_config(std::move(config)) {} /// @brief Constructor building a propagator @@ -100,8 +100,9 @@ class RiddersPropagator { /// @param [in] navigator Navigator that will be used /// @param [in] config Config for the Ridders propagation template - RiddersPropagator(stepper_t stepper, navigator_t navigator = navigator_t(), - Config config = {}) + explicit RiddersPropagator(stepper_t stepper, + navigator_t navigator = navigator_t(), + Config config = {}) : m_propagator(std::move(stepper), std::move(navigator)), m_config(std::move(config)) {} diff --git a/Core/include/Acts/Propagator/SurfaceCollector.hpp b/Core/include/Acts/Propagator/SurfaceCollector.hpp index 9d5afa9b226..9dd22a7b115 100644 --- a/Core/include/Acts/Propagator/SurfaceCollector.hpp +++ b/Core/include/Acts/Propagator/SurfaceCollector.hpp @@ -26,8 +26,8 @@ struct SurfaceSelector { /// @param sSensitive is the directive to select sensitive surfaces /// @param sMaterial is the directive to select material surfaces /// @param sPassive is the directive to select passive surfaces - SurfaceSelector(bool sSensitive = true, bool sMaterial = false, - bool sPassive = false) + explicit SurfaceSelector(bool sSensitive = true, bool sMaterial = false, + bool sPassive = false) : selectSensitive(sSensitive), selectMaterial(sMaterial), selectPassive(sPassive) {} diff --git a/Core/include/Acts/Propagator/TryAllNavigator.hpp b/Core/include/Acts/Propagator/TryAllNavigator.hpp index a01ba565f31..b61430e3ed6 100644 --- a/Core/include/Acts/Propagator/TryAllNavigator.hpp +++ b/Core/include/Acts/Propagator/TryAllNavigator.hpp @@ -259,9 +259,9 @@ class TryAllNavigator : public TryAllNavigatorBase { /// /// @param cfg The navigator configuration /// @param logger a logger instance - TryAllNavigator(Config cfg, - std::unique_ptr logger = - getDefaultLogger("TryAllNavigator", Logging::INFO)) + explicit TryAllNavigator(Config cfg, std::unique_ptr logger = + getDefaultLogger("TryAllNavigator", + Logging::INFO)) : TryAllNavigatorBase(std::move(cfg), std::move(logger)) {} State makeState(const Options& options) const { @@ -583,10 +583,9 @@ class TryAllOverstepNavigator : public TryAllNavigatorBase { /// /// @param cfg The navigator configuration /// @param logger a logger instance - TryAllOverstepNavigator(Config cfg, - std::unique_ptr logger = - getDefaultLogger("TryAllOverstepNavigator", - Logging::INFO)) + explicit TryAllOverstepNavigator( + Config cfg, std::unique_ptr logger = getDefaultLogger( + "TryAllOverstepNavigator", Logging::INFO)) : TryAllNavigatorBase(std::move(cfg), std::move(logger)) {} State makeState(const Options& options) const { diff --git a/Core/include/Acts/Propagator/VolumeCollector.hpp b/Core/include/Acts/Propagator/VolumeCollector.hpp index 5163b71bab7..95bd730bf79 100644 --- a/Core/include/Acts/Propagator/VolumeCollector.hpp +++ b/Core/include/Acts/Propagator/VolumeCollector.hpp @@ -25,8 +25,8 @@ struct VolumeSelector { /// @param sMaterial is the directive to select material volumes /// @param sLayer is the directive to select volumes with layers /// @param sPassive is the directive to select passive volumes - VolumeSelector(bool sMaterial = true, bool sLayer = false, - bool sPassive = false) + explicit VolumeSelector(bool sMaterial = true, bool sLayer = false, + bool sPassive = false) : selectMaterial(sMaterial), selectLayer(sLayer), selectPassive(sPassive) {} diff --git a/Core/include/Acts/Propagator/detail/LoopStepperUtils.hpp b/Core/include/Acts/Propagator/detail/LoopStepperUtils.hpp index 6e4686e44e9..114703c0e63 100644 --- a/Core/include/Acts/Propagator/detail/LoopStepperUtils.hpp +++ b/Core/include/Acts/Propagator/detail/LoopStepperUtils.hpp @@ -8,17 +8,17 @@ #pragma once -#include -#include -#include -#include +#include "Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp" +#include "Acts/Propagator/detail/CovarianceEngine.hpp" +#include "Acts/Surfaces/Surface.hpp" +#include "Acts/Utilities/Result.hpp" #include namespace Acts::detail { -/// A helper type for providinig a propagation state which can be used with -/// functions expecting single-component steppers and states +/// A helper struct to store a reference to a single-component state and its +/// associated navigation state and options template struct SinglePropState { @@ -44,7 +44,7 @@ struct LoopComponentProxyBase { component_t& cmp; - LoopComponentProxyBase(component_t& c) : cmp(c) {} + explicit LoopComponentProxyBase(component_t& c) : cmp(c) {} // These are the const accessors, which are shared between the mutable // ComponentProxy and the ConstComponentProxy diff --git a/Core/include/Acts/Propagator/detail/SteppingLogger.hpp b/Core/include/Acts/Propagator/detail/SteppingLogger.hpp index b5b95ff6487..e083d496dfb 100644 --- a/Core/include/Acts/Propagator/detail/SteppingLogger.hpp +++ b/Core/include/Acts/Propagator/detail/SteppingLogger.hpp @@ -37,7 +37,7 @@ struct Step { Vector3 position = Vector3(0., 0., 0.); Vector3 momentum = Vector3(0., 0., 0.); std::shared_ptr surface = nullptr; - GeometryIdentifier geoID = 0; + GeometryIdentifier geoID; /// Note that this is the total number of trials including the previous steps std::size_t nTotalTrials = 0; }; diff --git a/Core/include/Acts/Seeding/GbtsBase.hpp b/Core/include/Acts/Seeding/GbtsBase.hpp index 97adbea5fbd..bf27acec812 100644 --- a/Core/include/Acts/Seeding/GbtsBase.hpp +++ b/Core/include/Acts/Seeding/GbtsBase.hpp @@ -29,7 +29,7 @@ class TrigInDetTriplet { GbtsSP s3, float Q) : m_s1(std::move(s1)), m_s2(std::move(s2)), m_s3(std::move(s3)), m_Q(Q) {} - TrigInDetTriplet(TrigInDetTriplet* t) + explicit TrigInDetTriplet(TrigInDetTriplet* t) : m_s1(t->m_s1), m_s2(t->m_s2), m_s3(t->m_s3), m_Q(t->m_Q) {} const GbtsSP& s1() const { return m_s1; } diff --git a/Core/include/Acts/Seeding/GbtsDataStorage.hpp b/Core/include/Acts/Seeding/GbtsDataStorage.hpp index 0f2f8eaaf27..407ca0ce41e 100644 --- a/Core/include/Acts/Seeding/GbtsDataStorage.hpp +++ b/Core/include/Acts/Seeding/GbtsDataStorage.hpp @@ -48,8 +48,8 @@ struct GbtsSP { template class GbtsNode { public: - GbtsNode(const GbtsSP &spGbts, float minT = -100.0, - float maxT = 100.0) + explicit GbtsNode(const GbtsSP &spGbts, float minT = -100.0, + float maxT = 100.0) : m_spGbts(spGbts), m_minCutOnTau(minT), m_maxCutOnTau(maxT) {} inline void addIn(int i) { @@ -137,7 +137,7 @@ class GbtsEtaBin { template class GbtsDataStorage { public: - GbtsDataStorage(const GbtsGeometry &g) : m_geo(g) { + explicit GbtsDataStorage(const GbtsGeometry &g) : m_geo(g) { m_etaBins.reserve(g.num_bins()); for (int k = 0; k < g.num_bins(); k++) { m_etaBins.emplace_back(GbtsEtaBin()); diff --git a/Core/include/Acts/Seeding/GbtsTrackingFilter.hpp b/Core/include/Acts/Seeding/GbtsTrackingFilter.hpp index 8f4277c8769..13a4d6ca414 100644 --- a/Core/include/Acts/Seeding/GbtsTrackingFilter.hpp +++ b/Core/include/Acts/Seeding/GbtsTrackingFilter.hpp @@ -33,7 +33,7 @@ struct GbtsEdgeState { GbtsEdgeState() = default; - GbtsEdgeState(bool f) : m_initialized(f) {} + explicit GbtsEdgeState(bool f) : m_initialized(f) {} void initialize(GbtsEdge* pS) { m_initialized = true; diff --git a/Core/include/Acts/Seeding/HoughTransformUtils.hpp b/Core/include/Acts/Seeding/HoughTransformUtils.hpp index db3f94b94c7..39b0006c94d 100644 --- a/Core/include/Acts/Seeding/HoughTransformUtils.hpp +++ b/Core/include/Acts/Seeding/HoughTransformUtils.hpp @@ -164,7 +164,7 @@ class HoughPlane { /// @brief instantiate the (empty) hough plane /// @param cfg: configuration - HoughPlane(const HoughPlaneConfig& cfg); + explicit HoughPlane(const HoughPlaneConfig& cfg); /// fill and reset methods to modify the grid content @@ -329,7 +329,7 @@ class LayerGuidedCombinatoric { }; /// @brief constructor /// @param cfg: Configuration object - LayerGuidedCombinatoric(const LayerGuidedCombinatoricConfig& cfg); + explicit LayerGuidedCombinatoric(const LayerGuidedCombinatoricConfig& cfg); /// @brief main peak finder method. /// @param plane: Filled hough plane to search @@ -378,7 +378,7 @@ class IslandsAroundMax { }; /// @brief constructor. /// @param cfg: configuration object - IslandsAroundMax(const IslandsAroundMaxConfig& cfg); + explicit IslandsAroundMax(const IslandsAroundMaxConfig& cfg); /// @brief main peak finder method. /// @param plane: The filled hough plane to search diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index f619f1a0ab4..fea124502ca 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -97,7 +97,7 @@ class PathSeeder { }; /// @brief Constructor - PathSeeder(const Config& config) : m_cfg(config) {}; + explicit PathSeeder(const Config& config) : m_cfg(config) {}; /// @brief Destructor ~PathSeeder() = default; diff --git a/Core/include/Acts/Seeding/SeedFilter.hpp b/Core/include/Acts/Seeding/SeedFilter.hpp index d6e1479a9cd..44797207666 100644 --- a/Core/include/Acts/Seeding/SeedFilter.hpp +++ b/Core/include/Acts/Seeding/SeedFilter.hpp @@ -38,11 +38,13 @@ struct SeedFilterState { template class SeedFilter final { public: - SeedFilter(const SeedFilterConfig& config, - IExperimentCuts* expCuts = nullptr); - SeedFilter(const SeedFilterConfig& config, - std::unique_ptr logger, - IExperimentCuts* expCuts = nullptr); + explicit SeedFilter( + const SeedFilterConfig& config, + IExperimentCuts* expCuts = nullptr); + explicit SeedFilter( + const SeedFilterConfig& config, + std::unique_ptr logger, + IExperimentCuts* expCuts = nullptr); SeedFilter(const SeedFilter&) = delete; SeedFilter& operator=(const SeedFilter&) = delete; SeedFilter(SeedFilter&&) noexcept = default; diff --git a/Core/include/Acts/Seeding/SeedFinder.hpp b/Core/include/Acts/Seeding/SeedFinder.hpp index 35a101015a5..f5140d76010 100644 --- a/Core/include/Acts/Seeding/SeedFinder.hpp +++ b/Core/include/Acts/Seeding/SeedFinder.hpp @@ -89,9 +89,10 @@ class SeedFinder { /// The only constructor. Requires a config object. /// @param config the configuration for the SeedFinder /// @param logger the ACTS logger - SeedFinder(const Acts::SeedFinderConfig& config, - std::unique_ptr logger = - getDefaultLogger("Finder", Logging::Level::INFO)); + explicit SeedFinder( + const Acts::SeedFinderConfig& config, + std::unique_ptr logger = + getDefaultLogger("Finder", Logging::Level::INFO)); SeedFinder(SeedFinder&&) noexcept = default; SeedFinder& operator=(SeedFinder &config, std::unique_ptr logger = Acts::getDefaultLogger("Finder", Logging::Level::INFO)); diff --git a/Core/include/Acts/Surfaces/AnnulusBounds.hpp b/Core/include/Acts/Surfaces/AnnulusBounds.hpp index 4e56b56dac7..f95b698d849 100644 --- a/Core/include/Acts/Surfaces/AnnulusBounds.hpp +++ b/Core/include/Acts/Surfaces/AnnulusBounds.hpp @@ -46,25 +46,25 @@ class AnnulusBounds : public DiscBounds { }; /// @brief Default constructor from parameters - /// @param minR inner radius, in module system - /// @param maxR outer radius, in module system - /// @param minPhiRel right angular edge, in strip system, rel to avgPhi - /// @param maxPhiRel left angular edge, in strip system, rel to avgPhi - /// @param moduleOrigin The origin offset between the two systems. - /// @param avgPhi (Optional) internal rotation of this bounds object's local - /// frame + /// @param minR The inner radius of the annulus + /// @param maxR The outer radius of the annulus + /// @param minPhiRel The minimum phi relative to average phi + /// @param maxPhiRel The maximum phi relative to average phi + /// @param moduleOrigin The origin of the module in the strip frame + /// @param avgPhi The average phi value /// @note For @c morigin you need to actually calculate the cartesian /// offset - AnnulusBounds(double minR, double maxR, double minPhiRel, double maxPhiRel, - const Vector2& moduleOrigin = {0, 0}, - double avgPhi = 0) noexcept(false) + explicit AnnulusBounds(double minR, double maxR, double minPhiRel, + double maxPhiRel, const Vector2& moduleOrigin = {0, 0}, + double avgPhi = 0) noexcept(false) : AnnulusBounds({minR, maxR, minPhiRel, maxPhiRel, avgPhi, moduleOrigin.x(), moduleOrigin.y()}) {} - /// Constructor - from parameters array + /// Constructor - from fixed size array /// - /// @param values The parameter array - AnnulusBounds(const std::array& values) noexcept(false); + /// @param values The bound values stored in a fixed size array + explicit AnnulusBounds(const std::array& values) noexcept( + false); AnnulusBounds(const AnnulusBounds& source) = default; diff --git a/Core/include/Acts/Surfaces/ConeBounds.hpp b/Core/include/Acts/Surfaces/ConeBounds.hpp index 7d852f2df87..bc061da2701 100644 --- a/Core/include/Acts/Surfaces/ConeBounds.hpp +++ b/Core/include/Acts/Surfaces/ConeBounds.hpp @@ -69,7 +69,7 @@ class ConeBounds : public SurfaceBounds { /// Constructor - from parameters array /// /// @param values The parameter array - ConeBounds(const std::array& values) noexcept(false); + explicit ConeBounds(const std::array& values) noexcept(false); BoundsType type() const final { return SurfaceBounds::eCone; } diff --git a/Core/include/Acts/Surfaces/ConvexPolygonBounds.hpp b/Core/include/Acts/Surfaces/ConvexPolygonBounds.hpp index afb5bb406f9..d78c313650b 100644 --- a/Core/include/Acts/Surfaces/ConvexPolygonBounds.hpp +++ b/Core/include/Acts/Surfaces/ConvexPolygonBounds.hpp @@ -83,17 +83,18 @@ class ConvexPolygonBounds : public ConvexPolygonBoundsBase { /// This will throw if the vector size does not match `num_vertices`. /// This will throw if the vertices do not form a convex polygon. /// @param vertices The list of vertices. - ConvexPolygonBounds(const std::vector& vertices) noexcept(false); + explicit ConvexPolygonBounds(const std::vector& vertices) noexcept( + false); /// Constructor from a fixed size array of vertices. /// This will throw if the vertices do not form a convex polygon. /// @param vertices The vertices - ConvexPolygonBounds(const vertex_array& vertices) noexcept(false); + explicit ConvexPolygonBounds(const vertex_array& vertices) noexcept(false); /// Constructor from a fixed size array of parameters /// This will throw if the vertices do not form a convex polygon. /// @param values The values to build up the vertices - ConvexPolygonBounds(const value_array& values) noexcept(false); + explicit ConvexPolygonBounds(const value_array& values) noexcept(false); BoundsType type() const final { return SurfaceBounds::eConvexPolygon; } @@ -142,7 +143,7 @@ class ConvexPolygonBounds : public ConvexPolygonBoundsBase { /// Constructor from a vector of vertices, to facilitate construction. /// This will throw if the vertices do not form a convex polygon. /// @param vertices The list of vertices. - ConvexPolygonBounds(const std::vector& vertices); + explicit ConvexPolygonBounds(const std::vector& vertices); /// Return the bounds type of this bounds object. /// @return The bounds type diff --git a/Core/include/Acts/Surfaces/CylinderBounds.hpp b/Core/include/Acts/Surfaces/CylinderBounds.hpp index 10fab504635..189c2142876 100644 --- a/Core/include/Acts/Surfaces/CylinderBounds.hpp +++ b/Core/include/Acts/Surfaces/CylinderBounds.hpp @@ -73,10 +73,10 @@ class CylinderBounds : public SurfaceBounds { checkConsistency(); } - /// Constructor - from fixed size array - /// - /// @param values The parameter values - CylinderBounds(const std::array& values) noexcept(false) + /// Constructor from array + /// @param values The bound values stored in an array + explicit CylinderBounds(const std::array& values) noexcept( + false) : m_values(values), m_closed(std::abs(values[eHalfPhiSector] - std::numbers::pi) < s_epsilon) { diff --git a/Core/include/Acts/Surfaces/DiamondBounds.hpp b/Core/include/Acts/Surfaces/DiamondBounds.hpp index 096efc2dd27..bfa24aeb06e 100644 --- a/Core/include/Acts/Surfaces/DiamondBounds.hpp +++ b/Core/include/Acts/Surfaces/DiamondBounds.hpp @@ -58,7 +58,8 @@ class DiamondBounds : public PlanarBounds { /// Constructor - from fixed size array /// /// @param values The parameter values - DiamondBounds(const std::array& values) noexcept(false) + explicit DiamondBounds(const std::array& values) noexcept( + false) : m_values(values), m_boundingBox( Vector2{-(*std::max_element(values.begin(), values.begin() + 2)), diff --git a/Core/include/Acts/Surfaces/DiscSurface.hpp b/Core/include/Acts/Surfaces/DiscSurface.hpp index f9d34b590a7..ea67e09d686 100644 --- a/Core/include/Acts/Surfaces/DiscSurface.hpp +++ b/Core/include/Acts/Surfaces/DiscSurface.hpp @@ -61,8 +61,8 @@ class DiscSurface : public RegularSurface { /// @param rmax The outer radius of the disc surface /// @param hphisec The opening angle of the disc surface and is optional /// the default is a full disc - DiscSurface(const Transform3& transform, double rmin, double rmax, - double hphisec = std::numbers::pi); + explicit DiscSurface(const Transform3& transform, double rmin, double rmax, + double hphisec = std::numbers::pi); /// Constructor for Discs from Transform3, \f$ r_{min}, r_{max}, hx_{min}, /// hx_{max} \f$ @@ -75,22 +75,23 @@ class DiscSurface : public RegularSurface { /// @param maxR The inner radius of the disc surface /// @param avephi The position in phi (default is 0.) /// @param stereo The optional stereo angle - DiscSurface(const Transform3& transform, double minhalfx, double maxhalfx, - double minR, double maxR, double avephi = 0., double stereo = 0.); + explicit DiscSurface(const Transform3& transform, double minhalfx, + double maxhalfx, double minR, double maxR, + double avephi = 0., double stereo = 0.); /// Constructor for Discs from Transform3 and shared DiscBounds /// /// @param transform The transform that positions the disc in global 3D /// @param dbounds The disc bounds describing the surface coverage - DiscSurface(const Transform3& transform, - std::shared_ptr dbounds = nullptr); + explicit DiscSurface(const Transform3& transform, + std::shared_ptr dbounds = nullptr); /// Constructor from DetectorElementBase : Element proxy /// /// @param dbounds The disc bounds describing the surface coverage /// @param detelement The detector element represented by this surface - DiscSurface(std::shared_ptr dbounds, - const DetectorElementBase& detelement); + explicit DiscSurface(std::shared_ptr dbounds, + const DetectorElementBase& detelement); /// Copy Constructor /// diff --git a/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp b/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp index 57ffd86586a..24d7f2a2366 100644 --- a/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp +++ b/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp @@ -48,14 +48,16 @@ class DiscTrapezoidBounds : public DiscBounds { /// @param maxR outer radius /// @param avgPhi average phi value /// @param stereo optional stero angle applied - DiscTrapezoidBounds(double halfXminR, double halfXmaxR, double minR, - double maxR, double avgPhi = std::numbers::pi / 2., - double stereo = 0.) noexcept(false); + explicit DiscTrapezoidBounds(double halfXminR, double halfXmaxR, double minR, + double maxR, + double avgPhi = std::numbers::pi / 2., + double stereo = 0.) noexcept(false); /// Constructor - from fixed size array /// /// @param values The parameter values - DiscTrapezoidBounds(const std::array& values) noexcept(false) + explicit DiscTrapezoidBounds( + const std::array& values) noexcept(false) : m_values(values) { checkConsistency(); } diff --git a/Core/include/Acts/Surfaces/EllipseBounds.hpp b/Core/include/Acts/Surfaces/EllipseBounds.hpp index 007c0fd0aff..486c108efb2 100644 --- a/Core/include/Acts/Surfaces/EllipseBounds.hpp +++ b/Core/include/Acts/Surfaces/EllipseBounds.hpp @@ -50,9 +50,9 @@ class EllipseBounds : public PlanarBounds { /// @param outerRy The outer ellipse radius in y /// @param halfPhi spanning phi sector (is set to pi as default) /// @param averagePhi average phi (is set to 0. as default) - EllipseBounds(double innerRx, double innerRy, double outerRx, double outerRy, - double halfPhi = std::numbers::pi, - double averagePhi = 0.) noexcept(false) + explicit EllipseBounds(double innerRx, double innerRy, double outerRx, + double outerRy, double halfPhi = std::numbers::pi, + double averagePhi = 0.) noexcept(false) : m_values({innerRx, innerRy, outerRx, outerRy, halfPhi, averagePhi}), m_boundingBox(m_values[eInnerRy], m_values[eOuterRy]) { checkConsistency(); @@ -61,7 +61,8 @@ class EllipseBounds : public PlanarBounds { /// Constructor - from fixed size array /// /// @param values The parameter values - EllipseBounds(const std::array& values) noexcept(false) + explicit EllipseBounds(const std::array& values) noexcept( + false) : m_values(values), m_boundingBox(values[eInnerRy], values[eOuterRy]) { checkConsistency(); } diff --git a/Core/include/Acts/Surfaces/LineBounds.hpp b/Core/include/Acts/Surfaces/LineBounds.hpp index 7a8d2af2468..a62ea0f3cfb 100644 --- a/Core/include/Acts/Surfaces/LineBounds.hpp +++ b/Core/include/Acts/Surfaces/LineBounds.hpp @@ -27,16 +27,17 @@ class LineBounds : public SurfaceBounds { /// Constructor /// - /// @param r is the radius of the cylinder, default = 0. - /// @param halfZ is the half length in z, default = 0. - LineBounds(double r, double halfZ) noexcept(false) : m_values({r, halfZ}) { + /// @param r The radius of the line + /// @param halfZ The half length in z + explicit LineBounds(double r, double halfZ) noexcept(false) + : m_values({r, halfZ}) { checkConsistency(); } /// Constructor - from fixed size array /// - /// @param values The parameter values - LineBounds(const std::array& values) noexcept(false) + /// @param values The bound values stored in a fixed size array + explicit LineBounds(const std::array& values) noexcept(false) : m_values(values) { checkConsistency(); } diff --git a/Core/include/Acts/Surfaces/LineSurface.hpp b/Core/include/Acts/Surfaces/LineSurface.hpp index 2b1175c25b1..bab6175c510 100644 --- a/Core/include/Acts/Surfaces/LineSurface.hpp +++ b/Core/include/Acts/Surfaces/LineSurface.hpp @@ -41,29 +41,28 @@ class LineSurface : public Surface { friend class Surface; protected: - /// Constructor from Transform3 and bounds + /// Constructor for LineSurface from Transform3 and radial dimensions /// - /// @param transform The transform that positions the surface in the global - /// frame - /// @param radius The straw radius + /// @param transform The transform that positions the line in the global frame + /// @param radius The radius of the line /// @param halez The half length in z - LineSurface(const Transform3& transform, double radius, double halez); + explicit LineSurface(const Transform3& transform, double radius, + double halez); - /// Constructor from Transform3 and a shared bounds object - /// - /// @param transform The transform that positions the surface in the global - /// frame - /// @param lbounds The bounds describing the straw dimensions, can be - /// optionally nullptr - LineSurface(const Transform3& transform, - std::shared_ptr lbounds = nullptr); + /// Constructor for LineSurface from Transform3 and LineBounds + /// + /// @param transform The transform that positions the line in the global frame + /// @param lbounds The bounds describing the line dimensions + explicit LineSurface(const Transform3& transform, + std::shared_ptr lbounds = nullptr); /// Constructor from DetectorElementBase : Element proxy /// - /// @param lbounds The bounds describing the straw dimensions + /// @param lbounds are the bounds describing the line dimensions, they must + /// not be nullptr /// @param detelement for which this surface is (at least) one representation - LineSurface(std::shared_ptr lbounds, - const DetectorElementBase& detelement); + explicit LineSurface(std::shared_ptr lbounds, + const DetectorElementBase& detelement); /// Copy constructor /// @@ -75,8 +74,8 @@ class LineSurface : public Surface { /// @param gctx The current geometry context object, e.g. alignment /// @param other is the source cone surface /// @param shift is the additional transform applied after copying - LineSurface(const GeometryContext& gctx, const LineSurface& other, - const Transform3& shift); + explicit LineSurface(const GeometryContext& gctx, const LineSurface& other, + const Transform3& shift); public: /// Assignment operator diff --git a/Core/include/Acts/Surfaces/PerigeeSurface.hpp b/Core/include/Acts/Surfaces/PerigeeSurface.hpp index 660e0b3ad93..0ecdb08e306 100644 --- a/Core/include/Acts/Surfaces/PerigeeSurface.hpp +++ b/Core/include/Acts/Surfaces/PerigeeSurface.hpp @@ -34,12 +34,12 @@ class PerigeeSurface : public LineSurface { /// Constructor from GlobalPosition /// /// @param gp position where the perigee is centered - PerigeeSurface(const Vector3& gp); + explicit PerigeeSurface(const Vector3& gp); /// Constructor with a Transform - needed for tilt /// /// @param transform is the transform for position and tilting - PerigeeSurface(const Transform3& transform); + explicit PerigeeSurface(const Transform3& transform); /// Copy constructor /// diff --git a/Core/include/Acts/Surfaces/PlaneSurface.hpp b/Core/include/Acts/Surfaces/PlaneSurface.hpp index 0279443145d..075f9ca657c 100644 --- a/Core/include/Acts/Surfaces/PlaneSurface.hpp +++ b/Core/include/Acts/Surfaces/PlaneSurface.hpp @@ -66,8 +66,8 @@ class PlaneSurface : public RegularSurface { /// /// @param transform transform in 3D that positions this surface /// @param pbounds bounds object to describe the actual surface area - PlaneSurface(const Transform3& transform, - std::shared_ptr pbounds = nullptr); + explicit PlaneSurface(const Transform3& transform, + std::shared_ptr pbounds = nullptr); public: /// Assignment operator diff --git a/Core/include/Acts/Surfaces/RadialBounds.hpp b/Core/include/Acts/Surfaces/RadialBounds.hpp index f10884e5b75..51d510b134a 100644 --- a/Core/include/Acts/Surfaces/RadialBounds.hpp +++ b/Core/include/Acts/Surfaces/RadialBounds.hpp @@ -42,8 +42,9 @@ class RadialBounds : public DiscBounds { /// @param maxR The outer radius /// @param halfPhi The half opening angle (Pi for full angular coverage) /// @param avgPhi The average phi for the disc/ring sector - RadialBounds(double minR, double maxR, double halfPhi = std::numbers::pi, - double avgPhi = 0.) noexcept(false) + explicit RadialBounds(double minR, double maxR, + double halfPhi = std::numbers::pi, + double avgPhi = 0.) noexcept(false) : m_values({minR, maxR, halfPhi, avgPhi}) { checkConsistency(); } @@ -51,7 +52,7 @@ class RadialBounds : public DiscBounds { /// Constructor from array values /// /// @param values The bound values - RadialBounds(const std::array& values) noexcept(false) + explicit RadialBounds(const std::array& values) noexcept(false) : m_values(values) { checkConsistency(); } diff --git a/Core/include/Acts/Surfaces/RectangleBounds.hpp b/Core/include/Acts/Surfaces/RectangleBounds.hpp index 87620dadab8..7822d2d791a 100644 --- a/Core/include/Acts/Surfaces/RectangleBounds.hpp +++ b/Core/include/Acts/Surfaces/RectangleBounds.hpp @@ -48,7 +48,8 @@ class RectangleBounds : public PlanarBounds { /// Constructor - from fixed size array - generic /// /// @param values The parameter values - RectangleBounds(const std::array& values) noexcept(false) + explicit RectangleBounds(const std::array& values) noexcept( + false) : m_min({values[eMinX], values[eMinY]}), m_max({values[eMaxX], values[eMaxY]}) { checkConsistency(); diff --git a/Core/include/Acts/Surfaces/StrawSurface.hpp b/Core/include/Acts/Surfaces/StrawSurface.hpp index f638723ce8f..39cd042a5b2 100644 --- a/Core/include/Acts/Surfaces/StrawSurface.hpp +++ b/Core/include/Acts/Surfaces/StrawSurface.hpp @@ -49,16 +49,16 @@ class StrawSurface : public LineSurface { /// frame /// @param lbounds are the bounds describing the straw dimensions, can be /// optionally nullptr - StrawSurface(const Transform3& transform, - std::shared_ptr lbounds = nullptr); + explicit StrawSurface(const Transform3& transform, + std::shared_ptr lbounds = nullptr); /// Constructor from DetectorElementBase : Element proxy /// /// @param lbounds are the bounds describing the straw dimensions, they must /// not be nullptr /// @param detelement for which this surface is (at least) one representation - StrawSurface(const std::shared_ptr& lbounds, - const DetectorElementBase& detelement); + explicit StrawSurface(const std::shared_ptr& lbounds, + const DetectorElementBase& detelement); /// Copy constructor /// diff --git a/Core/include/Acts/Surfaces/Surface.hpp b/Core/include/Acts/Surfaces/Surface.hpp index 6bd1c126a93..7cb35afe5b9 100644 --- a/Core/include/Acts/Surfaces/Surface.hpp +++ b/Core/include/Acts/Surfaces/Surface.hpp @@ -82,7 +82,7 @@ class Surface : public virtual GeometryObject, /// /// @param transform Transform3 positions the surface in 3D global space /// @note also acts as default constructor - Surface(const Transform3& transform = Transform3::Identity()); + explicit Surface(const Transform3& transform = Transform3::Identity()); /// Copy constructor /// @@ -95,7 +95,7 @@ class Surface : public virtual GeometryObject, /// Constructor from DetectorElementBase: Element proxy /// /// @param detelement Detector element which is represented by this surface - Surface(const DetectorElementBase& detelement); + explicit Surface(const DetectorElementBase& detelement); /// Copy constructor with optional shift /// diff --git a/Core/include/Acts/Surfaces/SurfaceArray.hpp b/Core/include/Acts/Surfaces/SurfaceArray.hpp index 06212a90eec..2ccf264a21c 100644 --- a/Core/include/Acts/Surfaces/SurfaceArray.hpp +++ b/Core/include/Acts/Surfaces/SurfaceArray.hpp @@ -357,12 +357,13 @@ class SurfaceArray { struct SingleElementLookup : ISurfaceGridLookup { /// @brief Default constructor. /// @param element the one and only element. - SingleElementLookup(SurfaceVector::value_type element) + explicit SingleElementLookup(SurfaceVector::value_type element) : m_element({element}) {} /// @brief Default constructor. /// @param elements the surfaces that are provided through a single lookup - SingleElementLookup(const SurfaceVector& elements) : m_element(elements) {} + explicit SingleElementLookup(const SurfaceVector& elements) + : m_element(elements) {} /// @brief Lookup, always returns @c element /// @return reference to vector containing only @c element @@ -437,13 +438,13 @@ class SurfaceArray { /// @param surfaces The input vector of surfaces. This is only for /// bookkeeping, so we can ask /// @param transform Optional additional transform for this SurfaceArray - SurfaceArray(std::unique_ptr gridLookup, - std::vector> surfaces, - const Transform3& transform = Transform3::Identity()); + explicit SurfaceArray(std::unique_ptr gridLookup, + std::vector> surfaces, + const Transform3& transform = Transform3::Identity()); /// @brief Constructor with a single surface /// @param srf The one and only surface - SurfaceArray(std::shared_ptr srf); + explicit SurfaceArray(std::shared_ptr srf); /// @brief Get all surfaces in bin given by position. /// @param position the lookup position diff --git a/Core/include/Acts/Surfaces/TrapezoidBounds.hpp b/Core/include/Acts/Surfaces/TrapezoidBounds.hpp index f8bfebe2971..7eeae4b5ee3 100644 --- a/Core/include/Acts/Surfaces/TrapezoidBounds.hpp +++ b/Core/include/Acts/Surfaces/TrapezoidBounds.hpp @@ -43,13 +43,14 @@ class TrapezoidBounds : public PlanarBounds { /// @param halfXposY maximal half length X, definition at positive Y /// @param halfY half length Y - defined at x=0 /// @param rotAngle: rotation angle of the bounds w.r.t coordinate axes - TrapezoidBounds(double halfXnegY, double halfXposY, double halfY, - double rotAngle = 0.) noexcept(false); + explicit TrapezoidBounds(double halfXnegY, double halfXposY, double halfY, + double rotAngle = 0.) noexcept(false); /// Constructor for symmetric Trapezoid - from fixed size array /// /// @param values the values to be stream in - TrapezoidBounds(const std::array& values) noexcept(false); + explicit TrapezoidBounds(const std::array& values) noexcept( + false); BoundsType type() const final { return SurfaceBounds::eTrapezoid; } diff --git a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp index 5acda71be82..4ad4a731e79 100644 --- a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp +++ b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp @@ -159,10 +159,13 @@ class CombinatorialKalmanFilter { public: /// Default constructor is deleted CombinatorialKalmanFilter() = delete; - /// Constructor from arguments - CombinatorialKalmanFilter(propagator_t pPropagator, - std::unique_ptr _logger = - getDefaultLogger("CKF", Logging::INFO)) + + /// Constructor with propagator and logging level + /// @param pPropagator The propagator used for the track finding + /// @param _logger The logger for messages + explicit CombinatorialKalmanFilter(propagator_t pPropagator, + std::unique_ptr _logger = + getDefaultLogger("CKF", Logging::INFO)) : m_propagator(std::move(pPropagator)), m_logger(std::move(_logger)), m_actorLogger{m_logger->cloneWithSuffix("Actor")}, diff --git a/Core/include/Acts/TrackFinding/GbtsConnector.hpp b/Core/include/Acts/TrackFinding/GbtsConnector.hpp index 5cc4825f37a..a73325fa255 100644 --- a/Core/include/Acts/TrackFinding/GbtsConnector.hpp +++ b/Core/include/Acts/TrackFinding/GbtsConnector.hpp @@ -36,7 +36,7 @@ class GbtsConnector { m_sources; // the source layers of the group }; - GbtsConnector(std::ifstream &inFile); + explicit GbtsConnector(std::ifstream &inFile); float m_etaBin{}; diff --git a/Core/include/Acts/TrackFinding/TrackSelector.hpp b/Core/include/Acts/TrackFinding/TrackSelector.hpp index fe4287a38b0..c63d3dc3cf3 100644 --- a/Core/include/Acts/TrackFinding/TrackSelector.hpp +++ b/Core/include/Acts/TrackFinding/TrackSelector.hpp @@ -159,20 +159,20 @@ class TrackSelector { /// Constructor to create a config object that is not upper-bounded. /// This is useful to use the "fluent" API to populate the configuration. /// @param etaMin Minimum eta bin edge - EtaBinnedConfig(double etaMin) : cutSets{}, absEtaEdges{etaMin} {} + explicit EtaBinnedConfig(double etaMin) : cutSets{}, absEtaEdges{etaMin} {} /// Constructor from a vector of eta bin edges. This automatically /// initializes all the cuts to be the same for all eta and be essentially /// no-op. /// @param absEtaEdgesIn is the vector of eta bin edges - EtaBinnedConfig(std::vector absEtaEdgesIn) + explicit EtaBinnedConfig(std::vector absEtaEdgesIn) : absEtaEdges{std::move(absEtaEdgesIn)} { cutSets.resize(nEtaBins()); } /// Auto-converting constructor from a single cut configuration. /// Results in a single absolute eta bin from 0 to infinity. - EtaBinnedConfig(Config cutSet) : cutSets{std::move(cutSet)} {} + explicit EtaBinnedConfig(Config cutSet) : cutSets{std::move(cutSet)} {} /// Add a new eta bin with the given upper bound. /// @param etaMax Upper bound of the new eta bin @@ -217,11 +217,11 @@ class TrackSelector { /// Constructor from a single cut config object /// @param config is the configuration object - TrackSelector(const Config& config); + explicit TrackSelector(const Config& config); /// Constructor from a multi-eta /// @param config is the configuration object - TrackSelector(const EtaBinnedConfig& config); + explicit TrackSelector(const EtaBinnedConfig& config); /// Select tracks from an input container and copy them into an output /// container diff --git a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp index 72887f04842..c0997ea4536 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp @@ -683,9 +683,9 @@ class Gx2Fitter { std::is_same_v; public: - Gx2Fitter(propagator_t pPropagator, - std::unique_ptr _logger = - getDefaultLogger("Gx2Fitter", Logging::INFO)) + explicit Gx2Fitter(propagator_t pPropagator, + std::unique_ptr _logger = + getDefaultLogger("Gx2Fitter", Logging::INFO)) : m_propagator(std::move(pPropagator)), m_logger{std::move(_logger)}, m_actorLogger{m_logger->cloneWithSuffix("Actor")}, @@ -1339,6 +1339,9 @@ class Gx2Fitter { // We skip the check during the first iteration, since we cannot guarantee // to hit all/enough measurement surfaces with the initial parameter // guess. + // We skip the check during the first iteration, since we cannot guarantee + // to hit all/enough measurement surfaces with the initial parameter + // guess. if ((nUpdate > 0) && !extendedSystem.isWellDefined()) { ACTS_INFO("Not enough measurements. Require " << extendedSystem.findRequiredNdf() + 1 << ", but only " diff --git a/Core/include/Acts/TrackFitting/KalmanFitter.hpp b/Core/include/Acts/TrackFitting/KalmanFitter.hpp index f2d0a22a75d..762748c197e 100644 --- a/Core/include/Acts/TrackFitting/KalmanFitter.hpp +++ b/Core/include/Acts/TrackFitting/KalmanFitter.hpp @@ -15,6 +15,7 @@ #include "Acts/EventData/MultiTrajectoryHelpers.hpp" #include "Acts/EventData/SourceLink.hpp" #include "Acts/EventData/TrackParameters.hpp" +#include "Acts/EventData/TrackStateType.hpp" #include "Acts/EventData/VectorMultiTrajectory.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" @@ -267,9 +268,9 @@ class KalmanFitter { std::is_same_v; public: - KalmanFitter(propagator_t pPropagator, - std::unique_ptr _logger = - getDefaultLogger("KalmanFitter", Logging::INFO)) + explicit KalmanFitter(propagator_t pPropagator, + std::unique_ptr _logger = + getDefaultLogger("KalmanFitter", Logging::INFO)) : m_propagator(std::move(pPropagator)), m_logger{std::move(_logger)}, m_actorLogger{m_logger->cloneWithSuffix("Actor")} {} @@ -406,8 +407,8 @@ class KalmanFitter { // Remove the missing surfaces that occur after the last measurement result.missedActiveSurfaces.resize(result.measurementHoles); // now get track state proxy for the smoothing logic - auto trackStateProxy = - result.fittedStates->getTrackState(result.lastMeasurementIndex); + typename traj_t::ConstTrackStateProxy trackStateProxy{ + result.fittedStates->getTrackState(result.lastMeasurementIndex)}; if (reversedFiltering || extensions.reverseFilteringLogic(trackStateProxy)) { // Start to run reversed filtering: diff --git a/Core/include/Acts/TrackFitting/detail/KalmanUpdateHelpers.hpp b/Core/include/Acts/TrackFitting/detail/KalmanUpdateHelpers.hpp index 1098c342672..db32dc71d69 100644 --- a/Core/include/Acts/TrackFitting/detail/KalmanUpdateHelpers.hpp +++ b/Core/include/Acts/TrackFitting/detail/KalmanUpdateHelpers.hpp @@ -50,6 +50,8 @@ auto kalmanHandleMeasurement( typename traj_t::TrackStateProxy trackStateProxy = fittedStates.makeTrackState(mask, lastTrackIndex); + typename traj_t::ConstTrackStateProxy trackStateProxyConst{trackStateProxy}; + // Set the trackStateProxy components with the state from the ongoing // propagation { @@ -91,7 +93,7 @@ auto kalmanHandleMeasurement( // - tag it as a measurement // - update the stepping state. // Else, just tag it as an outlier - if (!extensions.outlierFinder(trackStateProxy)) { + if (!extensions.outlierFinder(trackStateProxyConst)) { // Run Kalman update auto updateRes = extensions.updater(state.geoContext, trackStateProxy, logger); diff --git a/Core/include/Acts/Utilities/AnnealingUtility.hpp b/Core/include/Acts/Utilities/AnnealingUtility.hpp index ce6fc9e7db3..722b70dd4a9 100644 --- a/Core/include/Acts/Utilities/AnnealingUtility.hpp +++ b/Core/include/Acts/Utilities/AnnealingUtility.hpp @@ -44,7 +44,7 @@ class AnnealingUtility { }; /// Constructor - AnnealingUtility(const Config& cfg = Config()) : m_cfg(cfg) { + explicit AnnealingUtility(const Config& cfg = Config()) : m_cfg(cfg) { // Set Gaussian cut-off terms for each temperature for (double temp : cfg.setOfTemperatures) { m_gaussCutTempVec.push_back(std::exp(-cfg.cutOff / (2. * temp))); diff --git a/Core/include/Acts/Utilities/Any.hpp b/Core/include/Acts/Utilities/Any.hpp index bf04ec47ca7..2326849a095 100644 --- a/Core/include/Acts/Utilities/Any.hpp +++ b/Core/include/Acts/Utilities/Any.hpp @@ -249,7 +249,7 @@ class AnyBase : public AnyBaseAll { return *this; } - operator bool() const { return m_handler != nullptr; } + explicit operator bool() const { return m_handler != nullptr; } private: void* dataPtr() { diff --git a/Core/include/Acts/Utilities/AnyGridView.hpp b/Core/include/Acts/Utilities/AnyGridView.hpp new file mode 100644 index 00000000000..ac1e10c8524 --- /dev/null +++ b/Core/include/Acts/Utilities/AnyGridView.hpp @@ -0,0 +1,202 @@ +// This file is part of the ACTS project. +// +// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. + +#pragma once + +#include "Acts/Utilities/Grid.hpp" +#include "Acts/Utilities/TypeTraits.hpp" + +#include + +namespace Acts { + +namespace detail { + +/// @brief Base class for type-safe views into grid objects +/// +/// @tparam T Type of values stored in the grid +/// @tparam isConst Whether this view provides const access (true) or mutable access (false) +/// +/// This class provides a type-safe interface to access grid objects through the +/// type-erased IGrid interface. It ensures that the grid being viewed contains +/// values of the expected type T. +template +class AnyGridViewBase { + public: + /// Type of pointer to grid, const or non-const depending on isConst + using GridPointerType = std::conditional_t; + /// Type for indices, imported from IGrid + using AnyIndexType = IGrid::AnyIndexType; + /// Type for points, imported from IGrid + using AnyPointType = IGrid::AnyPointType; + + /// @brief Constructor from const IGrid reference + /// @param grid The grid to view + /// @note This constructor is only available for const views (isConst=true) + explicit AnyGridViewBase(const IGrid& grid) + requires(isConst) + : m_grid(&grid) { + checkType(); + } + + /// @brief Constructor from non-const IGrid reference + /// @param grid The grid to view + explicit AnyGridViewBase(IGrid& grid) : m_grid(&grid) { checkType(); } + + /// @brief Constructor from non-const concrete Grid reference + /// @tparam Axes Parameter pack of axis types defining the grid + /// @param grid The concrete grid to view + /// @note This constructor is only available for non-const views (isConst=false) + template + explicit AnyGridViewBase(Grid& grid) + requires(!isConst) + : m_grid(&grid) { + checkType(); + } + + /// @brief Constructor from const concrete Grid reference + /// @tparam Axes Parameter pack of axis types defining the grid + /// @param grid The concrete grid to view + /// @note This constructor is only available for const views (isConst=true) + template + explicit AnyGridViewBase(const Grid& grid) + requires(isConst) + : m_grid(&grid) { + checkType(); + } + + /// Copy constructor + AnyGridViewBase(const AnyGridViewBase& other) = default; + /// Copy assignment operator + AnyGridViewBase& operator=(const AnyGridViewBase& other) = default; + + /// Move constructor + AnyGridViewBase(AnyGridViewBase&&) noexcept = default; + /// Move assignment operator + AnyGridViewBase& operator=(AnyGridViewBase&&) noexcept = default; + + /// @brief Access value at given local bin indices with mutable access + /// @param indices The local bin indices + /// @return Reference to the value at the specified bin + /// @note This method is only available for non-const views (isConst=false) + /// @throws std::invalid_argument if indices size doesn't match grid dimensions + /// @throws std::out_of_range if indices are out of bounds + T& atLocalBins(const AnyIndexType& indices) + requires(!isConst) + { + std::any any = m_grid->atLocalBinsAny(indices); + return *std::any_cast(any); + } + + /// @brief Access value at given local bin indices with const access + /// @param indices The local bin indices + /// @return Const reference to the value at the specified bin + /// @throws std::invalid_argument if indices size doesn't match grid dimensions + /// @throws std::out_of_range if indices are out of bounds + const T& atLocalBins(const AnyIndexType& indices) const { + std::any any = m_grid->atLocalBinsAny(indices); + return *std::any_cast(any); + } + + /// @brief Get the number of dimensions of the grid + /// @return The number of dimensions + std::size_t dimensions() const { return m_grid->dimensions(); } + + /// @brief Get the center position of a bin for given indices + /// @param indices The local bin indices + /// @return The center position of the bin + AnyPointType binCenter(const IGrid::AnyIndexType& indices) const { + return m_grid->binCenterAny(indices); + } + + /// @brief Get the lower left edge position of a bin for given indices + /// @param indices The local bin indices + /// @return The lower left edge position of the bin + AnyPointType lowerLeftBinEdge(const IGrid::AnyIndexType& indices) const { + return m_grid->lowerLeftBinEdgeAny(indices); + } + + /// @brief Get the upper right edge position of a bin for given indices + /// @param indices The local bin indices + /// @return The upper right edge position of the bin + AnyPointType upperRightBinEdge(const IGrid::AnyIndexType& indices) const { + return m_grid->upperRightBinEdgeAny(indices); + } + + /// @brief Get the number of bins along each axis + /// @return Vector containing the number of bins for each axis + AnyIndexType numLocalBins() const { return m_grid->numLocalBinsAny(); } + + private: + /// @brief Check if the grid's value type matches the template parameter T + /// @throws std::invalid_argument if there's a type mismatch + void checkType() { + if (m_grid->valueType() != typeid(T)) { + throw std::invalid_argument("Type mismatch between grid and view type"); + } + } + + /// Pointer to the underlying grid + GridPointerType m_grid; +}; + +} // namespace detail + +/// @brief Type-safe view into a grid with mutable access +/// +/// @tparam T Type of values stored in the grid +/// +/// This class provides a type-safe interface to access grid objects through the +/// type-erased IGrid interface with mutable access. It ensures that the grid +/// being viewed contains values of the expected type T. +/// +/// Example usage: +/// ``` +/// Grid grid(...); +/// AnyGridView view(grid); +/// view.atLocalBins({1}) = 42.0; // Modify the grid through the view +/// ``` +template +class AnyGridView : public detail::AnyGridViewBase { + public: + using detail::AnyGridViewBase::AnyGridViewBase; +}; + +/// @brief Deduction guide for AnyGridView from Grid +/// @tparam T Type of values stored in the grid +/// @tparam Axes Parameter pack of axis types defining the grid +template +AnyGridView(Grid& grid) -> AnyGridView; + +/// @brief Type-safe view into a grid with const access +/// +/// @tparam T Type of values stored in the grid +/// +/// This class provides a type-safe interface to access grid objects through the +/// type-erased IGrid interface with const access only. It ensures that the grid +/// being viewed contains values of the expected type T. +/// +/// Example usage: +/// ``` +/// const Grid grid(...); +/// AnyGridConstView view(grid); +/// double value = view.atLocalBins({1}); // Read-only access +/// ``` +template +class AnyGridConstView : public detail::AnyGridViewBase { + public: + using detail::AnyGridViewBase::AnyGridViewBase; +}; + +/// @brief Deduction guide for AnyGridConstView from const Grid +/// @tparam T Type of values stored in the grid +/// @tparam Axes Parameter pack of axis types defining the grid +template +AnyGridConstView(const Grid& grid) -> AnyGridConstView; + +} // namespace Acts diff --git a/Core/include/Acts/Utilities/Axis.hpp b/Core/include/Acts/Utilities/Axis.hpp index c6d5b53a541..ac5428e60e8 100644 --- a/Core/include/Acts/Utilities/Axis.hpp +++ b/Core/include/Acts/Utilities/Axis.hpp @@ -43,7 +43,8 @@ class NeighborHoodIndices { iterator() = default; // Specialized constructor for end() iterator - iterator(std::size_t current) : m_current(current), m_wrapped(true) {} + explicit iterator(std::size_t current) + : m_current(current), m_wrapped(true) {} iterator(std::size_t begin1, std::size_t end1, std::size_t begin2) : m_current(begin1), diff --git a/Core/include/Acts/Utilities/BinUtility.hpp b/Core/include/Acts/Utilities/BinUtility.hpp index 7a3b2649243..93fb1d7f428 100644 --- a/Core/include/Acts/Utilities/BinUtility.hpp +++ b/Core/include/Acts/Utilities/BinUtility.hpp @@ -87,9 +87,9 @@ class BinUtility { /// @param opt is the binning option : open, closed /// @param value is the axis direction : AxisX, AxisY, AxisZ, etc. /// @param tForm is the (optional) transform - BinUtility(std::vector& bValues, BinningOption opt = open, - AxisDirection value = AxisDirection::AxisPhi, - const Transform3& tForm = Transform3::Identity()) + explicit BinUtility(std::vector& bValues, BinningOption opt = open, + AxisDirection value = AxisDirection::AxisPhi, + const Transform3& tForm = Transform3::Identity()) : m_binningData(), m_transform(tForm), m_itransform(tForm.inverse()) { m_binningData.reserve(3); m_binningData.emplace_back(opt, value, bValues); diff --git a/Core/include/Acts/Utilities/BinnedArrayXD.hpp b/Core/include/Acts/Utilities/BinnedArrayXD.hpp index 139ec19fdca..ad76be6ec1c 100644 --- a/Core/include/Acts/Utilities/BinnedArrayXD.hpp +++ b/Core/include/Acts/Utilities/BinnedArrayXD.hpp @@ -41,7 +41,7 @@ class BinnedArrayXD : public BinnedArray { /// Constructor for single object /// /// @tparam object is the single object - BinnedArrayXD(T object) + explicit BinnedArrayXD(T object) : BinnedArray(), m_objectGrid( 1, std::vector>(1, std::vector(1, nullptr))), diff --git a/Core/include/Acts/Utilities/BoundingBox.hpp b/Core/include/Acts/Utilities/BoundingBox.hpp index 3c6f450a1b3..9cebd846c89 100644 --- a/Core/include/Acts/Utilities/BoundingBox.hpp +++ b/Core/include/Acts/Utilities/BoundingBox.hpp @@ -95,7 +95,7 @@ class AxisAlignedBoundingBox { /// contained in @p boxes, and additional envelope can be given. /// @param boxes Vector of child boxes to store in this bounding box. /// @param envelope Envelope that will be added/subtracted to the dimension. - AxisAlignedBoundingBox( + explicit AxisAlignedBoundingBox( const std::vector& boxes, vertex_array_type envelope = vertex_array_type::Zero()); diff --git a/Core/include/Acts/Utilities/DBScan.hpp b/Core/include/Acts/Utilities/DBScan.hpp index 9436a4e4b2e..bfb5babb296 100644 --- a/Core/include/Acts/Utilities/DBScan.hpp +++ b/Core/include/Acts/Utilities/DBScan.hpp @@ -70,8 +70,8 @@ class DBScan { /// @param minPoints The minimum number of points to form a cluster. /// @param onePointCluster If true, all the noise points are considered as /// individual one point clusters. - DBScan(scalar_t epsilon = 1.0, std::size_t minPoints = 1, - bool onePointCluster = false) + explicit DBScan(scalar_t epsilon = 1.0, std::size_t minPoints = 1, + bool onePointCluster = false) : m_eps(epsilon), m_minPoints(minPoints), m_onePointCluster(onePointCluster) {} diff --git a/Core/include/Acts/Utilities/Delegate.hpp b/Core/include/Acts/Utilities/Delegate.hpp index 8cac473abb9..af7321b2c96 100644 --- a/Core/include/Acts/Utilities/Delegate.hpp +++ b/Core/include/Acts/Utilities/Delegate.hpp @@ -348,8 +348,15 @@ class OwningDelegate : public Delegate { public: OwningDelegate() = default; - OwningDelegate(Delegate &&delegate) + explicit OwningDelegate( + Delegate &&delegate) : Delegate(std::move(delegate)) {} + + OwningDelegate &operator=( + Delegate &&delegate) { + *this = OwningDelegate{std::move(delegate)}; + return *this; + } }; } // namespace Acts diff --git a/Core/include/Acts/Utilities/DelegateChainBuilder.hpp b/Core/include/Acts/Utilities/DelegateChainBuilder.hpp index a24ab98ddb8..06d151027dc 100644 --- a/Core/include/Acts/Utilities/DelegateChainBuilder.hpp +++ b/Core/include/Acts/Utilities/DelegateChainBuilder.hpp @@ -38,7 +38,7 @@ class DelegateChainBuilder, DelegateChainBuilder() = default; template - DelegateChainBuilder(const D& /*unused*/) {} + explicit DelegateChainBuilder(const D& /*unused*/) {} template constexpr auto add(payload_type payload) @@ -87,7 +87,7 @@ class DelegateChainBuilder, } private: - DelegateChainBuilder(std::tuple payloads) + explicit DelegateChainBuilder(std::tuple payloads) : m_payloads(payloads) {} struct DispatchBlock { @@ -130,7 +130,8 @@ class DelegateChainBuilder, } } - DispatchBlock(tuple_type payloads) : m_payloads(std::move(payloads)) {} + explicit DispatchBlock(tuple_type payloads) + : m_payloads(std::move(payloads)) {} tuple_type m_payloads{}; diff --git a/Core/include/Acts/Utilities/FiniteStateMachine.hpp b/Core/include/Acts/Utilities/FiniteStateMachine.hpp index 1171b91d30a..dcddb300163 100644 --- a/Core/include/Acts/Utilities/FiniteStateMachine.hpp +++ b/Core/include/Acts/Utilities/FiniteStateMachine.hpp @@ -123,7 +123,7 @@ class FiniteStateMachine { /// Constructor from an explicit state. The FSM is initialized to this state. /// @param state Initial state for the FSM. - FiniteStateMachine(StateVariant state) : m_state(std::move(state)) {} + explicit FiniteStateMachine(StateVariant state) : m_state(std::move(state)) {} /// Get the current state of the FSM (as a variant). /// @return StateVariant The current state of the FSM. diff --git a/Core/include/Acts/Utilities/Grid.hpp b/Core/include/Acts/Utilities/Grid.hpp index f454e553cf0..e8a3694f9a4 100644 --- a/Core/include/Acts/Utilities/Grid.hpp +++ b/Core/include/Acts/Utilities/Grid.hpp @@ -8,26 +8,35 @@ #pragma once +#include "Acts/Definitions/Algebra.hpp" #include "Acts/Utilities/IAxis.hpp" #include "Acts/Utilities/Interpolation.hpp" #include "Acts/Utilities/TypeTag.hpp" +#include "Acts/Utilities/TypeTraits.hpp" #include "Acts/Utilities/detail/grid_helper.hpp" +#include #include #include #include +#include #include #include namespace Acts { + template class GridGlobalIterator; template class GridLocalIterator; -} // namespace Acts -namespace Acts { +namespace detail { + +template +class AnyGridViewBase; + +} // namespace detail /// Base class for all grid types class IGrid { @@ -38,6 +47,45 @@ class IGrid { /// @return a vector of axis pointers virtual boost::container::small_vector axes() const = 0; + /// @brief Get the number of dimensions of the grid + /// @return The number of dimensions of the grid + virtual std::size_t dimensions() const = 0; + + /// @brief Get the type of the values stored in the grid + /// @return The type of the values stored in the grid + virtual std::type_info const& valueType() const = 0; + + /// Type-erased interface to access the contents of the grid + /// + /// @note This interface has non-negligible runtime overhead due to packing + /// and unpacking from/to @c std::any and the dynamically sized index and + /// point types. **USE WITH CARE!** + /// + /// @{ + using AnyIndexType = boost::container::small_vector; + using AnyPointType = boost::container::small_vector; + + /// @brief Get the lower left edge of a bin for a given set of indices + /// @param indices The indices to get the lower left edge of the bin for + /// @return The lower left edge of the bin + virtual AnyPointType lowerLeftBinEdgeAny(AnyIndexType indices) const = 0; + + /// @brief Get the upper right edge of a bin for a given set of indices + /// @param indices The indices to get the upper right edge of the bin for + /// @return The upper right edge of the bin + virtual AnyPointType upperRightBinEdgeAny(AnyIndexType indices) const = 0; + + /// @brief Get the center of a bin for a given set of indices + /// @param indices The indices to get the center of the bin for + /// @return The center of the bin + virtual AnyPointType binCenterAny(AnyIndexType indices) const = 0; + + /// @brief Get the number of local bins for a given set of indices + /// @return The number of local bins + virtual AnyIndexType numLocalBinsAny() const = 0; + + /// @} + /// Helper to print out the grid /// @param os the output stream /// @param grid the grid to print @@ -57,6 +105,21 @@ class IGrid { protected: virtual void toStream(std::ostream& os) const = 0; + + /// @brief Get the value of a bin for a given set of indices + /// @param indices The indices to get the value of the bin for + /// @return The value of the bin: the @c std::any contains a const pointer to + /// the value + virtual std::any atLocalBinsAny(AnyIndexType indices) const = 0; + + /// @brief Get the value of a bin for a given set of indices + /// @param indices The indices to get the value of the bin for + /// @return The value of the bin: the @c std::any contains a pointer to the + /// value + virtual std::any atLocalBinsAny(AnyIndexType indices) = 0; + + template + friend class detail::AnyGridViewBase; }; /// @brief class for describing a regular multi-dimensional grid @@ -69,7 +132,10 @@ class IGrid { /// either by global bin index, local bin indices or position. /// /// @note @c T must be default-constructible. +/// @note @c T must not be @c bool, because @c std::vector is special +/// and does not return references to its elements. template + requires(std::is_default_constructible_v && !std::is_same_v) class Grid final : public IGrid { public: /// number of dimensions of the grid @@ -95,38 +161,39 @@ class Grid final : public IGrid { /// grid object. /// /// @param axes - Grid(const std::tuple& axes) : m_axes(axes) { + explicit Grid(const std::tuple& axes) : m_axes(axes) { m_values.resize(size()); } /// @brief Move constructor from axis tuple /// @param axes - Grid(std::tuple&& axes) : m_axes(std::move(axes)) { + explicit Grid(std::tuple&& axes) : m_axes(std::move(axes)) { m_values.resize(size()); } /// @brief constructor from parameters pack of axes /// @param axes - Grid(Axes&&... axes) : m_axes(std::forward_as_tuple(axes...)) { + explicit Grid(Axes&&... axes) : m_axes(std::forward_as_tuple(axes...)) { m_values.resize(size()); } /// @brief constructor from parameters pack of axes /// @param axes - Grid(const Axes&... axes) : m_axes(std::tuple(axes...)) { + explicit Grid(const Axes&... axes) : m_axes(std::tuple(axes...)) { m_values.resize(size()); } /// @brief constructor from parameters pack of axes and type tag /// @param axes - Grid(TypeTag /*tag*/, Axes&&... axes) + explicit Grid(TypeTag /*tag*/, Axes&&... axes) : m_axes(std::forward_as_tuple(axes...)) { m_values.resize(size()); } /// @brief constructor from parameters pack of axes and type tag /// @param axes - Grid(TypeTag /*tag*/, const Axes&... axes) : m_axes(std::tuple(axes...)) { + explicit Grid(TypeTag /*tag*/, const Axes&... axes) + : m_axes(std::tuple(axes...)) { m_values.resize(size()); } @@ -196,6 +263,12 @@ class Grid final : public IGrid { return m_values.at(globalBinFromLocalBins(localBins)); } + /// @copydoc Acts::IGrid::atLocalBinsAny + std::any atLocalBinsAny(AnyIndexType indices) const override { + const_reference cref = atLocalBins(toIndexType(indices)); + return &cref; + } + /// @brief access value stored in bin with given local bin numbers /// /// @param [in] localBins local bin indices along each axis @@ -208,6 +281,12 @@ class Grid final : public IGrid { return m_values.at(globalBinFromLocalBins(localBins)); } + /// @copydoc Acts::IGrid::atLocalBinsAny + std::any atLocalBinsAny(AnyIndexType indices) override { + reference ref = atLocalBins(toIndexType(indices)); + return &ref; + } + /// @brief get global bin indices for closest points on grid /// /// @tparam Point any type with point semantics supporting component access @@ -228,7 +307,10 @@ class Grid final : public IGrid { /// @brief dimensionality of grid /// /// @return number of axes spanning the grid - static constexpr std::size_t dimensions() { return DIM; } + std::size_t dimensions() const override { return DIM; } + + /// @copydoc Acts::IGrid::valueType + const std::type_info& valueType() const override { return typeid(T); } /// @brief get center position of bin with given local bin numbers /// @@ -237,10 +319,14 @@ class Grid final : public IGrid { /// /// @pre All local bin indices must be a valid index for the corresponding /// axis (excluding the under-/overflow bins for each axis). - std::array binCenter(const index_t& localBins) const { + point_t binCenter(const index_t& localBins) const { return detail::grid_helper::getBinCenter(localBins, m_axes); } + AnyPointType binCenterAny(AnyIndexType indices) const override { + return toAnyPointType(binCenter(toIndexType(indices))); + } + /// @brief determine global index for bin containing the given point /// /// @tparam Point any type with point semantics supporting component access @@ -348,6 +434,11 @@ class Grid final : public IGrid { return detail::grid_helper::getLowerLeftBinEdge(localBins, m_axes); } + /// @copydoc Acts::IGrid::lowerLeftBinEdgeAny + AnyPointType lowerLeftBinEdgeAny(AnyIndexType indices) const override { + return toAnyPointType(lowerLeftBinEdge(toIndexType(indices))); + } + /// @brief retrieve upper-right bin edge from set of local bin indices /// /// @param [in] localBins local bin indices along each axis @@ -359,6 +450,11 @@ class Grid final : public IGrid { return detail::grid_helper::getUpperRightBinEdge(localBins, m_axes); } + /// @copydoc Acts::IGrid::upperRightBinEdgeAny + AnyPointType upperRightBinEdgeAny(AnyIndexType indices) const override { + return toAnyPointType(upperRightBinEdge(toIndexType(indices))); + } + /// @brief get bin width along each specific axis /// /// @return array giving the bin width alonf all axes @@ -371,6 +467,11 @@ class Grid final : public IGrid { /// @note Not including under- and overflow bins index_t numLocalBins() const { return detail::grid_helper::getNBins(m_axes); } + /// @copydoc Acts::IGrid::numLocalBinsAny + AnyIndexType numLocalBinsAny() const override { + return toAnyIndexType(numLocalBins()); + } + /// @brief get the minimum value of all axes of one grid /// /// @return array returning the minima of all given axes @@ -631,6 +732,29 @@ class Grid final : public IGrid { }; (printOne(std::integral_constant()), ...); } + + static AnyIndexType toAnyIndexType(const index_t& indices) { + AnyIndexType anyIndices; + anyIndices.reserve(indices.size()); + std::ranges::copy(indices, std::back_inserter(anyIndices)); + return anyIndices; + } + + static AnyPointType toAnyPointType(const point_t& point) { + AnyPointType anyPoint; + anyPoint.reserve(point.size()); + std::ranges::copy(point, std::back_inserter(anyPoint)); + return anyPoint; + } + + static index_t toIndexType(const AnyIndexType& indices) { + if (indices.size() != DIM) { + throw std::invalid_argument("Invalid number of indices"); + } + index_t concrete; + std::ranges::copy(indices, concrete.begin()); + return concrete; + } }; template diff --git a/Core/include/Acts/Utilities/GridIterator.hpp b/Core/include/Acts/Utilities/GridIterator.hpp index cc4ba96c8a0..0e55e846d9a 100644 --- a/Core/include/Acts/Utilities/GridIterator.hpp +++ b/Core/include/Acts/Utilities/GridIterator.hpp @@ -42,7 +42,8 @@ class GridGlobalIterator { /// @param [in] idx The global bin /// /// @pre Global bin index must be a valid index for the grid - GridGlobalIterator(const Acts::Grid& grid, std::size_t idx = 0ul); + explicit GridGlobalIterator(const Acts::Grid& grid, + std::size_t idx = 0ul); /// @brief Copy constructor /// @param [in] other The GlobalBinIterator to be copied diff --git a/Core/include/Acts/Utilities/GridIterator.ipp b/Core/include/Acts/Utilities/GridIterator.ipp index 8c6c5fee6da..f797ab0d2ff 100644 --- a/Core/include/Acts/Utilities/GridIterator.ipp +++ b/Core/include/Acts/Utilities/GridIterator.ipp @@ -65,13 +65,13 @@ GridGlobalIterator& GridGlobalIterator::operator-=( template GridGlobalIterator GridGlobalIterator::operator+( const std::size_t offset) const { - return {*m_grid, m_idx + offset}; + return GridGlobalIterator(*m_grid, m_idx + offset); } template GridGlobalIterator GridGlobalIterator::operator-( const std::size_t offset) const { - return {*m_grid, m_idx - offset}; + return GridGlobalIterator(*m_grid, m_idx - offset); } template diff --git a/Core/include/Acts/Utilities/Holders.hpp b/Core/include/Acts/Utilities/Holders.hpp index 110b241451b..94552b897c6 100644 --- a/Core/include/Acts/Utilities/Holders.hpp +++ b/Core/include/Acts/Utilities/Holders.hpp @@ -52,7 +52,7 @@ struct ValueHolder { // @FIXME: Ideally we want this to be explicit, but cannot be explicit, // because using an explicit constructor and a deduction guide leads to // a SEGFAULT in GCC11 (an up?). Re-evaluate down the line - /* explicit */ ValueHolder(T&& _val) : val{std::move(_val)} {} + /* explicit */ ValueHolder(T&& _val) : val{std::move(_val)} {} // NOLINT // Does it make sense to allow copy operations? diff --git a/Core/include/Acts/Utilities/KDTree.hpp b/Core/include/Acts/Utilities/KDTree.hpp index dc8f9f9b844..e448ff50657 100644 --- a/Core/include/Acts/Utilities/KDTree.hpp +++ b/Core/include/Acts/Utilities/KDTree.hpp @@ -75,7 +75,7 @@ class KDTree { /// /// @param d The vector of position-value pairs to construct the k-d tree /// from. - KDTree(vector_t &&d) : m_elems(d) { + explicit KDTree(vector_t &&d) : m_elems(d) { // To start out, we need to check whether we need to construct a leaf node // or an internal node. We create a leaf only if we have at most as many // elements as the number of elements that can fit into a leaf node. diff --git a/Core/include/Acts/Utilities/Logger.hpp b/Core/include/Acts/Utilities/Logger.hpp index b9e499b74f3..ef7087ab518 100644 --- a/Core/include/Acts/Utilities/Logger.hpp +++ b/Core/include/Acts/Utilities/Logger.hpp @@ -49,7 +49,7 @@ #define ACTS_LOCAL_LOGGER(log_object) \ struct __local_acts_logger \ { \ - __local_acts_logger(std::unique_ptr logger): \ + explicit __local_acts_logger(std::unique_ptr logger): \ m_logger(std::move(logger)) \ {} \ \ @@ -446,8 +446,8 @@ class TimedOutputDecorator final : public OutputDecorator { /// /// @param [in] wrappee output print policy object to be wrapped /// @param [in] format format of time stamp (see std::strftime) - TimedOutputDecorator(std::unique_ptr wrappee, - const std::string& format = "%X") + explicit TimedOutputDecorator(std::unique_ptr wrappee, + const std::string& format = "%X") : OutputDecorator(std::move(wrappee)), m_format(format) {} /// @brief flush the debug message to the destination stream diff --git a/Core/include/Acts/Utilities/MultiIndex.hpp b/Core/include/Acts/Utilities/MultiIndex.hpp index ca7d330ba6b..23f6a75e782 100644 --- a/Core/include/Acts/Utilities/MultiIndex.hpp +++ b/Core/include/Acts/Utilities/MultiIndex.hpp @@ -37,9 +37,7 @@ class MultiIndex { /// The type of their underlying storage value. using Value = T; - enum : std::size_t { - NumLevels = sizeof...(BitsPerLevel), - }; + static constexpr std::size_t kNumLevels = sizeof...(BitsPerLevel); /// Construct a MultiIndex with all levels set to zero. static constexpr MultiIndex Zeros() { return MultiIndex(0u); } @@ -52,7 +50,7 @@ class MultiIndex { /// signature and could not be distinguished. template static constexpr MultiIndex Encode(Us&&... us) { - static_assert(sizeof...(Us) <= NumLevels, + static_assert(sizeof...(Us) <= kNumLevels, "Can only encode as many levels as in the MultiIndex"); MultiIndex index(0u); @@ -64,7 +62,7 @@ class MultiIndex { } /// Construct a MultiIndex from an already encoded value. - constexpr MultiIndex(Value encoded) : m_value(encoded) {} + explicit constexpr MultiIndex(Value encoded) : m_value(encoded) {} /// Construct a default MultiIndex with undefined values for each level. MultiIndex() = default; MultiIndex(const MultiIndex&) = default; @@ -81,12 +79,12 @@ class MultiIndex { constexpr Value value() const { return m_value; } /// Get the value for the index level. constexpr Value level(std::size_t lvl) const { - assert((lvl < NumLevels) && "Index level outside allowed range"); + assert((lvl < kNumLevels) && "Index level outside allowed range"); return (m_value >> shift(lvl)) & mask(lvl); } /// Set the value of the index level. constexpr MultiIndex& set(std::size_t lvl, Value val) { - assert((lvl < NumLevels) && "Index level outside allowed range"); + assert((lvl < kNumLevels) && "Index level outside allowed range"); // mask of valid bits at the encoded positions for the index level Value shiftedMask = (mask(lvl) << shift(lvl)); // value of the index level shifted to its encoded position @@ -98,30 +96,30 @@ class MultiIndex { /// Create index with the selected level increased and levels below zeroed. constexpr MultiIndex makeNextSibling(std::size_t lvl) const { - assert((lvl < NumLevels) && "Index level outside allowed range"); + assert((lvl < kNumLevels) && "Index level outside allowed range"); // remove lower levels by shifting the upper levels to the left edge Value upper = (m_value >> shift(lvl)); // increase to create sibling and shift back to zero lower levels again - return ((upper + 1u) << shift(lvl)); + return MultiIndex{(upper + 1u) << shift(lvl)}; } /// Create index with every level below the selected level maximized. constexpr MultiIndex makeLastDescendant(std::size_t lvl) const { - assert((lvl < NumLevels) && "Index level outside allowed range"); + assert((lvl < kNumLevels) && "Index level outside allowed range"); // mask everything below the selected level Value maskLower = (Value{1u} << shift(lvl)) - 1u; // replace the masked lower levels w/ ones - return (m_value & ~maskLower) | maskLower; + return MultiIndex{(m_value & ~maskLower) | maskLower}; } /// Get the number of bits for the associated level static constexpr std::size_t bits(std::size_t lvl) { - assert((lvl < NumLevels) && "Index level outside allowed range"); + assert((lvl < kNumLevels) && "Index level outside allowed range"); return s_bits[lvl]; } private: // per-level mask and right-most bit position for shifting - static constexpr std::array s_bits{BitsPerLevel...}; + static constexpr std::array s_bits{BitsPerLevel...}; static constexpr std::size_t shift(std::size_t lvl) { std::size_t s = 0u; // sum up all bits below the requested level @@ -147,7 +145,7 @@ class MultiIndex { friend inline std::ostream& operator<<(std::ostream& os, MultiIndex idx) { // one level is always defined os << idx.level(0u); - for (std::size_t lvl = 1; lvl < NumLevels; ++lvl) { + for (std::size_t lvl = 1; lvl < kNumLevels; ++lvl) { os << '|' << idx.level(lvl); } return os; diff --git a/Core/include/Acts/Utilities/RangeXD.hpp b/Core/include/Acts/Utilities/RangeXD.hpp index 19f82245460..3024b230b5f 100644 --- a/Core/include/Acts/Utilities/RangeXD.hpp +++ b/Core/include/Acts/Utilities/RangeXD.hpp @@ -67,7 +67,7 @@ class RangeXD { /// @brief Construct a range from a pair of minimum and maximum values /// @note Only available for one-dimensional ranges /// @param p The pair of minimum and maximum values - RangeXD(const std::pair& p) + explicit RangeXD(const std::pair& p) requires(Dims == 1) : m_minima({p.first}), m_maxima({p.second}) {} diff --git a/Core/include/Acts/Utilities/Result.hpp b/Core/include/Acts/Utilities/Result.hpp index 0b6f64dda31..5936728216a 100644 --- a/Core/include/Acts/Utilities/Result.hpp +++ b/Core/include/Acts/Utilities/Result.hpp @@ -27,7 +27,7 @@ class Result { /// Private constructor which accepts an external variant. /// This is used by the factory static methods to set up /// the variant unambiguously in all cases. - Result(std::variant&& var) : m_var(std::move(var)) {} + explicit Result(std::variant&& var) : m_var(std::move(var)) {} public: using ValueType = T; @@ -66,7 +66,8 @@ class Result { /// @param value The potential value, could be an actual valid value or an /// error. template - Result(T2 value) noexcept + Result(T2 value) noexcept // NOLINT(google-explicit-constructor) + // ^ Conversion here is crucial for ergonomics requires(!std::same_as && !std::constructible_from && !std::convertible_to && !std::constructible_from && !std::convertible_to && @@ -371,7 +372,9 @@ class Result { /// @tparam E2 The type of the actual error /// @param error The instance of the actual error template - Result(E2 error) noexcept : m_opt(std::move(error)) {} + Result(E2 error) noexcept // NOLINT(google-explicit-constructor) + // ^ Conversion here is crucial for ergonomics + : m_opt(std::move(error)) {} /// Assignment operator from an error. /// @tparam E2 The type of the actual error diff --git a/Core/include/Acts/Utilities/SpacePointUtility.hpp b/Core/include/Acts/Utilities/SpacePointUtility.hpp index f95ca4521f7..00fa0f64c1e 100644 --- a/Core/include/Acts/Utilities/SpacePointUtility.hpp +++ b/Core/include/Acts/Utilities/SpacePointUtility.hpp @@ -64,7 +64,8 @@ struct SpacePointParameters { class SpacePointUtility { public: /// Constructor - SpacePointUtility(SpacePointBuilderConfig cfg) : m_config(std::move(cfg)) {} + explicit SpacePointUtility(SpacePointBuilderConfig cfg) + : m_config(std::move(cfg)) {} /// @brief Getter method for the global coordinates of a SourceLink /// diff --git a/Core/include/Acts/Utilities/ThrowAssert.hpp b/Core/include/Acts/Utilities/ThrowAssert.hpp index 0717c6b63f6..85f01737ac7 100644 --- a/Core/include/Acts/Utilities/ThrowAssert.hpp +++ b/Core/include/Acts/Utilities/ThrowAssert.hpp @@ -25,7 +25,7 @@ class AssertionFailureException : public std::exception { public: /// @brief Converts to string - operator std::string() const { return stream.str(); } + explicit operator std::string() const { return stream.str(); } /// @brief Stream operator which takes everything and forwards /// it to the stringstream. @@ -67,11 +67,12 @@ class AssertionFailureException : public std::exception { } // namespace Acts -#define throw_assert(EXPRESSION, MESSAGE) \ - do { \ - if (!(EXPRESSION)) { \ - throw Acts::AssertionFailureException( \ - #EXPRESSION, __FILE__, __LINE__, \ - (Acts::AssertionFailureException::StreamFormatter() << MESSAGE)); \ - } \ +#define throw_assert(EXPRESSION, MESSAGE) \ + do { \ + if (!(EXPRESSION)) { \ + throw Acts::AssertionFailureException( \ + #EXPRESSION, __FILE__, __LINE__, \ + static_cast( \ + Acts::AssertionFailureException::StreamFormatter() << MESSAGE)); \ + } \ } while (0) diff --git a/Core/include/Acts/Utilities/TrackHelpers.hpp b/Core/include/Acts/Utilities/TrackHelpers.hpp index f8c61135502..b3965c48136 100644 --- a/Core/include/Acts/Utilities/TrackHelpers.hpp +++ b/Core/include/Acts/Utilities/TrackHelpers.hpp @@ -53,8 +53,7 @@ Result findFirstMeasurementState( // TODO specialize if track is forward linked - auto result = Result::failure( - TrackExtrapolationError::CompatibleTrackStateNotFound); + std::optional firstMeasurementOpt; for (const auto &trackState : track.trackStatesReversed()) { bool isMeasurement = @@ -62,11 +61,16 @@ Result findFirstMeasurementState( bool isOutlier = trackState.typeFlags().test(TrackStateFlag::OutlierFlag); if (isMeasurement && !isOutlier) { - result = trackState; + firstMeasurementOpt = trackState; } } - return result; + if (firstMeasurementOpt) { + return Result::success(*firstMeasurementOpt); + } + + return Result::failure( + TrackExtrapolationError::CompatibleTrackStateNotFound); } template @@ -80,7 +84,7 @@ Result findLastMeasurementState( bool isOutlier = trackState.typeFlags().test(TrackStateFlag::OutlierFlag); if (isMeasurement && !isOutlier) { - return trackState; + return TrackStateProxy{trackState}; } } @@ -378,8 +382,6 @@ template void calculateTrackQuantities(track_proxy_t track) requires(!track_proxy_t::ReadOnly) { - using ConstTrackStateProxy = typename track_proxy_t::ConstTrackStateProxy; - track.chi2() = 0; track.nDoF() = 0; @@ -388,7 +390,7 @@ void calculateTrackQuantities(track_proxy_t track) track.nSharedHits() = 0; track.nOutliers() = 0; - for (ConstTrackStateProxy trackState : track.trackStatesReversed()) { + for (const auto &trackState : track.trackStatesReversed()) { ConstTrackStateType typeFlags = trackState.typeFlags(); if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) { diff --git a/Core/include/Acts/Utilities/detail/Extendable.hpp b/Core/include/Acts/Utilities/detail/Extendable.hpp index 9c6c520eaf0..03b69c6b2ca 100644 --- a/Core/include/Acts/Utilities/detail/Extendable.hpp +++ b/Core/include/Acts/Utilities/detail/Extendable.hpp @@ -44,13 +44,13 @@ struct Extendable { /// Constructor from tuple /// /// @param extensions Source extensions tuple - Extendable(const std::tuple& extensions) + explicit Extendable(const std::tuple& extensions) : m_extensions(extensions) {} /// Constructor from tuple move /// /// @param extensions source extensions tuple - Extendable(std::tuple&& extensions) + explicit Extendable(std::tuple&& extensions) : m_extensions(std::move(extensions)) {} /// Default move assignment operator diff --git a/Core/include/Acts/Vertexing/AdaptiveGridDensityVertexFinder.hpp b/Core/include/Acts/Vertexing/AdaptiveGridDensityVertexFinder.hpp index 91c2bfd7409..4944d1eb7eb 100644 --- a/Core/include/Acts/Vertexing/AdaptiveGridDensityVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveGridDensityVertexFinder.hpp @@ -37,7 +37,8 @@ class AdaptiveGridDensityVertexFinder final : public IVertexFinder { /// @brief The Config struct struct Config { ///@param gDensity The grid density - Config(const AdaptiveGridTrackDensity& gDensity) : gridDensity(gDensity) {} + explicit Config(const AdaptiveGridTrackDensity& gDensity) + : gridDensity(gDensity) {} // The grid density object AdaptiveGridTrackDensity gridDensity; @@ -110,7 +111,7 @@ class AdaptiveGridDensityVertexFinder final : public IVertexFinder { /// @brief Constructor for user-defined InputTrack type /// /// @param cfg Configuration object - AdaptiveGridDensityVertexFinder(const Config& cfg) : m_cfg(cfg) {} + explicit AdaptiveGridDensityVertexFinder(const Config& cfg) : m_cfg(cfg) {} private: /// @brief Checks if a track passes the selection criteria for seeding diff --git a/Core/include/Acts/Vertexing/AdaptiveGridTrackDensity.hpp b/Core/include/Acts/Vertexing/AdaptiveGridTrackDensity.hpp index 0a5b6de8077..e3233982877 100644 --- a/Core/include/Acts/Vertexing/AdaptiveGridTrackDensity.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveGridTrackDensity.hpp @@ -87,7 +87,8 @@ class AdaptiveGridTrackDensity { double maxRelativeDensityDev = 0.01; }; - AdaptiveGridTrackDensity(const Config& cfg); + /// Constructor + explicit AdaptiveGridTrackDensity(const Config& cfg); /// @brief Returns the z and t coordinate of maximum (surrounding) /// track density diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp index 4d1ac3ad4fd..28d5136fb05 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp @@ -169,10 +169,9 @@ class AdaptiveMultiVertexFinder final : public IVertexFinder { /// /// @param cfg Configuration object /// @param logger The logging instance - AdaptiveMultiVertexFinder(Config cfg, - std::unique_ptr logger = - getDefaultLogger("AdaptiveMultiVertexFinder", - Logging::INFO)) + explicit AdaptiveMultiVertexFinder( + Config cfg, std::unique_ptr logger = getDefaultLogger( + "AdaptiveMultiVertexFinder", Logging::INFO)) : m_cfg(std::move(cfg)), m_logger(std::move(logger)) { if (!m_cfg.extractParameters.connected()) { throw std::invalid_argument( diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp index 91f18618673..7cf698be227 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp @@ -98,7 +98,7 @@ class AdaptiveMultiVertexFitter { /// @brief Config constructor /// /// @param est ImpactPointEstimator - Config(ImpactPointEstimator est) : ipEst(std::move(est)) {} + explicit Config(ImpactPointEstimator est) : ipEst(std::move(est)) {} // ImpactPointEstimator ImpactPointEstimator ipEst; @@ -145,10 +145,9 @@ class AdaptiveMultiVertexFitter { /// @param cfg Configuration object /// object /// @param logger The logging instance - AdaptiveMultiVertexFitter(Config cfg, - std::unique_ptr logger = - getDefaultLogger("AdaptiveMultiVertexFitter", - Logging::INFO)) + explicit AdaptiveMultiVertexFitter( + Config cfg, std::unique_ptr logger = getDefaultLogger( + "AdaptiveMultiVertexFitter", Logging::INFO)) : m_cfg(std::move(cfg)), m_logger(std::move(logger)) { if (!m_cfg.extractParameters.connected()) { throw std::invalid_argument( diff --git a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp index 16433d88825..ab732183e77 100644 --- a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp +++ b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp @@ -61,10 +61,10 @@ class FullBilloirVertexFitter { /// /// @param cfg Configuration object /// @param logger Logging instance - FullBilloirVertexFitter(const Config& cfg, - std::unique_ptr logger = - getDefaultLogger("FullBilloirVertexFitter", - Logging::INFO)) + explicit FullBilloirVertexFitter( + const Config& cfg, + std::unique_ptr logger = + getDefaultLogger("FullBilloirVertexFitter", Logging::INFO)) : m_cfg(cfg), m_logger(std::move(logger)) { if (!m_cfg.extractParameters.connected()) { throw std::invalid_argument( diff --git a/Core/include/Acts/Vertexing/GaussianGridTrackDensity.hpp b/Core/include/Acts/Vertexing/GaussianGridTrackDensity.hpp index 55b1aefe83e..8e0994b2287 100644 --- a/Core/include/Acts/Vertexing/GaussianGridTrackDensity.hpp +++ b/Core/include/Acts/Vertexing/GaussianGridTrackDensity.hpp @@ -38,8 +38,8 @@ class GaussianGridTrackDensity { /// in the d0-z0 plane. Note: trkGridSize has to be an odd value. /// @note The value of @p zMinMax_ together with @p mainGridSize_ determines the /// overall bin size to be used as seen below - Config(float zMinMax_ = 100, int mainGridSize_ = 2000, - int trkGridSize_ = 15) + explicit Config(float zMinMax_ = 100, int mainGridSize_ = 2000, + int trkGridSize_ = 15) : mainGridSize(mainGridSize_), trkGridSize(trkGridSize_), zMinMax(zMinMax_) { @@ -79,7 +79,7 @@ class GaussianGridTrackDensity { float maxRelativeDensityDev = 0.01; }; - GaussianGridTrackDensity(const Config& cfg) : m_cfg(cfg) {} + explicit GaussianGridTrackDensity(const Config& cfg) : m_cfg(cfg) {} /// @brief Returns the z position of maximum track density /// diff --git a/Core/include/Acts/Vertexing/GaussianTrackDensity.hpp b/Core/include/Acts/Vertexing/GaussianTrackDensity.hpp index 60853f46646..f9a125eb0f3 100644 --- a/Core/include/Acts/Vertexing/GaussianTrackDensity.hpp +++ b/Core/include/Acts/Vertexing/GaussianTrackDensity.hpp @@ -59,7 +59,7 @@ class GaussianTrackDensity { /// @brief The Config struct struct Config { - Config(double d0Sig = 3.5, double z0Sig = 12.) + explicit Config(double d0Sig = 3.5, double z0Sig = 12.) : d0MaxSignificance(d0Sig), z0MaxSignificance(z0Sig), d0SignificanceCut(d0Sig * d0Sig), @@ -84,13 +84,13 @@ class GaussianTrackDensity { /// @brief The State struct struct State { // Constructor with size track map - State(unsigned int nTracks) { trackEntries.reserve(nTracks); } + explicit State(unsigned int nTracks) { trackEntries.reserve(nTracks); } // Vector to cache track information std::vector trackEntries; }; /// Constructor with config - GaussianTrackDensity(const Config& cfg) : m_cfg(cfg) { + explicit GaussianTrackDensity(const Config& cfg) : m_cfg(cfg) { if (!m_cfg.extractParameters.connected()) { throw std::invalid_argument( "GaussianTrackDensity: " @@ -175,7 +175,8 @@ class GaussianTrackDensity { class GaussianTrackDensityStore { public: // Initialise at the z coordinate at which the density is to be evaluated - GaussianTrackDensityStore(double z_coordinate) : m_z(z_coordinate) {} + explicit GaussianTrackDensityStore(double z_coordinate) + : m_z(z_coordinate) {} // Add the contribution of a single track to the density void addTrackToDensity(const TrackEntry& entry); diff --git a/Core/include/Acts/Vertexing/GridDensityVertexFinder.hpp b/Core/include/Acts/Vertexing/GridDensityVertexFinder.hpp index 9d6c0ee9686..ce6fbca37eb 100644 --- a/Core/include/Acts/Vertexing/GridDensityVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/GridDensityVertexFinder.hpp @@ -37,7 +37,8 @@ class GridDensityVertexFinder final : public IVertexFinder { /// @brief The Config struct struct Config { ///@param gDensity The grid density - Config(GaussianGridTrackDensity gDensity) : gridDensity(gDensity) {} + explicit Config(GaussianGridTrackDensity gDensity) + : gridDensity(gDensity) {} // The grid density object GaussianGridTrackDensity gridDensity; @@ -67,7 +68,7 @@ class GridDensityVertexFinder final : public IVertexFinder { /// /// Only needed if cacheGridStateForTrackRemoval == true struct State { - State(MainGridVector mainGrid_) : mainGrid(std::move(mainGrid_)) {} + explicit State(MainGridVector mainGrid_) : mainGrid(std::move(mainGrid_)) {} // The main density grid MainGridVector mainGrid; @@ -117,7 +118,7 @@ class GridDensityVertexFinder final : public IVertexFinder { /// @brief Constructor for user-defined InputTrack type /// /// @param cfg Configuration object - GridDensityVertexFinder(const Config& cfg) : m_cfg(cfg) { + explicit GridDensityVertexFinder(const Config& cfg) : m_cfg(cfg) { if (!m_cfg.extractParameters.connected()) { throw std::invalid_argument( "GridDensityVertexFinder: " diff --git a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp index 0257d8ec730..bc9b31cc24e 100644 --- a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp +++ b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp @@ -60,9 +60,10 @@ class HelicalTrackLinearizer { /// /// @param config Configuration object /// @param _logger a logger instance - HelicalTrackLinearizer(const Config& config, - std::unique_ptr _logger = - getDefaultLogger("HelTrkLinProp", Logging::INFO)) + explicit HelicalTrackLinearizer( + const Config& config, + std::unique_ptr _logger = getDefaultLogger("HelTrkLinProp", + Logging::INFO)) : m_cfg(config), m_logger{std::move(_logger)} { if (!m_cfg.propagator) { throw std::invalid_argument("HelicalTrackLinearizer: propagator is null"); diff --git a/Core/include/Acts/Vertexing/ImpactPointEstimator.hpp b/Core/include/Acts/Vertexing/ImpactPointEstimator.hpp index 80968e9a320..35c533a9eea 100644 --- a/Core/include/Acts/Vertexing/ImpactPointEstimator.hpp +++ b/Core/include/Acts/Vertexing/ImpactPointEstimator.hpp @@ -57,15 +57,15 @@ class ImpactPointEstimator { /// /// @param bIn The magnetic field /// @param prop The propagator - Config(std::shared_ptr bIn, - std::shared_ptr prop) + explicit Config(std::shared_ptr bIn, + std::shared_ptr prop) : bField(std::move(bIn)), propagator(std::move(prop)) {} /// @brief Config constructor without B field -> uses NullBField /// provided) /// /// @param prop The propagator - Config(std::shared_ptr prop) + explicit Config(std::shared_ptr prop) : bField{std::make_shared()}, propagator(std::move(prop)) {} /// Magnetic field @@ -82,9 +82,10 @@ class ImpactPointEstimator { /// /// @param cfg Configuration object /// @param logger Logging instance - ImpactPointEstimator(const Config& cfg, - std::unique_ptr logger = getDefaultLogger( - "ImpactPointEstimator", Logging::INFO)) + explicit ImpactPointEstimator(const Config& cfg, + std::unique_ptr logger = + getDefaultLogger("ImpactPointEstimator", + Logging::INFO)) : m_cfg(cfg), m_logger(std::move(logger)) {} /// @brief Copy constructor to clone logger (class owns a unique pointer to it, diff --git a/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp b/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp index 1ca9c026f41..eacb7105357 100644 --- a/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp @@ -135,9 +135,10 @@ class IterativeVertexFinder final : public IVertexFinder { /// /// @param cfg Configuration object /// @param logger The logging instance - IterativeVertexFinder(Config cfg, - std::unique_ptr logger = getDefaultLogger( - "IterativeVertexFinder", Logging::INFO)); + explicit IterativeVertexFinder(Config cfg, + std::unique_ptr logger = + getDefaultLogger("IterativeVertexFinder", + Logging::INFO)); /// @brief Finds vertices corresponding to input trackVector /// diff --git a/Core/include/Acts/Vertexing/NumericalTrackLinearizer.hpp b/Core/include/Acts/Vertexing/NumericalTrackLinearizer.hpp index e9beca46f36..8808dd41247 100644 --- a/Core/include/Acts/Vertexing/NumericalTrackLinearizer.hpp +++ b/Core/include/Acts/Vertexing/NumericalTrackLinearizer.hpp @@ -63,14 +63,14 @@ class NumericalTrackLinearizer { /// /// @param bIn The magnetic field /// @param prop The propagator - Config(std::shared_ptr bIn, - std::shared_ptr prop) + explicit Config(std::shared_ptr bIn, + std::shared_ptr prop) : bField(std::move(bIn)), propagator(std::move(prop)) {} /// @brief Config constructor without B field -> uses NullBField /// /// @param prop Propagator - Config(std::shared_ptr prop) + explicit Config(std::shared_ptr prop) : bField{std::make_shared()}, propagator(std::move(prop)) {} std::shared_ptr bField; @@ -89,10 +89,11 @@ class NumericalTrackLinearizer { /// @brief Constructor /// /// @param config Configuration object - /// @param _logger Logger instance - NumericalTrackLinearizer(const Config& config, - std::unique_ptr _logger = - getDefaultLogger("NumTrkLinProp", Logging::INFO)) + /// @param _logger Logging instance + explicit NumericalTrackLinearizer( + const Config& config, + std::unique_ptr _logger = getDefaultLogger("NumTrkLinProp", + Logging::INFO)) : m_cfg(config), m_logger{std::move(_logger)} {} /// @brief Function that linearizes BoundTrackParameters at diff --git a/Core/include/Acts/Vertexing/SingleSeedVertexFinder.hpp b/Core/include/Acts/Vertexing/SingleSeedVertexFinder.hpp index cd05eb4eb0a..c3716071d6b 100644 --- a/Core/include/Acts/Vertexing/SingleSeedVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/SingleSeedVertexFinder.hpp @@ -99,9 +99,10 @@ class SingleSeedVertexFinder { /// @brief Constructor /// @param cfg Configuration object /// @param lgr Logging instance - SingleSeedVertexFinder(const Config& cfg, - std::unique_ptr lgr = getDefaultLogger( - "SingleSeedVertexFinder", Logging::INFO)); + explicit SingleSeedVertexFinder(const Config& cfg, + std::unique_ptr lgr = + getDefaultLogger("SingleSeedVertexFinder", + Logging::INFO)); /// @brief Destructor ~SingleSeedVertexFinder() = default; diff --git a/Core/include/Acts/Vertexing/TrackDensityVertexFinder.hpp b/Core/include/Acts/Vertexing/TrackDensityVertexFinder.hpp index e940292a7f0..d107bf5ed65 100644 --- a/Core/include/Acts/Vertexing/TrackDensityVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/TrackDensityVertexFinder.hpp @@ -66,7 +66,7 @@ class TrackDensityVertexFinder final : public IVertexFinder { /// @brief Constructor for user-defined InputTrack type /// /// @param cfg Configuration object - TrackDensityVertexFinder(const Config& cfg) : m_cfg(cfg) {} + explicit TrackDensityVertexFinder(const Config& cfg) : m_cfg(cfg) {} private: Config m_cfg; diff --git a/Core/include/Acts/Vertexing/Vertex.hpp b/Core/include/Acts/Vertexing/Vertex.hpp index 453fe34a9e0..a19e44bc59d 100644 --- a/Core/include/Acts/Vertexing/Vertex.hpp +++ b/Core/include/Acts/Vertexing/Vertex.hpp @@ -23,12 +23,12 @@ class Vertex { /// @brief Construct for vertex at given 3d-position, sets covariance to zero /// /// @param position Vertex position - Vertex(const Vector3& position); + explicit Vertex(const Vector3& position); /// @brief Construct for vertex at given 4d-position, sets covariance to zero /// /// @param position Vertex position - Vertex(const Vector4& position); + explicit Vertex(const Vector4& position); /// @brief Vertex constructor /// diff --git a/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp b/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp index 83477ed7db8..6fd6461099f 100644 --- a/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp @@ -37,7 +37,7 @@ class ZScanVertexFinder final : public IVertexFinder { /// @brief Finder configuration /// /// @param ipEst ImpactPointEstimator - Config(const ImpactPointEstimator& ipEst) : ipEstimator(ipEst) {} + explicit Config(const ImpactPointEstimator& ipEst) : ipEstimator(ipEst) {} // ImpactPointEstimator ImpactPointEstimator ipEstimator; @@ -72,9 +72,10 @@ class ZScanVertexFinder final : public IVertexFinder { /// /// @param cfg Configuration object /// @param logger Logging instance - ZScanVertexFinder(const Config& cfg, - std::unique_ptr logger = - getDefaultLogger("ZScanVertexFinder", Logging::INFO)); + explicit ZScanVertexFinder(const Config& cfg, + std::unique_ptr logger = + getDefaultLogger("ZScanVertexFinder", + Logging::INFO)); /// @brief Function that determines single vertex, /// based on z0 values of input tracks, diff --git a/Core/include/Acts/Visualization/ObjVisualization3D.hpp b/Core/include/Acts/Visualization/ObjVisualization3D.hpp index a9f496ce304..7c52e6d61bd 100644 --- a/Core/include/Acts/Visualization/ObjVisualization3D.hpp +++ b/Core/include/Acts/Visualization/ObjVisualization3D.hpp @@ -36,7 +36,7 @@ class ObjVisualization3D : public IVisualization3D { /// Constructor that allows to set scalor and precision /// @param prec The output precision with std::setprecision /// @param scale An (optional) scaling for the writing out - ObjVisualization3D(unsigned int prec = 4, double scale = 1.) + explicit ObjVisualization3D(unsigned int prec = 4, double scale = 1.) : m_outputPrecision(prec), m_outputScalor(scale) {} /// @copydoc Acts::IVisualization3D::vertex() diff --git a/Core/src/Detector/MultiWireStructureBuilder.cpp b/Core/src/Detector/MultiWireStructureBuilder.cpp index 8e2252f25e0..53ff7d2e06b 100644 --- a/Core/src/Detector/MultiWireStructureBuilder.cpp +++ b/Core/src/Detector/MultiWireStructureBuilder.cpp @@ -47,8 +47,7 @@ class MultiWireInternalStructureBuilder }; // Constructor - - MultiWireInternalStructureBuilder( + explicit MultiWireInternalStructureBuilder( const Config& cfg, std::unique_ptr mlogger = Acts::getDefaultLogger( "MUltiWireInternalBuilder", Acts::Logging::INFO)) diff --git a/Core/src/Geometry/BlueprintNode.cpp b/Core/src/Geometry/BlueprintNode.cpp index 7b64471cba7..7952653cca0 100644 --- a/Core/src/Geometry/BlueprintNode.cpp +++ b/Core/src/Geometry/BlueprintNode.cpp @@ -9,7 +9,9 @@ #include "Acts/Geometry/BlueprintNode.hpp" #include "Acts/Geometry/Blueprint.hpp" -#include "Acts/Geometry/CylinderContainerBlueprintNode.hpp" +#include "Acts/Geometry/ContainerBlueprintNode.hpp" +#include "Acts/Geometry/CuboidVolumeBounds.hpp" +#include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/LayerBlueprintNode.hpp" #include "Acts/Geometry/MaterialDesignatorBlueprintNode.hpp" #include "Acts/Geometry/StaticBlueprintNode.hpp" @@ -107,7 +109,7 @@ StaticBlueprintNode& BlueprintNode::addStaticVolume( StaticBlueprintNode& BlueprintNode::addStaticVolume( const Transform3& transform, std::shared_ptr volumeBounds, const std::string& volumeName, - const std::function& callback) { + const std::function& callback) { return addStaticVolume(std::make_unique( transform, std::move(volumeBounds), volumeName), callback); @@ -126,6 +128,17 @@ CylinderContainerBlueprintNode& BlueprintNode::addCylinderContainer( return *cylinder; } +CuboidContainerBlueprintNode& BlueprintNode::addCuboidContainer( + const std::string& name, AxisDirection direction, + const std::function& callback) { + auto box = std::make_shared(name, direction); + addChild(box); + if (callback) { + callback(*box); + } + return *box; +} + MaterialDesignatorBlueprintNode& BlueprintNode::addMaterial( const std::string& name, const std::function& diff --git a/Core/src/Geometry/CMakeLists.txt b/Core/src/Geometry/CMakeLists.txt index 16cf7869479..68555f9a05c 100644 --- a/Core/src/Geometry/CMakeLists.txt +++ b/Core/src/Geometry/CMakeLists.txt @@ -48,7 +48,6 @@ target_sources( BlueprintNode.cpp Blueprint.cpp BlueprintOptions.cpp - CylinderContainerBlueprintNode.cpp StaticBlueprintNode.cpp LayerBlueprintNode.cpp MaterialDesignatorBlueprintNode.cpp @@ -56,4 +55,7 @@ target_sources( VolumeResizeStrategy.cpp TrackingGeometryVisitor.cpp TrapezoidPortalShell.cpp + VolumeStack.cpp + ContainerBlueprintNode.cpp + ) diff --git a/Core/src/Geometry/CompositePortalLink.cpp b/Core/src/Geometry/CompositePortalLink.cpp index 461c0cd72a5..b86a27cbfd3 100644 --- a/Core/src/Geometry/CompositePortalLink.cpp +++ b/Core/src/Geometry/CompositePortalLink.cpp @@ -140,9 +140,9 @@ Result CompositePortalLink::resolveVolume( Vector3 global = m_surface->localToGlobal(gctx, position); auto res = resolveVolume(gctx, global, tolerance); if (!res.ok()) { - return res.error(); + return Result::failure(res.error()); } - return *res; + return Result::success(*res); } Result CompositePortalLink::resolveVolume( @@ -158,7 +158,8 @@ Result CompositePortalLink::resolveVolume( } } - return PortalError::PositionNotOnAnyChildPortalLink; + return Result::failure( + PortalError::PositionNotOnAnyChildPortalLink); } std::size_t CompositePortalLink::depth() const { @@ -246,12 +247,13 @@ std::unique_ptr CompositePortalLink::makeGrid( Axis axis{AxisBound, edges}; - auto grid = GridPortalLink::make(m_surface, m_direction, std::move(axis)); + auto gridPortalLink = + GridPortalLink::make(m_surface, m_direction, std::move(axis)); for (const auto& [i, child] : enumerate(trivialLinks)) { - grid->atLocalBins({i + 1}) = &child->volume(); + gridPortalLink->grid().atLocalBins({i + 1}) = &child->volume(); } - return grid; + return gridPortalLink; } else if (surface().type() == Surface::SurfaceType::Disc) { ACTS_VERBOSE("Combining composite into disc grid"); @@ -289,7 +291,7 @@ std::unique_ptr CompositePortalLink::makeGrid( auto grid = GridPortalLink::make(m_surface, m_direction, std::move(axis)); for (const auto& [i, child] : enumerate(trivialLinks)) { - grid->atLocalBins({i + 1}) = &child->volume(); + grid->grid().atLocalBins({i + 1}) = &child->volume(); } return grid; @@ -338,7 +340,7 @@ std::unique_ptr CompositePortalLink::makeGrid( auto grid = GridPortalLink::make(m_surface, m_direction, std::move(axis)); for (const auto& [i, child] : enumerate(trivialLinks)) { - grid->atLocalBins({i + 1}) = &child->volume(); + grid->grid().atLocalBins({i + 1}) = &child->volume(); } return grid; diff --git a/Core/src/Geometry/CylinderContainerBlueprintNode.cpp b/Core/src/Geometry/ContainerBlueprintNode.cpp similarity index 51% rename from Core/src/Geometry/CylinderContainerBlueprintNode.cpp rename to Core/src/Geometry/ContainerBlueprintNode.cpp index 42c10951a9b..2e043f6ba18 100644 --- a/Core/src/Geometry/CylinderContainerBlueprintNode.cpp +++ b/Core/src/Geometry/ContainerBlueprintNode.cpp @@ -6,40 +6,32 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -#include "Acts/Geometry/CylinderContainerBlueprintNode.hpp" +#include "Acts/Geometry/ContainerBlueprintNode.hpp" -#include "Acts/Geometry/BlueprintNode.hpp" +#include "Acts/Geometry/CuboidPortalShell.hpp" +#include "Acts/Geometry/CuboidVolumeStack.hpp" #include "Acts/Geometry/CylinderPortalShell.hpp" #include "Acts/Geometry/CylinderVolumeStack.hpp" -#include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Geometry/TrackingVolume.hpp" -#include "Acts/Navigation/INavigationPolicy.hpp" -#include "Acts/Utilities/GraphViz.hpp" -#include "Acts/Visualization/GeometryView3D.hpp" - -#include -#include namespace Acts::Experimental { -CylinderContainerBlueprintNode::CylinderContainerBlueprintNode( - const std::string& name, AxisDirection direction, +ContainerBlueprintNode::ContainerBlueprintNode( + const std::string& name, AxisDirection axis, VolumeAttachmentStrategy attachmentStrategy, VolumeResizeStrategy resizeStrategy) : m_name(name), - m_direction(direction), + m_direction(axis), m_attachmentStrategy(attachmentStrategy), m_resizeStrategy(resizeStrategy) {} -const std::string& CylinderContainerBlueprintNode::name() const { +const std::string& ContainerBlueprintNode::name() const { return m_name; } -Volume& CylinderContainerBlueprintNode::build(const BlueprintOptions& options, - const GeometryContext& gctx, - const Logger& logger) { - ACTS_DEBUG(prefix() << "cylinder container build (dir=" << m_direction - << ")"); +Volume& ContainerBlueprintNode::build( + const Experimental::BlueprintOptions& options, const GeometryContext& gctx, + const Logger& logger) { + ACTS_DEBUG(prefix() << "container build (dir=" << m_direction << ")"); if (m_stack != nullptr) { ACTS_ERROR(prefix() << "Volume is already built"); @@ -50,16 +42,13 @@ Volume& CylinderContainerBlueprintNode::build(const BlueprintOptions& options, Volume& volume = child.build(options, gctx, logger); m_childVolumes.push_back(&volume); // We need to remember which volume we got from which child, so we can - // assemble a correct portal shell later + // assemble a crrect portal shell later m_volumeToNode[&volume] = &child; } ACTS_VERBOSE(prefix() << "-> Collected " << m_childVolumes.size() << " child volumes"); - ACTS_VERBOSE(prefix() << "-> Building the stack"); - m_stack = std::make_unique(m_childVolumes, m_direction, - m_attachmentStrategy, - m_resizeStrategy, logger); + m_stack = makeStack(m_childVolumes, logger); ACTS_DEBUG(prefix() << "-> Stack bounds are: " << m_stack->volumeBounds()); ACTS_DEBUG(prefix() << " *** build complete ***"); @@ -67,99 +56,10 @@ Volume& CylinderContainerBlueprintNode::build(const BlueprintOptions& options, return *m_stack; } -std::vector -CylinderContainerBlueprintNode::collectChildShells( - const BlueprintOptions& options, const GeometryContext& gctx, - const Logger& logger) { - std::vector shells; - ACTS_DEBUG(prefix() << "Have " << m_childVolumes.size() << " child volumes"); - for (Volume* volume : m_childVolumes) { - if (isGapVolume(*volume)) { - // We need to create a TrackingVolume from the gap and put it in the shell - auto gap = std::make_unique(*volume); - gap->setVolumeName(name() + "::Gap" + std::to_string(m_gaps.size() + 1)); - ACTS_DEBUG(prefix() << " ~> Gap volume (" << gap->volumeName() - << "): " << gap->volumeBounds()); - auto shell = std::make_unique(*gap); - assert(shell->isValid()); - shells.push_back(shell.get()); - - m_gaps.emplace_back(std::move(shell), std::move(gap)); - - } else { - // Figure out which child we got this volume from - auto it = m_volumeToNode.find(volume); - if (it == m_volumeToNode.end()) { - throw std::runtime_error("Volume not found in child volumes"); - } - BlueprintNode& child = *it->second; - - ACTS_DEBUG(prefix() << " ~> Child (" << child.name() - << ") volume: " << volume->volumeBounds()); - - auto* shell = dynamic_cast( - &child.connect(options, gctx, logger)); - if (shell == nullptr) { - ACTS_ERROR(prefix() - << "Child volume of cylinder stack is not a cylinder"); - throw std::runtime_error( - "Child volume of cylinder stack is not a cylinder"); - } - assert(shell->isValid()); - - shells.push_back(shell); - } - } - return shells; -} - -CylinderStackPortalShell& CylinderContainerBlueprintNode::connect( - const BlueprintOptions& options, const GeometryContext& gctx, - const Logger& logger) { - ACTS_DEBUG(prefix() << "Cylinder container connect"); - if (m_stack == nullptr) { - ACTS_ERROR(prefix() << "Volume is not built"); - throw std::runtime_error("Volume is not built"); - } - - ACTS_DEBUG(prefix() << "Collecting child shells from " << children().size() - << " children"); - - // We have child volumes and gaps as bare Volumes in `m_childVolumes` after - // `build()` has completed. For the stack shell, we need TrackingVolumes in - // the right order. - - std::vector shells = - collectChildShells(options, gctx, logger); - - // Sanity checks - throw_assert(shells.size() == m_childVolumes.size(), - "Number of shells does not match number of child volumes"); - - throw_assert(std::ranges::none_of( - shells, [](const auto* shell) { return shell == nullptr; }), - "Invalid shell pointer"); - - throw_assert(std::ranges::all_of( - shells, [](const auto* shell) { return shell->isValid(); }), - "Invalid shell"); - - ACTS_DEBUG(prefix() << "Producing merged cylinder stack shell in " - << m_direction << " direction from " << shells.size() - << " shells"); - m_shell = std::make_unique(gctx, std::move(shells), - m_direction, logger); - - assert(m_shell != nullptr && "No shell was built at the end of connect"); - assert(m_shell->isValid() && "Shell is not valid at the end of connect"); - return *m_shell; -} - -void CylinderContainerBlueprintNode::finalize(const BlueprintOptions& options, - const GeometryContext& gctx, - TrackingVolume& parent, - const Logger& logger) { - ACTS_DEBUG(prefix() << "Finalizing cylinder container"); +void ContainerBlueprintNode::finalize( + const Experimental::BlueprintOptions& options, const GeometryContext& gctx, + TrackingVolume& parent, const Logger& logger) { + ACTS_DEBUG(prefix() << "Finalizing container"); if (m_stack == nullptr) { ACTS_ERROR(prefix() << "Volume is not built"); @@ -190,13 +90,7 @@ void CylinderContainerBlueprintNode::finalize(const BlueprintOptions& options, } } -bool CylinderContainerBlueprintNode::isGapVolume(const Volume& volume) const { - assert(m_stack != nullptr); - return std::ranges::any_of( - m_stack->gaps(), [&](const auto& gap) { return gap.get() == &volume; }); -} - -CylinderContainerBlueprintNode& CylinderContainerBlueprintNode::setDirection( +ContainerBlueprintNode& ContainerBlueprintNode::setDirection( AxisDirection direction) { if (m_stack != nullptr) { throw std::runtime_error("Cannot change direction after build"); @@ -205,8 +99,7 @@ CylinderContainerBlueprintNode& CylinderContainerBlueprintNode::setDirection( return *this; } -CylinderContainerBlueprintNode& -CylinderContainerBlueprintNode::setAttachmentStrategy( +ContainerBlueprintNode& ContainerBlueprintNode::setAttachmentStrategy( VolumeAttachmentStrategy attachmentStrategy) { if (m_stack != nullptr) { throw std::runtime_error("Cannot change direction after build"); @@ -215,8 +108,7 @@ CylinderContainerBlueprintNode::setAttachmentStrategy( return *this; } -CylinderContainerBlueprintNode& -CylinderContainerBlueprintNode::setResizeStrategy( +ContainerBlueprintNode& ContainerBlueprintNode::setResizeStrategy( VolumeResizeStrategy resizeStrategy) { if (m_stack != nullptr) { throw std::runtime_error("Cannot change direction after build"); @@ -225,10 +117,22 @@ CylinderContainerBlueprintNode::setResizeStrategy( return *this; } -void CylinderContainerBlueprintNode::addToGraphviz(std::ostream& os) const { +AxisDirection ContainerBlueprintNode::direction() const { + return m_direction; +} + +VolumeAttachmentStrategy ContainerBlueprintNode::attachmentStrategy() const { + return m_attachmentStrategy; +} + +VolumeResizeStrategy ContainerBlueprintNode::resizeStrategy() const { + return m_resizeStrategy; +} + +void ContainerBlueprintNode::addToGraphviz(std::ostream& os) const { std::stringstream ss; ss << "" + name() + ""; - ss << "
CylinderContainer"; + ss << "
" << typeName() << "Container"; ss << "
dir: " << m_direction; GraphViz::Node node{ .id = name(), .label = ss.str(), .shape = GraphViz::Shape::DoubleOctagon}; @@ -240,17 +144,129 @@ void CylinderContainerBlueprintNode::addToGraphviz(std::ostream& os) const { } } -AxisDirection CylinderContainerBlueprintNode::direction() const { - return m_direction; +template +std::vector ContainerBlueprintNode::collectChildShells( + const Experimental::BlueprintOptions& options, const GeometryContext& gctx, + VolumeStack& stack, const std::string& prefix, const Logger& logger) { + std::vector shells; + ACTS_DEBUG(prefix << "Have " << m_childVolumes.size() << " child volumes"); + std::size_t nGaps = 0; + for (Volume* volume : m_childVolumes) { + if (stack.isGapVolume(*volume)) { + // We need to create a TrackingVolume from the gap and put it in the + // shell + auto gap = std::make_unique(*volume); + gap->setVolumeName(name() + "::Gap" + std::to_string(nGaps + 1)); + nGaps++; + ACTS_DEBUG(prefix << " ~> Gap volume (" << gap->volumeName() + << "): " << gap->volumeBounds()); + auto shell = std::make_unique(*gap); + assert(shell->isValid()); + shells.push_back(shell.get()); + + m_gaps.emplace_back(std::move(shell), std::move(gap)); + + } else { + // Figure out which child we got this volume from + auto it = m_volumeToNode.find(volume); + if (it == m_volumeToNode.end()) { + throw std::runtime_error("Volume not found in child volumes"); + } + + BlueprintNode& child = *it->second; + + ACTS_DEBUG(prefix << " ~> Child (" << child.name() + << ") volume: " << volume->volumeBounds()); + + auto* shell = + dynamic_cast(&child.connect(options, gctx, logger)); + if (shell == nullptr) { + ACTS_ERROR(prefix << "Child volume stack type mismatch"); + throw std::runtime_error("Child volume stack type mismatch"); + } + assert(shell->isValid()); + + shells.push_back(shell); + } + } + return shells; } -VolumeAttachmentStrategy CylinderContainerBlueprintNode::attachmentStrategy() - const { - return m_attachmentStrategy; +template +PortalShellBase& ContainerBlueprintNode::connectImpl( + const Experimental::BlueprintOptions& options, const GeometryContext& gctx, + VolumeStack* stack, const std::string& prefix, const Logger& logger) { + ACTS_DEBUG(prefix << "Container connect"); + if (stack == nullptr) { + ACTS_ERROR(prefix << "Volume is not built"); + throw std::runtime_error("Volume is not built"); + } + ACTS_DEBUG(prefix << "Collecting child shells from " << children().size() + << " children"); + + // We have child volumes and gaps as bare Volumes in `m_childVolumes` after + // `build()` has completed. For the stack shell, we need TrackingVolumes in + // the right order. + + std::vector shells = collectChildShells( + options, gctx, *stack, prefix, logger); + + // Sanity checks + throw_assert(shells.size() == m_childVolumes.size(), + "Number of shells does not match number of child volumes"); + + throw_assert(std::ranges::none_of( + shells, [](const auto* shell) { return shell == nullptr; }), + "Invalid shell pointer"); + + throw_assert(std::ranges::all_of( + shells, [](const auto* shell) { return shell->isValid(); }), + "Invalid shell"); + + ACTS_DEBUG(prefix << "Producing merged stack shell in " << direction() + << " direction from " << shells.size() << " shells"); + m_shell = std::make_unique(gctx, std::move(shells), direction(), + logger); + + assert(m_shell != nullptr && "No shell was built at the end of connect"); + assert(m_shell->isValid() && "Shell is not valid at the end of connect"); + return *m_shell; } -VolumeResizeStrategy CylinderContainerBlueprintNode::resizeStrategy() const { - return m_resizeStrategy; +PortalShellBase& CylinderContainerBlueprintNode::connect( + const Experimental::BlueprintOptions& options, const GeometryContext& gctx, + const Logger& logger) { + return connectImpl(options, gctx, m_stack.get(), + prefix(), logger); +} + +const std::string& CylinderContainerBlueprintNode::typeName() const { + return s_typeName; +} + +std::unique_ptr CylinderContainerBlueprintNode::makeStack( + std::vector& volumes, const Logger& logger) { + return std::make_unique( + volumes, m_direction, m_attachmentStrategy, m_resizeStrategy, logger); +} + +PortalShellBase& CuboidContainerBlueprintNode::connect( + const Experimental::BlueprintOptions& options, const GeometryContext& gctx, + const Logger& logger) { + return connectImpl(options, gctx, m_stack.get(), + prefix(), logger); +} + +const std::string& CuboidContainerBlueprintNode::typeName() const { + return s_typeName; +} + +std::unique_ptr CuboidContainerBlueprintNode::makeStack( + std::vector& volumes, const Logger& logger) { + return std::make_unique( + volumes, m_direction, m_attachmentStrategy, m_resizeStrategy, logger); } } // namespace Acts::Experimental diff --git a/Core/src/Geometry/CuboidVolumeStack.cpp b/Core/src/Geometry/CuboidVolumeStack.cpp index 3bbb98ac577..905a865c236 100644 --- a/Core/src/Geometry/CuboidVolumeStack.cpp +++ b/Core/src/Geometry/CuboidVolumeStack.cpp @@ -125,23 +125,12 @@ CuboidVolumeStack::CuboidVolumeStack(std::vector& volumes, VolumeAttachmentStrategy strategy, VolumeResizeStrategy resizeStrategy, const Logger& logger) - : Volume(initialVolume(volumes)), - m_direction(direction), - m_resizeStrategy(resizeStrategy), - m_volumes(volumes) { + : VolumeStack(volumes, direction, resizeStrategy) { std::tie(m_dirOrth1, m_dirOrth2) = getOrthogonalAxes(m_direction); initializeOuterVolume(strategy, logger); } -Volume& CuboidVolumeStack::initialVolume(const std::vector& volumes) { - if (volumes.empty()) { - throw std::invalid_argument( - "CuboidVolumeStack requires at least one volume"); - } - return *volumes.front(); -} - void CuboidVolumeStack::initializeOuterVolume(VolumeAttachmentStrategy strategy, const Logger& logger) { ACTS_DEBUG("Creating CuboidVolumeStack from " @@ -867,15 +856,4 @@ void CuboidVolumeStack::update(std::shared_ptr volbounds, Volume::update(std::move(bounds), std::nullopt, logger); } -std::shared_ptr CuboidVolumeStack::addGapVolume( - const Transform3& transform, const std::shared_ptr& bounds) { - auto gapVolume = std::make_shared(transform, bounds); - m_gaps.push_back(gapVolume); - return gapVolume; -} - -const std::vector>& CuboidVolumeStack::gaps() const { - return m_gaps; -} - } // namespace Acts diff --git a/Core/src/Geometry/CylinderVolumeStack.cpp b/Core/src/Geometry/CylinderVolumeStack.cpp index 5761260c1f1..131dfe4c987 100644 --- a/Core/src/Geometry/CylinderVolumeStack.cpp +++ b/Core/src/Geometry/CylinderVolumeStack.cpp @@ -89,22 +89,10 @@ CylinderVolumeStack::CylinderVolumeStack(std::vector& volumes, VolumeAttachmentStrategy strategy, VolumeResizeStrategy resizeStrategy, const Logger& logger) - : Volume(initialVolume(volumes)), - m_direction(direction), - m_resizeStrategy(resizeStrategy), - m_volumes(volumes) { + : VolumeStack(volumes, direction, resizeStrategy) { initializeOuterVolume(direction, strategy, logger); } -Volume& CylinderVolumeStack::initialVolume( - const std::vector& volumes) { - if (volumes.empty()) { - throw std::invalid_argument( - "CylinderVolumeStack requires at least one volume"); - } - return *volumes.front(); -} - void CylinderVolumeStack::initializeOuterVolume( AxisDirection direction, VolumeAttachmentStrategy strategy, const Logger& logger) { @@ -1079,15 +1067,4 @@ void CylinderVolumeStack::checkNoPhiOrBevel(const CylinderVolumeBounds& bounds, } } -std::shared_ptr CylinderVolumeStack::addGapVolume( - const Transform3& transform, const std::shared_ptr& bounds) { - auto gapVolume = std::make_shared(transform, bounds); - m_gaps.push_back(gapVolume); - return gapVolume; -} - -const std::vector>& CylinderVolumeStack::gaps() const { - return m_gaps; -} - } // namespace Acts diff --git a/Core/src/Geometry/GridPortalLink.cpp b/Core/src/Geometry/GridPortalLink.cpp index 6a0917ba2ce..8be7525c608 100644 --- a/Core/src/Geometry/GridPortalLink.cpp +++ b/Core/src/Geometry/GridPortalLink.cpp @@ -11,6 +11,7 @@ #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RadialBounds.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" +#include "Acts/Utilities/AnyGridView.hpp" #include "Acts/Utilities/AxisDefinitions.hpp" #include @@ -282,8 +283,10 @@ void GridPortalLink::printContents(std::ostream& os) const { throw std::invalid_argument{"Unsupported surface type"}; } + AnyGridConstView view(grid()); + if (dim == 1) { - auto loc = numLocalBins(); + auto loc = grid().numLocalBinsAny(); if (flipped) { os << lpad(loc1, 4) << " > " << lpad("i=0", 10) << " "; @@ -295,7 +298,7 @@ void GridPortalLink::printContents(std::ostream& os) const { os << std::string(4, ' '); for (std::size_t i = 0; i <= loc.at(0) + 1; i++) { std::string name = "0x0"; - if (const auto* v = atLocalBins({i}); v != nullptr) { + if (const auto* v = view.atLocalBins({i}); v != nullptr) { name = v->volumeName(); } name = name.substr(0, std::min(name.size(), std::size_t{13})); @@ -308,7 +311,7 @@ void GridPortalLink::printContents(std::ostream& os) const { for (std::size_t i = 0; i <= loc.at(0) + 1; i++) { os << "i=" << i << " "; std::string name = "0x0"; - if (const auto* v = atLocalBins({i}); v != nullptr) { + if (const auto* v = view.atLocalBins({i}); v != nullptr) { name = v->volumeName(); } name = name.substr(0, std::min(name.size(), std::size_t{13})); @@ -318,7 +321,7 @@ void GridPortalLink::printContents(std::ostream& os) const { } } else { - auto loc = numLocalBins(); + auto loc = grid().numLocalBinsAny(); os << rpad("v " + loc0 + "|" + loc1 + " >", 14) + "j=0 "; for (std::size_t j = 1; j <= loc.at(1) + 1; j++) { os << lpad("j=" + std::to_string(j), 13) << " "; @@ -328,7 +331,7 @@ void GridPortalLink::printContents(std::ostream& os) const { os << "i=" << i << " "; for (std::size_t j = 0; j <= loc.at(1) + 1; j++) { std::string name = "0x0"; - if (const auto* v = atLocalBins({i, j}); v != nullptr) { + if (const auto* v = view.atLocalBins({i, j}); v != nullptr) { name = v->volumeName(); } name = name.substr(0, std::min(name.size(), std::size_t{13})); @@ -342,21 +345,26 @@ void GridPortalLink::printContents(std::ostream& os) const { void GridPortalLink::fillGrid1dTo2d(FillDirection dir, const GridPortalLink& grid1d, GridPortalLink& grid2d) { - const auto locSource = grid1d.numLocalBins(); - const auto locDest = grid2d.numLocalBins(); + const auto locSource = grid1d.grid().numLocalBinsAny(); + const auto locDest = grid2d.grid().numLocalBinsAny(); + assert(grid1d.grid().dimensions() == 1); + assert(grid2d.grid().dimensions() == 2); assert(locSource.size() == 1); assert(locDest.size() == 2); + AnyGridConstView sourceView(grid1d.grid()); + AnyGridView destView(grid2d.grid()); + for (std::size_t i = 0; i <= locSource[0] + 1; ++i) { - const TrackingVolume* source = grid1d.atLocalBins({i}); + const TrackingVolume* source = sourceView.atLocalBins({i}); if (dir == FillDirection::loc1) { for (std::size_t j = 0; j <= locDest[1] + 1; ++j) { - grid2d.atLocalBins({i, j}) = source; + destView.atLocalBins({i, j}) = source; } } else if (dir == FillDirection::loc0) { for (std::size_t j = 0; j <= locDest[0] + 1; ++j) { - grid2d.atLocalBins({j, i}) = source; + destView.atLocalBins({j, i}) = source; } } } diff --git a/Core/src/Geometry/GridPortalLinkMerging.cpp b/Core/src/Geometry/GridPortalLinkMerging.cpp index c013e7a19b0..dbef5ac3e09 100644 --- a/Core/src/Geometry/GridPortalLinkMerging.cpp +++ b/Core/src/Geometry/GridPortalLinkMerging.cpp @@ -13,6 +13,7 @@ #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RadialBounds.hpp" +#include "Acts/Utilities/AnyGridView.hpp" #include #include @@ -502,22 +503,26 @@ void GridPortalLink::fillMergedGrid(const GridPortalLink& a, ACTS_VERBOSE("Filling merged grid"); assert(a.dim() == b.dim()); assert(a.direction() == b.direction()); - const auto locBinsA = a.numLocalBins(); - const auto locBinsB = b.numLocalBins(); + const auto locBinsA = a.grid().numLocalBinsAny(); + const auto locBinsB = b.grid().numLocalBinsAny(); ACTS_VERBOSE("a: " << a.grid()); ACTS_VERBOSE("b: " << b.grid()); ACTS_VERBOSE("merged: " << merged.grid()); + AnyGridView mergedView(merged.grid()); + AnyGridConstView aView(a.grid()); + AnyGridConstView bView(b.grid()); + if (a.dim() == 1) { std::size_t nBinsA = locBinsA.at(0); std::size_t nBinsB = locBinsB.at(0); for (std::size_t i = 1; i <= nBinsA; ++i) { - merged.atLocalBins({i}) = a.atLocalBins({i}); + mergedView.atLocalBins({i}) = aView.atLocalBins({i}); } for (std::size_t i = 1; i <= nBinsB; ++i) { - merged.atLocalBins({nBinsA + i}) = b.atLocalBins({i}); + mergedView.atLocalBins({nBinsA + i}) = bView.atLocalBins({i}); } } else { if (a.direction() == direction) { @@ -527,14 +532,14 @@ void GridPortalLink::fillMergedGrid(const GridPortalLink& a, for (std::size_t i = 1; i <= nBinsA; ++i) { for (std::size_t j = 1; j <= nBinsCommon; ++j) { - merged.atLocalBins({i, j}) = a.atLocalBins({i, j}); + mergedView.atLocalBins({i, j}) = aView.atLocalBins({i, j}); } } for (std::size_t i = 1; i <= nBinsB; ++i) { for (std::size_t j = 1; j <= nBinsCommon; ++j) { std::size_t ti = i + nBinsA; - merged.atLocalBins({ti, j}) = b.atLocalBins({i, j}); + mergedView.atLocalBins({ti, j}) = bView.atLocalBins({i, j}); } } } else { @@ -544,14 +549,14 @@ void GridPortalLink::fillMergedGrid(const GridPortalLink& a, for (std::size_t i = 1; i <= nBinsCommon; ++i) { for (std::size_t j = 1; j <= nBinsA; ++j) { - merged.atLocalBins({i, j}) = a.atLocalBins({i, j}); + mergedView.atLocalBins({i, j}) = aView.atLocalBins({i, j}); } } for (std::size_t i = 1; i <= nBinsCommon; ++i) { for (std::size_t j = 1; j <= nBinsB; ++j) { std::size_t tj = j + nBinsA; - merged.atLocalBins({i, tj}) = b.atLocalBins({i, j}); + mergedView.atLocalBins({i, tj}) = bView.atLocalBins({i, j}); } } } diff --git a/Core/src/Geometry/VolumeStack.cpp b/Core/src/Geometry/VolumeStack.cpp new file mode 100644 index 00000000000..10c73659244 --- /dev/null +++ b/Core/src/Geometry/VolumeStack.cpp @@ -0,0 +1,43 @@ +// This file is part of the ACTS project. +// +// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. + +#include "Acts/Geometry/VolumeStack.hpp" + +namespace Acts { + +VolumeStack::VolumeStack(std::vector& volumes, AxisDirection direction, + VolumeResizeStrategy resizeStrategy) + : Volume(initialVolume(volumes)), + m_direction(direction), + m_resizeStrategy(resizeStrategy), + m_volumes(volumes) {} + +Volume& VolumeStack::initialVolume(std::span volumes) { + if (volumes.empty()) { + throw std::invalid_argument("VolumeStack requires at least one volume"); + } + return *volumes.front(); +} + +bool VolumeStack::isGapVolume(const Volume& volume) const { + return std::ranges::any_of( + gaps(), [&](const auto& gap) { return gap.get() == &volume; }); +} + +std::shared_ptr VolumeStack::addGapVolume( + const Transform3& transform, const std::shared_ptr& bounds) { + auto gapVolume = std::make_shared(transform, bounds); + m_gaps.push_back(gapVolume); + return gapVolume; +} + +const std::vector>& VolumeStack::gaps() const { + return m_gaps; +} + +} // namespace Acts diff --git a/Core/src/Material/AverageMaterials.cpp b/Core/src/Material/AverageMaterials.cpp index 32c0e84ed26..c2081d3cbd7 100644 --- a/Core/src/Material/AverageMaterials.cpp +++ b/Core/src/Material/AverageMaterials.cpp @@ -32,6 +32,13 @@ Acts::MaterialSlab Acts::detail::combineSlabs(const MaterialSlab& slab1, const double thickness1 = static_cast(slab1.thickness()); const double thickness2 = static_cast(slab2.thickness()); + if (thickness1 == 0) { + return slab2; + } + if (thickness2 == 0) { + return slab1; + } + // the thickness properties are purely additive const double thickness = thickness1 + thickness2; @@ -120,6 +127,26 @@ Acts::MaterialSlab Acts::detail::combineSlabs(const MaterialSlab& slab1, // the total volume for the same unit area, i.e. volume = totalThickness*1*1 const float molarDensity = static_cast(molarAmount / thickness); - return {Material::fromMolarDensity(x0, l0, ar, z, molarDensity), - static_cast(thickness)}; + const double molarElectronAmount1 = mat1.molarElectronDensity() * thickness1; + const double molarElectronAmount2 = mat2.molarElectronDensity() * thickness2; + const double molarElectronAmount = + molarElectronAmount1 + molarElectronAmount2; + const float molarElectronDensity = + static_cast(molarElectronAmount / thickness); + + float meanExcitationEnergy = 0.f; + if (mat1.meanExcitationEnergy() > 0 && mat2.meanExcitationEnergy() > 0) { + meanExcitationEnergy = static_cast( + std::exp(thicknessWeight1 * std::log(mat1.meanExcitationEnergy())) * + std::exp(thicknessWeight2 * std::log(mat2.meanExcitationEnergy()))); + } else { + meanExcitationEnergy = + static_cast(thicknessWeight1 * mat1.meanExcitationEnergy() + + thicknessWeight2 * mat2.meanExcitationEnergy()); + } + + return { + Material::fromMolarDensity(x0, l0, ar, z, molarDensity, + molarElectronDensity, meanExcitationEnergy), + static_cast(thickness)}; } diff --git a/Core/src/Material/Material.cpp b/Core/src/Material/Material.cpp index c2ffb784db3..1cf8efc3462 100644 --- a/Core/src/Material/Material.cpp +++ b/Core/src/Material/Material.cpp @@ -26,17 +26,23 @@ enum MaterialClassificationNumberIndices { // Avogadro constant constexpr double kAvogadro = 6.02214076e23 / UnitConstants::mol; + +constexpr float calculateMolarElectronDensity(float z, float molarRho) { + return z * molarRho; +} + +constexpr float approximateMeanExcitationEnergy(float z) { + using namespace UnitLiterals; + + // use approximative computation as defined in ATL-SOFT-PUB-2008-003 + return 16_eV * std::pow(z, 0.9f); +} } // namespace Material Material::fromMassDensity(float x0, float l0, float ar, float z, float massRho) { using namespace UnitLiterals; - Material mat; - mat.m_x0 = x0; - mat.m_l0 = l0; - mat.m_ar = ar; - mat.m_z = z; // mass density is defined as // // mass-density = atomic-mass * number-of-atoms / volume @@ -49,18 +55,30 @@ Material Material::fromMassDensity(float x0, float l0, float ar, float z, // // perform computations in double precision to avoid loss of precision const double atomicMass = static_cast(ar) * 1_u; - mat.m_molarRho = static_cast(massRho) / (atomicMass * kAvogadro); - return mat; + float molarRho = static_cast(massRho / (atomicMass * kAvogadro)); + + return Material::fromMolarDensity(x0, l0, ar, z, molarRho); } Material Material::fromMolarDensity(float x0, float l0, float ar, float z, float molarRho) { + return Material::fromMolarDensity(x0, l0, ar, z, molarRho, + calculateMolarElectronDensity(z, molarRho), + std::nullopt); +} + +Material Material::fromMolarDensity(float x0, float l0, float ar, float z, + float molarRho, float molarElectronRho, + std::optional meanExcitationEnergy) { Material mat; mat.m_x0 = x0; mat.m_l0 = l0; mat.m_ar = ar; mat.m_z = z; mat.m_molarRho = molarRho; + mat.m_molarElectronRho = molarElectronRho; + mat.m_meanExcitationEnergy = + meanExcitationEnergy.value_or(approximateMeanExcitationEnergy(z)); return mat; } @@ -69,7 +87,9 @@ Material::Material(const ParametersVector& parameters) m_l0(parameters[eInteractionLength]), m_ar(parameters[eRelativeAtomicMass]), m_z(parameters[eNuclearCharge]), - m_molarRho(parameters[eMolarDensity]) {} + m_molarRho(parameters[eMolarDensity]), + m_molarElectronRho(calculateMolarElectronDensity(m_z, m_molarRho)), + m_meanExcitationEnergy(approximateMeanExcitationEnergy(m_z)) {} float Material::massDensity() const { using namespace UnitLiterals; @@ -80,13 +100,6 @@ float Material::massDensity() const { return atomicMass * numberDensity; } -float Material::meanExcitationEnergy() const { - using namespace UnitLiterals; - - // use approximative computation as defined in ATL-SOFT-PUB-2008-003 - return 16_eV * std::pow(m_z, 0.9f); -} - Material::ParametersVector Material::parameters() const { ParametersVector parameters; parameters[eRadiationLength] = m_x0; @@ -106,6 +119,8 @@ std::ostream& operator<<(std::ostream& os, const Material& material) { os << "|ar=" << material.Ar(); os << "|z=" << material.Z(); os << "|molar_rho=" << material.molarDensity(); + os << "|molar_e_rho=" << material.molarElectronDensity(); + os << "|mean_excitation_energy=" << material.meanExcitationEnergy(); } return os; } diff --git a/Core/src/Material/VolumeMaterialMapper.cpp b/Core/src/Material/VolumeMaterialMapper.cpp index 3ff93528d4a..8a523de282f 100644 --- a/Core/src/Material/VolumeMaterialMapper.cpp +++ b/Core/src/Material/VolumeMaterialMapper.cpp @@ -489,7 +489,7 @@ void VolumeMaterialMapper::mapMaterialTrack( sfIter++; } } - rmIter->volume = volIter->volume; + rmIter->volume = InteractionVolume(volIter->volume); rmIter->intersectionID = currentID; rmIter->intersection = rmIter->position; } diff --git a/Core/src/Vertexing/FullBilloirVertexFitter.cpp b/Core/src/Vertexing/FullBilloirVertexFitter.cpp index 3c5b17121fb..6a72eed07e0 100644 --- a/Core/src/Vertexing/FullBilloirVertexFitter.cpp +++ b/Core/src/Vertexing/FullBilloirVertexFitter.cpp @@ -21,7 +21,8 @@ namespace { /// /// @brief Struct to cache track-specific matrix operations in Billoir fitter struct BilloirTrack { - BilloirTrack(const Acts::InputTrack& params) : originalTrack(params) {} + explicit BilloirTrack(const Acts::InputTrack& params) + : originalTrack(params) {} BilloirTrack(const BilloirTrack& arg) = default; diff --git a/Examples/Algorithms/Digitization/src/DigitizationCoordinatesConverter.cpp b/Examples/Algorithms/Digitization/src/DigitizationCoordinatesConverter.cpp index b996306fb13..06f3dd89d90 100644 --- a/Examples/Algorithms/Digitization/src/DigitizationCoordinatesConverter.cpp +++ b/Examples/Algorithms/Digitization/src/DigitizationCoordinatesConverter.cpp @@ -27,7 +27,7 @@ DigitizationCoordinatesConverter::DigitizationCoordinatesConverter( std::tuple DigitizationCoordinatesConverter::globalToLocal( std::uint64_t moduleId, double x, double y, double z) const { - const Acts::GeometryIdentifier moduleGeoId = moduleId; + const Acts::GeometryIdentifier moduleGeoId(moduleId); auto surfaceItr = m_cfg.surfaceByIdentifier.find(moduleGeoId); if (surfaceItr == m_cfg.surfaceByIdentifier.end()) { throw std::runtime_error("Surface not found for moduleGeoId"); @@ -47,7 +47,7 @@ std::tuple DigitizationCoordinatesConverter::globalToLocal( std::tuple DigitizationCoordinatesConverter::localToGlobal(std::uint64_t moduleId, double x, double y) const { - const Acts::GeometryIdentifier moduleGeoId = moduleId; + const Acts::GeometryIdentifier moduleGeoId{moduleId}; auto surfaceItr = m_cfg.surfaceByIdentifier.find(moduleGeoId); if (surfaceItr == m_cfg.surfaceByIdentifier.end()) { throw std::runtime_error("Surface not found for moduleGeoId"); diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp index df9dd637eca..84bb97560a7 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp @@ -158,8 +158,8 @@ class Geant4Simulation final : public Geant4SimulationBase { /// /// @param config is the configuration struct /// @param level is the logging level to be used - Geant4Simulation(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit Geant4Simulation(const Config& cfg, + Acts::Logging::Level level = Acts::Logging::INFO); ~Geant4Simulation() override; @@ -200,8 +200,8 @@ class Geant4MaterialRecording final : public Geant4SimulationBase { /// /// @param config is the configuration struct /// @param level is the logging level to be used - Geant4MaterialRecording(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit Geant4MaterialRecording( + const Config& cfg, Acts::Logging::Level level = Acts::Logging::INFO); ~Geant4MaterialRecording() override; diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp index 7581d5b6cf5..87eb6e226bd 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp @@ -34,10 +34,10 @@ class MagneticFieldWrapper : public G4MagneticField { /// /// @param cfg the configuration struct /// @param logger the ACTS logging instance - MagneticFieldWrapper(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("MagneticFieldWrapper", - Acts::Logging::INFO)); + explicit MagneticFieldWrapper( + const Config& cfg, + std::unique_ptr logger = + Acts::getDefaultLogger("MagneticFieldWrapper", Acts::Logging::INFO)); ~MagneticFieldWrapper() override = default; /// Public get field interface diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp index 23ccb88764e..048e843c8a3 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp @@ -41,10 +41,10 @@ class MaterialSteppingAction final : public G4UserSteppingAction { /// /// @param cfg the configuration struct for this Stepping action /// @param logger is an Acts::Logger for unique logging - MaterialSteppingAction(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("SimParticleTranslation", - Acts::Logging::INFO)); + explicit MaterialSteppingAction( + const Config& cfg, + std::unique_ptr logger = Acts::getDefaultLogger( + "SimParticleTranslation", Acts::Logging::INFO)); ~MaterialSteppingAction() override; /// @brief Action per step to be performed diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp index fe15a2d185c..e4b03d95437 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp @@ -47,10 +47,10 @@ class ParticleKillAction : public G4UserSteppingAction { /// /// @param cfg the configuration struct /// @param logger the ACTS logging instance - ParticleKillAction(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("ParticleKillAction", - Acts::Logging::INFO)); + explicit ParticleKillAction(const Config& cfg, + std::unique_ptr logger = + Acts::getDefaultLogger("ParticleKillAction", + Acts::Logging::INFO)); ~ParticleKillAction() override = default; /// @brief Called every step, conditionally sets the tracking state to `fStopAndKill` diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp index 4ff1d413f34..096fa2ee379 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp @@ -39,10 +39,10 @@ class ParticleTrackingAction : public G4UserTrackingAction { /// /// @param cfg the configuration struct /// @param logger the ACTS logging instance - ParticleTrackingAction(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("ParticleTrackingAction", - Acts::Logging::INFO)); + explicit ParticleTrackingAction( + const Config& cfg, + std::unique_ptr logger = Acts::getDefaultLogger( + "ParticleTrackingAction", Acts::Logging::INFO)); ~ParticleTrackingAction() override = default; /// Action before the track is processed in the diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp index 034f38943b6..73895db404f 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp @@ -50,10 +50,10 @@ class SensitiveSteppingAction : public G4UserSteppingAction { /// /// @param cfg the configuration struct /// @param logger the ACTS logging instance - SensitiveSteppingAction(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("SensitiveSteppingAction", - Acts::Logging::INFO)); + explicit SensitiveSteppingAction( + const Config& cfg, + std::unique_ptr logger = Acts::getDefaultLogger( + "SensitiveSteppingAction", Acts::Logging::INFO)); ~SensitiveSteppingAction() override = default; /// @brief Interface Method doing the step and records the data diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp index 7614635ff93..d466b29206d 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp @@ -103,10 +103,10 @@ class SensitiveSurfaceMapper { /// /// @param cfg the configuration struct /// @param logger the logging instance - SensitiveSurfaceMapper(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("SensitiveSurfaceMapper", - Acts::Logging::INFO)); + explicit SensitiveSurfaceMapper( + const Config& cfg, + std::unique_ptr logger = Acts::getDefaultLogger( + "SensitiveSurfaceMapper", Acts::Logging::INFO)); ~SensitiveSurfaceMapper() = default; /// Recursive mapping function that walks through the Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp index 5b43102d812..0bc4ba0045c 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp @@ -52,10 +52,10 @@ class SimParticleTranslation final : public G4VUserPrimaryGeneratorAction { /// /// @param cfg the configuration struct /// @param logger the ACTS logging instance - SimParticleTranslation(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("SimParticleTranslation", - Acts::Logging::INFO)); + explicit SimParticleTranslation( + const Config& cfg, + std::unique_ptr logger = Acts::getDefaultLogger( + "SimParticleTranslation", Acts::Logging::INFO)); ~SimParticleTranslation() override; diff --git a/Examples/Algorithms/Geant4HepMC/src/PrimaryGeneratorAction.hpp b/Examples/Algorithms/Geant4HepMC/src/PrimaryGeneratorAction.hpp index c0451c76bf1..b132d9ba26a 100644 --- a/Examples/Algorithms/Geant4HepMC/src/PrimaryGeneratorAction.hpp +++ b/Examples/Algorithms/Geant4HepMC/src/PrimaryGeneratorAction.hpp @@ -29,7 +29,8 @@ namespace ActsExamples::Geant4::HepMC3 { class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction { public: /// Constructor - PrimaryGeneratorAction(G4int randomSeed1 = 12345, G4int randomSeed2 = 23456); + explicit PrimaryGeneratorAction(G4int randomSeed1 = 12345, + G4int randomSeed2 = 23456); /// Destructor ~PrimaryGeneratorAction() override; diff --git a/Examples/Algorithms/Geometry/include/ActsExamples/Geometry/VolumeAssociationTest.hpp b/Examples/Algorithms/Geometry/include/ActsExamples/Geometry/VolumeAssociationTest.hpp index a468051aff2..d77aa91f4ea 100644 --- a/Examples/Algorithms/Geometry/include/ActsExamples/Geometry/VolumeAssociationTest.hpp +++ b/Examples/Algorithms/Geometry/include/ActsExamples/Geometry/VolumeAssociationTest.hpp @@ -42,8 +42,8 @@ class VolumeAssociationTest final : public IAlgorithm { /// /// @param cfg is the algorithm configuration /// @param level is the logging level - VolumeAssociationTest(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit VolumeAssociationTest( + const Config& cfg, Acts::Logging::Level level = Acts::Logging::INFO); /// Run the random point association test /// diff --git a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/CoreMaterialMapping.hpp b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/CoreMaterialMapping.hpp index 8fa2e31f831..4784ff8b46b 100644 --- a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/CoreMaterialMapping.hpp +++ b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/CoreMaterialMapping.hpp @@ -55,8 +55,8 @@ class CoreMaterialMapping : public IAlgorithm { /// /// @param cfg The configuration struct carrying the used tools /// @param level The output logging level - CoreMaterialMapping(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit CoreMaterialMapping( + const Config& cfg, Acts::Logging::Level level = Acts::Logging::INFO); /// Destructor /// - it also writes out the file diff --git a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialMapping.hpp b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialMapping.hpp index 762187683f7..713b9ad13e1 100644 --- a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialMapping.hpp +++ b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialMapping.hpp @@ -98,8 +98,8 @@ class MaterialMapping : public IAlgorithm { /// /// @param cfg The configuration struct carrying the used tools /// @param level The output logging level - MaterialMapping(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit MaterialMapping(const Config& cfg, + Acts::Logging::Level level = Acts::Logging::INFO); /// Framework execute method /// diff --git a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialValidation.hpp b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialValidation.hpp index 69558244027..73a87f741ae 100644 --- a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialValidation.hpp +++ b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialValidation.hpp @@ -56,8 +56,8 @@ class MaterialValidation : public IAlgorithm { /// /// @param cfg The configuration struct carrying the used tools /// @param level The output logging level - MaterialValidation(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit MaterialValidation(const Config& cfg, + Acts::Logging::Level level = Acts::Logging::INFO); /// Destructor /// - it also writes out the file diff --git a/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp b/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp index 999e8826333..6dd0e073509 100644 --- a/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp +++ b/Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.hpp @@ -53,10 +53,10 @@ class DetrayPropagator : public PropagatorInterface { /// /// @param cfg configuration struct /// @param logger The logger instance - DetrayPropagator(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("DetrayPropagator", - Acts::Logging::INFO)) + explicit DetrayPropagator(const Config& cfg, + std::unique_ptr logger = + Acts::getDefaultLogger("DetrayPropagator", + Acts::Logging::INFO)) : PropagatorInterface(), m_cfg(cfg), m_logger(std::move(logger)) {} ///@brief Execute a propagation for charged particle parameters diff --git a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp index 8169bba61c7..0ed1b83843d 100644 --- a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp @@ -286,7 +286,7 @@ TrackFindingAlgorithm::TrackFindingAlgorithm(Config config, if (m_cfg.trackSelectorCfg.has_value()) { m_trackSelector = std::visit( [](const auto& cfg) -> std::optional { - return {cfg}; + return Acts::TrackSelector(cfg); }, m_cfg.trackSelectorCfg.value()); } @@ -502,8 +502,8 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const { auto trackCandidate = tracksTemp.makeTrack(); trackCandidate.copyFrom(firstTrack, true); - auto firstSmoothingResult = - Acts::smoothTrack(ctx.geoContext, trackCandidate, logger()); + Acts::Result firstSmoothingResult{ + Acts::smoothTrack(ctx.geoContext, trackCandidate, logger())}; if (!firstSmoothingResult.ok()) { m_nFailedSmoothing++; ACTS_ERROR("First smoothing for seed " @@ -536,10 +536,13 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const { } if (firstMeasurementOpt.has_value()) { - auto& firstMeasurement = firstMeasurementOpt.value(); + TrackContainer::TrackStateProxy firstMeasurement{ + firstMeasurementOpt.value()}; + TrackContainer::ConstTrackStateProxy firstMeasurementConst{ + firstMeasurement}; Acts::BoundTrackParameters secondInitialParameters = - trackCandidate.createParametersFromState(firstMeasurement); + trackCandidate.createParametersFromState(firstMeasurementConst); if (!secondInitialParameters.referenceSurface().insideBounds( secondInitialParameters.localPosition())) { diff --git a/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp b/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp index 5330e55c76c..86cc9f9ac61 100644 --- a/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp +++ b/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp @@ -118,7 +118,8 @@ AdaptiveMultiVertexFinderAlgorithm::makeVertexSeeder() const { Acts::GaussianTrackDensity::Config trkDensityCfg; trkDensityCfg.extractParameters .connect<&Acts::InputTrack::extractParameters>(); - return std::make_unique(Seeder::Config{trkDensityCfg}); + return std::make_unique( + Seeder::Config{Acts::GaussianTrackDensity(trkDensityCfg)}); } if (m_cfg.seedFinder == SeedFinder::AdaptiveGridSeeder) { diff --git a/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp b/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp index 03d6c4f6ff7..7d92b0ddc27 100644 --- a/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp +++ b/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp @@ -97,7 +97,8 @@ ProcessCode IterativeVertexFinderAlgorithm::execute( Acts::GaussianTrackDensity::Config densityCfg; densityCfg.extractParameters.connect<&Acts::InputTrack::extractParameters>(); - auto seeder = std::make_shared(Seeder::Config{{densityCfg}}); + auto seeder = std::make_shared( + Seeder::Config{Acts::GaussianTrackDensity(densityCfg)}); // Set up the actual vertex finder Finder::Config finderCfg(std::move(vertexFitter), seeder, ipEst); finderCfg.trackLinearizer.connect<&Linearizer::linearizeTrack>(&linearizer); diff --git a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternalAlignmentDecorator.hpp b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternalAlignmentDecorator.hpp index 6b873a0bdc9..8f0fd09e96c 100644 --- a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternalAlignmentDecorator.hpp +++ b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternalAlignmentDecorator.hpp @@ -46,7 +46,7 @@ class ExternalAlignmentDecorator : public AlignmentDecorator { /// /// @param cfg Configuration struct /// @param logger The logging framework - ExternalAlignmentDecorator( + explicit ExternalAlignmentDecorator( const Config& cfg, std::unique_ptr logger = Acts::getDefaultLogger( "ExternalAlignmentDecorator", Acts::Logging::INFO)); diff --git a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternalAlignmentDecorator.hpp b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternalAlignmentDecorator.hpp index d571c02ec2c..c679ea278bc 100644 --- a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternalAlignmentDecorator.hpp +++ b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternalAlignmentDecorator.hpp @@ -46,10 +46,10 @@ class InternalAlignmentDecorator : public AlignmentDecorator { /// /// @param cfg Configuration struct /// @param logger The logging framework - InternalAlignmentDecorator(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("AlignmentDecorator", - Acts::Logging::INFO)); + explicit InternalAlignmentDecorator( + const Config& cfg, + std::unique_ptr logger = + Acts::getDefaultLogger("AlignmentDecorator", Acts::Logging::INFO)); /// Virtual destructor ~InternalAlignmentDecorator() override = default; diff --git a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/LayerBuilderT.hpp b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/LayerBuilderT.hpp index 66a5c8f2f37..aa473934584 100644 --- a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/LayerBuilderT.hpp +++ b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/LayerBuilderT.hpp @@ -76,10 +76,10 @@ class LayerBuilderT : public Acts::ILayerBuilder { /// Constructor /// @param glbConfig is the configuration class - LayerBuilderT(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("LayerBuilderT", - Acts::Logging::INFO)); + explicit LayerBuilderT(const Config& cfg, + std::unique_ptr logger = + Acts::getDefaultLogger("LayerBuilderT", + Acts::Logging::INFO)); /// LayerBuilder interface method - returning the layers at negative side const Acts::LayerVector negativeLayers( diff --git a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp index 8ddad182380..544f07b1021 100644 --- a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp +++ b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp @@ -125,10 +125,10 @@ class ProtoLayerCreatorT { /// Constructor /// @param cfg is the configuration class /// @param logger is the logging class for screen output - ProtoLayerCreatorT(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("ProtoLayerCreatorT", - Acts::Logging::INFO)); + explicit ProtoLayerCreatorT(const Config& cfg, + std::unique_ptr logger = + Acts::getDefaultLogger("ProtoLayerCreatorT", + Acts::Logging::INFO)); /// @brief construct the negative side layers /// @param gctx The geometry context for this construction call diff --git a/Examples/Detectors/MagneticField/include/ActsExamples/MagneticField/ScalableBField.hpp b/Examples/Detectors/MagneticField/include/ActsExamples/MagneticField/ScalableBField.hpp index a043306db49..580a65ce2b1 100644 --- a/Examples/Detectors/MagneticField/include/ActsExamples/MagneticField/ScalableBField.hpp +++ b/Examples/Detectors/MagneticField/include/ActsExamples/MagneticField/ScalableBField.hpp @@ -41,7 +41,7 @@ class ScalableBField final : public Acts::MagneticFieldProvider { /// @param [in] Bx magnetic field component in global x-direction /// @param [in] By magnetic field component in global y-direction /// @param [in] Bz magnetic field component in global z-direction - ScalableBField(double Bx = 0, double By = 0, double Bz = 0) + explicit ScalableBField(double Bx = 0, double By = 0, double Bz = 0) : m_BField(Bx, By, Bz) {} /// @brief retrieve magnetic field value diff --git a/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/TGeoITkModuleSplitter.hpp b/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/TGeoITkModuleSplitter.hpp index ab928752f49..ed158d78461 100644 --- a/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/TGeoITkModuleSplitter.hpp +++ b/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/TGeoITkModuleSplitter.hpp @@ -47,10 +47,10 @@ class TGeoITkModuleSplitter : public Acts::ITGeoDetectorElementSplitter { /// /// @param cfg the configuration struct /// @param logger the logging object - TGeoITkModuleSplitter(const Config& cfg, - std::unique_ptr logger = - Acts::getDefaultLogger("TGeoITkModuleSplitter", - Acts::Logging::INFO)); + explicit TGeoITkModuleSplitter( + const Config& cfg, + std::unique_ptr logger = + Acts::getDefaultLogger("TGeoITkModuleSplitter", Acts::Logging::INFO)); ~TGeoITkModuleSplitter() override = default; diff --git a/Examples/Framework/ML/src/NeuralCalibrator.cpp b/Examples/Framework/ML/src/NeuralCalibrator.cpp index 83c7a2bc09a..21fb67cfdb4 100644 --- a/Examples/Framework/ML/src/NeuralCalibrator.cpp +++ b/Examples/Framework/ML/src/NeuralCalibrator.cpp @@ -86,7 +86,8 @@ void ActsExamples::NeuralCalibrator::calibrate( assert((idxSourceLink.index() < measurements.size()) and "Source link index is outside the container bounds"); - if (!rangeContainsValue(m_volumeIds, idxSourceLink.geometryId())) { + if (!Acts::rangeContainsValue(m_volumeIds, + idxSourceLink.geometryId().volume())) { m_fallback.calibrate(measurements, clusters, gctx, cctx, sourceLink, trackState); return; diff --git a/Examples/Framework/include/ActsExamples/EventData/SimVertex.hpp b/Examples/Framework/include/ActsExamples/EventData/SimVertex.hpp index db906790e8b..7fcc4d032b6 100644 --- a/Examples/Framework/include/ActsExamples/EventData/SimVertex.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/SimVertex.hpp @@ -59,7 +59,7 @@ class SimVertexBarcode { private: /// The vertex ID /// Note that only primary, secondary and generation should be set - SimBarcode m_id = 0; + SimBarcode m_id; friend constexpr bool operator<(SimVertexBarcode lhs, SimVertexBarcode rhs) { return lhs.m_id < rhs.m_id; diff --git a/Examples/Framework/include/ActsExamples/Framework/IAlgorithm.hpp b/Examples/Framework/include/ActsExamples/Framework/IAlgorithm.hpp index 77fd2b41c98..06e53612822 100644 --- a/Examples/Framework/include/ActsExamples/Framework/IAlgorithm.hpp +++ b/Examples/Framework/include/ActsExamples/Framework/IAlgorithm.hpp @@ -29,8 +29,8 @@ class IAlgorithm : public SequenceElement { /// /// @name The algorithm name /// @level The logging level for this algorithm - IAlgorithm(std::string name, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit IAlgorithm(std::string name, + Acts::Logging::Level level = Acts::Logging::INFO); /// The algorithm name. std::string name() const override; diff --git a/Examples/Framework/include/ActsExamples/Framework/WhiteBoard.hpp b/Examples/Framework/include/ActsExamples/Framework/WhiteBoard.hpp index 61f73296bef..ff7afdd4531 100644 --- a/Examples/Framework/include/ActsExamples/Framework/WhiteBoard.hpp +++ b/Examples/Framework/include/ActsExamples/Framework/WhiteBoard.hpp @@ -33,7 +33,7 @@ namespace ActsExamples { /// Its lifetime is bound to the lifetime of the white board. class WhiteBoard { public: - WhiteBoard( + explicit WhiteBoard( std::unique_ptr logger = Acts::getDefaultLogger("WhiteBoard", Acts::Logging::INFO), std::unordered_multimap objectAliases = {}); diff --git a/Examples/Framework/include/ActsExamples/Utilities/tbbWrap.hpp b/Examples/Framework/include/ActsExamples/Utilities/tbbWrap.hpp index 79969369221..f5e61bd1db3 100644 --- a/Examples/Framework/include/ActsExamples/Utilities/tbbWrap.hpp +++ b/Examples/Framework/include/ActsExamples/Utilities/tbbWrap.hpp @@ -49,7 +49,8 @@ class task_arena { std::optional tbb; public: - task_arena(int nthreads = tbb::task_arena::automatic, unsigned res = 1) { + explicit task_arena(int nthreads = tbb::task_arena::automatic, + unsigned res = 1) { if (enableTBB(nthreads)) { tbb.emplace(nthreads, res); } diff --git a/Examples/HelloWorld/HelloRandomAlgorithm.hpp b/Examples/HelloWorld/HelloRandomAlgorithm.hpp index 1a4f804e4a2..9fbcb7fa3f4 100644 --- a/Examples/HelloWorld/HelloRandomAlgorithm.hpp +++ b/Examples/HelloWorld/HelloRandomAlgorithm.hpp @@ -35,8 +35,8 @@ class HelloRandomAlgorithm : public ActsExamples::IAlgorithm { std::string output; }; - HelloRandomAlgorithm(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit HelloRandomAlgorithm( + const Config& cfg, Acts::Logging::Level level = Acts::Logging::INFO); // Generate random numbers from various distributions. ActsExamples::ProcessCode execute(const AlgorithmContext& ctx) const override; diff --git a/Examples/HelloWorld/HelloWhiteBoardAlgorithm.hpp b/Examples/HelloWorld/HelloWhiteBoardAlgorithm.hpp index 65074585cb1..fb209071970 100644 --- a/Examples/HelloWorld/HelloWhiteBoardAlgorithm.hpp +++ b/Examples/HelloWorld/HelloWhiteBoardAlgorithm.hpp @@ -28,8 +28,8 @@ class HelloWhiteBoardAlgorithm : public ActsExamples::IAlgorithm { std::string output; }; - HelloWhiteBoardAlgorithm(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit HelloWhiteBoardAlgorithm( + const Config& cfg, Acts::Logging::Level level = Acts::Logging::INFO); /// Read input and copy to the output ActsExamples::ProcessCode execute(const AlgorithmContext& ctx) const override; diff --git a/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp b/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp index e141f470988..9eac2edd631 100644 --- a/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp +++ b/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp @@ -268,8 +268,9 @@ class NamedTupleDsvWriter { /// /// \param path Path to the output file /// \param precision Output floating point precision - NamedTupleDsvWriter(const std::string& path, - int precision = std::numeric_limits::max_digits10) + explicit NamedTupleDsvWriter( + const std::string& path, + int precision = std::numeric_limits::max_digits10) : m_writer(colum_names(), path, precision) {} /// Append a record to the file. @@ -330,9 +331,10 @@ class NamedTupleDsvReader { /// /// The set of optional columns must match names in the record. When allowing /// optional columns, header verification must be set to true. - NamedTupleDsvReader(const std::string& path, - const std::vector& optional_columns = {}, - bool verify_header = true); + explicit NamedTupleDsvReader( + const std::string& path, + const std::vector& optional_columns = {}, + bool verify_header = true); /// Read the next record from the file. /// diff --git a/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvSeedWriter.hpp b/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvSeedWriter.hpp index d893c5aae42..a94cfefff83 100644 --- a/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvSeedWriter.hpp +++ b/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvSeedWriter.hpp @@ -58,8 +58,8 @@ class CsvSeedWriter : public WriterT { /// /// @param config Configuration struct /// @param level Message level declaration - CsvSeedWriter(const Config& config, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit CsvSeedWriter(const Config& config, + Acts::Logging::Level level = Acts::Logging::INFO); /// Get readonly access to the config parameters const Config& config() const { return m_cfg; } diff --git a/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvTrackWriter.hpp b/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvTrackWriter.hpp index d3bbfe989f7..7e0d4e50ccc 100644 --- a/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvTrackWriter.hpp +++ b/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvTrackWriter.hpp @@ -63,8 +63,8 @@ class CsvTrackWriter : public WriterT { /// constructor /// @param config is the configuration object /// @param level is the output logging level - CsvTrackWriter(const Config& config, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit CsvTrackWriter(const Config& config, + Acts::Logging::Level level = Acts::Logging::INFO); /// Readonly access to the config const Config& config() const { return m_cfg; } diff --git a/Examples/Io/Csv/src/CsvMeasurementReader.cpp b/Examples/Io/Csv/src/CsvMeasurementReader.cpp index f426784ea30..6f4e062dc99 100644 --- a/Examples/Io/Csv/src/CsvMeasurementReader.cpp +++ b/Examples/Io/Csv/src/CsvMeasurementReader.cpp @@ -210,7 +210,7 @@ ActsExamples::ProcessCode ActsExamples::CsvMeasurementReader::read( } for (const MeasurementData& m : measurementData) { - Acts::GeometryIdentifier geoId = m.geometry_id; + Acts::GeometryIdentifier geoId{m.geometry_id}; // Create the measurement DigitizedParameters dParameters; diff --git a/Examples/Io/Csv/src/CsvMuonSimHitReader.cpp b/Examples/Io/Csv/src/CsvMuonSimHitReader.cpp index 28836dc48de..ea3e784945d 100644 --- a/Examples/Io/Csv/src/CsvMuonSimHitReader.cpp +++ b/Examples/Io/Csv/src/CsvMuonSimHitReader.cpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "ActsExamples/EventData/MuonSimHit.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Io/Csv/CsvInputOutput.hpp" #include "ActsExamples/Utilities/Paths.hpp" @@ -79,7 +80,10 @@ ActsExamples::ProcessCode ActsExamples::CsvMuonSimHitReader::read( f.stationPhi = data.StationPhi; f.stationName = data.StationName; - unordered.push_back(SimHit(compressId(f), data.pdgId, pos, mom, mom, -1)); + unordered.push_back( + SimHit(Acts::GeometryIdentifier(compressId(f)), + SimBarcode{static_cast(data.pdgId)}, pos, mom, + mom, -1)); } SimHitContainer simHits; simHits.insert(unordered.begin(), unordered.end()); diff --git a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepMultiTrajectoryWriter.hpp b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepMultiTrajectoryWriter.hpp index 8117e4b663d..40fc4c5dde9 100644 --- a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepMultiTrajectoryWriter.hpp +++ b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepMultiTrajectoryWriter.hpp @@ -49,7 +49,7 @@ class EDM4hepMultiTrajectoryWriter : public WriterT { /// constructor /// @param config is the configuration object /// @param level is the output logging level - EDM4hepMultiTrajectoryWriter( + explicit EDM4hepMultiTrajectoryWriter( const Config& config, Acts::Logging::Level level = Acts::Logging::INFO); ProcessCode finalize() final; diff --git a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepTrackReader.hpp b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepTrackReader.hpp index c795af039fe..06d85330722 100644 --- a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepTrackReader.hpp +++ b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepTrackReader.hpp @@ -40,8 +40,8 @@ class EDM4hepTrackReader : public IReader { /// constructor /// @param config is the configuration object /// @param level is the output logging level - EDM4hepTrackReader(const Config& config, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit EDM4hepTrackReader(const Config& config, + Acts::Logging::Level level = Acts::Logging::INFO); /// Readonly access to the config const Config& config() const { return m_cfg; } diff --git a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepTrackWriter.hpp b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepTrackWriter.hpp index 340301df810..f8b86fefcf6 100644 --- a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepTrackWriter.hpp +++ b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepTrackWriter.hpp @@ -37,8 +37,8 @@ class EDM4hepTrackWriter : public WriterT { /// constructor /// @param config is the configuration object /// @param level is the output logging level - EDM4hepTrackWriter(const Config& config, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit EDM4hepTrackWriter(const Config& config, + Acts::Logging::Level level = Acts::Logging::INFO); ProcessCode finalize() final; diff --git a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp index 4973763a087..febf105f1aa 100644 --- a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp +++ b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp @@ -34,7 +34,7 @@ using MapParticleIdTo = inline ActsFatras::Barcode zeroParticleMapper( const edm4hep::MCParticle& /*particle*/) { - return 0; + return ActsFatras::Barcode(); } using MapGeometryIdFrom = diff --git a/Examples/Io/HepMC3/src/HepMC3Event.cpp b/Examples/Io/HepMC3/src/HepMC3Event.cpp index ffd62c272f9..c825cc40b5a 100644 --- a/Examples/Io/HepMC3/src/HepMC3Event.cpp +++ b/Examples/Io/HepMC3/src/HepMC3Event.cpp @@ -179,7 +179,7 @@ void HepMC3Event::removeParticle(HepMC3::GenEvent& event, const auto id = particle->particleId(); // Search HepMC3::GenParticle with the same id as the Acts particle for (auto& genParticle : genParticles) { - if (genParticle->id() == id) { + if (genParticle->id() == static_cast(id.value())) { // Remove particle if found event.remove_particle(genParticle); break; diff --git a/Examples/Io/HepMC3/src/HepMC3Particle.cpp b/Examples/Io/HepMC3/src/HepMC3Particle.cpp index 315c79dced1..61e9398fd39 100644 --- a/Examples/Io/HepMC3/src/HepMC3Particle.cpp +++ b/Examples/Io/HepMC3/src/HepMC3Particle.cpp @@ -17,7 +17,7 @@ namespace ActsExamples { SimBarcode HepMC3Particle::barcode( const HepMC3::ConstGenParticlePtr& particle) { // TODO this is probably not quite right - return particle->id(); + return SimBarcode{static_cast(particle->id())}; } SimParticle HepMC3Particle::particle( diff --git a/Examples/Io/HepMC3/src/HepMC3Vertex.cpp b/Examples/Io/HepMC3/src/HepMC3Vertex.cpp index 397eba88085..687325263c3 100644 --- a/Examples/Io/HepMC3/src/HepMC3Vertex.cpp +++ b/Examples/Io/HepMC3/src/HepMC3Vertex.cpp @@ -73,7 +73,7 @@ HepMC3::GenParticlePtr matchParticles( const auto id = actsParticle->particleId(); // Search HepMC3::GenParticle with the same id as the Acts particle for (auto& genParticle : genParticles) { - if (genParticle->id() == id) { + if (genParticle->id() == static_cast(id.value())) { // Return particle if found return genParticle; } diff --git a/Examples/Io/Obj/include/ActsExamples/Io/Obj/ObjPropagationStepsWriter.hpp b/Examples/Io/Obj/include/ActsExamples/Io/Obj/ObjPropagationStepsWriter.hpp index 1a20c483976..d7a37a15345 100644 --- a/Examples/Io/Obj/include/ActsExamples/Io/Obj/ObjPropagationStepsWriter.hpp +++ b/Examples/Io/Obj/include/ActsExamples/Io/Obj/ObjPropagationStepsWriter.hpp @@ -43,8 +43,8 @@ class ObjPropagationStepsWriter : public WriterT { /// /// @param cfg configuration struct /// @param level Output logging level - ObjPropagationStepsWriter(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit ObjPropagationStepsWriter( + const Config& cfg, Acts::Logging::Level level = Acts::Logging::INFO); /// Virtual destructor ~ObjPropagationStepsWriter() override = default; diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootMaterialTrackWriter.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootMaterialTrackWriter.hpp index 3bd337a7fe8..1224c14a6c2 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootMaterialTrackWriter.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootMaterialTrackWriter.hpp @@ -77,8 +77,8 @@ class RootMaterialTrackWriter /// Constructor with /// @param config configuration struct /// @param level logging level - RootMaterialTrackWriter(const Config& config, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit RootMaterialTrackWriter( + const Config& config, Acts::Logging::Level level = Acts::Logging::INFO); /// Virtual destructor ~RootMaterialTrackWriter() override; diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationStepsWriter.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationStepsWriter.hpp index 330fe1e9151..54ee54ab48f 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationStepsWriter.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationStepsWriter.hpp @@ -54,8 +54,8 @@ class RootPropagationStepsWriter : public WriterT { /// Constructor with /// @param cfg configuration struct /// @param output logging level - RootPropagationStepsWriter(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit RootPropagationStepsWriter( + const Config& cfg, Acts::Logging::Level level = Acts::Logging::INFO); /// Virtual destructor ~RootPropagationStepsWriter() override; diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationSummaryWriter.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationSummaryWriter.hpp index f9eea212b12..33cb2c9172e 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationSummaryWriter.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationSummaryWriter.hpp @@ -51,7 +51,7 @@ class RootPropagationSummaryWriter : public WriterT { /// Constructor with /// @param cfg configuration struct /// @param output logging level - RootPropagationSummaryWriter( + explicit RootPropagationSummaryWriter( const Config& cfg, Acts::Logging::Level level = Acts::Logging::INFO); /// Virtual destructor diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootTrackParameterWriter.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootTrackParameterWriter.hpp index 22540f90399..c279b305993 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootTrackParameterWriter.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootTrackParameterWriter.hpp @@ -59,8 +59,8 @@ class RootTrackParameterWriter final /// /// @param config Configuration struct /// @param level Message level declaration - RootTrackParameterWriter(const Config& config, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit RootTrackParameterWriter( + const Config& config, Acts::Logging::Level level = Acts::Logging::INFO); /// Virtual destructor ~RootTrackParameterWriter() override; diff --git a/Examples/Io/Root/src/RootAthenaDumpReader.cpp b/Examples/Io/Root/src/RootAthenaDumpReader.cpp index e4a147d12c7..715ebdf0fd0 100644 --- a/Examples/Io/Root/src/RootAthenaDumpReader.cpp +++ b/Examples/Io/Root/src/RootAthenaDumpReader.cpp @@ -257,7 +257,8 @@ SimParticleContainer RootAthenaDumpReader::readParticles() const { continue; } - auto dummyBarcode = concatInts(Part_barcode[ip], Part_event_number[ip]); + SimBarcode dummyBarcode{ + concatInts(Part_barcode[ip], Part_event_number[ip])}; SimParticleState particle(dummyBarcode, static_cast(Part_pdg_id[ip])); @@ -453,7 +454,7 @@ RootAthenaDumpReader::readMeasurements( for (const auto& [subevt, barcode] : Acts::zip(CLparticleLink_eventIndex->at(im), CLparticleLink_barcode->at(im))) { - auto dummyBarcode = concatInts(barcode, subevt); + SimBarcode dummyBarcode{concatInts(barcode, subevt)}; // If we don't find the particle, create one with default values if (particles.find(dummyBarcode) == particles.end()) { ACTS_VERBOSE("Particle with subevt " << subevt << ", barcode " diff --git a/Examples/Io/Root/src/RootParticleReader.cpp b/Examples/Io/Root/src/RootParticleReader.cpp index 0eafeaa666b..56c3dc16ab3 100644 --- a/Examples/Io/Root/src/RootParticleReader.cpp +++ b/Examples/Io/Root/src/RootParticleReader.cpp @@ -155,7 +155,7 @@ ProcessCode RootParticleReader::read(const AlgorithmContext& context) { p.setPdg(static_cast((*m_particleType).at(i))); p.setCharge((*m_q).at(i) * Acts::UnitConstants::e); p.setMass((*m_m).at(i) * Acts::UnitConstants::GeV); - p.setParticleId((*m_particleId).at(i)); + p.setParticleId(SimBarcode((*m_particleId).at(i))); SimParticleState& initialState = p.initial(); diff --git a/Examples/Io/Root/src/RootSimHitReader.cpp b/Examples/Io/Root/src/RootSimHitReader.cpp index 407c70c5dea..a3cc83b9a6c 100644 --- a/Examples/Io/Root/src/RootSimHitReader.cpp +++ b/Examples/Io/Root/src/RootSimHitReader.cpp @@ -146,8 +146,8 @@ ProcessCode RootSimHitReader::read(const AlgorithmContext& context) { break; } - const Acts::GeometryIdentifier geoid = m_uint64Columns.at("geometry_id"); - const SimBarcode pid = m_uint64Columns.at("particle_id"); + const Acts::GeometryIdentifier geoid{m_uint64Columns.at("geometry_id")}; + const SimBarcode pid{m_uint64Columns.at("particle_id")}; const auto index = m_int32Columns.at("index"); const Acts::Vector4 pos4 = { diff --git a/Examples/Io/Root/src/RootTrackSummaryReader.cpp b/Examples/Io/Root/src/RootTrackSummaryReader.cpp index 33da0026ef7..7dbd885ef23 100644 --- a/Examples/Io/Root/src/RootTrackSummaryReader.cpp +++ b/Examples/Io/Root/src/RootTrackSummaryReader.cpp @@ -217,7 +217,7 @@ ProcessCode RootTrackSummaryReader::read(const AlgorithmContext& context) { truthParticle.setPosition4((*m_t_vx)[i], (*m_t_vy)[i], (*m_t_vz)[i], (*m_t_time)[i]); truthParticle.setDirection((*m_t_px)[i], (*m_t_py)[i], (*m_t_pz)[i]); - truthParticle.setParticleId((*m_majorityParticleId)[i]); + truthParticle.setParticleId(SimBarcode{(*m_majorityParticleId)[i]}); truthParticleCollection.insert(truthParticleCollection.end(), SimParticle(truthParticle, truthParticle)); diff --git a/Examples/Io/Root/src/RootVertexReader.cpp b/Examples/Io/Root/src/RootVertexReader.cpp index d2d2848749d..a48d0e05ba4 100644 --- a/Examples/Io/Root/src/RootVertexReader.cpp +++ b/Examples/Io/Root/src/RootVertexReader.cpp @@ -126,7 +126,7 @@ ProcessCode RootVertexReader::read(const AlgorithmContext& context) { // TODO ingoing particles for (auto& id : (*m_outgoingParticles)[i]) { - v.outgoing.insert(static_cast(id)); + v.outgoing.insert(SimBarcode{id}); } vertices.insert(v); diff --git a/Examples/Io/Root/src/TrackFinderNTupleWriter.cpp b/Examples/Io/Root/src/TrackFinderNTupleWriter.cpp index 4b9aa94b4d0..6673f4caa55 100644 --- a/Examples/Io/Root/src/TrackFinderNTupleWriter.cpp +++ b/Examples/Io/Root/src/TrackFinderNTupleWriter.cpp @@ -208,8 +208,8 @@ struct TrackFinderNTupleWriter::Impl { for (const auto& phc : particleMatch.contributingParticles) { trkParticleId.push_back(phc.particleId.value()); // count total number of hits for this particle - auto trueParticleHits = makeRange( - particleMeasurementsMap.equal_range(phc.particleId.value())); + auto trueParticleHits = + makeRange(particleMeasurementsMap.equal_range(phc.particleId)); trkParticleNumHitsTotal.push_back(trueParticleHits.size()); trkParticleNumHitsOnTrack.push_back(phc.hitCount); } diff --git a/Examples/Io/Root/src/VertexNTupleWriter.cpp b/Examples/Io/Root/src/VertexNTupleWriter.cpp index affd046b564..76e494c7a45 100644 --- a/Examples/Io/Root/src/VertexNTupleWriter.cpp +++ b/Examples/Io/Root/src/VertexNTupleWriter.cpp @@ -295,7 +295,8 @@ ProcessCode VertexNTupleWriter::writeT( const TrackMatchEntry& particleMatch = imatched->second; - auto iparticle = particles.find(particleMatch.particle->value()); + auto iparticle = + particles.find(SimBarcode{particleMatch.particle->value()}); if (iparticle == particles.end()) { ACTS_DEBUG( "Truth particle found but not monitored with this track, index = " diff --git a/Examples/Io/Svg/include/ActsExamples/Io/Svg/SvgPointWriter.hpp b/Examples/Io/Svg/include/ActsExamples/Io/Svg/SvgPointWriter.hpp index 8695fe2e7f1..b87a4b8c620 100644 --- a/Examples/Io/Svg/include/ActsExamples/Io/Svg/SvgPointWriter.hpp +++ b/Examples/Io/Svg/include/ActsExamples/Io/Svg/SvgPointWriter.hpp @@ -105,8 +105,8 @@ class SvgPointWriter final : public WriterT> { s_backgroundTrackingGeometryOptions; }; - SvgPointWriter(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); + explicit SvgPointWriter(const Config& cfg, + Acts::Logging::Level level = Acts::Logging::INFO); protected: ActsExamples::ProcessCode writeT( diff --git a/Examples/Python/src/Blueprint.cpp b/Examples/Python/src/Blueprint.cpp index 957bc374463..7a965fd1a41 100644 --- a/Examples/Python/src/Blueprint.cpp +++ b/Examples/Python/src/Blueprint.cpp @@ -10,7 +10,7 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/Geometry/BlueprintNode.hpp" -#include "Acts/Geometry/CylinderContainerBlueprintNode.hpp" +#include "Acts/Geometry/ContainerBlueprintNode.hpp" #include "Acts/Geometry/CylinderVolumeStack.hpp" #include "Acts/Geometry/LayerBlueprintNode.hpp" #include "Acts/Geometry/MaterialDesignatorBlueprintNode.hpp" @@ -214,6 +214,7 @@ void addBlueprint(Context& ctx) { using Acts::Experimental::Blueprint; using Acts::Experimental::BlueprintNode; using Acts::Experimental::BlueprintOptions; + using Acts::Experimental::CuboidContainerBlueprintNode; using Acts::Experimental::CylinderContainerBlueprintNode; using Acts::Experimental::LayerBlueprintNode; using Acts::Experimental::MaterialDesignatorBlueprintNode; @@ -372,6 +373,37 @@ void addBlueprint(Context& ctx) { }, py::arg("name"), py::arg("direction")); + auto boxNode = + py::class_>( + m, "CuboidContainerBlueprintNode") + .def(py::init(), + py::arg("name"), py::arg("direction"), + py::arg("attachmentStrategy") = VolumeAttachmentStrategy::Gap, + py::arg("resizeStrategy") = VolumeResizeStrategy::Gap) + .def_property("attachmentStrategy", + &CuboidContainerBlueprintNode::attachmentStrategy, + &CuboidContainerBlueprintNode::setAttachmentStrategy) + .def_property("resizeStrategy", + &CuboidContainerBlueprintNode::resizeStrategy, + &CuboidContainerBlueprintNode::setResizeStrategy) + .def_property("direction", &CuboidContainerBlueprintNode::direction, + &CuboidContainerBlueprintNode::setDirection); + + addContextManagerProtocol(boxNode); + + addNodeMethods( + "CuboidContainer", + [](BlueprintNode& self, const std::string& name, + AxisDirection direction) { + auto cylinder = + std::make_shared(name, direction); + self.addChild(cylinder); + return cylinder; + }, + py::arg("name"), py::arg("direction")); + auto matNode = py::class_>( diff --git a/Examples/Python/src/EventData.cpp b/Examples/Python/src/EventData.cpp index 3f8cfa50342..01643473349 100644 --- a/Examples/Python/src/EventData.cpp +++ b/Examples/Python/src/EventData.cpp @@ -25,12 +25,16 @@ void addEventData(Context& ctx) { auto [m, mex] = ctx.get("main", "examples"); py::class_(m, "ParticleHypothesis") - .def(py::init(), py::arg("pdg"), - py::arg("mass"), py::arg("absCharge")) + .def(py::init([](Acts::PdgParticle absPdg, float mass, float absCharge) { + return Acts::ParticleHypothesis(absPdg, mass, + AnyCharge{absCharge}); + }), + py::arg("pdg"), py::arg("mass"), py::arg("absCharge")) .def(py::init([](std::underlying_type_t absPdg, float mass, float absCharge) { return Acts::ParticleHypothesis( - static_cast(absPdg), mass, absCharge); + static_cast(absPdg), mass, + AnyCharge{absCharge}); }), py::arg("absPdg"), py::arg("mass"), py::arg("absCharge")) .def("__str__", diff --git a/Examples/Python/tests/root_file_hashes.txt b/Examples/Python/tests/root_file_hashes.txt index 25f1f003598..0c210afc9ec 100644 --- a/Examples/Python/tests/root_file_hashes.txt +++ b/Examples/Python/tests/root_file_hashes.txt @@ -24,9 +24,9 @@ test_truth_tracking_gsf[odd]__trackstates_gsf.root: 4691352f2f83a15f96336705a746 test_truth_tracking_gsf[odd]__tracksummary_gsf.root: 4562341f12a61ea0d5e25872b6bf466b79a73781dc95fc18ef9c6515f0a47916 test_particle_gun__particles.root: 669d0304eb8bcf244aa627809a117944e5e3b994fdfcfb8710f2b9a8f9a62d3b test_material_mapping__material-map_tracks.root: 938b1a855369e9304401cb10d2751df3fd7acf32a2573f2057eb1691cd94edf3 -test_material_mapping__propagation-material.root: e2b4eade0d8124c03c89e01bf6ff5029dd12e3c9efc0a19c22a12c5cd2800e77 +test_material_mapping__propagation-material.root: bae7fa81caa5a335cd72236495e04bf3cb65a9e3d18b993f21d41539f65df8a3 test_volume_material_mapping__material-map-volume_tracks.root: 98e212d32ca054fa3d01af4167c1f49755a139d43b82c57908197f5985e0a4ff -test_volume_material_mapping__propagation-volume-material.root: 42bb2fd9c50d44210c914e487903bbdef65a0491f0a85a7159c0e078ac983a80 +test_volume_material_mapping__propagation-volume-material.root: f5a65b6ce788ebd1f44c24fbec2baada99169b85c602a4d9036aaf2eba291c36 test_digitization_example[smeared]__measurements.root: a7980ac0186c772a2792045ca2aea6e2277f1a574ea0c6df7b0f84538f10f66f test_digitization_example[geometric]__measurements.root: 9051599b058e3637672166c10df4881d905fdb1b1d7e096b359252845ac4bb27 test_digitization_example_input[smeared]__particles.root: 669d0304eb8bcf244aa627809a117944e5e3b994fdfcfb8710f2b9a8f9a62d3b diff --git a/Fatras/include/ActsFatras/EventData/Particle.hpp b/Fatras/include/ActsFatras/EventData/Particle.hpp index fbf9244fcea..748e0b45f43 100644 --- a/Fatras/include/ActsFatras/EventData/Particle.hpp +++ b/Fatras/include/ActsFatras/EventData/Particle.hpp @@ -167,7 +167,9 @@ class Particle { /// Particle hypothesis. Acts::ParticleHypothesis hypothesis() const { - return Acts::ParticleHypothesis(absolutePdg(), mass(), absoluteCharge()); + return Acts::ParticleHypothesis( + absolutePdg(), static_cast(mass()), + Acts::AnyCharge{static_cast(absoluteCharge())}); } /// Particl qOverP. double qOverP() const { diff --git a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBlueprintFactory.hpp b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBlueprintFactory.hpp index 7eebf334484..e4edd0816a5 100644 --- a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBlueprintFactory.hpp +++ b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBlueprintFactory.hpp @@ -50,10 +50,10 @@ class DD4hepBlueprintFactory { /// /// @param cfg the config object /// @param mlogger the logging instance - DD4hepBlueprintFactory(const Config& cfg, - std::unique_ptr mlogger = - getDefaultLogger("DD4hepBlueprintFactory", - Acts::Logging::INFO)); + explicit DD4hepBlueprintFactory(const Config& cfg, + std::unique_ptr mlogger = + getDefaultLogger("DD4hepBlueprintFactory", + Acts::Logging::INFO)); /// @brief Create a blueprint from a DD4hep detector element /// diff --git a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp index 0dd6788c315..4ad8aa6226b 100644 --- a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp +++ b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp @@ -77,7 +77,7 @@ class DD4hepDetectorElement : public TGeoDetectorElement { /// TGeoTubeSeg should be translated to a disc surface. Per default it /// will be translated into a cylindrical surface. /// @param material Optional material of detector element - DD4hepDetectorElement( + explicit DD4hepDetectorElement( const dd4hep::DetElement detElement, const std::string& axes = "XYZ", double scalor = 1., bool isDisc = false, std::shared_ptr material = nullptr); diff --git a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepLayerStructure.hpp b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepLayerStructure.hpp index 31c0d6889c4..25b9151e15a 100644 --- a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepLayerStructure.hpp +++ b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepLayerStructure.hpp @@ -44,7 +44,7 @@ class DD4hepLayerStructure { /// @param logger is the screen output logger /// /// @note this needs to be provided - DD4hepLayerStructure( + explicit DD4hepLayerStructure( std::shared_ptr surfaceFactory, std::unique_ptr logger = getDefaultLogger("DD4hepLayerStructure", Acts::Logging::INFO)); diff --git a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionUtils.hpp b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionUtils.hpp index 7adc9bbe3f0..930ed4ec942 100644 --- a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionUtils.hpp +++ b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionUtils.hpp @@ -36,7 +36,8 @@ struct Cache { /// Explicit constructor with detector volumes /// /// @param detectorVolumes the number of detector volumes - Cache(const std::vector& dVolumes) + explicit Cache( + const std::vector& dVolumes) : detectorVolumes(dVolumes) {} /// The volumes of the detector for index lookup diff --git a/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp b/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp index e4836862769..279671f8d72 100644 --- a/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp +++ b/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp @@ -170,7 +170,7 @@ void writeTrack(const Acts::GeometryContext& gctx, track_proxy_t track, } template -void readTrack(const edm4hep::Track& from, track_proxy_t track, double Bz, +void readTrack(const edm4hep::Track& from, track_proxy_t& track, double Bz, const Logger& logger = getDummyLogger()) { ACTS_VERBOSE("Reading track from EDM4hep"); TrackStatePropMask mask = TrackStatePropMask::Smoothed; diff --git a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4PhysicalVolumeSelectors.hpp b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4PhysicalVolumeSelectors.hpp index fd05274a34d..068eeffa591 100644 --- a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4PhysicalVolumeSelectors.hpp +++ b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4PhysicalVolumeSelectors.hpp @@ -46,7 +46,7 @@ struct NameSelector : public IGeant4PhysicalVolumeSelector { /// Constructor with arguments /// @param ns the provided list of names /// @param e whether to select them exact or not - NameSelector(const std::vector& ns, bool e = false) + explicit NameSelector(const std::vector& ns, bool e = false) : names(ns), exact(e) {} /// Secect function for the volume diff --git a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4SurfaceProvider.hpp b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4SurfaceProvider.hpp index de73cb6466d..d775b61b8b8 100644 --- a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4SurfaceProvider.hpp +++ b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4SurfaceProvider.hpp @@ -88,8 +88,8 @@ class Geant4SurfaceProvider : public Acts::Experimental::ISurfacesProvider { /// Constructor /// @param config The configuration struct /// @param options The optional configuration for KDTree - Geant4SurfaceProvider(const Config& config, - const kdtOptions& options = kdtOptions()) { + explicit Geant4SurfaceProvider(const Config& config, + const kdtOptions& options = kdtOptions()) { if (config.g4World == nullptr) { throw std::invalid_argument( "Geant4SurfaceProvider: No World volume provided"); diff --git a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelBlueprintCreater.hpp b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelBlueprintCreater.hpp index 7eb2e7a94f6..69a8e0e0642 100644 --- a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelBlueprintCreater.hpp +++ b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelBlueprintCreater.hpp @@ -98,10 +98,10 @@ class GeoModelBlueprintCreater { /// /// @param cfg the configuration struct /// @param mlogger a screen output logger - GeoModelBlueprintCreater(const Config& cfg, - std::unique_ptr mlogger = - getDefaultLogger("GeoModelBlueprintCreater", - Acts::Logging::INFO)); + explicit GeoModelBlueprintCreater( + const Config& cfg, + std::unique_ptr mlogger = + getDefaultLogger("GeoModelBlueprintCreater", Acts::Logging::INFO)); /// Method that reads the GeoModel blueprint from database /// diff --git a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorObjectFactory.hpp b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorObjectFactory.hpp index 6fa0e9ccf02..35b9d1b177b 100644 --- a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorObjectFactory.hpp +++ b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorObjectFactory.hpp @@ -53,7 +53,7 @@ class GeoModelDetectorObjectFactory { std::vector boundingBoxes; }; - GeoModelDetectorObjectFactory( + explicit GeoModelDetectorObjectFactory( const Config& cfg, std::unique_ptr mlogger = getDefaultLogger( "GeoModelDetectorObjectFactory", Acts::Logging::WARNING)); diff --git a/Plugins/Json/include/Acts/Plugins/Json/GeometryHierarchyMapJsonConverter.hpp b/Plugins/Json/include/Acts/Plugins/Json/GeometryHierarchyMapJsonConverter.hpp index c1203cd02a8..b538d0e4e70 100644 --- a/Plugins/Json/include/Acts/Plugins/Json/GeometryHierarchyMapJsonConverter.hpp +++ b/Plugins/Json/include/Acts/Plugins/Json/GeometryHierarchyMapJsonConverter.hpp @@ -194,7 +194,7 @@ auto GeometryHierarchyMapJsonConverter::fromJson( auto value = entry.at("value").get(); elements.emplace_back(id, std::move(value)); } - return elements; + return Container(std::move(elements)); } } // namespace Acts diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioDynamicColumns.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioDynamicColumns.hpp index 295937efe7e..44b83767b25 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioDynamicColumns.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioDynamicColumns.hpp @@ -68,8 +68,8 @@ struct DynamicColumnBase : public ConstDynamicColumnBase { template struct DynamicColumn : public DynamicColumnBase { - DynamicColumn(std::string_view name, - podio::UserDataCollection collection = {}) + explicit DynamicColumn(std::string_view name, + podio::UserDataCollection collection = {}) : DynamicColumnBase(name), m_collection{std::move(collection)} {} std::any get(std::size_t i) override { return &m_collection.vec().at(i); } diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp index 442b36968b4..6de6bde9f72 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp @@ -63,7 +63,7 @@ class PodioTrackContainerBase { typename detail_lt::FixedSizeTypes::CovarianceMap; protected: - PodioTrackContainerBase(const PodioUtil::ConversionHelper& helper) + explicit PodioTrackContainerBase(const PodioUtil::ConversionHelper& helper) : m_helper{helper} {} template @@ -136,7 +136,7 @@ class PodioTrackContainerBase { auto track = instance.m_collection->at(itrack); const auto& src = track.getParticleHypothesis(); return ParticleHypothesis{static_cast(src.absPdg), src.mass, - src.absQ}; + AnyCharge{src.absQ}}; } static void populateSurfaceBuffer( @@ -156,7 +156,7 @@ class PodioTrackContainerBase { class MutablePodioTrackContainer : public PodioTrackContainerBase { public: - MutablePodioTrackContainer(const PodioUtil::ConversionHelper& helper) + explicit MutablePodioTrackContainer(const PodioUtil::ConversionHelper& helper) : PodioTrackContainerBase{helper}, m_collection{std::make_unique()} { populateSurfaceBuffer(m_helper, *m_collection, m_surfaces); @@ -165,7 +165,7 @@ class MutablePodioTrackContainer : public PodioTrackContainerBase { MutablePodioTrackContainer(const MutablePodioTrackContainer& other); MutablePodioTrackContainer(MutablePodioTrackContainer&& other) = default; - MutablePodioTrackContainer(const ConstPodioTrackContainer& other); + explicit MutablePodioTrackContainer(const ConstPodioTrackContainer& other); // BEGIN INTERFACE HELPER diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp index 2a5d1b799bf..a5a2e5f2bee 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp @@ -207,7 +207,8 @@ class ConstPodioTrackStateContainer final /// @warning If the source mutable container is modified, this container /// will be corrupted, as surface buffer and dynamic column state can /// not be synchronized! - ConstPodioTrackStateContainer(const MutablePodioTrackStateContainer& other); + explicit ConstPodioTrackStateContainer( + const MutablePodioTrackStateContainer& other); ConstPodioTrackStateContainer(const PodioUtil::ConversionHelper& helper, const podio::Frame& frame, @@ -356,7 +357,7 @@ class MutablePodioTrackStateContainer final : public PodioTrackStateContainerBase, public MultiTrajectory { public: - MutablePodioTrackStateContainer(PodioUtil::ConversionHelper& helper) + explicit MutablePodioTrackStateContainer(PodioUtil::ConversionHelper& helper) : m_helper{helper} { m_collection = std::make_unique(); m_jacs = std::make_unique(); diff --git a/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoCylinderDiscSplitter.hpp b/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoCylinderDiscSplitter.hpp index 24a21320619..45f59801fdd 100644 --- a/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoCylinderDiscSplitter.hpp +++ b/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoCylinderDiscSplitter.hpp @@ -43,7 +43,7 @@ class TGeoCylinderDiscSplitter : public ITGeoDetectorElementSplitter { /// /// @param cfg the configuration struct /// @param logger the logging object - TGeoCylinderDiscSplitter( + explicit TGeoCylinderDiscSplitter( const Config& cfg, std::unique_ptr logger = Acts::getDefaultLogger( "TGeoCylinderDiscSplitter", Acts::Logging::INFO)); diff --git a/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoLayerBuilder.hpp b/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoLayerBuilder.hpp index bf2eb7e9916..41d5dea5151 100644 --- a/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoLayerBuilder.hpp +++ b/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoLayerBuilder.hpp @@ -133,9 +133,10 @@ class TGeoLayerBuilder : public ILayerBuilder { /// Constructor /// @param config is the configuration struct /// @param logger the local logging instance - TGeoLayerBuilder(const Config& config, - std::unique_ptr logger = - getDefaultLogger("TGeoLayerBuilder", Logging::INFO)); + explicit TGeoLayerBuilder(const Config& config, + std::unique_ptr logger = + getDefaultLogger("TGeoLayerBuilder", + Logging::INFO)); /// Destructor ~TGeoLayerBuilder() override; diff --git a/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/CubicTrackingGeometry.hpp b/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/CubicTrackingGeometry.hpp index 9967d1b9750..fa51bcd1652 100644 --- a/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/CubicTrackingGeometry.hpp +++ b/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/CubicTrackingGeometry.hpp @@ -37,7 +37,8 @@ struct CubicTrackingGeometry { /// Default constructor for the Cubic tracking geometry /// /// @param gctx the geometry context for this geometry at building time - CubicTrackingGeometry(const GeometryContext& gctx) : geoContext(gctx) { + explicit CubicTrackingGeometry(const GeometryContext& gctx) + : geoContext(gctx) { using namespace UnitLiterals; // Construct the rotation diff --git a/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp b/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp index 84e51027a6e..de20beabcf7 100644 --- a/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp +++ b/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp @@ -45,7 +45,8 @@ struct CylindricalTrackingGeometry { std::reference_wrapper geoContext; /// Only allowed constructor with reference wrapper - CylindricalTrackingGeometry(const GeometryContext& gctx) : geoContext(gctx) {} + explicit CylindricalTrackingGeometry(const GeometryContext& gctx) + : geoContext(gctx) {} using DetectorStore = std::vector>; diff --git a/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/DetectorElementStub.hpp b/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/DetectorElementStub.hpp index 4f6b0d5ce79..5a7012b8ae8 100644 --- a/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/DetectorElementStub.hpp +++ b/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/DetectorElementStub.hpp @@ -33,7 +33,7 @@ class DetectorElementStub : public DetectorElementBase { public: DetectorElementStub() : DetectorElementBase() {} - DetectorElementStub(const Transform3& transform) + explicit DetectorElementStub(const Transform3& transform) : DetectorElementBase(), m_elementTransform(transform) {} /// Constructor for single sided detector element diff --git a/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/LineSurfaceStub.hpp b/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/LineSurfaceStub.hpp index 662969bc450..bdc71c44d10 100644 --- a/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/LineSurfaceStub.hpp +++ b/Tests/CommonHelpers/include/Acts/Tests/CommonHelpers/LineSurfaceStub.hpp @@ -21,8 +21,8 @@ class LineSurfaceStub : public LineSurface { LineSurfaceStub(const Transform3& htrans, double radius, double halfz) : GeometryObject(), LineSurface(htrans, radius, halfz) { /* nop */ } // - LineSurfaceStub(const Transform3& htrans, - std::shared_ptr lbounds = nullptr) + explicit LineSurfaceStub(const Transform3& htrans, + std::shared_ptr lbounds = nullptr) : GeometryObject(), LineSurface(htrans, std::move(lbounds)) { /*nop */ } // LineSurfaceStub(std::shared_ptr lbounds, diff --git a/Tests/IntegrationTests/InterpolatedSolenoidBFieldTest.cpp b/Tests/IntegrationTests/InterpolatedSolenoidBFieldTest.cpp index 9bfd63e6a88..341ac708ada 100644 --- a/Tests/IntegrationTests/InterpolatedSolenoidBFieldTest.cpp +++ b/Tests/IntegrationTests/InterpolatedSolenoidBFieldTest.cpp @@ -82,7 +82,7 @@ auto bFieldMap = makeFieldMap(bSolenoidField); auto bCache = bFieldMap.makeCache(Acts::MagneticFieldContext{}); struct StreamWrapper { - StreamWrapper(std::ofstream ofstr) : m_ofstr(std::move(ofstr)) { + explicit StreamWrapper(std::ofstream ofstr) : m_ofstr(std::move(ofstr)) { m_ofstr << "x;y;z;B_x;B_y;B_z;Bm_x;Bm_y;Bm_z" << std::endl; } diff --git a/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp b/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp index 86d668b5beb..5f51e61b6cb 100644 --- a/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp +++ b/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp @@ -93,7 +93,7 @@ struct TelescopeDetector { /// Default constructor for the Cubic tracking geometry /// /// @param gctx the geometry context for this geometry at building time - TelescopeDetector(std::reference_wrapper gctx) + explicit TelescopeDetector(std::reference_wrapper gctx) : geoContext(gctx) { // Construct the rotation rotation.col(0) = Acts::Vector3(0, 0, -1); diff --git a/Tests/UnitTests/Core/Clusterization/ClusterizationTests1D.cpp b/Tests/UnitTests/Core/Clusterization/ClusterizationTests1D.cpp index 1d30f88e646..92737093295 100644 --- a/Tests/UnitTests/Core/Clusterization/ClusterizationTests1D.cpp +++ b/Tests/UnitTests/Core/Clusterization/ClusterizationTests1D.cpp @@ -23,7 +23,7 @@ namespace Acts::Test { struct Cell1D { - Cell1D(int colv) : col(colv) {} + explicit Cell1D(int colv) : col(colv) {} int col; Ccl::Label label{Ccl::NO_LABEL}; }; diff --git a/Tests/UnitTests/Core/Detector/DetectorBuilderTests.cpp b/Tests/UnitTests/Core/Detector/DetectorBuilderTests.cpp index 784fc8d6d37..534de028388 100644 --- a/Tests/UnitTests/Core/Detector/DetectorBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/DetectorBuilderTests.cpp @@ -33,7 +33,7 @@ class CompBuilder final : public Acts::Experimental::IDetectorComponentBuilder { public: - CompBuilder( + explicit CompBuilder( const std::vector>& sensitives = {}) : m_sensitives(sensitives) {} diff --git a/Tests/UnitTests/Core/Detector/PortalTests.cpp b/Tests/UnitTests/Core/Detector/PortalTests.cpp index 46a0558db9d..b80d7950f85 100644 --- a/Tests/UnitTests/Core/Detector/PortalTests.cpp +++ b/Tests/UnitTests/Core/Detector/PortalTests.cpp @@ -39,7 +39,7 @@ class LinkToVolumeImpl : public IExternalNavigation { std::shared_ptr dVolume = nullptr; /// Constructor from volume - LinkToVolumeImpl(std::shared_ptr dv) + explicit LinkToVolumeImpl(std::shared_ptr dv) : dVolume(std::move(dv)) {} /// @return the link to the contained volume diff --git a/Tests/UnitTests/Core/EventData/MultiTrajectoryTests.cpp b/Tests/UnitTests/Core/EventData/MultiTrajectoryTests.cpp index 421fcc3c62f..4f7c4225fdb 100644 --- a/Tests/UnitTests/Core/EventData/MultiTrajectoryTests.cpp +++ b/Tests/UnitTests/Core/EventData/MultiTrajectoryTests.cpp @@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(ConstCorrectness) { { VectorMultiTrajectory::TrackStateProxy tsp = t.getTrackState(i0); static_cast(tsp); - VectorMultiTrajectory::ConstTrackStateProxy ctsp = t.getTrackState(i0); + VectorMultiTrajectory::ConstTrackStateProxy ctsp{t.getTrackState(i0)}; static_cast(ctsp); tsp.predicted().setRandom(); @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(ConstCorrectness) { } // is this something we actually want? - ConstVectorMultiTrajectory ct = t; + ConstVectorMultiTrajectory ct{t}; BOOST_CHECK_EQUAL(ct.size(), t.size()); ConstVectorMultiTrajectory ctm{std::move(t)}; diff --git a/Tests/UnitTests/Core/EventData/SpacePointContainerEdmTests.cpp b/Tests/UnitTests/Core/EventData/SpacePointContainerEdmTests.cpp index 7ca20985499..6b33a9843c8 100644 --- a/Tests/UnitTests/Core/EventData/SpacePointContainerEdmTests.cpp +++ b/Tests/UnitTests/Core/EventData/SpacePointContainerEdmTests.cpp @@ -41,7 +41,7 @@ class Adapter { using ValueType = value_type; Adapter(SpacePointCollection&&) = delete; - Adapter(const SpacePointCollection& externalCollection) + explicit Adapter(const SpacePointCollection& externalCollection) : m_storage(&externalCollection) {} private: diff --git a/Tests/UnitTests/Core/Geometry/AlignmentContextTests.cpp b/Tests/UnitTests/Core/Geometry/AlignmentContextTests.cpp index 382bb8a0075..3c58620a231 100644 --- a/Tests/UnitTests/Core/Geometry/AlignmentContextTests.cpp +++ b/Tests/UnitTests/Core/Geometry/AlignmentContextTests.cpp @@ -40,8 +40,9 @@ struct AlignmentContext { AlignmentContext() = default; /// Constructor with Store and context index - AlignmentContext(std::shared_ptr> aStore, - unsigned int aIndex = 0) + explicit AlignmentContext( + std::shared_ptr> aStore, + unsigned int aIndex = 0) : alignmentStore(std::move(aStore)), alignmentIndex(aIndex) {} }; diff --git a/Tests/UnitTests/Core/Geometry/BlueprintApiTests.cpp b/Tests/UnitTests/Core/Geometry/BlueprintApiTests.cpp index b1d1a7b7116..e14fce3977f 100644 --- a/Tests/UnitTests/Core/Geometry/BlueprintApiTests.cpp +++ b/Tests/UnitTests/Core/Geometry/BlueprintApiTests.cpp @@ -14,7 +14,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Units.hpp" #include "Acts/Geometry/Blueprint.hpp" -#include "Acts/Geometry/CylinderContainerBlueprintNode.hpp" +#include "Acts/Geometry/ContainerBlueprintNode.hpp" #include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/CylinderVolumeStack.hpp" #include "Acts/Geometry/GeometryContext.hpp" diff --git a/Tests/UnitTests/Core/Geometry/BlueprintTests.cpp b/Tests/UnitTests/Core/Geometry/BlueprintTests.cpp index c3f87aadae0..5939624eda2 100644 --- a/Tests/UnitTests/Core/Geometry/BlueprintTests.cpp +++ b/Tests/UnitTests/Core/Geometry/BlueprintTests.cpp @@ -14,7 +14,7 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/Geometry/Blueprint.hpp" #include "Acts/Geometry/BlueprintNode.hpp" -#include "Acts/Geometry/CylinderContainerBlueprintNode.hpp" +#include "Acts/Geometry/ContainerBlueprintNode.hpp" #include "Acts/Geometry/CylinderVolumeBounds.hpp" #include "Acts/Geometry/CylinderVolumeStack.hpp" #include "Acts/Geometry/GeometryContext.hpp" diff --git a/Tests/UnitTests/Core/Geometry/GeometryIdentifierTests.cpp b/Tests/UnitTests/Core/Geometry/GeometryIdentifierTests.cpp index acb43389209..cf1d7b2ba27 100644 --- a/Tests/UnitTests/Core/Geometry/GeometryIdentifierTests.cpp +++ b/Tests/UnitTests/Core/Geometry/GeometryIdentifierTests.cpp @@ -24,7 +24,7 @@ BOOST_AUTO_TEST_CASE(GeometryIdentifier_construct_default) { BOOST_AUTO_TEST_CASE(GeometryIdentifier_construct_encoded) { // not sure if it is a good idea to test for the encoding since it should be // an implementation detail. only the resulting functionality is relevant. - GeometryIdentifier id = 0xa0b00c00d00affe0u; + GeometryIdentifier id{0xa0b00c00d00affe0u}; BOOST_CHECK_EQUAL(id.volume(), 0xa0u); BOOST_CHECK_EQUAL(id.boundary(), 0xb0u); BOOST_CHECK_EQUAL(id.layer(), 0x0c0u); @@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(GeometryIdentifier_max_values) { constexpr GeometryIdentifier::Value sensitiveMax = (1u << 20) - 1; constexpr GeometryIdentifier::Value extraMax = (1u << 8) - 1; // reference values non-zero values everywhere - constexpr GeometryIdentifier ref = 0xdeadaffe01234567; + constexpr GeometryIdentifier ref{0xdeadaffe01234567}; // values above the maximum are truncated // max+1 has all available bits zeroed BOOST_CHECK_THROW( diff --git a/Tests/UnitTests/Core/Geometry/LayerStub.hpp b/Tests/UnitTests/Core/Geometry/LayerStub.hpp index a6eb0dbca1b..1b95fb2f8b6 100644 --- a/Tests/UnitTests/Core/Geometry/LayerStub.hpp +++ b/Tests/UnitTests/Core/Geometry/LayerStub.hpp @@ -24,9 +24,10 @@ class LayerStub : virtual public SurfaceStub, public Layer { /// copy constructor (deleted in Surface baseclass) LayerStub(const LayerStub& otherLayer) = delete; /// constructor with pointer to SurfaceArray (protected in Layer baseclass) - LayerStub(std::unique_ptr surfaceArray, double thickness = 0, - std::unique_ptr ad = nullptr, - LayerType ltype = passive) + explicit LayerStub(std::unique_ptr surfaceArray, + double thickness = 0, + std::unique_ptr ad = nullptr, + LayerType ltype = passive) : SurfaceStub(), Layer(std::move(surfaceArray), thickness, std::move(ad), ltype) {} diff --git a/Tests/UnitTests/Core/Geometry/TrackingGeometryClosureTests.cpp b/Tests/UnitTests/Core/Geometry/TrackingGeometryClosureTests.cpp index 19293c2fc93..c7fcab7d343 100644 --- a/Tests/UnitTests/Core/Geometry/TrackingGeometryClosureTests.cpp +++ b/Tests/UnitTests/Core/Geometry/TrackingGeometryClosureTests.cpp @@ -194,7 +194,7 @@ template struct CallableHook : public Acts::GeometryIdentifierHook { Callable callable; - CallableHook(const Callable& c) : callable(c) {} + explicit CallableHook(const Callable& c) : callable(c) {} Acts::GeometryIdentifier decorateIdentifier( Acts::GeometryIdentifier identifier, diff --git a/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp b/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp index 898e9229ea6..809046d4048 100644 --- a/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp +++ b/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp @@ -36,7 +36,7 @@ class GlobalToZPhi final : public Acts::GridAccess::IGlobalToGridLocal { public: double zShift = 0.; - GlobalToZPhi(double shift) : zShift(shift) {} + explicit GlobalToZPhi(double shift) : zShift(shift) {} std::array g2ZPhi(const Acts::Vector3& global) const { return {global.z() + zShift, Acts::VectorHelpers::phi(global)}; @@ -48,7 +48,7 @@ class LocalToZPhi final : public Acts::GridAccess::IBoundToGridLocal { public: double radius = 1.; - LocalToZPhi(double r) : radius(r) {} + explicit LocalToZPhi(double r) : radius(r) {} std::array l2ZPhi(const Acts::Vector2& local) const { return {local[1u], local[0u] / radius}; diff --git a/Tests/UnitTests/Core/Material/MaterialMapperTests.cpp b/Tests/UnitTests/Core/Material/MaterialMapperTests.cpp index c3debc42bce..5d93b9192b6 100644 --- a/Tests/UnitTests/Core/Material/MaterialMapperTests.cpp +++ b/Tests/UnitTests/Core/Material/MaterialMapperTests.cpp @@ -84,7 +84,8 @@ class IntersectSurfacesFinder : public IAssignmentFinder { /// @brief Interface for the material mapping, this is the accumulation step class MaterialBlender : public ISurfaceMaterialAccumulater { public: - MaterialBlender(const std::vector>& surfaces = {}) + explicit MaterialBlender( + const std::vector>& surfaces = {}) : m_surfaces(surfaces) {} /// The state of the material accumulater, this is used diff --git a/Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp b/Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp index f801939c418..3e55644bedf 100644 --- a/Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp +++ b/Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp @@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE(DetectorNavigatorTestsInitialization) { "volume", Acts::Transform3::Identity(), std::move(bounds), {}, {}, Acts::Experimental::tryNoVolumes(), Acts::Experimental::tryAllPortalsAndSurfaces()); - volume->assignGeometryId(1); + volume->assignGeometryId(Acts::GeometryIdentifier(1)); auto detector = Acts::Experimental::Detector::makeShared( "detector", {volume}, Acts::Experimental::tryRootVolumes()); @@ -257,21 +257,21 @@ BOOST_AUTO_TEST_CASE(DetectorNavigatorTestsForwardBackward) { // Volume ids: 1-3 for (auto& volume : detectorVolumes) { - volume->assignGeometryId(id); + volume->assignGeometryId(Acts::GeometryIdentifier(id)); id++; } // Intervolume portal ids: 6,7,10,11 for (auto& volume : detectorVolumes) { for (auto& port : volume->portalPtrs()) { - if (port->surface().geometryId() == 0) { - port->surface().assignGeometryId(id); + if (port->surface().geometryId() == Acts::GeometryIdentifier(0)) { + port->surface().assignGeometryId(Acts::GeometryIdentifier(id)); id++; } } } // Surface ids: 12-14 for (auto& surf : {surface1, surface2, surface3}) { - surf->assignGeometryId(id); + surf->assignGeometryId(Acts::GeometryIdentifier(id)); id++; } @@ -330,42 +330,54 @@ BOOST_AUTO_TEST_CASE(DetectorNavigatorTestsForwardBackward) { // Action list call before the first step // Starting in the volume1 - BOOST_CHECK_EQUAL(statesFwd[0].currentVolume->geometryId(), 1); + BOOST_CHECK_EQUAL(statesFwd[0].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); BOOST_CHECK_EQUAL(statesFwd[0].currentSurface, nullptr); BOOST_CHECK_EQUAL(statesFwd[0].currentPortal, nullptr); // Step to the surface inside volume1 - BOOST_CHECK_EQUAL(statesFwd[1].currentVolume->geometryId(), 1); - BOOST_CHECK_EQUAL(statesFwd[1].currentSurface->geometryId(), 12); + BOOST_CHECK_EQUAL(statesFwd[1].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); + BOOST_CHECK_EQUAL(statesFwd[1].currentSurface->geometryId(), + Acts::GeometryIdentifier(12)); BOOST_CHECK_EQUAL(statesFwd[1].currentPortal, nullptr); // Step to the volume1|volume2 boundary (portal has witched volume id) - BOOST_CHECK_EQUAL(statesFwd[2].currentVolume->geometryId(), 2); + BOOST_CHECK_EQUAL(statesFwd[2].currentVolume->geometryId(), + Acts::GeometryIdentifier(2)); BOOST_CHECK_EQUAL(statesFwd[2].currentSurface, &(statesFwd[2].currentPortal->surface())); - BOOST_CHECK_EQUAL(statesFwd[2].currentPortal->surface().geometryId(), 7); + BOOST_CHECK_EQUAL(statesFwd[2].currentPortal->surface().geometryId(), + Acts::GeometryIdentifier(7)); // Step to the surface inside volume2 - BOOST_CHECK_EQUAL(statesFwd[3].currentVolume->geometryId(), 2); - BOOST_CHECK_EQUAL(statesFwd[3].currentSurface->geometryId(), 13); + BOOST_CHECK_EQUAL(statesFwd[3].currentVolume->geometryId(), + Acts::GeometryIdentifier(2)); + BOOST_CHECK_EQUAL(statesFwd[3].currentSurface->geometryId(), + Acts::GeometryIdentifier(13)); BOOST_CHECK_EQUAL(statesFwd[3].currentPortal, nullptr); // Step to the volume2|volume3 boundary - volume has switched - BOOST_CHECK_EQUAL(statesFwd[4].currentVolume->geometryId(), 3); + BOOST_CHECK_EQUAL(statesFwd[4].currentVolume->geometryId(), + Acts::GeometryIdentifier(3)); BOOST_CHECK_EQUAL(statesFwd[4].currentSurface, &(statesFwd[4].currentPortal->surface())); - BOOST_CHECK_EQUAL(statesFwd[4].currentPortal->surface().geometryId(), 10); + BOOST_CHECK_EQUAL(statesFwd[4].currentPortal->surface().geometryId(), + Acts::GeometryIdentifier(10)); // Step to the surface inside volume3 - BOOST_CHECK_EQUAL(statesFwd[5].currentVolume->geometryId(), 3); - BOOST_CHECK_EQUAL(statesFwd[5].currentSurface->geometryId(), 14); + BOOST_CHECK_EQUAL(statesFwd[5].currentVolume->geometryId(), + Acts::GeometryIdentifier(3)); + BOOST_CHECK_EQUAL(statesFwd[5].currentSurface->geometryId(), + Acts::GeometryIdentifier(14)); BOOST_CHECK_EQUAL(statesFwd[5].currentPortal, nullptr); // Step to the volume3|endOfWorld boundary BOOST_CHECK_EQUAL(statesFwd[6].currentVolume, nullptr); BOOST_CHECK_EQUAL(statesFwd[6].currentSurface, &(statesFwd[6].currentPortal->surface())); - BOOST_CHECK_EQUAL(statesFwd[6].currentPortal->surface().geometryId(), 11); + BOOST_CHECK_EQUAL(statesFwd[6].currentPortal->surface().geometryId(), + Acts::GeometryIdentifier(11)); // Step to the end of world BOOST_CHECK(navigator.endOfWorldReached(statesFwd[7])); @@ -376,38 +388,50 @@ BOOST_AUTO_TEST_CASE(DetectorNavigatorTestsForwardBackward) { BOOST_CHECK_EQUAL(statesBwd[6].currentVolume, nullptr); BOOST_CHECK_EQUAL(statesBwd[6].currentSurface, &(statesBwd[6].currentPortal->surface())); - BOOST_CHECK_EQUAL(statesBwd[6].currentPortal->surface().geometryId(), 6); + BOOST_CHECK_EQUAL(statesBwd[6].currentPortal->surface().geometryId(), + Acts::GeometryIdentifier(6)); // Step to the surface inside volume1 - BOOST_CHECK_EQUAL(statesBwd[5].currentVolume->geometryId(), 1); - BOOST_CHECK_EQUAL(statesBwd[5].currentSurface->geometryId(), 12); + BOOST_CHECK_EQUAL(statesBwd[5].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); + BOOST_CHECK_EQUAL(statesBwd[5].currentSurface->geometryId(), + Acts::GeometryIdentifier(12)); BOOST_CHECK_EQUAL(statesBwd[5].currentPortal, nullptr); // Step to the volume1|volume2 boundary / preStep not yet set - BOOST_CHECK_EQUAL(statesBwd[4].currentVolume->geometryId(), 1); + BOOST_CHECK_EQUAL(statesBwd[4].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); BOOST_CHECK_EQUAL(statesBwd[4].currentSurface, &(statesBwd[4].currentPortal->surface())); - BOOST_CHECK_EQUAL(statesBwd[4].currentPortal->surface().geometryId(), 7); + BOOST_CHECK_EQUAL(statesBwd[4].currentPortal->surface().geometryId(), + Acts::GeometryIdentifier(7)); // Step to the surface inside volume2 - BOOST_CHECK_EQUAL(statesBwd[3].currentVolume->geometryId(), 2); - BOOST_CHECK_EQUAL(statesBwd[3].currentSurface->geometryId(), 13); + BOOST_CHECK_EQUAL(statesBwd[3].currentVolume->geometryId(), + Acts::GeometryIdentifier(2)); + BOOST_CHECK_EQUAL(statesBwd[3].currentSurface->geometryId(), + Acts::GeometryIdentifier(13)); BOOST_CHECK_EQUAL(statesBwd[3].currentPortal, nullptr); // Step to the volume2|volume3 boundary / pre-step not yet set - BOOST_CHECK_EQUAL(statesBwd[2].currentVolume->geometryId(), 2); + BOOST_CHECK_EQUAL(statesBwd[2].currentVolume->geometryId(), + Acts::GeometryIdentifier(2)); BOOST_CHECK_EQUAL(statesBwd[2].currentSurface, &(statesBwd[2].currentPortal->surface())); - BOOST_CHECK_EQUAL(statesBwd[2].currentPortal->surface().geometryId(), 10); + BOOST_CHECK_EQUAL(statesBwd[2].currentPortal->surface().geometryId(), + Acts::GeometryIdentifier(10)); BOOST_CHECK_EQUAL(statesBwd[2].surfaceCandidates.size(), 2u); // Step to the surface inside volume3 - BOOST_CHECK_EQUAL(statesBwd[1].currentVolume->geometryId(), 3); - BOOST_CHECK_EQUAL(statesBwd[1].currentSurface->geometryId(), 14); + BOOST_CHECK_EQUAL(statesBwd[1].currentVolume->geometryId(), + Acts::GeometryIdentifier(3)); + BOOST_CHECK_EQUAL(statesBwd[1].currentSurface->geometryId(), + Acts::GeometryIdentifier(14)); BOOST_CHECK_EQUAL(statesBwd[1].currentPortal, nullptr); // Step to the volume3|endOfWorld boundary - BOOST_CHECK_EQUAL(statesBwd[0].currentVolume->geometryId(), 3); + BOOST_CHECK_EQUAL(statesBwd[0].currentVolume->geometryId(), + Acts::GeometryIdentifier(3)); BOOST_CHECK_EQUAL(statesBwd[0].currentSurface, nullptr); BOOST_CHECK_EQUAL(statesBwd[0].currentPortal, nullptr); } @@ -427,11 +451,11 @@ BOOST_AUTO_TEST_CASE(DetectorNavigatorTestsAmbiguity) { Acts::Experimental::tryNoVolumes(), Acts::Experimental::tryAllPortalsAndSurfaces()); - volume->assignGeometryId(1); - surface->assignGeometryId(2); + volume->assignGeometryId(Acts::GeometryIdentifier(1)); + surface->assignGeometryId(Acts::GeometryIdentifier(2)); int id = 3; for (auto& port : volume->portalPtrs()) { - port->surface().assignGeometryId(id); + port->surface().assignGeometryId(Acts::GeometryIdentifier(id)); id++; } @@ -487,22 +511,25 @@ BOOST_AUTO_TEST_CASE(DetectorNavigatorTestsAmbiguity) { // Action list call before the first step // Starting in the volume - BOOST_CHECK_EQUAL(statesFwd[0].currentVolume->geometryId(), 1); + BOOST_CHECK_EQUAL(statesFwd[0].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); BOOST_CHECK_EQUAL(statesFwd[0].currentSurface, nullptr); BOOST_CHECK_EQUAL(statesFwd[0].currentPortal, nullptr); // Step to the cylindrical surface - BOOST_CHECK_EQUAL(statesFwd[1].currentVolume->geometryId(), 1); - BOOST_CHECK_EQUAL(statesFwd[1].currentSurface->geometryId(), 2); + BOOST_CHECK_EQUAL(statesFwd[1].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); + BOOST_CHECK_EQUAL(statesFwd[1].currentSurface->geometryId(), + Acts::GeometryIdentifier(2)); BOOST_CHECK_EQUAL(statesFwd[1].currentPortal, nullptr); - BOOST_CHECK_EQUAL(statesFwd[1].surfaceCandidates.size(), 2u); CHECK_CLOSE_REL(statesFwd[1].position.x(), 4, 1e-6); // Step to the volume|endOfWorld boundary BOOST_CHECK_EQUAL(statesFwd[2].currentVolume, nullptr); BOOST_CHECK_EQUAL(statesFwd[2].currentSurface, &(statesFwd[2].currentPortal->surface())); - BOOST_CHECK_EQUAL(statesFwd[2].currentPortal->surface().geometryId(), 6); + BOOST_CHECK_EQUAL(statesFwd[2].currentPortal->surface().geometryId(), + Acts::GeometryIdentifier(6)); // Step to the end of world BOOST_CHECK(navigator.endOfWorldReached(statesFwd[3])); @@ -512,17 +539,21 @@ BOOST_AUTO_TEST_CASE(DetectorNavigatorTestsAmbiguity) { BOOST_CHECK_EQUAL(statesBwd[2].currentVolume, nullptr); BOOST_CHECK_EQUAL(statesBwd[2].currentSurface, &(statesBwd[2].currentPortal->surface())); - BOOST_CHECK_EQUAL(statesBwd[2].currentPortal->surface().geometryId(), 5); + BOOST_CHECK_EQUAL(statesBwd[2].currentPortal->surface().geometryId(), + Acts::GeometryIdentifier(5)); // Step to the cylindrical surface - BOOST_CHECK_EQUAL(statesBwd[1].currentVolume->geometryId(), 1); - BOOST_CHECK_EQUAL(statesBwd[1].currentSurface->geometryId(), 2); + BOOST_CHECK_EQUAL(statesBwd[1].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); + BOOST_CHECK_EQUAL(statesBwd[1].currentSurface->geometryId(), + Acts::GeometryIdentifier(2)); BOOST_CHECK_EQUAL(statesBwd[1].currentPortal, nullptr); CHECK_CLOSE_REL(statesBwd[1].position.x(), -4, 1e-6); // Action list call before the first step // Starting in the volume - BOOST_CHECK_EQUAL(statesBwd[0].currentVolume->geometryId(), 1); + BOOST_CHECK_EQUAL(statesBwd[0].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); BOOST_CHECK_EQUAL(statesBwd[0].currentSurface, nullptr); BOOST_CHECK_EQUAL(statesBwd[0].currentPortal, nullptr); } @@ -542,11 +573,11 @@ BOOST_AUTO_TEST_CASE(DetectorNavigatorTestsMultipleIntersection) { Acts::Experimental::tryNoVolumes(), Acts::Experimental::tryAllPortalsAndSurfaces()); - volume->assignGeometryId(1); - surface->assignGeometryId(2); + volume->assignGeometryId(Acts::GeometryIdentifier(1)); + surface->assignGeometryId(Acts::GeometryIdentifier(2)); int id = 3; for (auto& port : volume->portalPtrs()) { - port->surface().assignGeometryId(id); + port->surface().assignGeometryId(Acts::GeometryIdentifier(id)); id++; } @@ -606,19 +637,24 @@ BOOST_AUTO_TEST_CASE(DetectorNavigatorTestsMultipleIntersection) { // Action list call before the first step // Starting in the volume - BOOST_CHECK_EQUAL(statesFwd[0].currentVolume->geometryId(), 1); + BOOST_CHECK_EQUAL(statesFwd[0].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); BOOST_CHECK_EQUAL(statesFwd[0].currentSurface, nullptr); BOOST_CHECK_EQUAL(statesFwd[0].currentPortal, nullptr); // First intersection of the cylindrical surface - BOOST_CHECK_EQUAL(statesFwd[1].currentVolume->geometryId(), 1); - BOOST_CHECK_EQUAL(statesFwd[1].currentSurface->geometryId(), 2); + BOOST_CHECK_EQUAL(statesFwd[1].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); + BOOST_CHECK_EQUAL(statesFwd[1].currentSurface->geometryId(), + Acts::GeometryIdentifier(2)); BOOST_CHECK_EQUAL(statesFwd[1].currentPortal, nullptr); CHECK_CLOSE_REL(statesFwd[1].position.x(), -4, 1e-6); // Second intersection of the cylindrical surface - BOOST_CHECK_EQUAL(statesFwd[2].currentVolume->geometryId(), 1); - BOOST_CHECK_EQUAL(statesFwd[2].currentSurface->geometryId(), 2); + BOOST_CHECK_EQUAL(statesFwd[2].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); + BOOST_CHECK_EQUAL(statesFwd[2].currentSurface->geometryId(), + Acts::GeometryIdentifier(2)); BOOST_CHECK_EQUAL(statesFwd[2].currentPortal, nullptr); CHECK_CLOSE_REL(statesFwd[2].position.x(), 4, 1e-6); @@ -626,7 +662,8 @@ BOOST_AUTO_TEST_CASE(DetectorNavigatorTestsMultipleIntersection) { BOOST_CHECK_EQUAL(statesFwd[3].currentVolume, nullptr); BOOST_CHECK_EQUAL(statesFwd[3].currentSurface, &(statesFwd[3].currentPortal->surface())); - BOOST_CHECK_EQUAL(statesFwd[3].currentPortal->surface().geometryId(), 6); + BOOST_CHECK_EQUAL(statesFwd[3].currentPortal->surface().geometryId(), + Acts::GeometryIdentifier(6)); // Step to the end of world BOOST_CHECK(navigator.endOfWorldReached(statesFwd[4])); @@ -636,23 +673,29 @@ BOOST_AUTO_TEST_CASE(DetectorNavigatorTestsMultipleIntersection) { BOOST_CHECK_EQUAL(statesBwd[3].currentVolume, nullptr); BOOST_CHECK_EQUAL(statesBwd[3].currentSurface, &(statesBwd[3].currentPortal->surface())); - BOOST_CHECK_EQUAL(statesBwd[3].currentPortal->surface().geometryId(), 5); + BOOST_CHECK_EQUAL(statesBwd[3].currentPortal->surface().geometryId(), + Acts::GeometryIdentifier(5)); - // Second intersection of the cylindrical surface - BOOST_CHECK_EQUAL(statesBwd[2].currentVolume->geometryId(), 1); - BOOST_CHECK_EQUAL(statesBwd[2].currentSurface->geometryId(), 2); + // Step to the cylindrical surface + BOOST_CHECK_EQUAL(statesBwd[2].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); + BOOST_CHECK_EQUAL(statesBwd[2].currentSurface->geometryId(), + Acts::GeometryIdentifier(2)); BOOST_CHECK_EQUAL(statesBwd[2].currentPortal, nullptr); CHECK_CLOSE_REL(statesBwd[2].position.x(), -4, 1e-6); // First intersection of the cylindrical surface - BOOST_CHECK_EQUAL(statesBwd[1].currentVolume->geometryId(), 1); - BOOST_CHECK_EQUAL(statesBwd[1].currentSurface->geometryId(), 2); + BOOST_CHECK_EQUAL(statesBwd[1].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); + BOOST_CHECK_EQUAL(statesBwd[1].currentSurface->geometryId(), + Acts::GeometryIdentifier(2)); BOOST_CHECK_EQUAL(statesBwd[1].currentPortal, nullptr); CHECK_CLOSE_REL(statesBwd[1].position.x(), 4, 1e-6); // Action list call before the first step // Starting in the volume - BOOST_CHECK_EQUAL(statesBwd[0].currentVolume->geometryId(), 1); + BOOST_CHECK_EQUAL(statesBwd[0].currentVolume->geometryId(), + Acts::GeometryIdentifier(1)); BOOST_CHECK_EQUAL(statesBwd[0].currentSurface, nullptr); BOOST_CHECK_EQUAL(statesBwd[0].currentPortal, nullptr); } diff --git a/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp b/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp index a4a7df56b9d..8a333230b78 100644 --- a/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp +++ b/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp @@ -419,7 +419,8 @@ BOOST_AUTO_TEST_CASE(BasicPropagatorInterface) { targetSurface.get()); auto resultBase = - base->propagateToSurface(startParameters, *targetSurface, options); + base->propagateToSurface(startParameters, *targetSurface, + static_cast(options)); BOOST_REQUIRE(resultBase.ok()); BOOST_CHECK_EQUAL(&resultBase.value().referenceSurface(), @@ -430,7 +431,8 @@ BOOST_AUTO_TEST_CASE(BasicPropagatorInterface) { // Propagation call with curvilinear also works auto resultCurv = - base->propagateToSurface(startCurv, *targetSurface, options); + base->propagateToSurface(startCurv, *targetSurface, + static_cast(options)); BOOST_CHECK(resultCurv.ok()); } @@ -452,7 +454,8 @@ BOOST_AUTO_TEST_CASE(BasicPropagatorInterface) { targetSurface.get()); auto resultBase = - base->propagateToSurface(startParameters, *targetSurface, options); + base->propagateToSurface(startParameters, *targetSurface, + static_cast(options)); BOOST_REQUIRE(resultBase.ok()); BOOST_CHECK_EQUAL(&resultBase.value().referenceSurface(), @@ -463,7 +466,8 @@ BOOST_AUTO_TEST_CASE(BasicPropagatorInterface) { // Propagation call with curvilinear also works auto resultCurv = - base->propagateToSurface(startCurv, *targetSurface, options); + base->propagateToSurface(startCurv, *targetSurface, + static_cast(options)); BOOST_CHECK(resultCurv.ok()); } diff --git a/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp b/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp index c97f8e4876d..be42bd9b967 100644 --- a/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp +++ b/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(volume_material_interaction_test) { // Create a propagator state State state; state.stepping.particleHypothesis = - ParticleHypothesis(static_cast(11), 10., 9.); + ParticleHypothesis(static_cast(11), 10., AnyCharge{9.}); state.stepping.pos = Vector3(1., 2., 3.); state.stepping.dir = Vector3(4., 5., 6.); state.stepping.t = 7.; diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index 003b8419cb6..5025c92d7d4 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -262,16 +262,16 @@ std::shared_ptr constructTelescopeDetector() { // changes int id = 1; - // Volume ids + // Volume ids: 1-3 for (auto& volume : volumes) { - volume->assignGeometryId(id); + volume->assignGeometryId(Acts::GeometryIdentifier(id)); id++; } - // Intervolume portal ids + // Intervolume portal ids: 6,7,10,11 for (auto& volume : volumes) { for (auto& port : volume->portalPtrs()) { - if (port->surface().geometryId() == 0) { - port->surface().assignGeometryId(id); + if (port->surface().geometryId() == Acts::GeometryIdentifier(0)) { + port->surface().assignGeometryId(Acts::GeometryIdentifier(id)); id++; } } diff --git a/Tests/UnitTests/Core/Seeding/SpacePointContainer.hpp b/Tests/UnitTests/Core/Seeding/SpacePointContainer.hpp index cc264666f0f..bd2f7678624 100644 --- a/Tests/UnitTests/Core/Seeding/SpacePointContainer.hpp +++ b/Tests/UnitTests/Core/Seeding/SpacePointContainer.hpp @@ -30,8 +30,10 @@ class SpacePointContainer { // the memory backend is independetly handled. This is only interfacing it to // ACTS SpacePointContainer(CollectionType&& container) = delete; - SpacePointContainer(CollectionType& container) : m_storage(container) {} - SpacePointContainer(CollectionType* container) : m_storage(container) {} + explicit SpacePointContainer(CollectionType& container) + : m_storage(container) {} + explicit SpacePointContainer(CollectionType* container) + : m_storage(container) {} // No copy constructor or copy operation allowed SpacePointContainer(const SpacePointContainer&) = delete; diff --git a/Tests/UnitTests/Core/Surfaces/ConvexPolygonBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/ConvexPolygonBoundsTests.cpp index 7b516b6bfec..52efbbcfc34 100644 --- a/Tests/UnitTests/Core/Surfaces/ConvexPolygonBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConvexPolygonBoundsTests.cpp @@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE(ConvexPolygonBoundsConvexity) { // wrong number of vertices BOOST_CHECK_THROW(poly<3> trip{vertices}, AssertionFailureException); } - { poly<4> quad = {vertices}; } + { poly<4> quad(vertices); } // this one is self intersecting vertices = {{0, 0}, {1, 0}, {0.5, 1}, {0.9, 1.2}}; @@ -44,13 +44,13 @@ BOOST_AUTO_TEST_CASE(ConvexPolygonBoundsConvexity) { // this one is not vertices = {{0, 0}, {1, 0}, {0.9, 1.2}, {0.5, 1}}; - { poly<4> quad = {vertices}; } + { poly<4> quad(vertices); } vertices = {{0, 0}, {1, 0}, {0.8, 0.5}, {1, 1}, {0, 1}}; - { BOOST_CHECK_THROW(poly<5> pent(vertices), std::logic_error); } + { BOOST_CHECK_THROW(poly<5> pent{vertices}, std::logic_error); } vertices = {{0, 0}, {1, 0}, {1.1, 0.5}, {1, 1}, {0, 1}}; - { poly<5> pent{vertices}; } + { poly<5> pent(vertices); } } BOOST_AUTO_TEST_CASE(ConvexPolygonBoundsConstruction) { diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp b/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp index 4815420aa1c..96e4a8d226f 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp @@ -21,12 +21,12 @@ namespace Acts { /// Surface derived class stub class SurfaceStub : public RegularSurface { public: - SurfaceStub(const Transform3& htrans = Transform3::Identity()) + explicit SurfaceStub(const Transform3& htrans = Transform3::Identity()) : GeometryObject(), RegularSurface(htrans) {} SurfaceStub(const GeometryContext& gctx, const SurfaceStub& sf, const Transform3& transf) : GeometryObject(), RegularSurface(gctx, sf, transf) {} - SurfaceStub(const DetectorElementBase& detelement) + explicit SurfaceStub(const DetectorElementBase& detelement) : GeometryObject(), RegularSurface(detelement) {} ~SurfaceStub() override = default; diff --git a/Tests/UnitTests/Core/TrackFinding/CombinatorialKalmanFilterTests.cpp b/Tests/UnitTests/Core/TrackFinding/CombinatorialKalmanFilterTests.cpp index 4b48c462487..39d227a9446 100644 --- a/Tests/UnitTests/Core/TrackFinding/CombinatorialKalmanFilterTests.cpp +++ b/Tests/UnitTests/Core/TrackFinding/CombinatorialKalmanFilterTests.cpp @@ -104,7 +104,7 @@ struct Detector { {Acts::GeometryIdentifier().withVolume(3).withLayer(8), resStrip1}, }; - Detector(const Acts::GeometryContext& geoCtx) + explicit Detector(const Acts::GeometryContext& geoCtx) : store(geoCtx), geometry(store()) {} }; @@ -208,7 +208,7 @@ struct Fixture { std::unique_ptr logger; - Fixture(double bz) + explicit Fixture(double bz) : detector(geoCtx), ckf(makeConstantFieldPropagator(detector.geometry, bz)), logger(Acts::getDefaultLogger("CkfTest", Acts::Logging::INFO)) { diff --git a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp index 9ec88ff9fd2..344dc23ab18 100644 --- a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp +++ b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp @@ -69,7 +69,7 @@ struct MockTrack { ConstTrackStateType typeFlags() const { static const ConstTrackStateType::raw_type raw{0}; - return {raw}; + return ConstTrackStateType{raw}; } }; diff --git a/Tests/UnitTests/Core/TrackFitting/GsfTests.cpp b/Tests/UnitTests/Core/TrackFitting/GsfTests.cpp index 59c1cc72867..3ea1aee856e 100644 --- a/Tests/UnitTests/Core/TrackFitting/GsfTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/GsfTests.cpp @@ -113,12 +113,14 @@ auto makeDefaultGsfOptions() { struct MultiCmpsParsInterface : public BoundTrackParameters { MultiComponentBoundTrackParameters multi_pars; - MultiCmpsParsInterface(const MultiComponentBoundTrackParameters &p) + explicit MultiCmpsParsInterface(const MultiComponentBoundTrackParameters &p) : BoundTrackParameters(p.referenceSurface().getSharedPtr(), p.parameters(), p.covariance(), electron), multi_pars(p) {} - operator MultiComponentBoundTrackParameters() const { return multi_pars; } + explicit operator MultiComponentBoundTrackParameters() const { + return multi_pars; + } }; auto makeParameters() { diff --git a/Tests/UnitTests/Core/Utilities/AnyGridViewTests.cpp b/Tests/UnitTests/Core/Utilities/AnyGridViewTests.cpp new file mode 100644 index 00000000000..6824516ebb6 --- /dev/null +++ b/Tests/UnitTests/Core/Utilities/AnyGridViewTests.cpp @@ -0,0 +1,400 @@ +// This file is part of the ACTS project. +// +// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. + +#include + +#include "Acts/Utilities/AnyGridView.hpp" +#include "Acts/Utilities/Axis.hpp" +#include "Acts/Utilities/AxisDefinitions.hpp" +#include "Acts/Utilities/Grid.hpp" +#include "Acts/Utilities/TypeTraits.hpp" + +#include +#include +#include +#include + +namespace Acts::Test { + +BOOST_AUTO_TEST_SUITE(AnyGridViewTests) + +// Helper function to create a 1D grid with int values +auto createIntGrid1D() { + Axis a(0.0, 4.0, 4u); + Grid g(Type, a); + + // Fill with values + for (std::size_t i = 0; i < g.size(); i++) { + g.at(i) = static_cast(i * 10); + } + + return g; +} + +// Helper function to create a 2D grid with double values +auto createDoubleGrid2D() { + Axis a(0.0, 4.0, 4u); + Axis b(0.0, 6.0, 3u); + Grid g(Type, std::move(a), std::move(b)); + + // Fill with values + for (std::size_t i = 0; i < g.size(); i++) { + g.at(i) = static_cast(i) * 1.5; + } + + return g; +} + +// Helper function to create a 2D grid with string values +auto createStringGrid2D() { + Axis a(0.0, 4.0, 4u); + Axis b(0.0, 6.0, 3u); + Grid g(Type, std::move(a), std::move(b)); + + // Fill with values + for (std::size_t i = 0; i < g.size(); i++) { + g.at(i) = "Value_" + std::to_string(i); + } + + return g; +} + +// Helper function to create a 3D grid with vector values +auto createVectorGrid3D() { + Axis a(0.0, 4.0, 2u); + Axis b(0.0, 6.0, 2u); + Axis c(0.0, 8.0, 2u); + Grid g(Type>, std::move(a), std::move(b), std::move(c)); + + // Fill with values + for (std::size_t i = 0; i < g.size(); i++) { + g.at(i) = {static_cast(i), static_cast(i * 2)}; + } + + return g; +} + +// Test read and write access to int grid using type safe interface +BOOST_AUTO_TEST_CASE(IntGridReadWriteAccess) { + auto grid = createIntGrid1D(); + + // Create mutable view + AnyGridView view(grid); + + // Test read access + BOOST_CHECK_EQUAL(view.atLocalBins({1}), 10); + BOOST_CHECK_EQUAL(view.atLocalBins({2}), 20); + + // Test write access + view.atLocalBins({1}) = 100; + BOOST_CHECK_EQUAL(view.atLocalBins({1}), 100); + BOOST_CHECK_EQUAL(grid.atLocalBins({1}), 100); +} + +// Test read-only access to int grid using type safe interface +BOOST_AUTO_TEST_CASE(IntGridReadOnlyAccess) { + auto grid = createIntGrid1D(); + + // Create const view + AnyGridConstView constView(grid); + + // Test read access + BOOST_CHECK_EQUAL(constView.atLocalBins({1}), 10); + BOOST_CHECK_EQUAL(constView.atLocalBins({2}), 20); + + // Verify that the following would not compile: + // constView.atLocalBins({1}) = 100; // Should cause compilation error +} + +// Test creation of any grid view from concrete grid type +BOOST_AUTO_TEST_CASE(CreateFromConcreteGrid) { + auto doubleGrid = createDoubleGrid2D(); + + // Create view from concrete grid + AnyGridView view(doubleGrid); + + // Check dimensions + BOOST_CHECK_EQUAL(view.dimensions(), 2u); + + // Check values + BOOST_CHECK_CLOSE(view.atLocalBins({1, 1}), + 1.5 * doubleGrid.globalBinFromLocalBins({1, 1}), 1e-10); + + // Modify through view + view.atLocalBins({1, 1}) = 42.0; + BOOST_CHECK_CLOSE(doubleGrid.atLocalBins({1, 1}), 42.0, 1e-10); +} + +// Test creation of any grid view from IGrid type +BOOST_AUTO_TEST_CASE(CreateFromIGrid) { + auto doubleGrid = createDoubleGrid2D(); + IGrid& iGrid = doubleGrid; + + // Create view from IGrid + AnyGridView view(iGrid); + + // Check dimensions + BOOST_CHECK_EQUAL(view.dimensions(), 2u); + + // Check values + BOOST_CHECK_CLOSE(view.atLocalBins({1, 1}), + 1.5 * doubleGrid.globalBinFromLocalBins({1, 1}), 1e-10); +} + +// Test creation of const grid view from const IGrid type +BOOST_AUTO_TEST_CASE(CreateConstViewFromConstIGrid) { + auto doubleGrid = createDoubleGrid2D(); + const IGrid& constIGrid = doubleGrid; + + // Create const view from const IGrid + AnyGridConstView constView(constIGrid); + + // Check dimensions + BOOST_CHECK_EQUAL(constView.dimensions(), 2u); + + // Check values + BOOST_CHECK_CLOSE(constView.atLocalBins({1, 1}), + 1.5 * doubleGrid.globalBinFromLocalBins({1, 1}), 1e-10); +} + +// Test type mismatch handling when creating from IGrid +BOOST_AUTO_TEST_CASE(TypeMismatchFromIGrid) { + auto doubleGrid = createDoubleGrid2D(); + IGrid& iGrid = doubleGrid; + + // Try to create int view from double grid + BOOST_CHECK_THROW((AnyGridView(iGrid)), std::invalid_argument); +} + +// Test type mismatch handling when creating const view from const IGrid +BOOST_AUTO_TEST_CASE(TypeMismatchFromConstIGrid) { + auto doubleGrid = createDoubleGrid2D(); + const IGrid& constIGrid = doubleGrid; + + // Try to create int view from double grid + BOOST_CHECK_THROW((AnyGridConstView(constIGrid)), std::invalid_argument); +} + +// Test creation of mutable view from mutable grid +BOOST_AUTO_TEST_CASE(MutableViewFromMutableGrid) { + auto stringGrid = createStringGrid2D(); + + // Create mutable view + AnyGridView view(stringGrid); + + // Modify through view + view.atLocalBins({2, 2}) = "Modified"; + + // Check modification in original grid + BOOST_CHECK_EQUAL(stringGrid.atLocalBins({2, 2}), "Modified"); +} + +// Test creation of const view from mutable grid +BOOST_AUTO_TEST_CASE(ConstViewFromMutableGrid) { + auto stringGrid = createStringGrid2D(); + + // Create const view from mutable grid + AnyGridConstView constView(stringGrid); + + // Check read access + BOOST_CHECK_EQUAL(constView.atLocalBins({2, 2}), + stringGrid.atLocalBins({2, 2})); + + // Verify that the following would not compile: + // constView.atLocalBins({2, 2}) = "Modified"; // Should cause compilation + // error +} + +// Test creation of const view from const grid +BOOST_AUTO_TEST_CASE(ConstViewFromConstGrid) { + const auto stringGrid = createStringGrid2D(); + + // Create const view from const grid + AnyGridConstView constView(stringGrid); + + // Check read access + BOOST_CHECK_EQUAL(constView.atLocalBins({2, 2}), + stringGrid.atLocalBins({2, 2})); +} + +// Test complex type (vector) with both IGrid and concrete grid type +// construction +BOOST_AUTO_TEST_CASE(VectorTypeWithBothConstructions) { + auto vectorGrid = createVectorGrid3D(); + + // Test with concrete grid type + AnyGridView> concreteView(vectorGrid); + BOOST_CHECK_EQUAL(concreteView.dimensions(), 3u); + BOOST_CHECK_EQUAL(concreteView.atLocalBins({1, 1, 1}).size(), 2u); + BOOST_CHECK_EQUAL(concreteView.atLocalBins({1, 1, 1})[0], + vectorGrid.atLocalBins({1, 1, 1})[0]); + + // Test with IGrid type + IGrid& iGrid = vectorGrid; + AnyGridView> iGridView(iGrid); + BOOST_CHECK_EQUAL(iGridView.dimensions(), 3u); + BOOST_CHECK_EQUAL(iGridView.atLocalBins({1, 1, 1}).size(), 2u); + BOOST_CHECK_EQUAL(iGridView.atLocalBins({1, 1, 1})[0], + vectorGrid.atLocalBins({1, 1, 1})[0]); + + // Test with const IGrid type + const IGrid& constIGrid = vectorGrid; + AnyGridConstView> constIGridView(constIGrid); + BOOST_CHECK_EQUAL(constIGridView.dimensions(), 3u); + BOOST_CHECK_EQUAL(constIGridView.atLocalBins({1, 1, 1}).size(), 2u); + BOOST_CHECK_EQUAL(constIGridView.atLocalBins({1, 1, 1})[0], + vectorGrid.atLocalBins({1, 1, 1})[0]); + + // Modify through view + std::vector newValue = {99.0f, 88.0f}; + concreteView.atLocalBins({1, 1, 1}) = newValue; + BOOST_CHECK_EQUAL(vectorGrid.atLocalBins({1, 1, 1})[0], 99.0f); + BOOST_CHECK_EQUAL(vectorGrid.atLocalBins({1, 1, 1})[1], 88.0f); +} + +// Test grid properties access through view +BOOST_AUTO_TEST_CASE(GridPropertiesAccess) { + auto doubleGrid = createDoubleGrid2D(); + AnyGridView view(doubleGrid); + + // Test dimensions + BOOST_CHECK_EQUAL(view.dimensions(), 2u); + + // Test bin center + auto center = view.binCenter({1, 1}); + auto expectedCenter = doubleGrid.binCenter({1, 1}); + BOOST_CHECK_CLOSE(center[0], expectedCenter[0], 1e-10); + BOOST_CHECK_CLOSE(center[1], expectedCenter[1], 1e-10); + + // Test lower left bin edge + auto lowerLeft = view.lowerLeftBinEdge({1, 1}); + auto expectedLowerLeft = doubleGrid.lowerLeftBinEdge({1, 1}); + BOOST_CHECK_CLOSE(lowerLeft[0], expectedLowerLeft[0], 1e-10); + BOOST_CHECK_CLOSE(lowerLeft[1], expectedLowerLeft[1], 1e-10); + + // Test upper right bin edge + auto upperRight = view.upperRightBinEdge({1, 1}); + auto expectedUpperRight = doubleGrid.upperRightBinEdge({1, 1}); + BOOST_CHECK_CLOSE(upperRight[0], expectedUpperRight[0], 1e-10); + BOOST_CHECK_CLOSE(upperRight[1], expectedUpperRight[1], 1e-10); + + // Test number of local bins + auto numBins = view.numLocalBins(); + auto expectedNumBins = doubleGrid.numLocalBins(); + BOOST_CHECK_EQUAL(numBins[0], expectedNumBins[0]); + BOOST_CHECK_EQUAL(numBins[1], expectedNumBins[1]); +} + +// Test grid properties access through const view from const IGrid +BOOST_AUTO_TEST_CASE(GridPropertiesAccessConstView) { + auto doubleGrid = createDoubleGrid2D(); + const IGrid& constIGrid = doubleGrid; + AnyGridConstView constView(constIGrid); + + // Test dimensions + BOOST_CHECK_EQUAL(constView.dimensions(), 2u); + + // Test bin center + auto center = constView.binCenter({1, 1}); + auto expectedCenter = doubleGrid.binCenter({1, 1}); + BOOST_CHECK_CLOSE(center[0], expectedCenter[0], 1e-10); + BOOST_CHECK_CLOSE(center[1], expectedCenter[1], 1e-10); + + // Test lower left bin edge + auto lowerLeft = constView.lowerLeftBinEdge({1, 1}); + auto expectedLowerLeft = doubleGrid.lowerLeftBinEdge({1, 1}); + BOOST_CHECK_CLOSE(lowerLeft[0], expectedLowerLeft[0], 1e-10); + BOOST_CHECK_CLOSE(lowerLeft[1], expectedLowerLeft[1], 1e-10); + + // Test upper right bin edge + auto upperRight = constView.upperRightBinEdge({1, 1}); + auto expectedUpperRight = doubleGrid.upperRightBinEdge({1, 1}); + BOOST_CHECK_CLOSE(upperRight[0], expectedUpperRight[0], 1e-10); + BOOST_CHECK_CLOSE(upperRight[1], expectedUpperRight[1], 1e-10); + + // Test number of local bins + auto numBins = constView.numLocalBins(); + auto expectedNumBins = doubleGrid.numLocalBins(); + BOOST_CHECK_EQUAL(numBins[0], expectedNumBins[0]); + BOOST_CHECK_EQUAL(numBins[1], expectedNumBins[1]); +} + +// Test error cases +BOOST_AUTO_TEST_CASE(ErrorCases) { + auto intGrid = createIntGrid1D(); + auto doubleGrid = createDoubleGrid2D(); + + // Test accessing with wrong number of indices + AnyGridView intView(intGrid); + BOOST_CHECK_THROW(intView.atLocalBins({1, 2}), std::invalid_argument); + + // Test accessing with out-of-bounds indices + BOOST_CHECK_THROW(intView.atLocalBins({10}), std::out_of_range); + + // Test creating view with wrong value type + IGrid& iGrid = doubleGrid; + BOOST_CHECK_THROW(AnyGridView{iGrid}, std::invalid_argument); + + // Test creating const view with wrong value type + const IGrid& constIGrid = doubleGrid; + BOOST_CHECK_THROW(AnyGridConstView{constIGrid}, + std::invalid_argument); +} + +// Test copy operations +BOOST_AUTO_TEST_CASE(CopyOperations) { + // Create grids that will live for the duration of the test + auto doubleGrid1 = createDoubleGrid2D(); + auto doubleGrid2 = createDoubleGrid2D(); + auto doubleGrid3 = createDoubleGrid2D(); + + // Test copy constructor + AnyGridView view1(doubleGrid1); + AnyGridView view2(view1); + BOOST_CHECK_CLOSE(view1.atLocalBins({1, 1}), view2.atLocalBins({1, 1}), + 1e-10); + + // Test copy assignment + AnyGridView view3(doubleGrid2); + view3 = view1; + BOOST_CHECK_CLOSE(view1.atLocalBins({1, 1}), view3.atLocalBins({1, 1}), + 1e-10); + + // Same for const views + AnyGridConstView constView1(doubleGrid1); + AnyGridConstView constView2(constView1); + BOOST_CHECK_CLOSE(constView1.atLocalBins({1, 1}), + constView2.atLocalBins({1, 1}), 1e-10); + + auto doubleGrid4 = createDoubleGrid2D(); + AnyGridConstView constView3(doubleGrid4); + constView3 = constView1; + BOOST_CHECK_CLOSE(constView1.atLocalBins({1, 1}), + constView3.atLocalBins({1, 1}), 1e-10); + + // Test const view from const IGrid + const IGrid& constIGrid = doubleGrid1; + AnyGridConstView constView4(constIGrid); + AnyGridConstView constView5(constView4); + BOOST_CHECK_CLOSE(constView4.atLocalBins({1, 1}), + constView5.atLocalBins({1, 1}), 1e-10); +} + +BOOST_AUTO_TEST_CASE(TypeDeduction) { + auto grid = createIntGrid1D(); + AnyGridView view(grid); + static_assert(std::is_same_v>); + + const auto constGrid = createIntGrid1D(); + AnyGridConstView constView(constGrid); + static_assert(std::is_same_v>); +} + +BOOST_AUTO_TEST_SUITE_END() + +} // namespace Acts::Test diff --git a/Tests/UnitTests/Core/Utilities/AnyTests.cpp b/Tests/UnitTests/Core/Utilities/AnyTests.cpp index 7389218e54a..1a843dd42ed 100644 --- a/Tests/UnitTests/Core/Utilities/AnyTests.cpp +++ b/Tests/UnitTests/Core/Utilities/AnyTests.cpp @@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE(AnyConstructCustom) { BOOST_AUTO_TEST_CASE(AnyConstructCustomInPlace) { struct A { int value; - A(int v) { value = v; } + explicit A(int v) { value = v; } }; Any a{std::in_place_type, 42}; @@ -174,7 +174,7 @@ BOOST_AUTO_TEST_CASE(AnyCopy) { struct D { bool* destroyed; - D(bool* d) : destroyed{d} {} + explicit D(bool* d) : destroyed{d} {} ~D() { *destroyed = true; } }; @@ -182,7 +182,7 @@ struct D2 { bool* destroyed{nullptr}; std::array blob{}; - D2(bool* d) : destroyed{d} {} + explicit D2(bool* d) : destroyed{d} {} ~D2() { *destroyed = true; } }; @@ -337,7 +337,7 @@ struct D3 { std::size_t* destroyed{nullptr}; std::array blob{}; - D3(std::size_t* d) : destroyed{d} {} + explicit D3(std::size_t* d) : destroyed{d} {} ~D3() { (*destroyed)++; } }; @@ -372,7 +372,7 @@ template <> struct Lifecycle<0> { LifecycleCounters* counters; - Lifecycle(LifecycleCounters* _counters) : counters{_counters} {} + explicit Lifecycle(LifecycleCounters* _counters) : counters{_counters} {} Lifecycle(Lifecycle&& o) { counters = o.counters; @@ -403,7 +403,7 @@ template struct Lifecycle : public Lifecycle<0> { std::array m_padding{}; - Lifecycle(LifecycleCounters* _counters) : Lifecycle<0>(_counters) {} + explicit Lifecycle(LifecycleCounters* _counters) : Lifecycle<0>(_counters) {} }; template diff --git a/Tests/UnitTests/Core/Utilities/CMakeLists.txt b/Tests/UnitTests/Core/Utilities/CMakeLists.txt index 4b6fe98de96..9265c0c7b57 100644 --- a/Tests/UnitTests/Core/Utilities/CMakeLists.txt +++ b/Tests/UnitTests/Core/Utilities/CMakeLists.txt @@ -63,3 +63,4 @@ add_unittest(VectorHelpers VectorHelpersTests.cpp) add_unittest(TrackHelpers TrackHelpersTests.cpp) add_unittest(GraphViz GraphVizTests.cpp) add_unittest(ContextType ContextTypeTests.cpp) +add_unittest(AnyGridView AnyGridViewTests.cpp) diff --git a/Tests/UnitTests/Core/Utilities/DelegateChainBuilderTests.cpp b/Tests/UnitTests/Core/Utilities/DelegateChainBuilderTests.cpp index 783eb9a85e2..38818d95e81 100644 --- a/Tests/UnitTests/Core/Utilities/DelegateChainBuilderTests.cpp +++ b/Tests/UnitTests/Core/Utilities/DelegateChainBuilderTests.cpp @@ -30,12 +30,12 @@ BOOST_AUTO_TEST_CASE(DelegateChainBuilderAdd) { int x = 0; // Basic building - OwningDelegate chain = DelegateChainBuilder{} - .add<&AddTo::add>(&a1) - .add<&addFive>() - .add<&AddTo::add>(&a2) - .add<&AddTo::add>(&a3) - .build(); + OwningDelegate chain{DelegateChainBuilder{} + .add<&AddTo::add>(&a1) + .add<&addFive>() + .add<&AddTo::add>(&a2) + .add<&AddTo::add>(&a3) + .build()}; chain(x); BOOST_CHECK_EQUAL(x, 11); diff --git a/Tests/UnitTests/Core/Utilities/DelegateTests.cpp b/Tests/UnitTests/Core/Utilities/DelegateTests.cpp index c2d575b58fe..124ceaa8d46 100644 --- a/Tests/UnitTests/Core/Utilities/DelegateTests.cpp +++ b/Tests/UnitTests/Core/Utilities/DelegateTests.cpp @@ -214,7 +214,7 @@ BOOST_AUTO_TEST_CASE(StatefullLambdas) { } struct CheckDestructor { - CheckDestructor(bool* _out) : destructorCalled{_out} {} + explicit CheckDestructor(bool* _out) : destructorCalled{_out} {} bool* destructorCalled; diff --git a/Tests/UnitTests/Core/Utilities/GridAxisGeneratorsTests.cpp b/Tests/UnitTests/Core/Utilities/GridAxisGeneratorsTests.cpp index 5d865047d28..da64bf98742 100644 --- a/Tests/UnitTests/Core/Utilities/GridAxisGeneratorsTests.cpp +++ b/Tests/UnitTests/Core/Utilities/GridAxisGeneratorsTests.cpp @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(Eq1D) { BOOST_CHECK(axisC.getBoundaryType() == AxisBoundaryType::Closed); // Test that we can make a grid out of this - EqBound::grid_type eqbGrid(std::move(axisTupleB)); + EqBound::grid_type eqbGrid(std::move(axisTupleB)); } BOOST_AUTO_TEST_CASE(EqEq2D) { @@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(EqEq2D) { BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Closed); BOOST_CHECK(axisEq.isEquidistant()); // Test that we can make a grid out of this - EqOpenEqClosed::grid_type eoecGrid(std::move(axisTuple)); + EqOpenEqClosed::grid_type eoecGrid(std::move(axisTuple)); } BOOST_AUTO_TEST_CASE(EqVar2D) { @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(EqVar2D) { BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Open); BOOST_CHECK(axisEq.isVariable()); // Test that we can make a grid out of this - EqBoundVarOpen::grid_type ebvoGrid(std::move(axisTuple)); + EqBoundVarOpen::grid_type ebvoGrid(std::move(axisTuple)); } BOOST_AUTO_TEST_CASE(VarEq2D) { @@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(VarEq2D) { BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Closed); BOOST_CHECK(axisEq.isEquidistant()); // Test that we can make a grid out of this - VarBoundEqClosed::grid_type vbecGrid(std::move(axisTuple)); + VarBoundEqClosed::grid_type vbecGrid(std::move(axisTuple)); } BOOST_AUTO_TEST_CASE(VarVar2D) { @@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(VarVar2D) { BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Bound); BOOST_CHECK(axisEq.isVariable()); // Test that we can make a grid out of this - VarBoundVarBound::grid_type vbvbGrid(std::move(axisTuple)); + VarBoundVarBound::grid_type vbvbGrid(std::move(axisTuple)); } BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Core/Utilities/MultiIndexTests.cpp b/Tests/UnitTests/Core/Utilities/MultiIndexTests.cpp index b52737e22b8..41f4456c3f0 100644 --- a/Tests/UnitTests/Core/Utilities/MultiIndexTests.cpp +++ b/Tests/UnitTests/Core/Utilities/MultiIndexTests.cpp @@ -44,14 +44,6 @@ BOOST_AUTO_TEST_CASE(index32_construct) { BOOST_CHECK_EQUAL(idx.level(1), 0x24u); BOOST_CHECK_EQUAL(idx.level(2), 0x00u); } - // assign from encoded value - { - Index32 idx = 0xabcd2400u; - BOOST_CHECK_EQUAL(idx.value(), 0xabcd2400u); - BOOST_CHECK_EQUAL(idx.level(0), 0xabcdu); - BOOST_CHECK_EQUAL(idx.level(1), 0x24u); - BOOST_CHECK_EQUAL(idx.level(2), 0x00u); - } } BOOST_AUTO_TEST_CASE(index32_set) { @@ -214,9 +206,9 @@ BOOST_AUTO_TEST_CASE(index32_as_key) { BOOST_CHECK(!set.count(Index32(0u))); BOOST_CHECK(!set.count(Index32(std::numeric_limits::max()))); BOOST_CHECK_EQUAL(set.size(), 3); - // automatically converts encoded value to MultiIndex - BOOST_CHECK(set.count(0x00010204u)); - BOOST_CHECK(set.count(0x00010304u)); + // Does not automatically convert encoded value to MultiIndex + BOOST_CHECK(set.count(Index32{0x00010204u})); + BOOST_CHECK(set.count(Index32{0x00010304u})); BOOST_CHECK(set.count(Index32::Encode(2u))); } diff --git a/Tests/UnitTests/Core/Utilities/ResultTests.cpp b/Tests/UnitTests/Core/Utilities/ResultTests.cpp index 748e0d7211e..37c1bc6793f 100644 --- a/Tests/UnitTests/Core/Utilities/ResultTests.cpp +++ b/Tests/UnitTests/Core/Utilities/ResultTests.cpp @@ -240,7 +240,7 @@ BOOST_AUTO_TEST_CASE(TestErrorCodes) { } struct NoCopy { - NoCopy(int i) : num(i) {} + explicit NoCopy(int i) : num(i) {} NoCopy(const NoCopy&) = delete; NoCopy& operator=(const NoCopy&) = delete; NoCopy(NoCopy&&) = default; @@ -253,7 +253,7 @@ Result make_nocopy(int i, bool v = true) { if (!v) { return MyError::Failure; } - return i; + return NoCopy{i}; } BOOST_AUTO_TEST_CASE(CopyBehaviour) { diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp index 0b6c5982067..60258b9cb17 100644 --- a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp @@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) { GaussianTrackDensity::Config densityCfg; densityCfg.extractParameters.connect<&InputTrack::extractParameters>(); auto seedFinder = std::make_shared( - TrackDensityVertexFinder::Config{densityCfg}); + TrackDensityVertexFinder::Config{Acts::GaussianTrackDensity(densityCfg)}); AdaptiveMultiVertexFinder::Config finderConfig(std::move(fitter), seedFinder, ipEstimator, bField); @@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_usertype_test) { GaussianTrackDensity::Config densityCfg; densityCfg.extractParameters.connect(extractParameters); auto seedFinder = std::make_shared( - TrackDensityVertexFinder::Config{densityCfg}); + TrackDensityVertexFinder::Config{Acts::GaussianTrackDensity(densityCfg)}); AdaptiveMultiVertexFinder::Config finderConfig( std::move(fitter), std::move(seedFinder), ipEstimator, bField); @@ -415,7 +415,9 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_grid_seed_finder_test) { Fitter fitter(fitterCfg); using SeedFinder = GridDensityVertexFinder; - SeedFinder::Config seedFinderCfg{{{250, 4000, 55}}}; + GaussianGridTrackDensity::Config gDensityConfig(250, 4000, 55); + GaussianGridTrackDensity gDensity(gDensityConfig); + SeedFinder::Config seedFinderCfg(gDensity); seedFinderCfg.cacheGridStateForTrackRemoval = true; seedFinderCfg.extractParameters.connect<&InputTrack::extractParameters>(); diff --git a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp index 5c4deb84a38..41aab8e1c99 100644 --- a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp @@ -94,7 +94,8 @@ std::uniform_int_distribution nTracksDist(3, 10); // Dummy user-defined InputTrack type struct InputTrackStub { - InputTrackStub(const BoundTrackParameters& params) : m_parameters(params) {} + explicit InputTrackStub(const BoundTrackParameters& params) + : m_parameters(params) {} const BoundTrackParameters& parameters() const { return m_parameters; } diff --git a/Tests/UnitTests/Core/Vertexing/GridDensityVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/GridDensityVertexFinderTests.cpp index d8aa16a1c94..6a60e0382fa 100644 --- a/Tests/UnitTests/Core/Vertexing/GridDensityVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/GridDensityVertexFinderTests.cpp @@ -96,7 +96,10 @@ BOOST_AUTO_TEST_CASE(grid_density_vertex_finder_test) { VertexingOptions vertexingOptions(geoContext, magFieldContext); using Finder1 = GridDensityVertexFinder; - Finder1::Config cfg1{{{100, mainGridSize, trkGridSize}}}; + GaussianGridTrackDensity::Config gDensityConfig(100, mainGridSize, + trkGridSize); + GaussianGridTrackDensity gDensity(gDensityConfig); + Finder1::Config cfg1(gDensity); cfg1.cacheGridStateForTrackRemoval = false; cfg1.extractParameters.connect<&InputTrack::extractParameters>(); Finder1 finder1(cfg1); @@ -381,7 +384,10 @@ BOOST_AUTO_TEST_CASE(grid_density_vertex_finder_seed_width_test) { vertexingOptions.constraint = constraintVtx; using Finder1 = GridDensityVertexFinder; - Finder1::Config cfg1{{{100, mainGridSize, trkGridSize}}}; + GaussianGridTrackDensity::Config gDensityConfig(100, mainGridSize, + trkGridSize); + GaussianGridTrackDensity gDensity(gDensityConfig); + Finder1::Config cfg1(gDensity); cfg1.cacheGridStateForTrackRemoval = false; cfg1.estimateSeedWidth = true; cfg1.extractParameters.connect<&InputTrack::extractParameters>(); diff --git a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp index 37925947d28..d0fa5dec9f3 100644 --- a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp @@ -99,7 +99,8 @@ std::uniform_int_distribution nTracksDist(5, 15); // Dummy user-defined InputTrack type struct InputTrackStub { - InputTrackStub(const BoundTrackParameters& params) : m_parameters(params) {} + explicit InputTrackStub(const BoundTrackParameters& params) + : m_parameters(params) {} const BoundTrackParameters& parameters() const { return m_parameters; } diff --git a/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp index a865a19f7ba..50ccdea04de 100644 --- a/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp @@ -69,7 +69,8 @@ BOOST_AUTO_TEST_CASE(track_density_finder_test) { VertexingOptions vertexingOptions(geoContext, magFieldContext); GaussianTrackDensity::Config densityCfg; densityCfg.extractParameters.connect<&InputTrack::extractParameters>(); - TrackDensityVertexFinder finder{{{densityCfg}}}; + TrackDensityVertexFinder finder{ + TrackDensityVertexFinder::Config{Acts::GaussianTrackDensity(densityCfg)}}; auto state = finder.makeState(magFieldContext); // Start creating some track parameters @@ -148,7 +149,8 @@ BOOST_AUTO_TEST_CASE(track_density_finder_constr_test) { VertexingOptions vertexingOptions(geoContext, magFieldContext, constraint); GaussianTrackDensity::Config densityCfg; densityCfg.extractParameters.connect<&InputTrack::extractParameters>(); - TrackDensityVertexFinder finder{{{densityCfg}}}; + TrackDensityVertexFinder finder{ + TrackDensityVertexFinder::Config{Acts::GaussianTrackDensity(densityCfg)}}; auto state = finder.makeState(magFieldContext); // Start creating some track parameters @@ -225,7 +227,8 @@ BOOST_AUTO_TEST_CASE(track_density_finder_random_test) { VertexingOptions vertexingOptions(geoContext, magFieldContext); GaussianTrackDensity::Config densityCfg; densityCfg.extractParameters.connect<&InputTrack::extractParameters>(); - TrackDensityVertexFinder finder{{{densityCfg}}}; + TrackDensityVertexFinder finder{ + TrackDensityVertexFinder::Config{Acts::GaussianTrackDensity(densityCfg)}}; auto state = finder.makeState(magFieldContext); int mySeed = 31415; @@ -282,7 +285,8 @@ BOOST_AUTO_TEST_CASE(track_density_finder_random_test) { // Dummy user-defined InputTrackStub type struct InputTrackStub { - InputTrackStub(const BoundTrackParameters& params) : m_parameters(params) {} + explicit InputTrackStub(const BoundTrackParameters& params) + : m_parameters(params) {} const BoundTrackParameters& parameters() const { return m_parameters; } @@ -325,7 +329,8 @@ BOOST_AUTO_TEST_CASE(track_density_finder_usertrack_test) { GaussianTrackDensity::Config densityCfg; densityCfg.extractParameters.connect(extractParameters); - TrackDensityVertexFinder finder{{{densityCfg}}}; + TrackDensityVertexFinder finder{ + TrackDensityVertexFinder::Config{Acts::GaussianTrackDensity(densityCfg)}}; auto state = finder.makeState(magFieldContext); // Start creating some track parameters diff --git a/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp index 01d0c033bb1..2828450dbd8 100644 --- a/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp @@ -187,7 +187,8 @@ BOOST_AUTO_TEST_CASE(zscan_finder_test) { // Dummy user-defined InputTrackStub type struct InputTrackStub { - InputTrackStub(const BoundTrackParameters& params) : m_parameters(params) {} + explicit InputTrackStub(const BoundTrackParameters& params) + : m_parameters(params) {} const BoundTrackParameters& parameters() const { return m_parameters; } diff --git a/Tests/UnitTests/Examples/EventData/MeasurementTests.cpp b/Tests/UnitTests/Examples/EventData/MeasurementTests.cpp index 1cb5450a792..9769232adf5 100644 --- a/Tests/UnitTests/Examples/EventData/MeasurementTests.cpp +++ b/Tests/UnitTests/Examples/EventData/MeasurementTests.cpp @@ -35,7 +35,7 @@ namespace { constexpr BoundIndices boundIndices[] = { eBoundLoc0, eBoundLoc1, eBoundTime, eBoundPhi, eBoundTheta, eBoundQOverP, }; -constexpr Acts::GeometryIdentifier geoId = 1; +constexpr Acts::GeometryIdentifier geoId{1}; // fix seed for reproducible tests std::default_random_engine rng(123); } // namespace diff --git a/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp b/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp index 45ed254ddd0..cd0e2e88488 100644 --- a/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp +++ b/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp @@ -269,8 +269,6 @@ BOOST_AUTO_TEST_CASE(RoundTripTests) { auto trackStateContainer = std::make_shared(); TrackContainer tracks(trackContainer, trackStateContainer); - using const_proxy_t = decltype(tracks)::ConstTrackProxy; - std::mt19937 rng{42}; std::normal_distribution gauss(0., 1.); std::uniform_real_distribution f(-1, 1); @@ -352,7 +350,7 @@ BOOST_AUTO_TEST_CASE(RoundTripTests) { auto logger = getDefaultLogger("EDM4hep", Logging::INFO); - for (const_proxy_t track : tracks) { + for (const auto& track : tracks) { auto to = edm4hepTracks.create(); EDM4hepUtil::writeTrack(gctx, track, to, Bz, *logger); } @@ -374,7 +372,8 @@ BOOST_AUTO_TEST_CASE(RoundTripTests) { std::make_shared()); for (const auto edm4hepTrack : edm4hepTracksConst) { - EDM4hepUtil::readTrack(edm4hepTrack, readTracks.makeTrack(), Bz, *logger); + auto track = readTracks.makeTrack(); + EDM4hepUtil::readTrack(edm4hepTrack, track, Bz, *logger); } BOOST_CHECK_EQUAL(tracks.size(), readTracks.size()); diff --git a/Tests/UnitTests/Plugins/Podio/PodioTrackStateContainerTest.cpp b/Tests/UnitTests/Plugins/Podio/PodioTrackStateContainerTest.cpp index 9169568fd60..efd653364b0 100644 --- a/Tests/UnitTests/Plugins/Podio/PodioTrackStateContainerTest.cpp +++ b/Tests/UnitTests/Plugins/Podio/PodioTrackStateContainerTest.cpp @@ -97,7 +97,9 @@ struct Factory { MapHelper m_helper; - MutablePodioTrackStateContainer create() { return {m_helper}; } + MutablePodioTrackStateContainer create() { + return MutablePodioTrackStateContainer{m_helper}; + } }; using CommonTests = MultiTrajectoryTestsCommon; diff --git a/docs/_extensions/lazy_autodoc.py b/docs/_extensions/lazy_autodoc.py index dfc259e50fc..39590927257 100644 --- a/docs/_extensions/lazy_autodoc.py +++ b/docs/_extensions/lazy_autodoc.py @@ -98,6 +98,7 @@ def run() -> None: "Acts::TrapezoidVolumeBounds", "Acts::CylinderVolumeStack", "Acts::CuboidVolumeStack", + "Acts::VolumeStack", "Acts::GeometryObject", "Acts::TrackContainer", "Acts::ConeLayer", diff --git a/docs/core/geometry/construction.md b/docs/core/geometry/construction.md index 076b5ef5fbf..7a6c9eede61 100644 --- a/docs/core/geometry/construction.md +++ b/docs/core/geometry/construction.md @@ -17,6 +17,12 @@ Not complete yet :::{doxygenclass} Acts::Experimental::CylinderContainerBlueprintNode ::: +:::{doxygenclass} Acts::Experimental::CuboidContainerBlueprintNode +::: + +:::{doxygenclass} Acts::Experimental::ContainerBlueprintNode +::: + ### Material nodes :::{doxygenclass} Acts::Experimental::MaterialDesignatorBlueprintNode