Skip to content

Commit

Permalink
further cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Dec 18, 2024
1 parent 1155b26 commit 5ff93a4
Show file tree
Hide file tree
Showing 33 changed files with 90 additions and 170 deletions.
25 changes: 0 additions & 25 deletions Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <array>
#include <iosfwd>
#include <memory>
#include <stdexcept>
#include <vector>

namespace Acts {
Expand Down Expand Up @@ -47,8 +46,6 @@ class CutoutCylinderVolumeBounds : public VolumeBounds {
eSize
};

CutoutCylinderVolumeBounds() = delete;

/// Constructor from defining parameters
///
/// @param rmin Minimum radius at the "choke points"
Expand All @@ -73,8 +70,6 @@ class CutoutCylinderVolumeBounds : public VolumeBounds {
buildSurfaceBounds();
}

~CutoutCylinderVolumeBounds() override = default;

VolumeBounds::BoundsType type() const final {
return VolumeBounds::eCutoutCylinder;
}
Expand Down Expand Up @@ -151,24 +146,4 @@ class CutoutCylinderVolumeBounds : public VolumeBounds {
void checkConsistency() noexcept(false);
};

inline std::vector<double> CutoutCylinderVolumeBounds::values() const {
std::vector<double> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}

inline void CutoutCylinderVolumeBounds::checkConsistency() noexcept(false) {
if (get(eMinR) < 0. || get(eMedR) <= 0. || get(eMaxR) <= 0. ||
get(eMinR) >= get(eMedR) || get(eMinR) >= get(eMaxR) ||
get(eMedR) >= get(eMaxR)) {
throw std::invalid_argument(
"CutoutCylinderVolumeBounds: invalid radial input.");
}
if (get(eHalfLengthZ) <= 0 || get(eHalfLengthZcutout) <= 0. ||
get(eHalfLengthZcutout) > get(eHalfLengthZ)) {
throw std::invalid_argument(
"CutoutCylinderVolumeBounds: invalid longitudinal input.");
}
}

} // namespace Acts
4 changes: 1 addition & 3 deletions Core/include/Acts/Surfaces/AnnulusBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ class AnnulusBounds : public DiscBounds {

AnnulusBounds(const AnnulusBounds& source) = default;

SurfaceBounds::BoundsType type() const final {
return SurfaceBounds::eAnnulus;
}
BoundsType type() const final { return SurfaceBounds::eAnnulus; }

/// Return the bound values as dynamically sized vector
///
Expand Down
2 changes: 2 additions & 0 deletions Core/include/Acts/Surfaces/ConeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class ConeBounds : public SurfaceBounds {

/// Private helper function to shift a local 2D position
///
/// Shift r-phi coordinate to be centered around the average phi.
///
/// @param lposition The original local position
Vector2 shifted(const Vector2& lposition) const;
};
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Surfaces/ConvexPolygonBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ConvexPolygonBounds : public ConvexPolygonBoundsBase {
/// @param values The values to build up the vertices
ConvexPolygonBounds(const value_array& values) noexcept(false);

BoundsType type() const final;
BoundsType type() const final { return SurfaceBounds::eConvexPolygon; }

/// Return whether a local 2D point lies inside of the bounds defined by this
/// object.
Expand Down Expand Up @@ -146,7 +146,7 @@ class ConvexPolygonBounds<PolygonDynamic> : public ConvexPolygonBoundsBase {

/// Return the bounds type of this bounds object.
/// @return The bounds type
BoundsType type() const final;
BoundsType type() const final { return SurfaceBounds::eConvexPolygon; }

/// Return whether a local 2D point lies inside of the bounds defined by this
/// object.
Expand Down
5 changes: 0 additions & 5 deletions Core/include/Acts/Surfaces/ConvexPolygonBounds.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ Acts::ConvexPolygonBounds<N>::ConvexPolygonBounds(
checkConsistency();
}

template <int N>
Acts::SurfaceBounds::BoundsType Acts::ConvexPolygonBounds<N>::type() const {
return SurfaceBounds::eConvexPolygon;
}

template <int N>
bool Acts::ConvexPolygonBounds<N>::inside(
const Acts::Vector2& lposition,
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/CylinderBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CylinderBounds : public SurfaceBounds {
checkConsistency();
}

BoundsType type() const final;
BoundsType type() const final { return SurfaceBounds::eCylinder; }

/// Return the bound values as dynamically sized vector
///
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/DiamondBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class DiamondBounds : public PlanarBounds {
Vector2{*std::max_element(values.begin(), values.begin() + 2),
values[eHalfLengthYpos]}) {}

BoundsType type() const final;
BoundsType type() const final { return SurfaceBounds::eDiamond; }

/// Return the bound values as dynamically sized vector
///
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DiscTrapezoidBounds : public DiscBounds {
checkConsistency();
}

SurfaceBounds::BoundsType type() const final;
BoundsType type() const final { return SurfaceBounds::eDiscTrapezoid; }

/// Return the bound values as dynamically sized vector
///
Expand Down
4 changes: 3 additions & 1 deletion Core/include/Acts/Surfaces/EllipseBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class EllipseBounds : public PlanarBounds {
checkConsistency();
}

BoundsType type() const final;
BoundsType type() const final { return SurfaceBounds::eEllipse; }

/// Return the bound values as dynamically sized vector
///
Expand All @@ -79,6 +79,8 @@ class EllipseBounds : public PlanarBounds {
/// two ellipsoids if only tol0 is given and additional in the phi sector is
/// tol1 is given
///
/// @warning This **only** works for tolerance-based checks
///
/// @param lposition Local position (assumed to be in right surface frame)
/// @param boundaryTolerance boundary check directive
/// @return boolean indicator for the success of this operation
Expand Down
4 changes: 1 addition & 3 deletions Core/include/Acts/Surfaces/InfiniteBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ namespace Acts {
///
class InfiniteBounds : public SurfaceBounds {
public:
SurfaceBounds::BoundsType type() const final {
return SurfaceBounds::eBoundless;
}
BoundsType type() const final { return SurfaceBounds::eBoundless; }

std::vector<double> values() const final { return {}; }

Expand Down
17 changes: 1 addition & 16 deletions Core/include/Acts/Surfaces/LineBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LineBounds : public SurfaceBounds {
checkConsistency();
}

BoundsType type() const final;
BoundsType type() const final { return SurfaceBounds::eLine; }

/// Return the bound values as dynamically sized vector
///
Expand Down Expand Up @@ -77,19 +77,4 @@ class LineBounds : public SurfaceBounds {
void checkConsistency() noexcept(false);
};

inline std::vector<double> LineBounds::values() const {
std::vector<double> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}

inline void LineBounds::checkConsistency() noexcept(false) {
if (get(eR) < 0.) {
throw std::invalid_argument("LineBounds: zero radius.");
}
if (get(eHalfLengthZ) <= 0.) {
throw std::invalid_argument("LineBounds: zero/negative length.");
}
}

} // namespace Acts
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/RadialBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class RadialBounds : public DiscBounds {
checkConsistency();
}

SurfaceBounds::BoundsType type() const final;
BoundsType type() const final { return SurfaceBounds::eDisc; }

/// Return the bound values as dynamically sized vector
///
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Surfaces/TrapezoidBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TrapezoidBounds : public PlanarBounds {
/// @param values the values to be stream in
TrapezoidBounds(const std::array<double, eSize>& values) noexcept(false);

BoundsType type() const final;
BoundsType type() const final { return SurfaceBounds::eTrapezoid; }

std::vector<double> values() const final;

Expand Down
12 changes: 5 additions & 7 deletions Core/src/Geometry/ConeVolumeBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
#include <cmath>
#include <numbers>
#include <stdexcept>
#include <type_traits>
#include <utility>

namespace Acts {

ConeVolumeBounds::ConeVolumeBounds(double innerAlpha, double innerOffsetZ,
double outerAlpha, double outerOffsetZ,
double halflengthZ, double averagePhi,
Expand Down Expand Up @@ -92,6 +92,10 @@ ConeVolumeBounds::ConeVolumeBounds(double cylinderR, double alpha,
checkConsistency();
}

std::vector<double> ConeVolumeBounds::values() const {
return {m_values.begin(), m_values.end()};
}

std::vector<Acts::OrientedSurface> Acts::ConeVolumeBounds::orientedSurfaces(
const Transform3& transform) const {
std::vector<OrientedSurface> oSurfaces;
Expand Down Expand Up @@ -334,10 +338,4 @@ double ConeVolumeBounds::outerTanAlpha() const {
return m_outerTanAlpha;
}

std::vector<double> ConeVolumeBounds::values() const {
std::vector<double> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}

} // namespace Acts
10 changes: 4 additions & 6 deletions Core/src/Geometry/CuboidVolumeBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ CuboidVolumeBounds::CuboidVolumeBounds(const std::array<double, eSize>& values)
buildSurfaceBounds();
}

std::vector<double> CuboidVolumeBounds::values() const {
return {m_values.begin(), m_values.end()};
}

std::vector<Acts::OrientedSurface> Acts::CuboidVolumeBounds::orientedSurfaces(
const Transform3& transform) const {
std::vector<OrientedSurface> oSurfaces;
Expand Down Expand Up @@ -119,12 +123,6 @@ bool CuboidVolumeBounds::inside(const Vector3& pos, double tol) const {
std::abs(pos.z()) <= get(eHalfLengthZ) + tol);
}

std::vector<double> CuboidVolumeBounds::values() const {
std::vector<double> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}

void CuboidVolumeBounds::checkConsistency() noexcept(false) {
if (get(eHalfLengthX) <= 0 || get(eHalfLengthY) <= 0 ||
get(eHalfLengthZ) <= 0.) {
Expand Down
45 changes: 32 additions & 13 deletions Core/src/Geometry/CutoutCylinderVolumeBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,30 @@

#include <memory>
#include <ostream>
#include <type_traits>
#include <stdexcept>
#include <utility>

bool Acts::CutoutCylinderVolumeBounds::inside(const Acts::Vector3& gpos,
double tol) const {
namespace Acts {

std::vector<double> CutoutCylinderVolumeBounds::values() const {
return {m_values.begin(), m_values.end()};
}

void CutoutCylinderVolumeBounds::checkConsistency() noexcept(false) {
if (get(eMinR) < 0. || get(eMedR) <= 0. || get(eMaxR) <= 0. ||
get(eMinR) >= get(eMedR) || get(eMinR) >= get(eMaxR) ||
get(eMedR) >= get(eMaxR)) {
throw std::invalid_argument(
"CutoutCylinderVolumeBounds: invalid radial input.");
}
if (get(eHalfLengthZ) <= 0 || get(eHalfLengthZcutout) <= 0. ||
get(eHalfLengthZcutout) > get(eHalfLengthZ)) {
throw std::invalid_argument(
"CutoutCylinderVolumeBounds: invalid longitudinal input.");
}
}

bool CutoutCylinderVolumeBounds::inside(const Vector3& gpos, double tol) const {
// first check whether we are in the outer envelope at all (ignore r_med)
using VectorHelpers::perp;
using VectorHelpers::phi;
Expand All @@ -48,8 +67,7 @@ bool Acts::CutoutCylinderVolumeBounds::inside(const Acts::Vector3& gpos,
return !insideRInner || !insideZInner; // we are not, inside bounds
}

std::vector<Acts::OrientedSurface>
Acts::CutoutCylinderVolumeBounds::orientedSurfaces(
std::vector<OrientedSurface> CutoutCylinderVolumeBounds::orientedSurfaces(
const Transform3& transform) const {
std::vector<OrientedSurface> oSurfaces;

Expand Down Expand Up @@ -122,9 +140,9 @@ Acts::CutoutCylinderVolumeBounds::orientedSurfaces(
return oSurfaces;
}

Acts::Volume::BoundingBox Acts::CutoutCylinderVolumeBounds::boundingBox(
const Acts::Transform3* trf, const Acts::Vector3& envelope,
const Acts::Volume* entity) const {
Volume::BoundingBox CutoutCylinderVolumeBounds::boundingBox(
const Transform3* trf, const Vector3& envelope,
const Volume* entity) const {
Vector3 vmin, vmax;

// no phi sector is possible, so this is just the outer size of
Expand All @@ -133,21 +151,20 @@ Acts::Volume::BoundingBox Acts::CutoutCylinderVolumeBounds::boundingBox(
vmax = {get(eMaxR), get(eMaxR), get(eHalfLengthZ)};
vmin = {-get(eMaxR), -get(eMaxR), -get(eHalfLengthZ)};

Acts::Volume::BoundingBox box(entity, vmin - envelope, vmax + envelope);
Volume::BoundingBox box(entity, vmin - envelope, vmax + envelope);
// transform at the very end, if required
return trf == nullptr ? box : box.transformed(*trf);
}

std::ostream& Acts::CutoutCylinderVolumeBounds::toStream(
std::ostream& sl) const {
sl << "Acts::CutoutCylinderVolumeBounds(\n";
std::ostream& CutoutCylinderVolumeBounds::toStream(std::ostream& sl) const {
sl << "CutoutCylinderVolumeBounds(\n";
sl << "rmin = " << get(eMinR) << " rmed = " << get(eMedR)
<< " rmax = " << get(eMaxR) << "\n";
sl << "dz1 = " << get(eHalfLengthZ) << " dz2 = " << get(eHalfLengthZcutout);
return sl;
}

void Acts::CutoutCylinderVolumeBounds::buildSurfaceBounds() {
void CutoutCylinderVolumeBounds::buildSurfaceBounds() {
if (get(eMinR) > s_epsilon) {
double hlChoke = (get(eHalfLengthZ) - get(eHalfLengthZcutout)) * 0.5;
m_innerCylinderBounds =
Expand All @@ -164,3 +181,5 @@ void Acts::CutoutCylinderVolumeBounds::buildSurfaceBounds() {

m_outerDiscBounds = std::make_shared<RadialBounds>(get(eMinR), get(eMaxR));
}

} // namespace Acts
4 changes: 1 addition & 3 deletions Core/src/Geometry/CylinderVolumeBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@ double CylinderVolumeBounds::binningBorder(BinningValue bValue) const {
}

std::vector<double> CylinderVolumeBounds::values() const {
std::vector<double> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
return {m_values.begin(), m_values.end()};
}

void CylinderVolumeBounds::checkConsistency() {
Expand Down
10 changes: 4 additions & 6 deletions Core/src/Geometry/TrapezoidVolumeBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ TrapezoidVolumeBounds::TrapezoidVolumeBounds(double minhalex, double haley,
buildSurfaceBounds();
}

std::vector<double> TrapezoidVolumeBounds::values() const {
return {m_values.begin(), m_values.end()};
}

std::vector<OrientedSurface> TrapezoidVolumeBounds::orientedSurfaces(
const Transform3& transform) const {
std::vector<OrientedSurface> oSurfaces;
Expand Down Expand Up @@ -198,12 +202,6 @@ Volume::BoundingBox TrapezoidVolumeBounds::boundingBox(
return {entity, vmin - envelope, vmax + envelope};
}

std::vector<double> TrapezoidVolumeBounds::values() const {
std::vector<double> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
}

void TrapezoidVolumeBounds::checkConsistency() noexcept(false) {
if (get(eHalfLengthXnegY) < 0. || get(eHalfLengthXposY) < 0.) {
throw std::invalid_argument(
Expand Down
4 changes: 1 addition & 3 deletions Core/src/Surfaces/AnnulusBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ AnnulusBounds::AnnulusBounds(const std::array<double, eSize>& values) noexcept(
}

std::vector<double> AnnulusBounds::values() const {
std::vector<double> valvector;
valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
return valvector;
return {m_values.begin(), m_values.end()};
}

void AnnulusBounds::checkConsistency() noexcept(false) {
Expand Down
Loading

0 comments on commit 5ff93a4

Please sign in to comment.