Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:19:03

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Surfaces/PointBounds.hpp"
0010 
0011 #include "Acts/Utilities/detail/OstreamStateGuard.hpp"
0012 
0013 #include <iomanip>
0014 #include <iostream>
0015 #include <stdexcept>
0016 
0017 namespace Acts {
0018 
0019 std::vector<double> PointBounds::values() const {
0020   return {m_values.begin(), m_values.end()};
0021 }
0022 
0023 void PointBounds::checkConsistency() noexcept(false) {
0024   if (get(eR) < 0.) {
0025     throw std::invalid_argument("PointBounds: negative radius.");
0026   }
0027 }
0028 
0029 bool PointBounds::inside(const Vector2& lposition) const {
0030   const double r = get(eR);
0031   return lposition.squaredNorm() <= r * r;
0032 }
0033 
0034 Vector2 PointBounds::closestPoint(const Vector2& lposition,
0035                                   const SquareMatrix2& metric) const {
0036   static_cast<void>(metric);
0037   // The bounds are a disc of radius R; the closest point on the boundary
0038   // circle is the radial projection of the local position. For a position at
0039   // the origin any boundary point is equidistant, pick (R, 0).
0040   const double r = get(eR);
0041   const double norm = lposition.norm();
0042   if (norm == 0.) {
0043     return Vector2(r, 0.);
0044   }
0045   return lposition * (r / norm);
0046 }
0047 
0048 std::ostream& PointBounds::toStream(std::ostream& sl) const {
0049   detail::OstreamStateGuard guard{sl};
0050   sl << std::fixed << std::setprecision(7);
0051   sl << "Acts::PointBounds: (maxDistance) = ";
0052   sl << "(" << get(eR) << ")";
0053   return sl;
0054 }
0055 
0056 }  // namespace Acts