Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-04 07:59:31

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 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/EventData/SourceLink.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/GeometryIdentifier.hpp"
0016 #include "Acts/Geometry/TrackingGeometry.hpp"
0017 #include "Acts/SpacePointFormation/SpacePointBuilderConfig.hpp"
0018 #include "Acts/SpacePointFormation/SpacePointBuilderOptions.hpp"
0019 #include "Acts/Utilities/Diagnostics.hpp"
0020 #include "Acts/Utilities/Result.hpp"
0021 
0022 #include <cstddef>
0023 #include <system_error>
0024 #include <utility>
0025 
0026 ACTS_PUSH_IGNORE_DEPRECATED()
0027 
0028 namespace Acts {
0029 
0030 class SourceLink;
0031 
0032 /// @brief Storage container for variables related to the calculation of space
0033 /// points
0034 struct SpacePointParameters {
0035   /// Vector pointing from bottom to top end of first SDE
0036   Vector3 firstBtmToTop{};
0037   /// Vector pointing from bottom to top end of second SDE
0038   Vector3 secondBtmToTop{};
0039   /// Twice the vector pointing from vertex to to midpoint of first SDE
0040   Vector3 vtxToFirstMid2{};
0041   /// Twice the vector pointing from vertex to to midpoint of second SDE
0042   Vector3 vtxToSecondMid2{};
0043   /// Cross product between firstBtmToTop and vtxToFirstMid2
0044   Vector3 firstBtmToTopXvtxToFirstMid2{};
0045   /// Cross product between secondBtmToTop and vtxToSecondMid2
0046   Vector3 secondBtmToTopXvtxToSecondMid2{};
0047   /// Magnitude of SpacePointParameters::firstBtmToTop
0048   double mag_firstBtmToTop = 0.;
0049   /// Parameter that determines the hit position on the first SDE
0050   double m = 0.;
0051   /// Parameter that determines the hit position on the second SDE
0052   double n = 0.;
0053   /// Regular limit of the absolute values of SpacePointParameters::m and
0054   /// SpacePointParameters::n
0055   double limit = 1.;
0056   /// Limit of SpacePointParameters::m and SpacePointParameters::n in case of
0057   /// variable vertex
0058   double limitExtended = 0.;
0059 };
0060 
0061 /// @class SpacePointUtility
0062 /// Utility helper for space point calculations.
0063 class [[deprecated(
0064     "Will be dropped soon and is replaced by PixelSpacePointBuilder / "
0065     "StripSpacePointBuilder")]] SpacePointUtility {
0066  public:
0067   /// Constructor
0068   /// @param cfg Configuration for the space point builder
0069   explicit SpacePointUtility(SpacePointBuilderConfig cfg)
0070       : m_config(std::move(cfg)) {}
0071 
0072   /// @brief Getter method for the global coordinates of a SourceLink
0073   ///
0074   /// @param gctx The current geometry context object, e.g. alignment
0075   /// @param slink SourceLink that holds the necessary
0076   /// information
0077   /// @param surfaceAccessor function to extract surface from SourceLink
0078   /// @param par local position
0079   /// @param cov local covariance
0080   /// @return vectors of the global coordinates and covariance of the SourceLink
0081   std::tuple<Vector3, std::optional<double>, Vector2, std::optional<double>>
0082   globalCoords(const GeometryContext& gctx, const SourceLink& slink,
0083                const SourceLinkSurfaceAccessor& surfaceAccessor,
0084                const BoundVector& par, const BoundMatrix& cov) const;
0085 
0086   /// @brief Get rho and z 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 globalPos The global position
0090   /// @param localCov The local covariance matrix
0091   /// @return (rho, z) components of the global covariance
0092   Vector2 rhoZCovariance(const GeometryContext& gctx, const Surface& surface,
0093                          const Vector3& globalPos,
0094                          const SquareMatrix2& localCov) const;
0095 
0096   /// @brief Calculate the rho and z covariance from the front and back SourceLink in the strip SP formation
0097   /// @param gctx The current geometry context object, e.g. alignment
0098   /// @param slinkFront The SourceLink on the front layer
0099   /// @param slinkBack The SourceLink on the back layer
0100   /// @param paramCovAccessor function to extract local position and covariance from SourceLink
0101   /// @param surfaceAccessor function to extract surface from SourceLink
0102   /// @param globalPos global position
0103   /// @param theta The angle between the two strips
0104   /// @return (rho, z) components of the global covariance
0105   Vector2 calcRhoZVars(const GeometryContext& gctx,
0106                        const SourceLink& slinkFront,
0107                        const SourceLink& slinkBack,
0108                        const SourceLinkSurfaceAccessor& surfaceAccessor,
0109                        const ParamCovAccessor& paramCovAccessor,
0110                        const Vector3& globalPos, const double theta) const;
0111 
0112   /// @brief This function performs a straight forward calculation of a space
0113   /// point and returns whether it was successful or not.
0114   ///
0115   /// @param [in] stripEnds1 Top and bottom end of the first strip
0116   /// @param [in] stripEnds2 Top and bottom end of the second strip
0117   /// @param [in] posVertex Position of the vertex
0118   /// @param [in, out] spParams Data container of the calculations
0119   /// @param [in] stripLengthTolerance Tolerance scaling factor on the strip
0120   /// detector element length
0121   ///
0122   /// @return Result whether the space point calculation was successful
0123   Result<void> calculateStripSPPosition(
0124       const std::pair<Vector3, Vector3>& stripEnds1,
0125       const std::pair<Vector3, Vector3>& stripEnds2, const Vector3& posVertex,
0126       SpacePointParameters& spParams, const double stripLengthTolerance) const;
0127 
0128   /// @brief This function tests if a space point can be estimated by a more
0129   /// tolerant treatment of construction. In fact, this function indirectly
0130   /// allows shifts of the vertex.
0131   ///
0132   /// @param [in] spParams container that stores geometric parameters and rules of
0133   /// the space point formation
0134   /// @param [in] stripLengthGapTolerance Tolerance scaling factor of the gap
0135   /// between strip detector elements
0136   ///
0137   /// @return indicator if the test was successful
0138   Result<void> recoverSpacePoint(SpacePointParameters& spParams,
0139                                  double stripLengthGapTolerance) const;
0140 
0141   /// @brief Calculates (Delta theta)^2 + (Delta phi)^2 between two SourceLinks
0142   ///
0143   /// @param [in] pos1 position of the first SourceLink
0144   /// @param [in] pos2 position the second SourceLink
0145   /// @param [in] posVertex Position of the vertex
0146   /// @param [in] maxDistance Maximum distance between two SourceLinks
0147   /// @param [in] maxAngleTheta2 Maximum squared theta angle between two
0148   /// SourceLinks
0149   /// @param [in] maxAnglePhi2 Maximum squared phi angle between two SourceLinks
0150   ///
0151   /// @return Result with the squared sum within configuration parameters.
0152   Result<double> differenceOfMeasurementsChecked(
0153       const Vector3& pos1, const Vector3& pos2, const Vector3& posVertex,
0154       const double maxDistance, const double maxAngleTheta2,
0155       const double maxAnglePhi2) const;
0156 
0157   /// @brief Calculates a space point without using the vertex
0158   /// @note This is mostly to resolve space points from cosmic data
0159   /// @param stripEnds1 The ends of one strip
0160   /// @param stripEnds2 The ends of another strip
0161   /// @param spParams SpacePointParamaters for the SP
0162   /// @return parameter that indicates the location of the space point; returns
0163   /// 1. if it failed
0164   /// @note The meaning of the parameter is explained in more detail in the
0165   /// function body
0166   Result<double> calcPerpendicularProjection(
0167       const std::pair<Vector3, Vector3>& stripEnds1,
0168       const std::pair<Vector3, Vector3>& stripEnds2,
0169       SpacePointParameters& spParams) const;
0170 
0171  private:
0172   SpacePointBuilderConfig m_config;
0173   std::error_code m_error;
0174 };
0175 
0176 }  // namespace Acts
0177 
0178 ACTS_POP_IGNORE_DEPRECATED()