Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:40

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2020 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Surfaces/EllipseBounds.hpp"
0010 
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012 #include "Acts/Surfaces/detail/VerticesHelper.hpp"
0013 #include "Acts/Utilities/VectorHelpers.hpp"
0014 
0015 #include <iomanip>
0016 #include <iostream>
0017 
0018 using Acts::VectorHelpers::perp;
0019 using Acts::VectorHelpers::phi;
0020 
0021 Acts::SurfaceBounds::BoundsType Acts::EllipseBounds::type() const {
0022   return SurfaceBounds::eEllipse;
0023 }
0024 
0025 static inline double square(double x) {
0026   return x * x;
0027 }
0028 
0029 /// @warning This **only** works for tolerance-based checks
0030 bool Acts::EllipseBounds::inside(const Vector2& lposition,
0031                                  const BoundaryCheck& bcheck) const {
0032   double tol0 = bcheck.m_tolerance[0];
0033   double tol1 = bcheck.m_tolerance[1];
0034   double phi =
0035       detail::radian_sym(VectorHelpers::phi(lposition) - get(eAveragePhi));
0036   double phiHalf = get(eHalfPhiSector) + tol1;
0037 
0038   bool insidePhi = (-phiHalf <= phi) && (phi < phiHalf);
0039   bool insideInner =
0040       (get(eInnerRx) <= tol0) || (get(eOuterRx) <= tol0) ||
0041       (1 < (square(lposition[Acts::eBoundLoc0] / (get(eInnerRx) - tol0)) +
0042             square(lposition[Acts::eBoundLoc1] / (get(eOuterRx) - tol0))));
0043   bool insideOuter =
0044       ((square(lposition[Acts::eBoundLoc0] / (get(eInnerRy) + tol0)) +
0045         square(lposition[Acts::eBoundLoc1] / (get(eOuterRy) + tol0))) < 1);
0046   return (insidePhi && insideInner && insideOuter);
0047 }
0048 
0049 std::vector<Acts::Vector2> Acts::EllipseBounds::vertices(
0050     unsigned int lseg) const {
0051   return detail::VerticesHelper::ellipsoidVertices(
0052       get(eInnerRx), get(eInnerRy), get(eOuterRx), get(eOuterRy),
0053       get(eAveragePhi), get(eHalfPhiSector), lseg);
0054 }
0055 
0056 const Acts::RectangleBounds& Acts::EllipseBounds::boundingBox() const {
0057   return m_boundingBox;
0058 }
0059 
0060 // ostream operator overload
0061 std::ostream& Acts::EllipseBounds::toStream(std::ostream& sl) const {
0062   sl << std::setiosflags(std::ios::fixed);
0063   sl << std::setprecision(7);
0064   sl << "Acts::EllipseBounds:  (innerRadius0, outerRadius0, innerRadius1, "
0065         "outerRadius1, hPhiSector, averagePhi) = ";
0066   sl << "(" << get(eInnerRx) << ", " << get(eInnerRy) << ", " << get(eOuterRx)
0067      << ", " << get(eOuterRy) << ", " << get(eAveragePhi) << ", "
0068      << get(eHalfPhiSector) << ", " << get(eAveragePhi) << ")";
0069   sl << std::setprecision(-1);
0070   return sl;
0071 }