ATLAS Offline Software
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"
9 #include "Acts/EventData/SpacePointContainer.hpp"
10 #include "Acts/EventData/Seed.hpp"
12 
13 #include <vector>
14 #include <algorithm>
15 #include <type_traits>
16 
17 namespace ActsTrk {
18  struct Seed;
19  struct SeedContainer : public Acts::SeedContainer2 {
20  using Base = Acts::SeedContainer2;
21  using value_type = Seed;
22  using const_iterator = Acts::detail::ContainerIterator<SeedContainer, value_type, Index, true>;
24  using SpacePointContainer = std::vector<SpacePointValue>;
25  // legacy Seed type used in SeedingTool etc.
26  using SpacePointValueBase = std::remove_const_t<std::remove_pointer_t<SpacePointValue>>;
27  using Seed1 = Acts::Seed<SpacePointValueBase, 3ul>;
28 
29  const_iterator begin() const noexcept { return const_iterator(*this, 0); }
30  const_iterator end() const noexcept { return const_iterator(*this, size()); }
31  Seed at(Index index) const;
32  Seed operator[](Index index) const noexcept;
33 
34  Acts::MutableSeedProxy2 push_back(Acts::MutableSeedProxy2 seed);
35  Acts::MutableSeedProxy2 push_back(Acts::SpacePointIndexSubset2 sp) {
36  Acts::MutableSeedProxy2 seed = createSeed();
37  seed.assignSpacePointIndices(sp);
38  return seed;
39  }
40 
41  const SpacePointContainer &spacePoints() const noexcept { return m_spacePoints; }
43 
44  // convert from old Acts::Seed
45  Acts::MutableSeedProxy2 push_back(std::unique_ptr<Seed1> pSeed) { return push_back(pSeed.get()); }
46  template <template <typename> class seed_type, typename container_t>
47  Acts::MutableSeedProxy2 push_back(const seed_type<Acts::SpacePointProxy<container_t>> *pSeed) {
48  return push_back(pSeed, [this](const Acts::SpacePointProxy<container_t> *sp) -> Acts::SpacePointIndex2 {
49  assert(sp->index() < m_spacePoints.size());
50  assert(m_spacePoints[sp->index()] == &sp->externalSpacePoint());
51  std::ignore = m_spacePoints.size(); // Silence Clang warning about unused lambda capture
52  return sp->index();
53  });
54  }
55  Acts::MutableSeedProxy2 push_back(const Seed1 *pSeed) {
56  return push_back(pSeed, [this](SpacePointValue sp) -> Acts::SpacePointIndex2 {
57  auto it = std::find(m_spacePoints.begin(), m_spacePoints.end(), sp);
58  if (it == m_spacePoints.end()) {
59  m_spacePoints.push_back(sp);
60  return m_spacePoints.size() - 1ul;
61  } else {
62  return std::distance(m_spacePoints.begin(), it);
63  }
64  });
65  }
66  template <typename seed_type, typename spindex_fun>
67  Acts::MutableSeedProxy2 push_back(seed_type *pSeed, spindex_fun spindex);
68 
69  private:
71  };
72 
73  // Following classes are proxies based on SeedContainer, so don't need a CLID
74  struct SpacePointIndexSubset;
75  struct Seed : public Acts::ConstSeedProxy2 {
76  using Base = Acts::ConstSeedProxy2;
79 
80  const SpacePointContainer &spacePointContainer() const noexcept { return static_cast<const SeedContainer &>(container()).spacePoints(); }
81  SpacePointIndexSubset sp() const;
82  // emulate old Acts::Seed methods
83  float z() const noexcept { return vertexZ(); }
84  float seedQuality() const noexcept { return quality(); }
85  };
86 
87  inline Seed SeedContainer::at(Index index) const { return static_cast<Seed>(Base::at(index)); }
88  inline Seed SeedContainer::operator[](Index index) const noexcept { return static_cast<Seed>(Base::operator[](index)); }
89  inline Acts::MutableSeedProxy2 SeedContainer::push_back(Acts::MutableSeedProxy2 seed) {
90  auto newseed = push_back(seed.spacePointIndices());
91  newseed.vertexZ() = seed.vertexZ();
92  newseed.quality() = seed.quality();
93  return newseed;
94  }
95 
96  template <typename seed_type, typename spindex_fun>
97  inline Acts::MutableSeedProxy2 SeedContainer::push_back(seed_type *pSeed, spindex_fun spindex) {
98  std::vector<Acts::SpacePointIndex2> spacePointIndices;
99  spacePointIndices.reserve(pSeed->sp().size());
100  for (auto sp2 : pSeed->sp()) {
101  Acts::SpacePointIndex2 ind = spindex(sp2);
102  spacePointIndices.push_back(ind);
103  }
104  Acts::MutableSeedProxy2 seed = createSeed();
105  seed.assignSpacePointIndices(spacePointIndices);
106  seed.vertexZ() = pSeed->z();
107  seed.quality() = pSeed->seedQuality();
108  return seed;
109  }
110 
111  struct SpacePointIndexSubset : public Acts::SpacePointIndexSubset2 {
112  using Base = Acts::SpacePointIndexSubset2;
115  using Index = Base::size_type;
116  using const_iterator = Acts::detail::ContainerIterator<SpacePointIndexSubset, value_type, Index, true>;
117 
119  SpacePointIndexSubset(const SpacePointContainer &spacePointContainer, Base spacePointIndices)
120  : Base(spacePointIndices), m_spacePointContainer(&spacePointContainer) {}
121 
122  const_iterator begin() const noexcept { return const_iterator(*this, 0); }
123  const_iterator end() const noexcept { return const_iterator(*this, size()); }
125  value_type at(Index index) const { return m_spacePointContainer->at(Base::operator[](index)); }
126  value_type front() const { return operator[](0ul); }
127  value_type back() const { return operator[](size() - 1ul); }
128 
129  private:
131  };
132 
133  inline SpacePointIndexSubset Seed::sp() const { return SpacePointIndexSubset(spacePointContainer(), spacePointIndices()); }
134 
135 } // namespace ActsTrk
136 
137 // Set up a CLID for the type:
138 #include "AthenaKernel/CLASS_DEF.h"
139 CLASS_DEF(ActsTrk::SeedContainer, 1261318102, 2)
140 
141 #endif
ActsTrk::SeedContainer::SpacePointValueBase
std::remove_const_t< std::remove_pointer_t< SpacePointValue > > SpacePointValueBase
Definition: SeedContainer.h:26
ActsTrk::SpacePointIndexSubset::SpacePointContainer
SeedContainer::SpacePointContainer SpacePointContainer
Definition: SeedContainer.h:114
ActsTrk::SeedContainer
Definition: SeedContainer.h:19
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
ActsTrk::SeedContainer::operator[]
Seed operator[](Index index) const noexcept
Definition: SeedContainer.h:88
index
Definition: index.py:1
ActsTrk::SpacePointIndexSubset::Index
Base::size_type Index
Definition: SeedContainer.h:115
ActsTrk::SeedContainer::Seed1
Acts::Seed< SpacePointValueBase, 3ul > Seed1
Definition: SeedContainer.h:27
skel.it
it
Definition: skel.GENtoEVGEN.py:407
ActsTrk::SpacePointIndexSubset::m_spacePointContainer
const SpacePointContainer * m_spacePointContainer
Definition: SeedContainer.h:130
xAOD::SpacePoint_v1
Definition: SpacePoint_v1.h:29
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
ActsTrk::SpacePointIndexSubset::operator[]
value_type operator[](Index index) const noexcept
Definition: SeedContainer.h:124
ActsTrk::SeedContainer::begin
const_iterator begin() const noexcept
Definition: SeedContainer.h:29
ActsTrk::SeedContainer::SpacePointContainer
std::vector< SpacePointValue > SpacePointContainer
Definition: SeedContainer.h:24
ActsTrk::SeedContainer::push_back
Acts::MutableSeedProxy2 push_back(Acts::SpacePointIndexSubset2 sp)
Definition: SeedContainer.h:35
ActsTrk::Seed::spacePointContainer
const SpacePointContainer & spacePointContainer() const noexcept
Definition: SeedContainer.h:80
ActsTrk::SeedContainer::m_spacePoints
SpacePointContainer m_spacePoints
Definition: SeedContainer.h:70
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:58
ActsTrk::SpacePointIndexSubset::back
value_type back() const
Definition: SeedContainer.h:127
ActsTrk::SeedContainer::SpacePointValue
const xAOD::SpacePoint * SpacePointValue
Definition: SeedContainer.h:23
Index
IndexedConstituentUserInfo::Index Index
Definition: IndexedConstituentUserInfo.cxx:12
ActsTrk::SpacePointIndexSubset::end
const_iterator end() const noexcept
Definition: SeedContainer.h:123
ActsTrk::SpacePointIndexSubset::begin
const_iterator begin() const noexcept
Definition: SeedContainer.h:122
ActsTrk::Seed::seedQuality
float seedQuality() const noexcept
Definition: SeedContainer.h:84
ActsTrk::SeedContainer::end
const_iterator end() const noexcept
Definition: SeedContainer.h:30
Base
ActsTrk::SeedContainer::at
Seed at(Index index) const
Definition: SeedContainer.h:87
ActsTrk::SeedContainer::const_iterator
Acts::detail::ContainerIterator< SeedContainer, value_type, Index, true > const_iterator
Definition: SeedContainer.h:22
detail::ul
unsigned long ul
Definition: PrimitiveHelpers.h:46
ActsTrk::SeedContainer::spacePoints
const SpacePointContainer & spacePoints() const noexcept
Definition: SeedContainer.h:41
F600IntegrationConfig.spacePoints
spacePoints
Definition: F600IntegrationConfig.py:122
ActsTrk::SpacePointIndexSubset::SpacePointIndexSubset
SpacePointIndexSubset(const SpacePointContainer &spacePointContainer, Base spacePointIndices)
Definition: SeedContainer.h:119
SpacePoint.h
ActsTrk::SeedContainer::push_back
Acts::MutableSeedProxy2 push_back(Acts::MutableSeedProxy2 seed)
Definition: SeedContainer.h:89
ActsTrk::SpacePointIndexSubset::front
value_type front() const
Definition: SeedContainer.h:126
columnar::operator[]
ObjectId< CI, CM > operator[](std::size_t) const noexcept
Definition: ObjectRange.h:173
ActsTrk::Seed::SpacePointContainer
SeedContainer::SpacePointContainer SpacePointContainer
Definition: SeedContainer.h:78
ActsTrk::SeedContainer::push_back
Acts::MutableSeedProxy2 push_back(std::unique_ptr< Seed1 > pSeed)
Definition: SeedContainer.h:45
ActsTrk::Seed::sp
SpacePointIndexSubset sp() const
Definition: SeedContainer.h:133
ActsTrk::Seed::z
float z() const noexcept
Definition: SeedContainer.h:83
ActsTrk::Seed
Definition: SeedContainer.h:75
ActsTrk::SeedContainer::push_back
Acts::MutableSeedProxy2 push_back(const Seed1 *pSeed)
Definition: SeedContainer.h:55
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:67
python.TrackLeptonConfig.quality
quality
Definition: TrackLeptonConfig.py:16
ActsTrk::SpacePointIndexSubset::SpacePointIndexSubset
SpacePointIndexSubset()=default
ActsTrk::SeedContainer::push_back
Acts::MutableSeedProxy2 push_back(const seed_type< Acts::SpacePointProxy< container_t >> *pSeed)
Definition: SeedContainer.h:47
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MdtCalibInput.h:31
ActsTrk::SpacePointIndexSubset::const_iterator
Acts::detail::ContainerIterator< SpacePointIndexSubset, value_type, Index, true > const_iterator
Definition: SeedContainer.h:116
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
CLASS_DEF.h
macros to associate a CLID to a type
ActsTrk::SpacePointIndexSubset
Definition: SeedContainer.h:111
ActsTrk::SeedContainer::spacePoints
SpacePointContainer & spacePoints() noexcept
Definition: SeedContainer.h:42
ActsTrk::SpacePointIndexSubset::at
value_type at(Index index) const
Definition: SeedContainer.h:125