ATLAS Offline Software
Loading...
Searching...
No Matches
SeedContainer.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ACTSTRKEVENT_SEEDCONTAINER_H
6#define ACTSTRKEVENT_SEEDCONTAINER_H 1
7
8#include "Acts/EventData/SeedContainer2.hpp"
10#include "Acts/EventData/Seed.hpp" // only needed for conversion from Acts::Seed
11
12#include <vector>
13#include <algorithm>
14#include <utility>
15
16namespace ActsTrk {
17 struct Seed;
18 struct SeedContainer : public Acts::SeedContainer2 {
19 using Base = Acts::SeedContainer2;
21 using const_iterator = Acts::detail::ContainerIterator<SeedContainer, value_type, Index, true>;
23 using SpacePointContainer = std::vector<SpacePointValue>;
24
25 const_iterator begin() const noexcept { return const_iterator(*this, 0); }
26 const_iterator end() const noexcept { return const_iterator(*this, size()); }
27 Seed at(Index index) const;
28 Seed operator[](Index index) const noexcept;
29
30 const SpacePointContainer& spacePoints() const noexcept { return m_spacePoints; }
32
33 // various push_back() styles
34
35 Acts::MutableSeedProxy2 push_back(Acts::SpacePointIndexSubset2 sp) {
36 Acts::MutableSeedProxy2 seed = createSeed();
37 seed.assignSpacePointIndices(sp);
38 return seed;
39 }
40
41 Acts::MutableSeedProxy2 push_back(Acts::MutableSeedProxy2 seed) {
42 Acts::MutableSeedProxy2 newseed = push_back(seed.spacePointIndices());
43 newseed.vertexZ() = seed.vertexZ();
44 newseed.quality() = seed.quality();
45 return newseed;
46 }
47
48 // convert from old Acts::Seed<Acts::SpacePointProxy> used by SeedingTool and OrthogonalSeedingTool
49 template <typename SpacePointProxy_t, std::size_t N>
50 Acts::MutableSeedProxy2 push_back(const Acts::Seed<SpacePointProxy_t, N>* pSeed) {
51 return push_back_helper(pSeed, [this](const SpacePointProxy_t* sp) -> Acts::SpacePointIndex2 {
52 assert(sp->index() < m_spacePoints.size());
53 assert(m_spacePoints[sp->index()] == &sp->externalSpacePoint());
54 std::ignore = m_spacePoints.size(); // Silence Clang warning about unused lambda capture
55 return sp->index();
56 });
57 }
58
59 // convert from old Acts::Seed<xAOD::SpacePoint> used by GbtsSeedingTool.
60 Acts::MutableSeedProxy2 push_back(const Acts::Seed<xAOD::SpacePoint, 3ul>* pSeed) {
61 return push_back_helper(pSeed, [this](SpacePointValue sp) -> Acts::SpacePointIndex2 {
62 auto it = std::find(m_spacePoints.begin(), m_spacePoints.end(), sp);
63 if (it == m_spacePoints.end()) {
64 m_spacePoints.push_back(sp);
65 return m_spacePoints.size() - 1ul;
66 } else {
67 return std::distance(m_spacePoints.begin(), it);
68 }
69 });
70 }
71
72 private:
73 // helper to do push_back() for different old-style seed types
74 template <typename seed_type, typename spindex_fun>
75 Acts::MutableSeedProxy2 push_back_helper(seed_type* pSeed, spindex_fun spindex) {
76 std::vector<Acts::SpacePointIndex2> spacePointIndices;
77 spacePointIndices.reserve(pSeed->sp().size());
78 for (auto sp2 : pSeed->sp()) {
79 Acts::SpacePointIndex2 ind = spindex(sp2);
80 spacePointIndices.push_back(ind);
81 }
82 Acts::MutableSeedProxy2 seed = createSeed();
83 seed.assignSpacePointIndices(spacePointIndices);
84 seed.vertexZ() = pSeed->z();
85 seed.quality() = pSeed->seedQuality();
86 return seed;
87 }
88
90 };
91
92 // Following classes are proxies based on SeedContainer, so don't need a CLID
94 struct Seed : public Acts::ConstSeedProxy2 {
95 using Base = Acts::ConstSeedProxy2;
98
99 const SpacePointContainer& spacePointContainer() const noexcept { return static_cast<const SeedContainer&>(container()).spacePoints(); }
101 // emulate old Acts::Seed methods
102 float z() const noexcept { return vertexZ(); }
103 float seedQuality() const noexcept { return quality(); }
104 };
105
106 inline Seed SeedContainer::at(Index index) const { return static_cast<Seed>(Base::at(index)); }
107 inline Seed SeedContainer::operator[](Index index) const noexcept { return static_cast<Seed>(Base::operator[](index)); }
108
109 struct SpacePointIndexSubset : public Acts::SpacePointIndexSubset2 {
110 using Base = Acts::SpacePointIndexSubset2;
113 using Index = Base::size_type;
114 using const_iterator = Acts::detail::ContainerIterator<SpacePointIndexSubset, value_type, Index, true>;
115
117 SpacePointIndexSubset(const SpacePointContainer& spacePointContainer, Base spacePointIndices)
118 : Base(spacePointIndices), m_spacePointContainer(&spacePointContainer) {}
119
120 const_iterator begin() const noexcept { return const_iterator(*this, 0); }
121 const_iterator end() const noexcept { return const_iterator(*this, size()); }
122 value_type operator[](Index index) const noexcept { return (*m_spacePointContainer)[Base::operator[](index)]; }
123 value_type at(Index index) const { return m_spacePointContainer->at(Base::operator[](index)); }
124 value_type front() const noexcept { return operator[](0ul); }
125 value_type back() const noexcept { return operator[](size() - 1ul); }
126
127 private:
129 };
130
131 inline SpacePointIndexSubset Seed::sp() const { return SpacePointIndexSubset(spacePointContainer(), spacePointIndices()); }
132
133} // namespace ActsTrk
134
135// Set up a CLID for the type:
137CLASS_DEF(ActsTrk::SeedContainer, 1261318102, 2)
138
139#endif
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
IndexedConstituentUserInfo::Index Index
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition index.py:1
Seed at(Index index) const
Acts::SeedContainer2 Base
Acts::MutableSeedProxy2 push_back(const Acts::Seed< xAOD::SpacePoint, 3ul > *pSeed)
Acts::MutableSeedProxy2 push_back(const Acts::Seed< SpacePointProxy_t, N > *pSeed)
SpacePointContainer m_spacePoints
Acts::MutableSeedProxy2 push_back(Acts::MutableSeedProxy2 seed)
Seed operator[](Index index) const noexcept
SpacePointContainer & spacePoints() noexcept
Acts::MutableSeedProxy2 push_back_helper(seed_type *pSeed, spindex_fun spindex)
Acts::detail::ContainerIterator< SeedContainer, value_type, Index, true > const_iterator
const_iterator begin() const noexcept
Acts::MutableSeedProxy2 push_back(Acts::SpacePointIndexSubset2 sp)
std::vector< SpacePointValue > SpacePointContainer
const xAOD::SpacePoint * SpacePointValue
const_iterator end() const noexcept
const SpacePointContainer & spacePoints() const noexcept
Acts::ConstSeedProxy2 Base
SeedContainer::SpacePointValue SpacePointValue
float z() const noexcept
SpacePointIndexSubset sp() const
const SpacePointContainer & spacePointContainer() const noexcept
float seedQuality() const noexcept
SeedContainer::SpacePointContainer SpacePointContainer
value_type front() const noexcept
value_type back() const noexcept
const_iterator end() const noexcept
SeedContainer::SpacePointContainer SpacePointContainer
const_iterator begin() const noexcept
SeedContainer::SpacePointValue value_type
SpacePointIndexSubset(const SpacePointContainer &spacePointContainer, Base spacePointIndices)
value_type operator[](Index index) const noexcept
Acts::SpacePointIndexSubset2 Base
Acts::detail::ContainerIterator< SpacePointIndexSubset, value_type, Index, true > const_iterator
value_type at(Index index) const
const SpacePointContainer * m_spacePointContainer