Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-25 09:24:43

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 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 
0013 namespace Acts {
0014 
0015 class GeometryContext;
0016 class Surface;
0017 
0018 namespace PixelSpacePointBuilder {
0019 
0020 /// @brief Transform a local covariance to z and r
0021 ///
0022 /// Only for surfaces whose reference frame depends on the geometry context
0023 /// alone, i.e. plane and disc, so that a caller can look it up once per module
0024 /// with `Surface::referenceFrame(gctx)`.
0025 ///
0026 /// @note Only the diagonal of the result feeds a space point. Prefer
0027 /// @c computeVarianceZR, which skips the off-diagonal term and is inline.
0028 ///
0029 /// @note A common cheaper shortcut is to split a single variance by the module
0030 /// normal, `varZ = v * (1 - nz²)` and `varR = v * nz²`, dropping the second
0031 /// local variance and the correlation.
0032 ///
0033 /// @param rotLocalToGlobal The surface reference frame
0034 /// @param spacePoint The global position
0035 /// @param localCov The local covariance matrix
0036 /// @return The (z, r) covariance
0037 SquareMatrix2 computeCovarianceZR(const RotationMatrix3& rotLocalToGlobal,
0038                                   const Vector3& spacePoint,
0039                                   const SquareMatrix2& localCov);
0040 
0041 /// @brief Transform a local covariance to the z and r variances
0042 ///
0043 /// The diagonal of @c computeCovarianceZR, without forming the off-diagonal
0044 /// term. Space point formation runs this once per measurement, so it is kept
0045 /// inline and written out as two quadratic forms over the Jacobian rows.
0046 ///
0047 /// See @c computeCovarianceZR for the requirement on the reference frame.
0048 ///
0049 /// @param rotLocalToGlobal The surface reference frame
0050 /// @param spacePoint The global position
0051 /// @param localCov The local covariance matrix
0052 /// @return The (z, r) variances
0053 inline Vector2 computeVarianceZR(const RotationMatrix3& rotLocalToGlobal,
0054                                  const Vector3& spacePoint,
0055                                  const SquareMatrix2& localCov) {
0056   // the two local axes in global coordinates
0057   const double a0x = rotLocalToGlobal(0, 0);
0058   const double a0y = rotLocalToGlobal(1, 0);
0059   const double a0z = rotLocalToGlobal(2, 0);
0060   const double a1x = rotLocalToGlobal(0, 1);
0061   const double a1y = rotLocalToGlobal(1, 1);
0062   const double a1z = rotLocalToGlobal(2, 1);
0063 
0064   const double c00 = localCov(0, 0);
0065   const double c01 = localCov(0, 1) + localCov(1, 0);
0066   const double c11 = localCov(1, 1);
0067 
0068   // v^T localCov v for a two component Jacobian v
0069   const auto quadraticForm = [c00, c01, c11](double v0, double v1) {
0070     return c00 * v0 * v0 + c01 * v0 * v1 + c11 * v1 * v1;
0071   };
0072 
0073   const double x = spacePoint.x();
0074   const double y = spacePoint.y();
0075 
0076   // dz/dl is the z component of the local axis, dr/dl the radial one over r.
0077   // the radial Jacobian is left unnormalised, so its 1/r comes out of the
0078   // quadratic form as one division by r squared and no square root is needed
0079   const double varZ = quadraticForm(a0z, a1z);
0080   const double varR =
0081       quadraticForm(x * a0x + y * a0y, x * a1x + y * a1y) / (x * x + y * y);
0082 
0083   return {varZ, varR};
0084 }
0085 
0086 /// @brief Get z and r covariance from the local position and covariance
0087 /// @param gctx The current geometry context object, e.g. alignment
0088 /// @param surface The surface associated
0089 /// @param spacePoint The global position
0090 /// @param localCov The local covariance matrix
0091 /// @return (z, r) components of the global covariance
0092 /// @deprecated Use computeVarianceZR with a reference frame from
0093 ///             Surface::referenceFrame
0094 [[deprecated(
0095     "Use computeVarianceZR with a reference frame from "
0096     "Surface::referenceFrame")]]
0097 Vector2 computeVarianceZR(const GeometryContext& gctx, const Surface& surface,
0098                           const Vector3& spacePoint,
0099                           const SquareMatrix2& localCov);
0100 
0101 }  // namespace PixelSpacePointBuilder
0102 
0103 }  // namespace Acts