Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:32:31

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2020 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/Definitions/Common.hpp"
0013 #include "Acts/EventData/SourceLink.hpp"
0014 #include "ActsExamples/EventData/Index.hpp"
0015 #include "ActsExamples/EventData/IndexSourceLink.hpp"
0016 
0017 #include <cmath>
0018 #include <vector>
0019 
0020 #include <boost/container/static_vector.hpp>
0021 
0022 namespace ActsExamples {
0023 
0024 /// Space point representation of a measurement suitable for track seeding.
0025 class SimSpacePoint {
0026   using Scalar = Acts::ActsScalar;
0027 
0028  public:
0029   /// Construct the space point from global position and selected variances.
0030   ///
0031   /// @tparam position_t Input position type
0032   /// @param pos Global position
0033   /// @param t Global time
0034   /// @param varRho Measurement variance of the global transverse distance
0035   /// @param varZ Measurement variance of the global longitudinal position
0036   /// @param varT Measurement variance of the global time
0037   /// @param sourceLinks sourceLinks of the measurements
0038   /// @param topHalfStripLength half of the length of the top strip
0039   /// @param bottomHalfStripLength half of the length of the bottom strip
0040   /// @param topStripDirection direction of the top strip
0041   /// @param bottomStripDirection direction of the bottom strip
0042   /// @param stripCenterDistance distance between the center of the two strips
0043   /// @param topStripCenterPosition position of the center of the top strip
0044   /// @param validDoubleMeasurementDetails boolean to check if double measurements are valid
0045   template <typename position_t>
0046   SimSpacePoint(
0047       const Eigen::MatrixBase<position_t>& pos, std::optional<Scalar> t,
0048       Scalar varRho, Scalar varZ, std::optional<Scalar> varT,
0049       boost::container::static_vector<Acts::SourceLink, 2> sourceLinks,
0050       Scalar topHalfStripLength, Scalar bottomHalfStripLength,
0051       const Acts::Vector3& topStripDirection,
0052       const Acts::Vector3& bottomStripDirection,
0053       const Acts::Vector3& stripCenterDistance,
0054       const Acts::Vector3& topStripCenterPosition)
0055       : m_x(pos[Acts::ePos0]),
0056         m_y(pos[Acts::ePos1]),
0057         m_z(pos[Acts::ePos2]),
0058         m_t(t),
0059         m_rho(std::hypot(m_x, m_y)),
0060         m_varianceRho(varRho),
0061         m_varianceZ(varZ),
0062         m_varianceT(varT),
0063         m_sourceLinks(std::move(sourceLinks)),
0064         m_topHalfStripLength(topHalfStripLength),
0065         m_bottomHalfStripLength(bottomHalfStripLength),
0066         m_topStripDirection(topStripDirection),
0067         m_bottomStripDirection(bottomStripDirection),
0068         m_stripCenterDistance(stripCenterDistance),
0069         m_topStripCenterPosition(topStripCenterPosition),
0070         m_validDoubleMeasurementDetails(true) {
0071     EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(position_t, 3);
0072   }
0073 
0074   /// Construct the space point from global position and selected variances.
0075   ///
0076   /// @tparam position_t Input position type
0077   /// @param pos Global position
0078   /// @param t Global time
0079   /// @param varRho Measurement variance of the global transverse distance
0080   /// @param varZ Measurement variance of the global longitudinal position
0081   /// @param varT Measurement variance of the global time
0082   /// @param sourceLinks sourceLinks of the measurements
0083   template <typename position_t>
0084   SimSpacePoint(
0085       const Eigen::MatrixBase<position_t>& pos, std::optional<Scalar> t,
0086       Scalar varRho, Scalar varZ, std::optional<Scalar> varT,
0087       boost::container::static_vector<Acts::SourceLink, 2> sourceLinks)
0088       : m_x(pos[Acts::ePos0]),
0089         m_y(pos[Acts::ePos1]),
0090         m_z(pos[Acts::ePos2]),
0091         m_t(t),
0092         m_rho(std::hypot(m_x, m_y)),
0093         m_varianceRho(varRho),
0094         m_varianceZ(varZ),
0095         m_varianceT(varT),
0096         m_sourceLinks(std::move(sourceLinks)) {
0097     EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(position_t, 3);
0098   }
0099 
0100   constexpr Scalar x() const { return m_x; }
0101   constexpr Scalar y() const { return m_y; }
0102   constexpr Scalar z() const { return m_z; }
0103   constexpr std::optional<Scalar> t() const { return m_t; }
0104   constexpr Scalar r() const { return m_rho; }
0105   constexpr Scalar varianceR() const { return m_varianceRho; }
0106   constexpr Scalar varianceZ() const { return m_varianceZ; }
0107   constexpr std::optional<Scalar> varianceT() const { return m_varianceT; }
0108 
0109   const boost::container::static_vector<Acts::SourceLink, 2>& sourceLinks()
0110       const {
0111     return m_sourceLinks;
0112   }
0113 
0114   constexpr float topHalfStripLength() const { return m_topHalfStripLength; }
0115   constexpr float bottomHalfStripLength() const {
0116     return m_bottomHalfStripLength;
0117   }
0118   Acts::Vector3 topStripDirection() const { return m_topStripDirection; }
0119   Acts::Vector3 bottomStripDirection() const { return m_bottomStripDirection; }
0120   Acts::Vector3 stripCenterDistance() const { return m_stripCenterDistance; }
0121   Acts::Vector3 topStripCenterPosition() const {
0122     return m_topStripCenterPosition;
0123   }
0124   constexpr bool validDoubleMeasurementDetails() const {
0125     return m_validDoubleMeasurementDetails;
0126   }
0127 
0128  private:
0129   // Global position
0130   Scalar m_x;
0131   Scalar m_y;
0132   Scalar m_z;
0133   std::optional<Scalar> m_t;
0134   Scalar m_rho;
0135   // Variance in rho/z of the global coordinates
0136   Scalar m_varianceRho;
0137   Scalar m_varianceZ;
0138   std::optional<Scalar> m_varianceT;
0139   // SourceLinks of the corresponding measurements. A Pixel (strip) SP has one
0140   // (two) sourceLink(s).
0141   boost::container::static_vector<Acts::SourceLink, 2> m_sourceLinks;
0142 
0143   // half of the length of the top strip
0144   float m_topHalfStripLength = 0;
0145   // half of the length of the bottom strip
0146   float m_bottomHalfStripLength = 0;
0147   // direction of the top strip
0148   Acts::Vector3 m_topStripDirection = {0, 0, 0};
0149   // direction of the bottom strip
0150   Acts::Vector3 m_bottomStripDirection = {0, 0, 0};
0151   // distance between the center of the two strips
0152   Acts::Vector3 m_stripCenterDistance = {0, 0, 0};
0153   // position of the center of the bottom strip
0154   Acts::Vector3 m_topStripCenterPosition = {0, 0, 0};
0155   bool m_validDoubleMeasurementDetails = false;
0156 };
0157 
0158 inline bool operator==(const SimSpacePoint& lhs, const SimSpacePoint& rhs) {
0159   // TODO would it be sufficient to check just the index under the assumption
0160   //   that the same measurement index always produces the same space point?
0161   // no need to check r since it is fully defined by x/y
0162 
0163   return (std::equal(lhs.sourceLinks().begin(), lhs.sourceLinks().end(),
0164                      rhs.sourceLinks().begin(),
0165                      [](const auto& lsl, const auto& rsl) {
0166                        return lsl.template get<IndexSourceLink>() ==
0167                               rsl.template get<IndexSourceLink>();
0168                      }) &&
0169           (lhs.x() == rhs.x()) && (lhs.y() == rhs.y()) &&
0170           (lhs.z() == rhs.z()) && (lhs.t() == rhs.t()) &&
0171           (lhs.varianceR() == rhs.varianceR()) &&
0172           (lhs.varianceZ() == rhs.varianceZ()) &&
0173           (lhs.varianceT() == rhs.varianceT()));
0174 }
0175 
0176 /// Container of space points.
0177 using SimSpacePointContainer = std::vector<SimSpacePoint>;
0178 
0179 }  // namespace ActsExamples