Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Core/src/Surfaces/RadialBounds.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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/RadialBounds.hpp"
0010 
0011 #include "Acts/Surfaces/detail/VerticesHelper.hpp"
0012 #include "Acts/Utilities/detail/periodic.hpp"
0013 
0014 #include <iomanip>
0015 #include <iostream>
0016 #include <stdexcept>
0017 
0018 namespace Acts {
0019 
0020 std::vector<double> RadialBounds::values() const {
0021   return {m_values.begin(), m_values.end()};
0022 }
0023 
0024 void RadialBounds::checkConsistency() noexcept(false) {
0025   if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) > get(eMaxR)) {
0026     throw std::invalid_argument("RadialBounds: invalid radial setup");
0027   }
0028   if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > std::numbers::pi) {
0029     throw std::invalid_argument("RadialBounds: invalid phi sector setup.");
0030   }
0031   if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
0032     throw std::invalid_argument("RadialBounds: invalid phi positioning.");
0033   }
0034 }
0035 
0036 SquareMatrix2 RadialBounds::boundToCartesianJacobian(
0037     const Vector2& lposition) const {
0038   SquareMatrix2 j;
0039   j(0, 0) = std::cos(lposition[1] - get(eAveragePhi));
0040   j(0, 1) = -lposition[0] * std::sin(lposition[1] - get(eAveragePhi));
0041   j(1, 0) = std::sin(lposition[1] - get(eAveragePhi));
0042   j(1, 1) = lposition[0] * std::cos(lposition[1] - get(eAveragePhi));
0043   return j;
0044 }
0045 
0046 SquareMatrix2 RadialBounds::boundToCartesianMetric(
0047     const Vector2& lposition) const {
0048   SquareMatrix2 m;
0049   m(0, 0) = 1;
0050   m(0, 1) = 0;
0051   m(1, 0) = 0;
0052   m(1, 1) = lposition[0] * lposition[0];
0053   return m;
0054 }
0055 
0056 Vector2 RadialBounds::shifted(const Vector2& lposition) const {
0057   Vector2 tmp;
0058   tmp[0] = lposition[0];
0059   tmp[1] = detail::radian_sym(lposition[1] - get(eAveragePhi));
0060   return tmp;
0061 }
0062 
0063 bool RadialBounds::inside(const Vector2& lposition) const {
0064   return detail::VerticesHelper::isInsideRectangle(
0065       shifted(lposition), Vector2(get(eMinR), -get(eHalfPhiSector)),
0066       Vector2(get(eMaxR), get(eHalfPhiSector)));
0067 }
0068 
0069 Vector2 RadialBounds::closestPoint(const Vector2& lposition,
0070                                    const SquareMatrix2& metric) const {
0071   return detail::VerticesHelper::computeClosestPointOnAlignedBox(
0072       Vector2(get(eMinR), -get(eHalfPhiSector)),
0073       Vector2(get(eMaxR), get(eHalfPhiSector)), shifted(lposition), metric);
0074 }
0075 
0076 std::vector<Vector2> RadialBounds::vertices(unsigned int lseg) const {
0077   return detail::VerticesHelper::circularVertices(
0078       get(eMinR), get(eMaxR), get(eAveragePhi), get(eHalfPhiSector), lseg);
0079 }
0080 
0081 Vector2 RadialBounds::center() const {
0082   // For radial bounds in polar coordinates (r, phi),
0083   // centroid is at the middle radius and average phi
0084   double rCentroid = 0.5 * (get(eMinR) + get(eMaxR));
0085   double phiCentroid = get(eAveragePhi);
0086   return Vector2(rCentroid, phiCentroid);
0087 }
0088 
0089 std::ostream& RadialBounds::toStream(std::ostream& sl) const {
0090   sl << std::setiosflags(std::ios::fixed);
0091   sl << std::setprecision(7);
0092   sl << "Acts::RadialBounds:  (innerRadius, outerRadius, hPhiSector, "
0093         "averagePhi) = ";
0094   sl << "(" << get(eMinR) << ", " << get(eMaxR) << ", " << get(eHalfPhiSector)
0095      << ", " << get(eAveragePhi) << ")";
0096   sl << std::setprecision(-1);
0097   return sl;
0098 }
0099 
0100 }  // namespace Acts