Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:23:34

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2019 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 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Utilities/Intersection.hpp"
0013 
0014 /// @brief Helpers for planar surfaces that share the same maths
0015 namespace Acts::PlanarHelper {
0016 
0017 /// Intersection with a planar surface
0018 ///
0019 /// @param transform The 3D affine transform that places the surface
0020 /// @param position The starting position for the intersection
0021 /// @param direction The starting direction for the intersection
0022 ///
0023 /// @return The intersection
0024 inline Intersection3D intersect(const Transform3& transform,
0025                                 const Vector3& position,
0026                                 const Vector3& direction,
0027                                 ActsScalar tolerance) {
0028   // Get the matrix from the transform (faster access)
0029   const auto& tMatrix = transform.matrix();
0030   const Vector3 pnormal = tMatrix.block<3, 1>(0, 2).transpose();
0031   const Vector3 pcenter = tMatrix.block<3, 1>(0, 3).transpose();
0032   // It is solvable, so go on
0033   ActsScalar denom = direction.dot(pnormal);
0034   if (denom != 0.0) {
0035     // Translate that into a path
0036     ActsScalar path = (pnormal.dot((pcenter - position))) / (denom);
0037     // Is valid hence either on surface or reachable
0038     Intersection3D::Status status = std::abs(path) < std::abs(tolerance)
0039                                         ? Intersection3D::Status::onSurface
0040                                         : Intersection3D::Status::reachable;
0041     // Return the intersection
0042     return Intersection3D{(position + path * direction), path, status};
0043   }
0044   return Intersection3D::invalid();
0045 }
0046 
0047 }  // namespace Acts::PlanarHelper