Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VectorTrackContainer.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VectorTrackContainer.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
12 
13 #include <iterator>
14 
15 namespace Acts {
16 
17 namespace detail_vtc {
18 
20  const VectorTrackContainerBase& other)
21  : m_tipIndex{other.m_tipIndex},
22  m_stemIndex{other.m_stemIndex},
23  m_particleHypothesis{other.m_particleHypothesis},
24  m_params{other.m_params},
25  m_cov{other.m_cov},
26  m_referenceSurfaces{other.m_referenceSurfaces},
27  m_nMeasurements{other.m_nMeasurements},
28  m_nHoles{other.m_nHoles},
29  m_chi2{other.m_chi2},
30  m_ndf{other.m_ndf},
31  m_nOutliers{other.m_nOutliers},
32  m_nSharedHits{other.m_nSharedHits} {
33  for (const auto& [key, value] : other.m_dynamic) {
34  m_dynamic.insert({key, value->clone()});
35  }
36  assert(checkConsistency());
37 }
38 } // namespace detail_vtc
39 
42 
43  m_tipIndex.emplace_back(kInvalid);
44  m_stemIndex.emplace_back(kInvalid);
45 
47  m_params.emplace_back();
48  m_cov.emplace_back();
49  m_referenceSurfaces.emplace_back();
50 
51  m_nMeasurements.emplace_back();
52  m_nHoles.emplace_back();
53 
54  m_chi2.emplace_back();
55  m_ndf.emplace_back();
56 
57  m_nOutliers.emplace_back();
58  m_nSharedHits.emplace_back();
59 
60  // dynamic columns
61  for (auto& [key, vec] : m_dynamic) {
62  vec->add();
63  }
64 
66 
67  return m_tipIndex.size() - 1;
68 }
69 
71  auto erase = [&](auto& vec) {
72  assert(itrack < vec.size() && "Index is out of range");
73  auto it = vec.begin();
74  std::advance(it, itrack);
75  vec.erase(it);
76  };
77 
78  erase(m_tipIndex);
79  erase(m_stemIndex);
80 
81  erase(m_params);
82  erase(m_cov);
83  erase(m_referenceSurfaces);
84 
85  erase(m_nMeasurements);
86  erase(m_nHoles);
87 
88  erase(m_chi2);
89  erase(m_ndf);
90 
91  erase(m_nOutliers);
92  erase(m_nSharedHits);
93 
94  for (auto& [key, vec] : m_dynamic) {
95  vec->erase(itrack);
96  }
97 }
98 
100  IndexType dstIdx, const VectorTrackContainerBase& src, IndexType srcIdx) {
101  for (const auto& [key, value] : src.m_dynamic) {
102  auto it = m_dynamic.find(key);
103  if (it == m_dynamic.end()) {
104  throw std::invalid_argument{
105  "Destination container does not have matching dynamic column"};
106  }
107 
108  it->second->copyFrom(dstIdx, *value, srcIdx);
109  }
110 }
111 
114  for (auto& [key, value] : other.m_dynamic) {
115  if (m_dynamic.find(key) == m_dynamic.end()) {
116  m_dynamic[key] = value->clone(true);
117  }
118  }
119 }
120 
122  m_tipIndex.reserve(size);
123  m_stemIndex.reserve(size);
124 
125  m_particleHypothesis.reserve(size);
126  m_params.reserve(size);
127  m_cov.reserve(size);
128  m_referenceSurfaces.reserve(size);
129 
130  m_nMeasurements.reserve(size);
131  m_nHoles.reserve(size);
132 
133  m_chi2.reserve(size);
134  m_ndf.reserve(size);
135 
136  m_nOutliers.reserve(size);
137  m_nSharedHits.reserve(size);
138 
139  for (auto& [key, vec] : m_dynamic) {
140  vec->reserve(size);
141  }
142 }
143 
145  m_tipIndex.clear();
146  m_stemIndex.clear();
147 
148  m_particleHypothesis.clear();
149  m_params.clear();
150  m_cov.clear();
151  m_referenceSurfaces.clear();
152 
153  m_nMeasurements.clear();
154  m_nHoles.clear();
155 
156  m_chi2.clear();
157  m_ndf.clear();
158 
159  m_nOutliers.clear();
160  m_nSharedHits.clear();
161 
162  for (auto& [key, vec] : m_dynamic) {
163  vec->clear();
164  }
165 }
166 
167 } // namespace Acts