Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 08:19:55

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/LineBounds.hpp"
0010 
0011 #include "Acts/Surfaces/detail/VerticesHelper.hpp"
0012 #include "Acts/Utilities/detail/OstreamStateGuard.hpp"
0013 
0014 #include <iomanip>
0015 #include <iostream>
0016 
0017 namespace Acts {
0018 
0019 std::vector<double> LineBounds::values() const {
0020   return {m_values.begin(), m_values.end()};
0021 }
0022 
0023 void LineBounds::checkConsistency() noexcept(false) {
0024   if (get(eR) < 0.) {
0025     throw std::invalid_argument("LineBounds: zero radius.");
0026   }
0027   if (get(eHalfLengthZ) <= 0.) {
0028     throw std::invalid_argument("LineBounds: zero/negative length.");
0029   }
0030 }
0031 
0032 bool LineBounds::inside(const Vector2& lposition) const {
0033   double r = get(LineBounds::eR);
0034   double halfLengthZ = get(LineBounds::eHalfLengthZ);
0035   return detail::VerticesHelper::isInsideRectangle(
0036       lposition, Vector2(-r, -halfLengthZ), Vector2(r, halfLengthZ));
0037 }
0038 
0039 Vector2 LineBounds::closestPoint(const Vector2& lposition,
0040                                  const SquareMatrix2& metric) const {
0041   double r = get(LineBounds::eR);
0042   double halfLengthZ = get(LineBounds::eHalfLengthZ);
0043   return detail::VerticesHelper::computeClosestPointOnAlignedBox(
0044       Vector2(-r, -halfLengthZ), Vector2(r, halfLengthZ), lposition, metric);
0045 }
0046 
0047 Vector2 LineBounds::center() const {
0048   // LineBounds is symmetric around the origin in both dimensions
0049   return Vector2::Zero();
0050 }
0051 
0052 std::ostream& LineBounds::toStream(std::ostream& sl) const {
0053   detail::OstreamStateGuard guard{sl};
0054   sl << std::fixed << std::setprecision(7);
0055   sl << "Acts::LineBounds: (radius, halflengthInZ) = ";
0056   sl << "(" << get(LineBounds::eR) << ", " << get(LineBounds::eHalfLengthZ)
0057      << ")";
0058   return sl;
0059 }
0060 
0061 }  // namespace Acts