diff --git a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp index 0e08b0d9a80..75344e256a2 100644 --- a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp @@ -69,22 +69,17 @@ class CuboidVolumeBounds : public VolumeBounds { /// Constructor - from a fixed size array /// /// @param values iw the bound values - CuboidVolumeBounds(const std::array& values) noexcept( - false) - : m_values(values) { - checkConsistency(); - buildSurfaceBounds(); - } + CuboidVolumeBounds(const std::array& values); /// Copy Constructor /// /// @param bobo is the source volume bounds to be copied - CuboidVolumeBounds(const CuboidVolumeBounds& bobo); + CuboidVolumeBounds(const CuboidVolumeBounds& bobo) = default; /// Assignment operator /// /// @param bobo is the source volume bounds to be assigned - CuboidVolumeBounds& operator=(const CuboidVolumeBounds& bobo); + CuboidVolumeBounds& operator=(const CuboidVolumeBounds& bobo) = default; ~CuboidVolumeBounds() override = default; @@ -143,6 +138,15 @@ class CuboidVolumeBounds : public VolumeBounds { /// @param bValue the class nested enum for the array access ActsScalar get(BoundValues bValue) const { return m_values[bValue]; } + /// Set a bound value + /// @param bValue the bound value identifier + /// @param value the value to be set + void set(BoundValues bValue, ActsScalar value); + + /// Set a range of bound values + /// @param keyValues the initializer list of key value pairs + void set(std::initializer_list> keyValues); + /// Output Method for std::ostream /// /// @param os is ostream operator to be dumped into diff --git a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp index bbee85fdb5c..3f16bd6a6f5 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp @@ -12,15 +12,12 @@ #include "Acts/Geometry/Volume.hpp" #include "Acts/Geometry/VolumeBounds.hpp" #include "Acts/Utilities/BinningType.hpp" -#include "Acts/Utilities/detail/periodic.hpp" #include -#include -#include +#include #include #include #include -#include #include namespace Acts { @@ -96,36 +93,24 @@ class CylinderVolumeBounds : public VolumeBounds { /// @param bevelMaxZ The bevel angle, in radians, for the positive side CylinderVolumeBounds(ActsScalar rmin, ActsScalar rmax, ActsScalar halfz, ActsScalar halfphi = M_PI, ActsScalar avgphi = 0., - ActsScalar bevelMinZ = 0., - ActsScalar bevelMaxZ = 0.) noexcept(false) - : m_values({rmin, rmax, halfz, halfphi, avgphi, bevelMinZ, bevelMaxZ}) { - checkConsistency(); - buildSurfaceBounds(); - } + ActsScalar bevelMinZ = 0., ActsScalar bevelMaxZ = 0.); /// Constructor - from a fixed size array /// /// @param values The bound values - CylinderVolumeBounds(const std::array& values) noexcept( - false) - : m_values(values) { - checkConsistency(); - buildSurfaceBounds(); - } + CylinderVolumeBounds(const std::array& values); /// Constructor - extruded from cylinder bounds and thickness /// /// @param cBounds the cylinder bounds /// @param thickness of the extrusion - CylinderVolumeBounds(const CylinderBounds& cBounds, - ActsScalar thickness) noexcept(false); + CylinderVolumeBounds(const CylinderBounds& cBounds, ActsScalar thickness); /// Constructor - extruded from radial bounds and thickness /// /// @param rBounds the Radial bounds /// @param thickness - CylinderVolumeBounds(const RadialBounds& rBounds, - ActsScalar thickness) noexcept(false); + CylinderVolumeBounds(const RadialBounds& rBounds, ActsScalar thickness); /// Copy Constructor /// @@ -199,9 +184,19 @@ class CylinderVolumeBounds : public VolumeBounds { /// @param bValue the class nested enum for the array access ActsScalar get(BoundValues bValue) const { return m_values[bValue]; } + /// Set a bound value + /// @param bValue the bound value identifier + /// @param value the value to be set + void set(BoundValues bValue, ActsScalar value); + + /// Set a range of bound values + /// @param keyValues the initializer list of key value pairs + void set(std::initializer_list> keyValues); + private: /// The internal version of the bounds can be float/ActsScalar std::array m_values{}; + /// Bounds of the inner CylinderBounds std::shared_ptr m_innerCylinderBounds{nullptr}; /// Bounds of the inner CylinderBounds @@ -213,7 +208,7 @@ class CylinderVolumeBounds : public VolumeBounds { /// Check the input values for consistency, /// will throw a logic_exception if consistency is not given - void checkConsistency() noexcept(false); + void checkConsistency(); /// Helper method to create the surface bounds void buildSurfaceBounds(); diff --git a/Core/include/Acts/Geometry/CylinderVolumeHelper.hpp b/Core/include/Acts/Geometry/CylinderVolumeHelper.hpp index 84ce33f41cb..ec1ee433a88 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeHelper.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeHelper.hpp @@ -79,7 +79,7 @@ class CylinderVolumeHelper : public ITrackingVolumeHelper { MutableTrackingVolumePtr createTrackingVolume( const GeometryContext& gctx, const LayerVector& layers, std::shared_ptr volumeMaterial, - std::shared_ptr volumeBounds, + std::shared_ptr volumeBounds, MutableTrackingVolumeVector mtvVector = {}, const Transform3& transform = Transform3::Identity(), const std::string& volumeName = "UndefinedVolume", @@ -205,7 +205,7 @@ class CylinderVolumeHelper : public ITrackingVolumeHelper { /// @param bType is the type of binning: equidistant, arbitrary bool estimateAndCheckDimension( const GeometryContext& gctx, const LayerVector& layers, - const CylinderVolumeBounds*& cylinderVolumeBounds, + std::shared_ptr& cylinderVolumeBounds, const Transform3& transform, double& rMinClean, double& rMaxClean, double& zMinClean, double& zMaxClean, BinningValue& bValue, BinningType bType = arbitrary) const; diff --git a/Core/include/Acts/Geometry/ITrackingVolumeHelper.hpp b/Core/include/Acts/Geometry/ITrackingVolumeHelper.hpp index df3e75f2549..dce7319e8b5 100644 --- a/Core/include/Acts/Geometry/ITrackingVolumeHelper.hpp +++ b/Core/include/Acts/Geometry/ITrackingVolumeHelper.hpp @@ -63,7 +63,7 @@ class ITrackingVolumeHelper { virtual MutableTrackingVolumePtr createTrackingVolume( const GeometryContext& gctx, const LayerVector& layers, std::shared_ptr volumeMaterial, - std::shared_ptr volumeBounds, + std::shared_ptr volumeBounds, MutableTrackingVolumeVector mtvVector = {}, const Transform3& transform = Transform3::Identity(), const std::string& volumeName = "UndefinedVolume", diff --git a/Core/include/Acts/Geometry/TrackingVolume.hpp b/Core/include/Acts/Geometry/TrackingVolume.hpp index 6b6a98f195a..f49c3bd3745 100644 --- a/Core/include/Acts/Geometry/TrackingVolume.hpp +++ b/Core/include/Acts/Geometry/TrackingVolume.hpp @@ -113,51 +113,38 @@ class TrackingVolume : public Volume { TrackingVolume(const TrackingVolume&) = delete; TrackingVolume& operator=(const TrackingVolume&) = delete; - /// Factory constructor for a container TrackingVolume - /// - by definition a Vacuum volume + /// Constructor for a container Volume + /// - vacuum filled volume either as a for other tracking volumes /// /// @param transform is the global 3D transform to position the volume in /// space - /// @param volumeBounds is the description of the volume boundaries - /// @param containedVolumes are the static volumes that fill this volume + /// @param volbounds is the description of the volume boundaries + /// @param containedVolumeArray are the static volumes that fill this volume /// @param volumeName is a string identifier - /// - /// @return shared pointer to a new TrackingVolume - static MutableTrackingVolumePtr create( - const Transform3& transform, - std::shared_ptr volumeBounds, - const std::shared_ptr& containedVolumes = - nullptr, - const std::string& volumeName = "undefined") { - return MutableTrackingVolumePtr(new TrackingVolume( - transform, std::move(volumeBounds), containedVolumes, volumeName)); - } - /// Factory constructor for Tracking Volumes with content - /// - can not be a container volume + TrackingVolume(const Transform3& transform, + std::shared_ptr volbounds, + const std::shared_ptr& + containedVolumeArray = nullptr, + const std::string& volumeName = "undefined"); + + /// Constructor for a full equipped Tracking Volume /// /// @param transform is the global 3D transform to position the volume in /// space /// @param volumeBounds is the description of the volume boundaries /// @param volumeMaterial is are materials of the tracking volume - /// @param containedLayers is the confined layer array (optional) - /// @param containedVolumes is the confined volume array (optional) - /// @param denseVolumes is the array of dense volulmes (optional) + /// @param staticLayerArray is the confined layer array (optional) + /// @param containedVolumeArray are the sub volumes if the volume is a + /// container + /// @param denseVolumeVector The contained dense volumes /// @param volumeName is a string identifier - /// - /// @return shared pointer to a new TrackingVolume - static MutableTrackingVolumePtr create( - const Transform3& transform, - std::shared_ptr volumeBounds, + TrackingVolume( + const Transform3& transform, std::shared_ptr volumeBounds, std::shared_ptr volumeMaterial, - std::unique_ptr containedLayers = nullptr, - std::shared_ptr containedVolumes = nullptr, - MutableTrackingVolumeVector denseVolumes = {}, - const std::string& volumeName = "undefined") { - return MutableTrackingVolumePtr(new TrackingVolume( - transform, std::move(volumeBounds), std::move(volumeMaterial), - std::move(containedLayers), std::move(containedVolumes), - std::move(denseVolumes), volumeName)); - } + std::unique_ptr staticLayerArray = nullptr, + std::shared_ptr containedVolumeArray = nullptr, + MutableTrackingVolumeVector denseVolumeVector = {}, + const std::string& volumeName = "undefined"); /// Return the associated Layer to the global position /// @@ -200,21 +187,6 @@ class TrackingVolume : public Volume { const Vector3& direction, const NavigationOptions& options, const Logger& logger = getDummyLogger()) const; - /// @brief Return surfaces in given direction from bounding volume hierarchy - /// @tparam options_t Type of navigation options object for decomposition - /// - /// @param gctx The current geometry context object, e.g. alignment - /// @param position The position to start from - /// @param direction The direction towards which to test - /// @param angle The opening angle - /// @param options The templated navigation options - /// - /// @return Vector of surface candidates - std::vector compatibleSurfacesFromHierarchy( - const GeometryContext& gctx, const Vector3& position, - const Vector3& direction, double angle, - const NavigationOptions& options) const; - /// Return the associated sub Volume, returns THIS if no subVolume exists /// /// @param gctx The current geometry context object, e.g. alignment @@ -413,45 +385,13 @@ class TrackingVolume : public Volume { /// Return the MotherVolume - if it exists const TrackingVolume* motherVolume() const; + /// Return the MotherVolume - if it exists + TrackingVolume* motherVolume(); + /// Set the MotherVolume /// /// @param mvol is the mother volume - void setMotherVolume(const TrackingVolume* mvol); - - protected: - /// Constructor for a container Volume - /// - vacuum filled volume either as a for other tracking volumes - /// - /// @param transform is the global 3D transform to position the volume in - /// space - /// @param volbounds is the description of the volume boundaries - /// @param containedVolumeArray are the static volumes that fill this volume - /// @param volumeName is a string identifier - TrackingVolume(const Transform3& transform, - std::shared_ptr volbounds, - const std::shared_ptr& - containedVolumeArray = nullptr, - const std::string& volumeName = "undefined"); - - /// Constructor for a full equipped Tracking Volume - /// - /// @param transform is the global 3D transform to position the volume in - /// space - /// @param volumeBounds is the description of the volume boundaries - /// @param volumeMaterial is are materials of the tracking volume - /// @param staticLayerArray is the confined layer array (optional) - /// @param containedVolumeArray are the sub volumes if the volume is a - /// container - /// @param denseVolumeVector The contained dense volumes - /// @param volumeName is a string identifier - TrackingVolume( - const Transform3& transform, - std::shared_ptr volumeBounds, - std::shared_ptr volumeMaterial, - std::unique_ptr staticLayerArray = nullptr, - std::shared_ptr containedVolumeArray = nullptr, - MutableTrackingVolumeVector denseVolumeVector = {}, - const std::string& volumeName = "undefined"); + void setMotherVolume(TrackingVolume* mvol); private: void connectDenseBoundarySurfaces( @@ -474,7 +414,7 @@ class TrackingVolume : public Volume { /// @param vol is the geometry id of the volume /// as calculated by the TrackingGeometry /// @param hook Identifier hook to be applied to surfaces - /// @param logger A @c LoggerWrapper instance + /// @param logger A @c Logger instance /// void closeGeometry( const IMaterialDecorator* materialDecorator, @@ -489,7 +429,7 @@ class TrackingVolume : public Volume { std::shared_ptr m_volumeMaterial{nullptr}; /// Remember the mother volume - const TrackingVolume* m_motherVolume{nullptr}; + TrackingVolume* m_motherVolume{nullptr}; // the boundary surfaces std::vector m_boundarySurfaces; @@ -511,47 +451,4 @@ class TrackingVolume : public Volume { std::string m_name; }; -inline const std::string& TrackingVolume::volumeName() const { - return m_name; -} - -inline const IVolumeMaterial* TrackingVolume::volumeMaterial() const { - return m_volumeMaterial.get(); -} - -inline const std::shared_ptr& -TrackingVolume::volumeMaterialSharedPtr() const { - return m_volumeMaterial; -} - -inline void TrackingVolume::assignVolumeMaterial( - std::shared_ptr material) { - m_volumeMaterial = std::move(material); -} - -inline const LayerArray* TrackingVolume::confinedLayers() const { - return m_confinedLayers.get(); -} - -inline const MutableTrackingVolumeVector TrackingVolume::denseVolumes() const { - return m_confinedDenseVolumes; -} - -inline std::shared_ptr -TrackingVolume::confinedVolumes() const { - return m_confinedVolumes; -} - -inline const TrackingVolume* TrackingVolume::motherVolume() const { - return m_motherVolume; -} - -inline void TrackingVolume::setMotherVolume(const TrackingVolume* mvol) { - m_motherVolume = mvol; -} - -#ifndef DOXYGEN -#include "Acts/Geometry/detail/TrackingVolume.ipp" -#endif - } // namespace Acts diff --git a/Core/include/Acts/Geometry/Volume.hpp b/Core/include/Acts/Geometry/Volume.hpp index 037bfdfaeb7..93cf47b11d7 100644 --- a/Core/include/Acts/Geometry/Volume.hpp +++ b/Core/include/Acts/Geometry/Volume.hpp @@ -37,8 +37,6 @@ class Volume : public virtual GeometryObject { /// /// @param transform is the transform to position the volume in 3D space /// @param volbounds is the volume boundary definitions - /// @note This will automatically build an oriented bounding box with an - /// envelope value of (0.05, 0.05, 0.05)mm Volume(const Transform3& transform, std::shared_ptr volbounds); @@ -46,8 +44,6 @@ class Volume : public virtual GeometryObject { /// /// @param vol is the source volume for the copy /// @param shift is the optional shift applied as : shift * vol.transform() - /// @note This will automatically build an oriented bounding box with an - /// envelope value of (0.05, 0.05, 0.05)mm Volume(const Volume& vol, const Transform3& shift = Transform3::Identity()); Volume() = delete; @@ -67,11 +63,11 @@ class Volume : public virtual GeometryObject { /// returns the center of the volume const Vector3& center() const; - /// returns the volumeBounds() + /// Returns const reference to the volume bounds const VolumeBounds& volumeBounds() const; /// Set volume bounds and update volume bounding boxes implicitly - void assignVolumeBounds(std::shared_ptr volbounds); + void assignVolumeBounds(std::shared_ptr volbounds); /// Construct bounding box for this shape /// @param envelope Optional envelope to add / subtract from min/max @@ -79,8 +75,10 @@ class Volume : public virtual GeometryObject { BoundingBox boundingBox(const Vector3& envelope = {0, 0, 0}) const; /// Construct oriented bounding box for this shape + /// @note This will build an oriented bounding box with an + /// envelope value of (0.05, 0.05, 0.05)mm /// @return Constructed oriented bounding box pointing to this volume - const BoundingBox& orientedBoundingBox() const; + BoundingBox orientedBoundingBox() const; /// Inside() method for checks /// @@ -105,7 +103,6 @@ class Volume : public virtual GeometryObject { Transform3 m_itransform; Vector3 m_center; std::shared_ptr m_volumeBounds; - BoundingBox m_orientedBoundingBox; }; /**Overload of << operator for std::ostream for debug output*/ diff --git a/Core/include/Acts/Geometry/detail/TrackingVolume.ipp b/Core/include/Acts/Geometry/detail/TrackingVolume.ipp deleted file mode 100644 index 6894648867a..00000000000 --- a/Core/include/Acts/Geometry/detail/TrackingVolume.ipp +++ /dev/null @@ -1,18 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2018 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -inline const Acts::Layer* TrackingVolume::associatedLayer( - const GeometryContext& /*gctx*/, const Vector3& position) const { - // confined static layers - highest hierarchy - if (m_confinedLayers != nullptr) { - return (m_confinedLayers->object(position).get()); - } - - // return the null pointer - return nullptr; -} diff --git a/Core/src/Geometry/CuboidVolumeBounds.cpp b/Core/src/Geometry/CuboidVolumeBounds.cpp index ea286735d5b..2f4c122cb0f 100644 --- a/Core/src/Geometry/CuboidVolumeBounds.cpp +++ b/Core/src/Geometry/CuboidVolumeBounds.cpp @@ -14,7 +14,6 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/BoundingBox.hpp" -#include #include namespace Acts { @@ -26,22 +25,11 @@ CuboidVolumeBounds::CuboidVolumeBounds(ActsScalar halex, ActsScalar haley, buildSurfaceBounds(); } -CuboidVolumeBounds::CuboidVolumeBounds(const CuboidVolumeBounds& bobo) - : VolumeBounds(), - m_values(bobo.m_values), - m_xyBounds(bobo.m_xyBounds), - m_yzBounds(bobo.m_yzBounds), - m_zxBounds(bobo.m_zxBounds) {} - -CuboidVolumeBounds& CuboidVolumeBounds::operator=( - const CuboidVolumeBounds& bobo) { - if (this != &bobo) { - m_values = bobo.m_values; - m_xyBounds = bobo.m_xyBounds; - m_yzBounds = bobo.m_yzBounds; - m_zxBounds = bobo.m_zxBounds; - } - return *this; +CuboidVolumeBounds::CuboidVolumeBounds( + const std::array& values) + : m_values(values) { + checkConsistency(); + buildSurfaceBounds(); } std::vector Acts::CuboidVolumeBounds::orientedSurfaces( @@ -144,4 +132,24 @@ void CuboidVolumeBounds::checkConsistency() noexcept(false) { "CuboidVolumeBounds: invalid input, zero or negative."); } } + +void CuboidVolumeBounds::set(BoundValues bValue, ActsScalar value) { + set({{bValue, value}}); +} + +void CuboidVolumeBounds::set( + std::initializer_list> keyValues) { + std::array previous = m_values; + for (const auto& [key, value] : keyValues) { + m_values[key] = value; + } + try { + checkConsistency(); + buildSurfaceBounds(); + } catch (std::invalid_argument& e) { + m_values = previous; + throw e; + } +} + } // namespace Acts diff --git a/Core/src/Geometry/CuboidVolumeBuilder.cpp b/Core/src/Geometry/CuboidVolumeBuilder.cpp index 617694d06ad..4edf66a0a44 100644 --- a/Core/src/Geometry/CuboidVolumeBuilder.cpp +++ b/Core/src/Geometry/CuboidVolumeBuilder.cpp @@ -149,7 +149,7 @@ std::shared_ptr Acts::CuboidVolumeBuilder::buildVolume( Transform3 trafo(Transform3::Identity()); trafo.translation() = cfg.position; // Set bounds - auto bounds = std::make_shared( + auto bounds = std::make_shared( cfg.length.x() * 0.5, cfg.length.y() * 0.5, cfg.length.z() * 0.5); // Gather the layers @@ -186,14 +186,14 @@ std::shared_ptr Acts::CuboidVolumeBuilder::buildVolume( std::shared_ptr trackVolume; if (layVec.empty()) { // Build TrackingVolume - trackVolume = - TrackingVolume::create(trafo, bounds, cfg.volumeMaterial, nullptr, - nullptr, cfg.trackingVolumes, cfg.name); + trackVolume = std::make_shared( + trafo, bounds, cfg.volumeMaterial, nullptr, nullptr, + cfg.trackingVolumes, cfg.name); } else { // Build TrackingVolume - trackVolume = TrackingVolume::create(trafo, bounds, cfg.volumeMaterial, - std::move(layArr), nullptr, - cfg.trackingVolumes, cfg.name); + trackVolume = std::make_shared( + trafo, bounds, cfg.volumeMaterial, std::move(layArr), nullptr, + cfg.trackingVolumes, cfg.name); } return trackVolume; } @@ -230,7 +230,7 @@ Acts::MutableTrackingVolumePtr Acts::CuboidVolumeBuilder::trackingVolume( trafo.translation() = m_cfg.position; // Size of the volume - auto volume = std::make_shared( + auto volume = std::make_shared( m_cfg.length.x() * 0.5, m_cfg.length.y() * 0.5, m_cfg.length.z() * 0.5); // Build vector of confined volumes @@ -259,7 +259,7 @@ Acts::MutableTrackingVolumePtr Acts::CuboidVolumeBuilder::trackingVolume( // Create world volume MutableTrackingVolumePtr mtvp( - TrackingVolume::create(trafo, volume, trVolArr, "World")); + std::make_shared(trafo, volume, trVolArr, "World")); return mtvp; } diff --git a/Core/src/Geometry/CylinderLayer.cpp b/Core/src/Geometry/CylinderLayer.cpp index 5ad76e6e89f..c11455e4cba 100644 --- a/Core/src/Geometry/CylinderLayer.cpp +++ b/Core/src/Geometry/CylinderLayer.cpp @@ -34,7 +34,7 @@ Acts::CylinderLayer::CylinderLayer( : CylinderSurface(transform, cBounds), Layer(std::move(surfaceArray), thickness, std::move(ades), laytyp) { // create the representing volume - auto cVolumeBounds = std::make_shared( + auto cVolumeBounds = std::make_shared( *CylinderSurface::m_bounds, thickness); // @todo rotate around x for the avePhi if you have a sector m_representingVolume = std::make_unique(m_transform, cVolumeBounds); diff --git a/Core/src/Geometry/CylinderVolumeBounds.cpp b/Core/src/Geometry/CylinderVolumeBounds.cpp index 0f6a10a7f09..84f34edcf2f 100644 --- a/Core/src/Geometry/CylinderVolumeBounds.cpp +++ b/Core/src/Geometry/CylinderVolumeBounds.cpp @@ -8,6 +8,7 @@ #include "Acts/Geometry/CylinderVolumeBounds.hpp" +#include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Direction.hpp" #include "Acts/Definitions/Tolerance.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" @@ -20,13 +21,36 @@ #include "Acts/Utilities/BoundingBox.hpp" #include -#include #include namespace Acts { +CylinderVolumeBounds::CylinderVolumeBounds(ActsScalar rmin, ActsScalar rmax, + ActsScalar halfz, ActsScalar halfphi, + ActsScalar avgphi, + ActsScalar bevelMinZ, + ActsScalar bevelMaxZ) + : m_values() { + m_values[eMinR] = rmin; + m_values[eMaxR] = rmax; + m_values[eHalfLengthZ] = halfz; + m_values[eHalfPhiSector] = halfphi; + m_values[eAveragePhi] = avgphi; + m_values[eBevelMinZ] = bevelMinZ; + m_values[eBevelMaxZ] = bevelMaxZ; + checkConsistency(); + buildSurfaceBounds(); +} + +CylinderVolumeBounds::CylinderVolumeBounds( + const std::array& values) + : m_values(values) { + checkConsistency(); + buildSurfaceBounds(); +} + CylinderVolumeBounds::CylinderVolumeBounds(const CylinderBounds& cBounds, - ActsScalar thickness) noexcept(false) + ActsScalar thickness) : VolumeBounds() { ActsScalar cR = cBounds.get(CylinderBounds::eR); if (thickness <= 0. || (cR - 0.5 * thickness) < 0.) { @@ -44,7 +68,7 @@ CylinderVolumeBounds::CylinderVolumeBounds(const CylinderBounds& cBounds, } CylinderVolumeBounds::CylinderVolumeBounds(const RadialBounds& rBounds, - ActsScalar thickness) noexcept(false) + ActsScalar thickness) : VolumeBounds() { if (thickness <= 0.) { throw(std::invalid_argument( @@ -55,8 +79,8 @@ CylinderVolumeBounds::CylinderVolumeBounds(const RadialBounds& rBounds, m_values[eHalfLengthZ] = 0.5 * thickness; m_values[eHalfPhiSector] = rBounds.get(RadialBounds::eHalfPhiSector); m_values[eAveragePhi] = rBounds.get(RadialBounds::eAveragePhi); - m_values[eBevelMinZ] = (ActsScalar)0.; - m_values[eBevelMaxZ] = (ActsScalar)0.; + m_values[eBevelMinZ] = 0.; + m_values[eBevelMaxZ] = 0.; buildSurfaceBounds(); } @@ -231,7 +255,7 @@ std::vector CylinderVolumeBounds::values() const { return valvector; } -void CylinderVolumeBounds::checkConsistency() noexcept(false) { +void CylinderVolumeBounds::checkConsistency() { if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) >= get(eMaxR)) { throw std::invalid_argument("CylinderVolumeBounds: invalid radial input."); } @@ -255,4 +279,23 @@ void CylinderVolumeBounds::checkConsistency() noexcept(false) { } } +void CylinderVolumeBounds::set(BoundValues bValue, ActsScalar value) { + set({{bValue, value}}); +} + +void CylinderVolumeBounds::set( + std::initializer_list> keyValues) { + std::array previous = m_values; + for (const auto& [key, value] : keyValues) { + m_values[key] = value; + } + try { + checkConsistency(); + buildSurfaceBounds(); + } catch (std::invalid_argument& e) { + m_values = previous; + throw e; + } +} + } // namespace Acts diff --git a/Core/src/Geometry/CylinderVolumeHelper.cpp b/Core/src/Geometry/CylinderVolumeHelper.cpp index fd19dd52a49..519712e451e 100644 --- a/Core/src/Geometry/CylinderVolumeHelper.cpp +++ b/Core/src/Geometry/CylinderVolumeHelper.cpp @@ -67,7 +67,7 @@ std::shared_ptr Acts::CylinderVolumeHelper::createTrackingVolume( const GeometryContext& gctx, const LayerVector& layers, std::shared_ptr volumeMaterial, - std::shared_ptr volumeBounds, + std::shared_ptr volumeBounds, MutableTrackingVolumeVector mtvVector, const Transform3& transform, const std::string& volumeName, BinningType bType) const { // the final one to build / sensitive Volume / Bounds @@ -85,16 +85,13 @@ Acts::CylinderVolumeHelper::createTrackingVolume( // translation from layers bool idTrf = transform.isApprox(Transform3::Identity()); - const CylinderVolumeBounds* cylinderBounds = nullptr; + auto cylinderBounds = + std::dynamic_pointer_cast(volumeBounds); // this is the implementation of CylinderVolumeHelper - if (volumeBounds) { - cylinderBounds = - dynamic_cast(volumeBounds.get()); - if (cylinderBounds == nullptr) { - ACTS_WARNING( - "[!] Problem: given bounds are not cylindrical - return nullptr"); - return tVolume; - } + if (volumeBounds != nullptr && cylinderBounds == nullptr) { + ACTS_WARNING( + "[!] Problem: given bounds are not cylindrical - return nullptr"); + return tVolume; } // this is only needed if layers are provided if (!layers.empty()) { @@ -113,12 +110,10 @@ Acts::CylinderVolumeHelper::createTrackingVolume( ACTS_WARNING( "[!] Problem with given dimensions - return nullptr and " "delete provided objects"); - // delete if newly created bounds - if (volumeBounds == nullptr) { - delete cylinderBounds; - } return tVolume; } + // we might have overwritten the bounds in estimateAndCheckDimension + volumeBounds = cylinderBounds; // get the zMin/Max double zMin = (!idTrf ? transform.translation().z() : 0.) + @@ -150,15 +145,10 @@ Acts::CylinderVolumeHelper::createTrackingVolume( zMax, bType, bValue); } // layers are created and done - // make sure the ownership of the bounds is correct - std::shared_ptr volumeBoundsFinal = - volumeBounds.get() != nullptr - ? volumeBounds - : std::shared_ptr(cylinderBounds); // finally create the TrackingVolume - tVolume = TrackingVolume::create(transform, volumeBoundsFinal, volumeMaterial, - std::move(layerArray), nullptr, mtvVector, - volumeName); + tVolume = std::make_shared( + transform, volumeBounds, volumeMaterial, std::move(layerArray), nullptr, + mtvVector, volumeName); // screen output ACTS_VERBOSE( "Created cylindrical volume at z-position :" << tVolume->center().z()); @@ -174,9 +164,6 @@ Acts::CylinderVolumeHelper::createTrackingVolume( std::shared_ptr volumeMaterial, double rMin, double rMax, double zMin, double zMax, const std::string& volumeName, BinningType bType) const { - // The Bounds to e created - CylinderVolumeBounds* cBounds = nullptr; - // Screen output ACTS_VERBOSE("Create cylindrical TrackingVolume '" << volumeName << "'."); ACTS_VERBOSE(" -> with given dimensions of (rMin/rMax/zMin/Max) = " @@ -197,14 +184,14 @@ Acts::CylinderVolumeHelper::createTrackingVolume( zPosition = std::abs(zPosition) < 0.1 ? 0. : zPosition; // now create the cylinder volume bounds - cBounds = new CylinderVolumeBounds(rMin, rMax, halflengthZ); + auto cBounds = + std::make_shared(rMin, rMax, halflengthZ); // transform const Transform3 transform = Transform3(Translation3(0., 0., zPosition)); // call to the creation method with Bounds & Translation3 - return createTrackingVolume(gctx, layers, volumeMaterial, - std::shared_ptr(cBounds), - mtvVector, transform, volumeName, bType); + return createTrackingVolume(gctx, layers, volumeMaterial, cBounds, mtvVector, + transform, volumeName, bType); } std::shared_ptr @@ -401,7 +388,7 @@ Acts::CylinderVolumeHelper::createContainerTrackingVolume( return nullptr; } // we have the bounds and the volume array, create the volume - std::shared_ptr topVolume = TrackingVolume::create( + std::shared_ptr topVolume = std::make_shared( topVolumeTransform, topVolumeBounds, volumeArray, volumeName); // glueing section // -------------------------------------------------------------------------------------- @@ -423,7 +410,7 @@ Acts::CylinderVolumeHelper::createContainerTrackingVolume( * volume */ bool Acts::CylinderVolumeHelper::estimateAndCheckDimension( const GeometryContext& gctx, const LayerVector& layers, - const CylinderVolumeBounds*& cylinderVolumeBounds, + std::shared_ptr& cylinderVolumeBounds, const Transform3& transform, double& rMinClean, double& rMaxClean, double& zMinClean, double& zMaxClean, BinningValue& bValue, BinningType /*bType*/) const { @@ -518,8 +505,8 @@ bool Acts::CylinderVolumeHelper::estimateAndCheckDimension( // no CylinderBounds and Translation given - make it if ((cylinderVolumeBounds == nullptr) && idTrf) { // create the CylinderBounds from parsed layer inputs - cylinderVolumeBounds = - new CylinderVolumeBounds(layerRmin, layerRmax, halflengthFromLayer); + cylinderVolumeBounds = std::make_shared( + layerRmin, layerRmax, halflengthFromLayer); // and the transform vtransform = concentric ? Transform3(Translation3(0., 0., zEstFromLayerEnv)) : Transform3::Identity(); @@ -527,8 +514,8 @@ bool Acts::CylinderVolumeHelper::estimateAndCheckDimension( vtransform = Transform3(Translation3(0., 0., zEstFromLayerEnv)); } else if (!idTrf && (cylinderVolumeBounds == nullptr)) { // create the CylinderBounds from parsed layer inputs - cylinderVolumeBounds = - new CylinderVolumeBounds(layerRmin, layerRmax, halflengthFromLayer); + cylinderVolumeBounds = std::make_shared( + layerRmin, layerRmax, halflengthFromLayer); } ACTS_VERBOSE(" -> dimensions from layers (rMin/rMax/zMin/zMax) = " diff --git a/Core/src/Geometry/DiscLayer.cpp b/Core/src/Geometry/DiscLayer.cpp index 12bae79d970..ccb167f70a1 100644 --- a/Core/src/Geometry/DiscLayer.cpp +++ b/Core/src/Geometry/DiscLayer.cpp @@ -37,7 +37,7 @@ Acts::DiscLayer::DiscLayer(const Transform3& transform, if (rBounds != nullptr) { // The volume bounds auto rVolumeBounds = - std::make_shared(*rBounds, thickness); + std::make_shared(*rBounds, thickness); // @todo rotate around x for the avePhi if you have a sector m_representingVolume = std::make_unique(m_transform, rVolumeBounds); } diff --git a/Core/src/Geometry/TrackingVolume.cpp b/Core/src/Geometry/TrackingVolume.cpp index ab7c4745baa..7ede9c8eca0 100644 --- a/Core/src/Geometry/TrackingVolume.cpp +++ b/Core/src/Geometry/TrackingVolume.cpp @@ -34,10 +34,9 @@ namespace Acts { class ISurfaceMaterial; -} // namespace Acts -Acts::TrackingVolume::TrackingVolume( - const Transform3& transform, std::shared_ptr volbounds, +TrackingVolume::TrackingVolume( + const Transform3& transform, std::shared_ptr volbounds, const std::shared_ptr& containedVolumeArray, const std::string& volumeName) : Volume(transform, std::move(volbounds)), @@ -51,9 +50,8 @@ Acts::TrackingVolume::TrackingVolume( } // constructor for arguments -Acts::TrackingVolume::TrackingVolume( - const Transform3& transform, - std::shared_ptr volumeBounds, +TrackingVolume::TrackingVolume( + const Transform3& transform, std::shared_ptr volumeBounds, std::shared_ptr volumeMaterial, std::unique_ptr staticLayerArray, std::shared_ptr containedVolumeArray, @@ -70,11 +68,11 @@ Acts::TrackingVolume::TrackingVolume( connectDenseBoundarySurfaces(denseVolumeVector); } -Acts::TrackingVolume::~TrackingVolume() { +TrackingVolume::~TrackingVolume() { delete m_glueVolumeDescriptor; } -const Acts::TrackingVolume* Acts::TrackingVolume::lowestTrackingVolume( +const TrackingVolume* TrackingVolume::lowestTrackingVolume( const GeometryContext& /*gctx*/, const Vector3& position, const double tol) const { // confined static volumes - highest hierarchy @@ -95,12 +93,11 @@ const Acts::TrackingVolume* Acts::TrackingVolume::lowestTrackingVolume( return this; } -const Acts::TrackingVolumeBoundaries& Acts::TrackingVolume::boundarySurfaces() - const { +const TrackingVolumeBoundaries& TrackingVolume::boundarySurfaces() const { return (m_boundarySurfaces); } -void Acts::TrackingVolume::connectDenseBoundarySurfaces( +void TrackingVolume::connectDenseBoundarySurfaces( MutableTrackingVolumeVector& confinedDenseVolumes) { if (!confinedDenseVolumes.empty()) { Direction dir = Direction::Positive; @@ -141,7 +138,7 @@ void Acts::TrackingVolume::connectDenseBoundarySurfaces( } } -void Acts::TrackingVolume::createBoundarySurfaces() { +void TrackingVolume::createBoundarySurfaces() { using Boundary = BoundarySurfaceT; // Transform Surfaces To BoundarySurfaces @@ -161,10 +158,10 @@ void Acts::TrackingVolume::createBoundarySurfaces() { } } -void Acts::TrackingVolume::glueTrackingVolume(const GeometryContext& gctx, - BoundarySurfaceFace bsfMine, - TrackingVolume* neighbor, - BoundarySurfaceFace bsfNeighbor) { +void TrackingVolume::glueTrackingVolume(const GeometryContext& gctx, + BoundarySurfaceFace bsfMine, + TrackingVolume* neighbor, + BoundarySurfaceFace bsfNeighbor) { // Find the connection of the two tracking volumes: binR returns the center // except for cylindrical volumes Vector3 bPosition(binningPosition(gctx, binR)); @@ -204,7 +201,7 @@ void Acts::TrackingVolume::glueTrackingVolume(const GeometryContext& gctx, } } -void Acts::TrackingVolume::glueTrackingVolumes( +void TrackingVolume::glueTrackingVolumes( const GeometryContext& gctx, BoundarySurfaceFace bsfMine, const std::shared_ptr& neighbors, BoundarySurfaceFace bsfNeighbor) { @@ -243,7 +240,7 @@ void Acts::TrackingVolume::glueTrackingVolumes( } } -void Acts::TrackingVolume::assignBoundaryMaterial( +void TrackingVolume::assignBoundaryMaterial( std::shared_ptr surfaceMaterial, BoundarySurfaceFace bsFace) { auto bSurface = m_boundarySurfaces.at(bsFace); @@ -252,7 +249,7 @@ void Acts::TrackingVolume::assignBoundaryMaterial( surface->assignSurfaceMaterial(std::move(surfaceMaterial)); } -void Acts::TrackingVolume::updateBoundarySurface( +void TrackingVolume::updateBoundarySurface( BoundarySurfaceFace bsf, std::shared_ptr> bs, bool checkmaterial) { @@ -270,20 +267,19 @@ void Acts::TrackingVolume::updateBoundarySurface( m_boundarySurfaces.at(bsf) = std::move(bs); } -void Acts::TrackingVolume::registerGlueVolumeDescriptor( - GlueVolumesDescriptor* gvd) { +void TrackingVolume::registerGlueVolumeDescriptor(GlueVolumesDescriptor* gvd) { delete m_glueVolumeDescriptor; m_glueVolumeDescriptor = gvd; } -Acts::GlueVolumesDescriptor& Acts::TrackingVolume::glueVolumesDescriptor() { +GlueVolumesDescriptor& TrackingVolume::glueVolumesDescriptor() { if (m_glueVolumeDescriptor == nullptr) { m_glueVolumeDescriptor = new GlueVolumesDescriptor; } return (*m_glueVolumeDescriptor); } -void Acts::TrackingVolume::synchronizeLayers(double envelope) const { +void TrackingVolume::synchronizeLayers(double envelope) const { // case a : Layers exist // msgstream << MSG::VERBOSE << " -> synchronizing Layer dimensions of // TrackingVolume '" << volumeName() << "'." << endreq; @@ -317,7 +313,7 @@ void Acts::TrackingVolume::synchronizeLayers(double envelope) const { } } -void Acts::TrackingVolume::interlinkLayers() { +void TrackingVolume::interlinkLayers() { if (m_confinedLayers) { auto& layers = m_confinedLayers->arrayObjects(); @@ -347,7 +343,7 @@ void Acts::TrackingVolume::interlinkLayers() { } } -void Acts::TrackingVolume::closeGeometry( +void TrackingVolume::closeGeometry( const IMaterialDecorator* materialDecorator, std::unordered_map& volumeMap, std::size_t& vol, const GeometryIdentifierHook& hook, @@ -368,7 +364,7 @@ void Acts::TrackingVolume::closeGeometry( if (thisVolume->volumeMaterial() == nullptr && thisVolume->motherVolume() != nullptr && thisVolume->motherVolume()->volumeMaterial() != nullptr) { - auto protoMaterial = dynamic_cast( + auto protoMaterial = dynamic_cast( thisVolume->motherVolume()->volumeMaterial()); if (protoMaterial == nullptr) { thisVolume->assignVolumeMaterial( @@ -433,15 +429,16 @@ void Acts::TrackingVolume::closeGeometry( } // Returns the boundary surfaces ordered in probability to hit them based on -boost::container::small_vector -Acts::TrackingVolume::compatibleBoundaries( - const GeometryContext& gctx, const Vector3& position, - const Vector3& direction, const NavigationOptions& options, - const Logger& logger) const { +boost::container::small_vector +TrackingVolume::compatibleBoundaries(const GeometryContext& gctx, + const Vector3& position, + const Vector3& direction, + const NavigationOptions& options, + const Logger& logger) const { ACTS_VERBOSE("Finding compatibleBoundaries"); // Loop over boundarySurfaces and calculate the intersection auto excludeObject = options.startObject; - boost::container::small_vector bIntersections; + boost::container::small_vector bIntersections; // The Limits: current, path & overstepping double nearLimit = 0; @@ -549,12 +546,12 @@ Acts::TrackingVolume::compatibleBoundaries( return bIntersections; } -boost::container::small_vector -Acts::TrackingVolume::compatibleLayers( +boost::container::small_vector +TrackingVolume::compatibleLayers( const GeometryContext& gctx, const Vector3& position, const Vector3& direction, const NavigationOptions& options) const { // the layer intersections which are valid - boost::container::small_vector lIntersections; + boost::container::small_vector lIntersections; // the confinedLayers if (m_confinedLayers != nullptr) { @@ -594,3 +591,58 @@ Acts::TrackingVolume::compatibleLayers( // and return return lIntersections; } + +const std::string& TrackingVolume::volumeName() const { + return m_name; +} + +const IVolumeMaterial* TrackingVolume::volumeMaterial() const { + return m_volumeMaterial.get(); +} + +const std::shared_ptr& +TrackingVolume::volumeMaterialSharedPtr() const { + return m_volumeMaterial; +} + +void TrackingVolume::assignVolumeMaterial( + std::shared_ptr material) { + m_volumeMaterial = std::move(material); +} + +const LayerArray* TrackingVolume::confinedLayers() const { + return m_confinedLayers.get(); +} + +const MutableTrackingVolumeVector TrackingVolume::denseVolumes() const { + return m_confinedDenseVolumes; +} + +std::shared_ptr TrackingVolume::confinedVolumes() + const { + return m_confinedVolumes; +} + +const TrackingVolume* TrackingVolume::motherVolume() const { + return m_motherVolume; +} + +TrackingVolume* TrackingVolume::motherVolume() { + return m_motherVolume; +} + +void TrackingVolume::setMotherVolume(TrackingVolume* mvol) { + m_motherVolume = mvol; +} + +const Acts::Layer* TrackingVolume::associatedLayer( + const GeometryContext& /*gctx*/, const Vector3& position) const { + // confined static layers - highest hierarchy + if (m_confinedLayers != nullptr) { + return (m_confinedLayers->object(position).get()); + } + + // return the null pointer + return nullptr; +} +} // namespace Acts diff --git a/Core/src/Geometry/Volume.cpp b/Core/src/Geometry/Volume.cpp index d87da05a010..f3af6701e12 100644 --- a/Core/src/Geometry/Volume.cpp +++ b/Core/src/Geometry/Volume.cpp @@ -24,18 +24,14 @@ Volume::Volume(const Transform3& transform, m_transform(transform), m_itransform(m_transform.inverse()), m_center(m_transform.translation()), - m_volumeBounds(std::move(volbounds)), - m_orientedBoundingBox(m_volumeBounds->boundingBox( - nullptr, {0.05_mm, 0.05_mm, 0.05_mm}, this)) {} + m_volumeBounds(std::move(volbounds)) {} Volume::Volume(const Volume& vol, const Transform3& shift) : GeometryObject(), m_transform(shift * vol.m_transform), m_itransform(m_transform.inverse()), m_center(m_transform.translation()), - m_volumeBounds(vol.m_volumeBounds), - m_orientedBoundingBox(m_volumeBounds->boundingBox( - nullptr, {0.05_mm, 0.05_mm, 0.05_mm}, this)) {} + m_volumeBounds(vol.m_volumeBounds) {} Vector3 Volume::binningPosition(const GeometryContext& /*gctx*/, BinningValue bValue) const { @@ -73,14 +69,13 @@ Volume::BoundingBox Volume::boundingBox(const Vector3& envelope) const { return m_volumeBounds->boundingBox(&m_transform, envelope, this); } -const Volume::BoundingBox& Volume::orientedBoundingBox() const { - return m_orientedBoundingBox; +Volume::BoundingBox Volume::orientedBoundingBox() const { + return m_volumeBounds->boundingBox(nullptr, {0.05_mm, 0.05_mm, 0.05_mm}, + this); } -void Volume::assignVolumeBounds(std::shared_ptr volbounds) { +void Volume::assignVolumeBounds(std::shared_ptr volbounds) { m_volumeBounds = std::move(volbounds); - m_orientedBoundingBox = - m_volumeBounds->boundingBox(nullptr, {0.05_mm, 0.05_mm, 0.05_mm}, this); } const Transform3& Volume::transform() const { diff --git a/Examples/Detectors/TelescopeDetector/src/BuildTelescopeDetector.cpp b/Examples/Detectors/TelescopeDetector/src/BuildTelescopeDetector.cpp index 0f8d2732ef1..35136911325 100644 --- a/Examples/Detectors/TelescopeDetector/src/BuildTelescopeDetector.cpp +++ b/Examples/Detectors/TelescopeDetector/src/BuildTelescopeDetector.cpp @@ -128,12 +128,12 @@ ActsExamples::Telescope::buildDetector( // The volume bounds is set to be a bit larger than either cubic with planes // or cylinder with discs auto length = positions.back() - positions.front(); - std::shared_ptr boundsVol = nullptr; + std::shared_ptr boundsVol = nullptr; if (surfaceType == TelescopeSurfaceType::Plane) { - boundsVol = std::make_shared( + boundsVol = std::make_shared( bounds[0] + 5._mm, bounds[1] + 5._mm, length + 10._mm); } else { - boundsVol = std::make_shared( + boundsVol = std::make_shared( std::max(bounds[0] - 5.0_mm, 0.), bounds[1] + 5._mm, length + 10._mm); } @@ -152,9 +152,9 @@ ActsExamples::Telescope::buildDetector( Acts::BinningType::arbitrary, binValue)); // Build the tracking volume - auto trackVolume = - Acts::TrackingVolume::create(trafoVol, boundsVol, nullptr, - std::move(layArr), nullptr, {}, "Telescope"); + auto trackVolume = std::make_shared( + trafoVol, boundsVol, nullptr, std::move(layArr), nullptr, + Acts::MutableTrackingVolumeVector{}, "Telescope"); // Build and return tracking geometry return std::make_unique(trackVolume); diff --git a/Plugins/DD4hep/src/DD4hepVolumeBuilder.cpp b/Plugins/DD4hep/src/DD4hepVolumeBuilder.cpp index 3b1d29ad7be..4b426d4c2b4 100644 --- a/Plugins/DD4hep/src/DD4hepVolumeBuilder.cpp +++ b/Plugins/DD4hep/src/DD4hepVolumeBuilder.cpp @@ -79,9 +79,8 @@ Acts::DD4hepVolumeBuilder::centralVolumes() const { "constructor!")); } // Build boundaries - CylinderVolumeBounds cvBounds(rMin, rMax, dz); - volumes.push_back(TrackingVolume::create( - transform, std::make_shared(cvBounds))); + volumes.push_back(std::make_shared( + transform, std::make_shared(rMin, rMax, dz))); } return volumes; } diff --git a/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CubicTrackingGeometry.hpp b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CubicTrackingGeometry.hpp index aeecc8d5f44..4dfdc816ac2 100644 --- a/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CubicTrackingGeometry.hpp +++ b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CubicTrackingGeometry.hpp @@ -126,8 +126,7 @@ struct CubicTrackingGeometry { Transform3 trafoVol1(Transform3::Identity()); trafoVol1.translation() = Vector3(-1.5_m, 0., 0.); - auto boundsVol = - std::make_shared(1.5_m, 0.5_m, 0.5_m); + auto boundsVol = std::make_shared(1.5_m, 0.5_m, 0.5_m); LayerArrayCreator::Config lacConfig; LayerArrayCreator layArrCreator( @@ -140,9 +139,9 @@ struct CubicTrackingGeometry { geoContext, layVec, -2_m - 1._mm, -1._m + 1._mm, BinningType::arbitrary, BinningValue::binX)); - auto trackVolume1 = - TrackingVolume::create(trafoVol1, boundsVol, nullptr, - std::move(layArr1), nullptr, {}, "Volume 1"); + auto trackVolume1 = std::make_shared( + trafoVol1, boundsVol, nullptr, std::move(layArr1), nullptr, + MutableTrackingVolumeVector{}, "Volume 1"); // Build volume for surfaces with positive x-values Transform3 trafoVol2(Transform3::Identity()); @@ -156,9 +155,9 @@ struct CubicTrackingGeometry { layArrCreator.layerArray(geoContext, layVec, 1._m - 2._mm, 2._m + 2._mm, BinningType::arbitrary, BinningValue::binX)); - auto trackVolume2 = - TrackingVolume::create(trafoVol2, boundsVol, nullptr, - std::move(layArr2), nullptr, {}, "Volume 2"); + auto trackVolume2 = std::make_shared( + trafoVol2, boundsVol, nullptr, std::move(layArr2), nullptr, + MutableTrackingVolumeVector{}, "Volume 2"); // Glue volumes trackVolume2->glueTrackingVolume( @@ -173,8 +172,7 @@ struct CubicTrackingGeometry { Transform3 trafoWorld(Transform3::Identity()); trafoWorld.translation() = Vector3(0., 0., 0.); - auto worldVol = - std::make_shared(3._m, 0.5_m, 0.5_m); + auto worldVolBds = std::make_shared(3._m, 0.5_m, 0.5_m); std::vector> tapVec; @@ -189,12 +187,11 @@ struct CubicTrackingGeometry { std::shared_ptr trVolArr( new BinnedArrayXD(tapVec, std::move(bu))); - MutableTrackingVolumePtr mtvpWorld( - TrackingVolume::create(trafoWorld, worldVol, trVolArr, "World")); + MutableTrackingVolumePtr mtvpWorld(std::make_shared( + trafoWorld, worldVolBds, trVolArr, "World")); // Build and return tracking geometry - return std::shared_ptr( - new Acts::TrackingGeometry(mtvpWorld)); + return std::make_shared(mtvpWorld); } RotationMatrix3 rotation = RotationMatrix3::Identity(); diff --git a/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp index 708e28f662c..e5a8fd1d49f 100644 --- a/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp +++ b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp @@ -319,11 +319,11 @@ struct CylindricalTrackingGeometry { auto pLayerArray = layerArrayCreator->layerArray(geoContext, pLayers, 25., 300., arbitrary, binR); auto pVolumeBounds = - std::make_shared(25., 300., 1100.); + std::make_shared(25., 300., 1100.); // create the Tracking volume - auto pVolume = TrackingVolume::create(Transform3::Identity(), pVolumeBounds, - nullptr, std::move(pLayerArray), - nullptr, {}, "Pixel::Barrel"); + auto pVolume = std::make_shared( + Transform3::Identity(), pVolumeBounds, nullptr, std::move(pLayerArray), + nullptr, MutableTrackingVolumeVector{}, "Pixel::Barrel"); // The combined volume auto detectorVolume = cylinderVolumeHelper->createContainerTrackingVolume( diff --git a/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp b/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp index 20e2f8c676a..77549e821cf 100644 --- a/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp +++ b/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp @@ -143,10 +143,9 @@ struct TelescopeDetector { // The volume transform Translation3 transVol(0, 0, 0); Transform3 trafoVol(rotation * transVol); - std::shared_ptr boundsVol = - std::make_shared( - rBounds->halfLengthX() + 10._mm, rBounds->halfLengthY() + 10._mm, - length + 10._mm); + auto boundsVol = std::make_shared( + rBounds->halfLengthX() + 10._mm, rBounds->halfLengthY() + 10._mm, + length + 10._mm); LayerArrayCreator::Config lacConfig; LayerArrayCreator layArrCreator( @@ -162,9 +161,9 @@ struct TelescopeDetector { BinningType::arbitrary, BinningValue::binX)); // Build the tracking volume - auto trackVolume = - TrackingVolume::create(trafoVol, boundsVol, nullptr, std::move(layArr), - nullptr, {}, "Telescope"); + auto trackVolume = std::make_shared( + trafoVol, boundsVol, nullptr, std::move(layArr), nullptr, + MutableTrackingVolumeVector{}, "Telescope"); return std::make_shared(trackVolume); } diff --git a/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp b/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp index 7b23dc662f3..79b92e46ea8 100644 --- a/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp @@ -176,6 +176,32 @@ BOOST_AUTO_TEST_CASE(CuboidVolumeBoundarySurfaces) { BOOST_CHECK(pFaceZX.col(2).isApprox(yaxis)); } +BOOST_AUTO_TEST_CASE(CuboidVolumeBoundsSetValues) { + CuboidVolumeBounds box(5, 8, 7); + + for (auto bValue : + {CuboidVolumeBounds::eHalfLengthX, CuboidVolumeBounds::eHalfLengthY, + CuboidVolumeBounds::eHalfLengthZ}) { + ActsScalar target = 0.5 * box.get(bValue); + ActsScalar previous = box.get(bValue); + BOOST_CHECK_THROW(box.set(bValue, -1), std::logic_error); + BOOST_CHECK_EQUAL(box.get(bValue), previous); + box.set(bValue, target); + BOOST_CHECK_EQUAL(box.get(bValue), target); + } + + auto previous = box.values(); + + BOOST_CHECK_THROW(box.set({ + {CuboidVolumeBounds::eHalfLengthX, -1}, + {CuboidVolumeBounds::eHalfLengthY, 1}, + }), + std::logic_error); + auto act = box.values(); + BOOST_CHECK_EQUAL_COLLECTIONS(previous.begin(), previous.end(), act.begin(), + act.end()); +} + BOOST_AUTO_TEST_SUITE_END() } // namespace Test diff --git a/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp b/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp index 7340558591d..609a445a86f 100644 --- a/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp @@ -16,7 +16,6 @@ #include "Acts/Geometry/VolumeBounds.hpp" #include "Acts/Surfaces/CylinderBounds.hpp" #include "Acts/Surfaces/RadialBounds.hpp" -#include "Acts/Surfaces/Surface.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/BoundingBox.hpp" @@ -26,7 +25,6 @@ #include #include #include -#include #include namespace bdata = boost::unit_test::data; @@ -327,6 +325,87 @@ BOOST_AUTO_TEST_CASE(CylinderVolumeOrientedBoundaries) { } } +BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsSetValues) { + CylinderVolumeBounds cyl(100, 300, 200); + + BOOST_CHECK_THROW(cyl.set(CylinderVolumeBounds::eMinR, 400), + std::invalid_argument); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eMinR), 100); + + cyl.set(CylinderVolumeBounds::eMinR, 200); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eMinR), 200); + + BOOST_CHECK_THROW(cyl.set(CylinderVolumeBounds::eMaxR, 50), + std::invalid_argument); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eMaxR), 300); + + cyl.set(CylinderVolumeBounds::eMaxR, 250); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eMaxR), 250); + + BOOST_CHECK_THROW(cyl.set(CylinderVolumeBounds::eHalfLengthZ, -200), + std::invalid_argument); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfLengthZ), 200); + + cyl.set(CylinderVolumeBounds::eHalfLengthZ, 250); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfLengthZ), 250); + + cyl.set(CylinderVolumeBounds::eHalfLengthZ, 150); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfLengthZ), 150); + + BOOST_CHECK_THROW(cyl.set(CylinderVolumeBounds::eHalfPhiSector, -M_PI), + std::invalid_argument); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), M_PI); + + BOOST_CHECK_THROW(cyl.set(CylinderVolumeBounds::eHalfPhiSector, 1.5 * M_PI), + std::invalid_argument); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), M_PI); + + cyl.set(CylinderVolumeBounds::eHalfPhiSector, M_PI / 2); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), M_PI / 2); + + for (auto bValue : + {CylinderVolumeBounds::eAveragePhi, CylinderVolumeBounds::eBevelMaxZ, + CylinderVolumeBounds::eBevelMinZ}) { + BOOST_CHECK_THROW(cyl.set(bValue, -1.5 * M_PI), std::invalid_argument); + BOOST_CHECK_EQUAL(cyl.get(bValue), 0); + + BOOST_CHECK_THROW(cyl.set(bValue, 1.5 * M_PI), std::invalid_argument); + BOOST_CHECK_EQUAL(cyl.get(bValue), 0); + + cyl.set(bValue, 0.5 * M_PI); + BOOST_CHECK_EQUAL(cyl.get(bValue), 0.5 * M_PI); + cyl.set(bValue, -0.5 * M_PI); + BOOST_CHECK_EQUAL(cyl.get(bValue), -0.5 * M_PI); + } + + cyl = CylinderVolumeBounds(100, 300, 200); + auto previous = cyl.values(); + + BOOST_CHECK_THROW(cyl.set({ + {CylinderVolumeBounds::eMinR, 50}, + {CylinderVolumeBounds::eMaxR, 200}, + {CylinderVolumeBounds::eHalfLengthZ, -1}, + }), + std::logic_error); + auto act = cyl.values(); + BOOST_CHECK_EQUAL_COLLECTIONS(previous.begin(), previous.end(), act.begin(), + act.end()); + + cyl.set({ + {CylinderVolumeBounds::eMinR, 50}, + {CylinderVolumeBounds::eMaxR, 200}, + {CylinderVolumeBounds::eHalfLengthZ, 150}, + }); + + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eMinR), 50); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eMaxR), 200); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfLengthZ), 150); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), M_PI); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eAveragePhi), 0); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eBevelMinZ), 0); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eBevelMaxZ), 0); +} + BOOST_AUTO_TEST_SUITE_END() } // namespace Test } // namespace Acts diff --git a/Tests/UnitTests/Core/Geometry/TrackingVolumeCreation.hpp b/Tests/UnitTests/Core/Geometry/TrackingVolumeCreation.hpp index ca53aa77ae1..2cb8411ba70 100644 --- a/Tests/UnitTests/Core/Geometry/TrackingVolumeCreation.hpp +++ b/Tests/UnitTests/Core/Geometry/TrackingVolumeCreation.hpp @@ -76,12 +76,12 @@ TrackingVolumePtr constructCylinderVolume( std::make_unique>(layer0); /// create the volume - auto volumeBounds = std::make_shared( + auto volumeBounds = std::make_shared( innerVolumeR, outerVolumeR, bUmax + volumeEnvelope); - TrackingVolumePtr volume = - TrackingVolume::create(Transform3::Identity(), volumeBounds, nullptr, - std::move(layerArray), nullptr, {}, name); + TrackingVolumePtr volume = std::make_shared( + Transform3::Identity(), volumeBounds, nullptr, std::move(layerArray), + nullptr, MutableTrackingVolumeVector{}, name); /// return the volume return volume; } @@ -98,8 +98,8 @@ MutableTrackingVolumePtr constructContainerVolume(const GeometryContext& gctx, std::vector volumes = {{iVolume, iVolume->binningPosition(gctx, binR)}, {oVolume, oVolume->binningPosition(gctx, binR)}}; /// the bounds for the container - auto hVolumeBounds = std::make_shared( - 0., hVolumeR, hVolumeHalflength); + auto hVolumeBounds = + std::make_shared(0., hVolumeR, hVolumeHalflength); /// create the BinUtility & the BinnedArray auto vUtility = std::make_unique(volumes.size(), 0., hVolumeR, open, binR); @@ -107,8 +107,8 @@ MutableTrackingVolumePtr constructContainerVolume(const GeometryContext& gctx, std::make_shared>( volumes, std::move(vUtility)); /// create the container volume - auto hVolume = TrackingVolume::create(Transform3::Identity(), hVolumeBounds, - vArray, name); + auto hVolume = std::make_shared(Transform3::Identity(), + hVolumeBounds, vArray, name); // return the container return hVolume; } diff --git a/Tests/UnitTests/Core/Geometry/VolumeTests.cpp b/Tests/UnitTests/Core/Geometry/VolumeTests.cpp index 71c9372c56d..ed719db4eac 100644 --- a/Tests/UnitTests/Core/Geometry/VolumeTests.cpp +++ b/Tests/UnitTests/Core/Geometry/VolumeTests.cpp @@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE(VolumeTest) { CuboidVolumeBounds bounds(4_mm, 5_mm, 6_mm); // Build and test the volume - Volume volume(transform, std::make_shared(bounds)); + Volume volume(transform, std::make_shared(bounds)); BOOST_CHECK_EQUAL(volume.transform().matrix(), transform.matrix()); CHECK_CLOSE_ABS(volume.itransform().matrix(), transform.inverse().matrix(), eps); diff --git a/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp b/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp index ef56860c69e..cbef61a954b 100644 --- a/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp +++ b/Tests/UnitTests/Core/Propagator/VolumeMaterialInteractionTests.cpp @@ -83,10 +83,10 @@ struct Navigator { BOOST_AUTO_TEST_CASE(volume_material_interaction_test) { // Create a Tracking Volume auto htrans = Transform3(Translation3{-10., -10., 0.}); - auto bound = std::make_shared(1_m, 1_m, 1_m); + auto bound = std::make_shared(1_m, 1_m, 1_m); auto mat = makeSilicon(); auto volMat = std::make_shared(mat); - auto volume = TrackingVolume::create(htrans, bound, volMat); + auto volume = std::make_shared(htrans, bound, volMat); // Create a propagator state State state;