Back to home page

EIC code displayed by LXR

 
 

    


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

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