Skip to content

Commit

Permalink
runs standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
cvarni authored and cvarni committed Oct 5, 2024
1 parent 32293a7 commit 143518a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 37 deletions.
15 changes: 6 additions & 9 deletions Core/include/Acts/EventData/SpacePointContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ class SpacePointContainer {

using iterator =
ContainerIndexIterator<Acts::SpacePointContainer<container_t, holder_t>,
SpacePointProxyType&, false>;
SpacePointProxyType, false>;
using const_iterator =
ContainerIndexIterator<Acts::SpacePointContainer<container_t, holder_t>,
const SpacePointProxyType&, true>;
const SpacePointProxyType, true>;

using ValueType = typename container_t::ValueType;
using ProxyType = SpacePointProxyType;
Expand Down Expand Up @@ -128,17 +128,15 @@ class SpacePointContainer {
const_iterator begin() const;
const_iterator end() const;

ProxyType& at(const std::size_t n);
const ProxyType& at(const std::size_t n) const;
ProxyType at(const std::size_t n);
ProxyType at(const std::size_t n) const;
const ValueType& sp(const std::size_t n) const;

private:
void initialize();

const container_t& container() const;
const ProxyType& proxy(const std::size_t n) const;
std::vector<ProxyType>& proxies();
const std::vector<ProxyType>& proxies() const;
ProxyType proxy(const std::size_t n) const;

float x(const std::size_t n) const;
float y(const std::size_t n) const;
Expand All @@ -157,7 +155,6 @@ class SpacePointContainer {
Acts::SpacePointContainerOptions m_options;
Acts::SpacePointData m_data;
holder_t<const container_t> m_container;
std::vector<ProxyType> m_proxies;
};

} // namespace Acts
Expand Down
29 changes: 7 additions & 22 deletions Core/include/Acts/EventData/SpacePointContainer.ipp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// -*- C++ -*-
// This file is part of the ACTS project.
//
// Copyright (C) 2016 CERN for the benefit of the ACTS project
Expand Down Expand Up @@ -36,7 +37,6 @@ SpacePointContainer<container_t, holder_t>::SpacePointContainer(
template <typename container_t, template <typename> class holder_t>
void SpacePointContainer<container_t, holder_t>::initialize() {
m_data.resize(size(), m_config.useDetailedDoubleMeasurementInfo);
m_proxies.reserve(size());
const auto& external_container = container();
for (std::size_t i(0); i < size(); ++i) {
m_data.setX(i, external_container.x_impl(i) - m_options.beamPos[0]);
Expand All @@ -47,8 +47,6 @@ void SpacePointContainer<container_t, holder_t>::initialize() {
m_data.setPhi(i, atan2f(m_data.y(i), m_data.x(i)));
m_data.setVarianceR(i, external_container.varianceR_impl(i));
m_data.setVarianceZ(i, external_container.varianceZ_impl(i));

m_proxies.emplace_back(*this, i);
}

// Dynamic variables
Expand Down Expand Up @@ -146,15 +144,15 @@ const container_t& SpacePointContainer<container_t, holder_t>::container()
}

template <typename container_t, template <typename> class holder_t>
typename SpacePointContainer<container_t, holder_t>::ProxyType&
typename SpacePointContainer<container_t, holder_t>::ProxyType
SpacePointContainer<container_t, holder_t>::at(const std::size_t n) {
return proxies().at(n);
return ProxyType(*this, n);
}

template <typename container_t, template <typename> class holder_t>
const typename SpacePointContainer<container_t, holder_t>::ProxyType&
typename SpacePointContainer<container_t, holder_t>::ProxyType
SpacePointContainer<container_t, holder_t>::at(const std::size_t n) const {
return proxies().at(n);
return ProxyType(*this, n);
}

template <typename container_t, template <typename> class holder_t>
Expand Down Expand Up @@ -203,23 +201,10 @@ float SpacePointContainer<container_t, holder_t>::varianceZ(
}

template <typename container_t, template <typename> class holder_t>
const typename SpacePointContainer<container_t, holder_t>::ProxyType&
typename SpacePointContainer<container_t, holder_t>::ProxyType
SpacePointContainer<container_t, holder_t>::proxy(const std::size_t n) const {
assert(n < proxies().size());
return proxies()[n];
}

template <typename container_t, template <typename> class holder_t>
std::vector<typename SpacePointContainer<container_t, holder_t>::ProxyType>&
SpacePointContainer<container_t, holder_t>::proxies() {
return m_proxies;
}

template <typename container_t, template <typename> class holder_t>
const std::vector<
typename SpacePointContainer<container_t, holder_t>::ProxyType>&
SpacePointContainer<container_t, holder_t>::proxies() const {
return m_proxies;
return {this, n};
}

} // namespace Acts
4 changes: 2 additions & 2 deletions Core/include/Acts/Utilities/Iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class ContainerIndexIterator {
using container_type =
std::conditional_t<Const, const _Container, _Container>;
using difference_type = std::ptrdiff_t;
using pointer = std::remove_reference_t<value_type>*;
using reference = std::remove_reference_t<value_type>&;
using pointer = value_type*;
using reference = value_type&;

ContainerIndexIterator() : m_container(nullptr), m_index(0) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ BOOST_AUTO_TEST_CASE(spacepoint_container_edm_traits) {
using container_t =
Acts::SpacePointContainer<adapter_t, Acts::detail::RefHolder>;
using proxy_t = Acts::SpacePointProxy<container_t>;
using iterator_t = Acts::ContainerIndexIterator<container_t, proxy_t&, false>;
using iterator_t = Acts::ContainerIndexIterator<container_t, proxy_t, false>;

static_assert(std::ranges::sized_range<container_t>);
static_assert(std::ranges::random_access_range<container_t>);
static_assert(std::same_as<typename iterator_t::iterator_category,
std::random_access_iterator_tag>);
static_assert(
Expand Down Expand Up @@ -148,9 +148,9 @@ BOOST_AUTO_TEST_CASE(spacepoint_container_edm_functionalities) {
std::same_as<typename proxy_t::ValueType, Acts::Test::SpacePoint>);

using iterator_t =
Acts::ContainerIndexIterator<decltype(spContainer), proxy_t&, false>;
Acts::ContainerIndexIterator<decltype(spContainer), proxy_t, false>;
using const_iterator_t =
Acts::ContainerIndexIterator<decltype(spContainer), const proxy_t&, true>;
Acts::ContainerIndexIterator<decltype(spContainer), const proxy_t, true>;
static_assert(
std::same_as<iterator_t, typename decltype(spContainer)::iterator>);
static_assert(std::same_as<const_iterator_t,
Expand Down

0 comments on commit 143518a

Please sign in to comment.