File indexing completed on 2025-01-18 09:11:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/EventData/VectorTrackContainer.hpp"
0010
0011 #include "Acts/EventData/ParticleHypothesis.hpp"
0012 #include "Acts/Utilities/HashedString.hpp"
0013
0014 #include <iterator>
0015
0016 namespace Acts {
0017
0018 namespace detail_vtc {
0019
0020 VectorTrackContainerBase::VectorTrackContainerBase(
0021 const VectorTrackContainerBase& other)
0022 : m_tipIndex{other.m_tipIndex},
0023 m_stemIndex{other.m_stemIndex},
0024 m_particleHypothesis{other.m_particleHypothesis},
0025 m_params{other.m_params},
0026 m_cov{other.m_cov},
0027 m_referenceSurfaces{other.m_referenceSurfaces},
0028 m_nMeasurements{other.m_nMeasurements},
0029 m_nHoles{other.m_nHoles},
0030 m_chi2{other.m_chi2},
0031 m_ndf{other.m_ndf},
0032 m_nOutliers{other.m_nOutliers},
0033 m_nSharedHits{other.m_nSharedHits} {
0034 for (const auto& [key, value] : other.m_dynamic) {
0035 m_dynamic.insert({key, value->clone()});
0036 }
0037 m_dynamicKeys = other.m_dynamicKeys;
0038 assert(checkConsistency());
0039 }
0040 }
0041
0042 VectorTrackContainer::IndexType VectorTrackContainer::addTrack_impl() {
0043 assert(checkConsistency());
0044
0045 m_tipIndex.emplace_back(kInvalid);
0046 m_stemIndex.emplace_back(kInvalid);
0047
0048 m_particleHypothesis.emplace_back(ParticleHypothesis::pion());
0049 m_params.emplace_back();
0050 m_cov.emplace_back();
0051 m_referenceSurfaces.emplace_back();
0052
0053 m_nMeasurements.emplace_back();
0054 m_nHoles.emplace_back();
0055
0056 m_chi2.emplace_back();
0057 m_ndf.emplace_back();
0058
0059 m_nOutliers.emplace_back();
0060 m_nSharedHits.emplace_back();
0061
0062
0063 for (auto& [key, vec] : m_dynamic) {
0064 vec->add();
0065 }
0066
0067 assert(checkConsistency());
0068
0069 return m_tipIndex.size() - 1;
0070 }
0071
0072 void VectorTrackContainer::removeTrack_impl(IndexType itrack) {
0073 auto erase = [&](auto& vec) {
0074 assert(itrack < vec.size() && "Index is out of range");
0075 auto it = vec.begin();
0076 std::advance(it, itrack);
0077 vec.erase(it);
0078 };
0079
0080 erase(m_tipIndex);
0081 erase(m_stemIndex);
0082
0083 erase(m_particleHypothesis);
0084
0085 erase(m_params);
0086 erase(m_cov);
0087 erase(m_referenceSurfaces);
0088
0089 erase(m_nMeasurements);
0090 erase(m_nHoles);
0091
0092 erase(m_chi2);
0093 erase(m_ndf);
0094
0095 erase(m_nOutliers);
0096 erase(m_nSharedHits);
0097
0098 for (auto& [key, vec] : m_dynamic) {
0099 vec->erase(itrack);
0100 }
0101 }
0102
0103 void VectorTrackContainer::copyDynamicFrom_impl(IndexType dstIdx,
0104 HashedString key,
0105 const std::any& srcPtr) {
0106 auto it = m_dynamic.find(key);
0107 if (it == m_dynamic.end()) {
0108 throw std::invalid_argument{
0109 "Destination container does not have matching dynamic column"};
0110 }
0111
0112 it->second->copyFrom(dstIdx, srcPtr);
0113 }
0114
0115 void VectorTrackContainer::ensureDynamicColumns_impl(
0116 const detail_vtc::VectorTrackContainerBase& other) {
0117 for (auto& [key, value] : other.m_dynamic) {
0118 if (!m_dynamic.contains(key)) {
0119 m_dynamic[key] = value->clone(true);
0120 }
0121 }
0122 }
0123
0124 void VectorTrackContainer::reserve(IndexType size) {
0125 m_tipIndex.reserve(size);
0126 m_stemIndex.reserve(size);
0127
0128 m_particleHypothesis.reserve(size);
0129 m_params.reserve(size);
0130 m_cov.reserve(size);
0131 m_referenceSurfaces.reserve(size);
0132
0133 m_nMeasurements.reserve(size);
0134 m_nHoles.reserve(size);
0135
0136 m_chi2.reserve(size);
0137 m_ndf.reserve(size);
0138
0139 m_nOutliers.reserve(size);
0140 m_nSharedHits.reserve(size);
0141
0142 for (auto& [key, vec] : m_dynamic) {
0143 vec->reserve(size);
0144 }
0145 }
0146
0147 void VectorTrackContainer::clear() {
0148 m_tipIndex.clear();
0149 m_stemIndex.clear();
0150
0151 m_particleHypothesis.clear();
0152 m_params.clear();
0153 m_cov.clear();
0154 m_referenceSurfaces.clear();
0155
0156 m_nMeasurements.clear();
0157 m_nHoles.clear();
0158
0159 m_chi2.clear();
0160 m_ndf.clear();
0161
0162 m_nOutliers.clear();
0163 m_nSharedHits.clear();
0164
0165 for (auto& [key, vec] : m_dynamic) {
0166 vec->clear();
0167 }
0168 }
0169
0170 std::size_t VectorTrackContainer::size() const {
0171 return m_tipIndex.size();
0172 }
0173
0174 }