-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enable removing tracks from container (#1870)
This also moves some method definitions to a cpp file for VectorTrackContainer, and adds the ability to copy a const track vector container to a mutable one (for modification).
- Loading branch information
1 parent
2c2c0fc
commit bcc917d
Showing
5 changed files
with
138 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2023 CERN for the benefit of the Acts project | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#include "Acts/EventData/VectorTrackContainer.hpp" | ||
|
||
namespace Acts { | ||
|
||
namespace detail_vtc { | ||
|
||
VectorTrackContainerBase::VectorTrackContainerBase( | ||
const VectorTrackContainerBase& other) | ||
: m_tipIndex{other.m_tipIndex}, | ||
m_params{other.m_params}, | ||
m_cov{other.m_cov}, | ||
m_referenceSurfaces{other.m_referenceSurfaces}, | ||
m_nMeasurements{other.m_nMeasurements}, | ||
m_nHoles{other.m_nHoles} { | ||
for (const auto& [key, value] : other.m_dynamic) { | ||
m_dynamic.insert({key, value->clone()}); | ||
} | ||
|
||
assert(checkConsistency()); | ||
} | ||
} // namespace detail_vtc | ||
|
||
VectorTrackContainer::IndexType VectorTrackContainer::addTrack_impl() { | ||
assert(checkConsistency()); | ||
|
||
m_tipIndex.emplace_back(); | ||
|
||
m_params.emplace_back(); | ||
m_cov.emplace_back(); | ||
m_referenceSurfaces.emplace_back(); | ||
|
||
m_nMeasurements.emplace_back(); | ||
m_nHoles.emplace_back(); | ||
|
||
// dynamic columns | ||
for (auto& [key, vec] : m_dynamic) { | ||
vec->add(); | ||
} | ||
|
||
assert(checkConsistency()); | ||
|
||
return m_tipIndex.size() - 1; | ||
} | ||
|
||
void VectorTrackContainer::removeTrack_impl(IndexType itrack) { | ||
auto erase = [&](auto& vec) { | ||
assert(itrack < vec.size() && "Index is out of range"); | ||
auto it = vec.begin(); | ||
std::advance(it, itrack); | ||
vec.erase(it); | ||
}; | ||
|
||
erase(m_tipIndex); | ||
|
||
erase(m_params); | ||
erase(m_cov); | ||
erase(m_referenceSurfaces); | ||
|
||
erase(m_nMeasurements); | ||
erase(m_nHoles); | ||
|
||
for (auto& [key, vec] : m_dynamic) { | ||
vec->erase(itrack); | ||
} | ||
} | ||
|
||
} // namespace Acts |