Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 07:48:33

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/SurfaceBounds.hpp>
0010 
0011 namespace Acts {
0012 
0013 bool SurfaceBounds::inside(const Vector2& lposition,
0014                            const BoundaryTolerance& boundaryTolerance) const {
0015   using enum BoundaryTolerance::ToleranceMode;
0016 
0017   if (boundaryTolerance.isInfinite()) {
0018     return true;
0019   }
0020 
0021   BoundaryTolerance::ToleranceMode toleranceMode =
0022       boundaryTolerance.toleranceMode();
0023   bool strictlyInside = inside(lposition);
0024 
0025   if (toleranceMode == None) {
0026     return strictlyInside;
0027   }
0028 
0029   if (toleranceMode == Extend && strictlyInside) {
0030     return true;
0031   }
0032 
0033   SquareMatrix2 boundToCartesian = boundToCartesianJacobian(lposition);
0034   SquareMatrix2 metric = SquareMatrix2::Identity();
0035   if (boundaryTolerance.hasAbsoluteEuclidean()) {
0036     metric = boundToCartesian.transpose() * boundToCartesian;
0037   } else if (boundaryTolerance.hasChi2Bound()) {
0038     metric = boundToCartesian.transpose() *
0039              boundaryTolerance.asChi2Bound().weightMatrix() * boundToCartesian;
0040   } else if (boundaryTolerance.hasChi2Cartesian()) {
0041     metric = boundToCartesian.transpose() *
0042              boundaryTolerance.asChi2Cartesian().weightMatrix() *
0043              boundToCartesian;
0044   } else {
0045     throw std::runtime_error(
0046         "SurfaceBounds::inside: Unsupported boundary tolerance type.");
0047   }
0048 
0049   Vector2 closest = closestPoint(lposition, metric);
0050   Vector2 distance = closest - lposition;
0051 
0052   if (toleranceMode == Shrink) {
0053     return boundaryTolerance.isTolerated(distance, boundToCartesian) &&
0054            strictlyInside;
0055   }
0056   return boundaryTolerance.isTolerated(distance, boundToCartesian);
0057 }
0058 
0059 }  // namespace Acts