Skip to content

Commit

Permalink
minor annulus cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Dec 18, 2024
1 parent ae9e432 commit 00f7a6e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
7 changes: 0 additions & 7 deletions Core/include/Acts/Surfaces/AnnulusBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,6 @@ class AnnulusBounds : public DiscBounds {
/// @param vStripXY the position in the cartesian strip system
/// @return the position in the module polar coordinate system
Vector2 stripXYToModulePC(const Vector2& vStripXY) const;

/// Private helper method
Vector2 closestOnSegment(const Vector2& a, const Vector2& b, const Vector2& p,
const SquareMatrix2& weight) const;

/// Private helper method
double squaredNorm(const Vector2& v, const SquareMatrix2& weight) const;
};

} // namespace Acts
38 changes: 20 additions & 18 deletions Core/src/Surfaces/AnnulusBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@

namespace Acts {

namespace {

Vector2 closestOnSegment(const Vector2& a, const Vector2& b, const Vector2& p,
const SquareMatrix2& weight) {
// connecting vector
auto n = b - a;
// squared norm of line
auto f = (n.transpose() * weight * n).value();
// weighted scalar product of line to point and segment line
auto u = ((p - a).transpose() * weight * n).value() / f;
// clamp to [0, 1], convert to point
return std::clamp(u, 0., 1.) * n + a;
}

double squaredNorm(const Vector2& v, const SquareMatrix2& weight) {
return (v.transpose() * weight * v).value();
}

} // namespace

AnnulusBounds::AnnulusBounds(const std::array<double, eSize>& values) noexcept(
false)
: m_values(values), m_moduleOrigin({values[eOriginX], values[eOriginY]}) {
Expand Down Expand Up @@ -363,24 +383,6 @@ Vector2 AnnulusBounds::stripXYToModulePC(const Vector2& vStripXY) const {
return {vecModuleXY.norm(), VectorHelpers::phi(vecModuleXY)};
}

Vector2 AnnulusBounds::closestOnSegment(const Vector2& a, const Vector2& b,
const Vector2& p,
const SquareMatrix2& weight) const {
// connecting vector
auto n = b - a;
// squared norm of line
auto f = (n.transpose() * weight * n).value();
// weighted scalar product of line to point and segment line
auto u = ((p - a).transpose() * weight * n).value() / f;
// clamp to [0, 1], convert to point
return std::min(std::max(u, 0.), 1.) * n + a;
}

double AnnulusBounds::squaredNorm(const Vector2& v,
const SquareMatrix2& weight) const {
return (v.transpose() * weight * v).value();
}

Vector2 AnnulusBounds::moduleOrigin() const {
return Eigen::Rotation2D<double>(get(eAveragePhi)) * m_moduleOrigin;
}
Expand Down

0 comments on commit 00f7a6e

Please sign in to comment.