Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:14:12

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