Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:30

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/RectangleBounds.hpp"
0010 
0011 #include "Acts/Surfaces/detail/BoundaryCheckHelper.hpp"
0012 
0013 #include <iomanip>
0014 #include <iostream>
0015 #include <stdexcept>
0016 
0017 namespace Acts {
0018 
0019 double RectangleBounds::get(BoundValues bValue) const {
0020   switch (bValue) {
0021     case eMinX:
0022       return m_min.x();
0023     case eMinY:
0024       return m_min.y();
0025     case eMaxX:
0026       return m_max.x();
0027     case eMaxY:
0028       return m_max.y();
0029     default:
0030       assert(false && "Invalid BoundValue enum value");
0031       return std::numeric_limits<double>::quiet_NaN();
0032   }
0033 }
0034 
0035 void RectangleBounds::checkConsistency() noexcept(false) {
0036   if (get(eMinX) > get(eMaxX)) {
0037     throw std::invalid_argument("RectangleBounds: invalid local x setup");
0038   }
0039   if (get(eMinY) > get(eMaxY)) {
0040     throw std::invalid_argument("RectangleBounds: invalid local y setup");
0041   }
0042 }
0043 
0044 bool RectangleBounds::inside(const Vector2& lposition,
0045                              const BoundaryTolerance& boundaryTolerance) const {
0046   return detail::insideAlignedBox(m_min, m_max, boundaryTolerance, lposition,
0047                                   std::nullopt);
0048 }
0049 
0050 std::vector<Vector2> RectangleBounds::vertices(unsigned int /*lseg*/) const {
0051   // counter-clockwise starting from bottom-left corner
0052   return {m_min, {m_max.x(), m_min.y()}, m_max, {m_min.x(), m_max.y()}};
0053 }
0054 
0055 const RectangleBounds& RectangleBounds::boundingBox() const {
0056   return (*this);
0057 }
0058 
0059 std::ostream& RectangleBounds::toStream(std::ostream& sl) const {
0060   sl << std::setiosflags(std::ios::fixed);
0061   sl << std::setprecision(7);
0062   sl << "Acts::RectangleBounds:  (hlX, hlY) = "
0063      << "(" << 0.5 * (get(eMaxX) - get(eMinX)) << ", "
0064      << 0.5 * (get(eMaxY) - get(eMinY)) << ")";
0065   sl << "\n(lower left, upper right):\n";
0066   sl << min().transpose() << "\n" << max().transpose();
0067   sl << std::setprecision(-1);
0068   return sl;
0069 }
0070 
0071 }  // namespace Acts