Back to home page

EIC code displayed by LXR

 
 

    


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

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/CurvilinearSurface.hpp"
0010 
0011 #include "Acts/Definitions/Tolerance.hpp"
0012 #include "Acts/Surfaces/PlaneSurface.hpp"
0013 #include "Acts/Utilities/JacobianHelpers.hpp"
0014 
0015 #include <iomanip>
0016 #include <ios>
0017 #include <ostream>
0018 
0019 namespace Acts {
0020 
0021 bool CurvilinearSurface::isStandardRepresentation() const {
0022   Vector3 T = m_direction.normalized();
0023   return std::abs(T.dot(Vector3::UnitZ())) < s_curvilinearProjTolerance;
0024 }
0025 
0026 RotationMatrix3 CurvilinearSurface::referenceFrame() const {
0027   // the right-handed coordinate system is defined as
0028   // T = normal
0029   // U = Z x T if T not parallel to Z otherwise U = X x T
0030   // V = T x U
0031   Vector3 T = m_direction.normalized();
0032   Vector3 U = (isStandardRepresentation() ? Vector3::UnitZ() : Vector3::UnitX())
0033                   .cross(T)
0034                   .normalized();
0035   Vector3 V = T.cross(U);
0036 
0037   RotationMatrix3 rframe;
0038   rframe << U, V, T;
0039   return rframe;
0040 }
0041 
0042 Transform3 CurvilinearSurface::transform() const {
0043   Transform3 transform = Transform3(referenceFrame());
0044   transform.pretranslate(center());
0045   return transform;
0046 }
0047 
0048 BoundToFreeMatrix CurvilinearSurface::boundToFreeJacobian() const {
0049   // this is copied from the `Surface::boundToFreeJacobian`
0050   // implementation without bounds check and definite direction
0051 
0052   // Initialize the jacobian from local to global
0053   BoundToFreeMatrix jacobian = BoundToFreeMatrix::Zero();
0054 
0055   // retrieve the reference frame
0056   const auto rframe = referenceFrame();
0057 
0058   // the local error components - given by reference frame
0059   jacobian.topLeftCorner<3, 2>() = rframe.topLeftCorner<3, 2>();
0060   // the time component
0061   jacobian(eFreeTime, eBoundTime) = 1;
0062   // the momentum components
0063   jacobian.block<3, 2>(eFreeDir0, eBoundPhi) =
0064       sphericalToFreeDirectionJacobian(m_direction);
0065   jacobian(eFreeQOverP, eBoundQOverP) = 1;
0066 
0067   return jacobian;
0068 }
0069 
0070 FreeToBoundMatrix CurvilinearSurface::freeToBoundJacobian() const {
0071   // this is copied from the `Surface::freeToBoundJacobian`
0072   // implementation without bounds check and definite direction
0073 
0074   // Initialize the jacobian from global to local
0075   FreeToBoundMatrix jacobian = FreeToBoundMatrix::Zero();
0076 
0077   // The measurement frame of the surface
0078   RotationMatrix3 rframeT = referenceFrame().transpose();
0079 
0080   // Local position component given by the reference frame
0081   jacobian.block<2, 3>(eBoundLoc0, eFreePos0) = rframeT.block<2, 3>(0, 0);
0082   // Time component
0083   jacobian(eBoundTime, eFreeTime) = 1;
0084   // Directional and momentum elements for reference frame surface
0085   jacobian.block<2, 3>(eBoundPhi, eFreeDir0) =
0086       freeToSphericalDirectionJacobian(m_direction);
0087   jacobian(eBoundQOverP, eFreeQOverP) = 1;
0088 
0089   return jacobian;
0090 }
0091 
0092 FreeToPathMatrix CurvilinearSurface::freeToPathDerivative() const {
0093   FreeToPathMatrix freeToPath = FreeToPathMatrix::Zero();
0094   freeToPath.segment<3>(eFreePos0) = -1.0 * m_direction;
0095   return freeToPath;
0096 }
0097 
0098 std::ostream& CurvilinearSurface::toStream(std::ostream& sl) const {
0099   sl << "Curvilinear Surface" << std::endl;
0100   sl << "     Center position  (x, y, z) = (" << m_position.x() << ", "
0101      << m_position.y() << ", " << m_position.z() << ")" << std::endl;
0102   sl << "     Direction  (x, y, z) = (" << m_direction.x() << ", "
0103      << m_direction.y() << ", " << m_direction.z() << ")" << std::endl;
0104   return sl;
0105 }
0106 
0107 std::string CurvilinearSurface::toString() const {
0108   std::stringstream ss;
0109   ss << std::setiosflags(std::ios::fixed);
0110   ss << std::setprecision(4);
0111   ss << std::boolalpha;
0112   toStream(ss);
0113   return ss.str();
0114 }
0115 
0116 std::shared_ptr<PlaneSurface> CurvilinearSurface::planeSurface() const {
0117   return Surface::makeShared<PlaneSurface>(transform());
0118 }
0119 
0120 std::shared_ptr<Surface> CurvilinearSurface::surface() const {
0121   return planeSurface();
0122 }
0123 
0124 std::ostream& operator<<(std::ostream& os, const CurvilinearSurface& surface) {
0125   return surface.toStream(os);
0126 }
0127 
0128 }  // namespace Acts