File indexing completed on 2025-07-02 07:52:20
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/EventData/SpacePointContainer.hpp"
0012 #include "Acts/Utilities/Holders.hpp"
0013
0014 #include <any>
0015
0016 namespace ActsExamples {
0017
0018 template <typename collection_t>
0019 class SpacePointContainer {
0020 public:
0021 using CollectionType = collection_t;
0022 using ValueType = typename CollectionType::value_type;
0023
0024 friend Acts::SpacePointContainer<
0025 ActsExamples::SpacePointContainer<collection_t>, Acts::detail::RefHolder>;
0026
0027
0028 SpacePointContainer() = delete;
0029
0030
0031
0032 SpacePointContainer(CollectionType&& container) = delete;
0033 explicit SpacePointContainer(CollectionType& container)
0034 : m_storage(container) {}
0035 explicit SpacePointContainer(CollectionType* container)
0036 : m_storage(container) {}
0037
0038
0039 SpacePointContainer(const SpacePointContainer<collection_t>&) = delete;
0040 SpacePointContainer<collection_t>& operator=(
0041 const SpacePointContainer<collection_t>&) = delete;
0042
0043
0044 SpacePointContainer(SpacePointContainer<collection_t>&& other) noexcept
0045 : m_storage(std::exchange(other.m_storage.ptr, nullptr)) {}
0046 SpacePointContainer<collection_t>& operator=(
0047 SpacePointContainer<collection_t>&& other) noexcept {
0048 m_storage = std::exchange(other.m_storage.ptr, nullptr);
0049 return *this;
0050 }
0051
0052 ~SpacePointContainer() = default;
0053
0054 private:
0055 std::size_t size_impl() const;
0056
0057 float x_impl(std::size_t idx) const;
0058 float y_impl(std::size_t idx) const;
0059 float z_impl(std::size_t idx) const;
0060 float varianceR_impl(std::size_t idx) const;
0061 float varianceZ_impl(std::size_t idx) const;
0062
0063 const ValueType& get_impl(std::size_t idx) const { return storage()[idx]; }
0064
0065 std::any component_impl(Acts::HashedString key, std::size_t ) const {
0066 using namespace Acts::HashedStringLiteral;
0067 switch (key) {
0068 case "TopStripVector"_hash:
0069 case "BottomStripVector"_hash:
0070 case "StripCenterDistance"_hash:
0071 case "TopStripCenterPosition"_hash:
0072 return Acts::Vector3(0, 0, 0);
0073 default:
0074 throw std::runtime_error("no such component " + std::to_string(key));
0075 }
0076 }
0077
0078 private:
0079 const CollectionType& storage() const;
0080
0081 private:
0082 Acts::detail::RefHolder<CollectionType> m_storage;
0083 };
0084
0085 template <typename collection_t>
0086 inline std::size_t SpacePointContainer<collection_t>::size_impl() const {
0087 return storage().size();
0088 }
0089
0090
0091
0092
0093 template <typename collection_t>
0094 inline float SpacePointContainer<collection_t>::x_impl(std::size_t idx) const {
0095 return storage()[idx]->x();
0096 }
0097
0098 template <typename collection_t>
0099 inline float SpacePointContainer<collection_t>::y_impl(std::size_t idx) const {
0100 return storage()[idx]->y();
0101 }
0102
0103 template <typename collection_t>
0104 inline float SpacePointContainer<collection_t>::z_impl(std::size_t idx) const {
0105 return storage()[idx]->z();
0106 }
0107
0108 template <typename collection_t>
0109 inline float SpacePointContainer<collection_t>::varianceR_impl(
0110 std::size_t idx) const {
0111 return storage()[idx]->varianceR;
0112 }
0113
0114 template <typename collection_t>
0115 inline float SpacePointContainer<collection_t>::varianceZ_impl(
0116 std::size_t idx) const {
0117 return storage()[idx]->varianceZ;
0118 }
0119
0120 template <typename collection_t>
0121 const typename SpacePointContainer<collection_t>::CollectionType&
0122 SpacePointContainer<collection_t>::storage() const {
0123 return *m_storage;
0124 }
0125
0126 }