Skip to content

Commit

Permalink
Merge branch 'main' into feat-enable-geant4-propagation-xcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
asalzburger authored Sep 30, 2024
2 parents 8adcac1 + a45d452 commit 0d8ebe5
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 22 deletions.
16 changes: 11 additions & 5 deletions Core/include/Acts/EventData/Seed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,27 @@

namespace Acts {

template <typename external_spacepoint_t>
template <typename external_spacepoint_t, std::size_t N = 3ul>
requires(N >= 3)
class Seed {
public:
Seed(const external_spacepoint_t& b, const external_spacepoint_t& m,
const external_spacepoint_t& u);
using value_type = external_spacepoint_t;
static constexpr std::size_t DIM = N;

template <typename... args_t>
requires(sizeof...(args_t) == N) &&
(std::same_as<external_spacepoint_t, args_t> && ...)
explicit Seed(const args_t&... points);

void setVertexZ(float vertex);
void setQuality(float seedQuality);

const std::array<const external_spacepoint_t*, 3>& sp() const;
const std::array<const external_spacepoint_t*, N>& sp() const;
float z() const;
float seedQuality() const;

private:
std::array<const external_spacepoint_t*, 3> m_spacepoints;
std::array<const external_spacepoint_t*, N> m_spacepoints{};
float m_vertexZ{0.f};
float m_seedQuality{-std::numeric_limits<float>::infinity()};
};
Expand Down
41 changes: 24 additions & 17 deletions Core/include/Acts/EventData/Seed.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,42 @@

namespace Acts {

template <typename external_spacepoint_t>
Seed<external_spacepoint_t>::Seed(const external_spacepoint_t& b,
const external_spacepoint_t& m,
const external_spacepoint_t& u)
: m_spacepoints({&b, &m, &u}) {}

template <typename external_spacepoint_t>
void Seed<external_spacepoint_t>::setVertexZ(float vertex) {
template <typename external_spacepoint_t, std::size_t N>
requires(N >= 3)
template <typename... args_t>
requires(sizeof...(args_t) == N) &&
(std::same_as<external_spacepoint_t, args_t> && ...)
Seed<external_spacepoint_t, N>::Seed(const args_t&... points)
: m_spacepoints({&points...}) {}

template <typename external_spacepoint_t, std::size_t N>
requires(N >= 3)
void Seed<external_spacepoint_t, N>::setVertexZ(float vertex) {
m_vertexZ = vertex;
}

template <typename external_spacepoint_t>
void Seed<external_spacepoint_t>::setQuality(float seedQuality) {
template <typename external_spacepoint_t, std::size_t N>
requires(N >= 3)
void Seed<external_spacepoint_t, N>::setQuality(float seedQuality) {
m_seedQuality = seedQuality;
}

template <typename external_spacepoint_t>
const std::array<const external_spacepoint_t*, 3>&
Seed<external_spacepoint_t>::sp() const {
template <typename external_spacepoint_t, std::size_t N>
requires(N >= 3)
const std::array<const external_spacepoint_t*, N>&
Seed<external_spacepoint_t, N>::sp() const {
return m_spacepoints;
}

template <typename external_spacepoint_t>
float Seed<external_spacepoint_t>::z() const {
template <typename external_spacepoint_t, std::size_t N>
requires(N >= 3)
float Seed<external_spacepoint_t, N>::z() const {
return m_vertexZ;
}

template <typename external_spacepoint_t>
float Seed<external_spacepoint_t>::seedQuality() const {
template <typename external_spacepoint_t, std::size_t N>
requires(N >= 3)
float Seed<external_spacepoint_t, N>::seedQuality() const {
return m_seedQuality;
}

Expand Down
1 change: 1 addition & 0 deletions Tests/UnitTests/Core/EventData/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ add_unittest(TrackStatePropMask TrackStatePropMaskTests.cpp)
add_unittest(ParticleHypothesis ParticleHypothesisTests.cpp)
add_unittest(MultiTrajectoryHelpers MultiTrajectoryHelpersTests.cpp)
add_unittest(SubspaceHelpers SubspaceHelpersTests.cpp)
add_unittest(SeedEdm SeedEdmTests.cpp)

add_non_compile_test(MultiTrajectory TrackContainerComplianceTests.cpp)
105 changes: 105 additions & 0 deletions Tests/UnitTests/Core/EventData/SeedEdmTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// This file is part of the Acts project.
//
// Copyright (C) 2024 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 <boost/test/unit_test.hpp>

#include "Acts/EventData/Seed.hpp"

#include <vector>

namespace Acts::Test {

struct SpacePoint {};

BOOST_AUTO_TEST_CASE(seed_edm_constructors) {
std::array<Acts::Test::SpacePoint, 5> storage{};
Acts::Seed<Acts::Test::SpacePoint, 5> seed(storage[0], storage[1], storage[2],
storage[3], storage[4]);
const std::array<const Acts::Test::SpacePoint*, 5>& sps = seed.sp();
for (std::size_t i(0ul); i < 5ul; ++i) {
BOOST_CHECK_NE(sps[i], nullptr);
BOOST_CHECK_EQUAL(sps[i], &storage[i]);
}

// Copy 1
Acts::Seed<Acts::Test::SpacePoint, 5> seedCopy1(seed);
const std::array<const Acts::Test::SpacePoint*, 5>& spsCopy1 = seedCopy1.sp();
for (std::size_t i(0ul); i < 5ul; ++i) {
BOOST_CHECK_NE(spsCopy1[i], nullptr);
BOOST_CHECK_EQUAL(spsCopy1[i], sps[i]);
}

// Copy 2
Acts::Seed<Acts::Test::SpacePoint, 5> seedCopy2{seed};
const std::array<const Acts::Test::SpacePoint*, 5>& spsCopy2 = seedCopy2.sp();
for (std::size_t i(0ul); i < 5ul; ++i) {
BOOST_CHECK_NE(spsCopy2[i], nullptr);
BOOST_CHECK_EQUAL(spsCopy2[i], sps[i]);
}

// Collection
std::vector<Acts::Seed<Acts::Test::SpacePoint, 5>> seeds{seed};
// Copy 1
std::vector<Acts::Seed<Acts::Test::SpacePoint, 5>> seedsCopy1(seeds);
BOOST_CHECK_EQUAL(seedsCopy1.size(), seeds.size());
// Copy 2
std::vector<Acts::Seed<Acts::Test::SpacePoint, 5>> seedsCopy2{seeds};
BOOST_CHECK_EQUAL(seedsCopy2.size(), seeds.size());
}

BOOST_AUTO_TEST_CASE(seed_edm_default) {
std::array<Acts::Test::SpacePoint, 3> storage{};
Acts::Seed<Acts::Test::SpacePoint> seed(storage[0], storage[1], storage[2]);
const std::array<const Acts::Test::SpacePoint*, 3>& sps = seed.sp();
for (std::size_t i(0ul); i < 3ul; ++i) {
BOOST_CHECK_NE(sps[i], nullptr);
BOOST_CHECK_EQUAL(sps[i], &storage[i]);
}

seed.setVertexZ(-1.2f);
BOOST_CHECK_EQUAL(seed.z(), -1.2f);

seed.setQuality(345.23f);
BOOST_CHECK_EQUAL(seed.seedQuality(), 345.23f);
}

BOOST_AUTO_TEST_CASE(seed_edm_3d) {
std::array<Acts::Test::SpacePoint, 3> storage{};
Acts::Seed<Acts::Test::SpacePoint, 3> seed(storage[0], storage[1],
storage[2]);
const std::array<const Acts::Test::SpacePoint*, 3>& sps = seed.sp();
for (std::size_t i(0ul); i < 3ul; ++i) {
BOOST_CHECK_NE(sps[i], nullptr);
BOOST_CHECK_EQUAL(sps[i], &storage[i]);
}

seed.setVertexZ(-1.2f);
BOOST_CHECK_EQUAL(seed.z(), -1.2f);

seed.setQuality(345.23f);
BOOST_CHECK_EQUAL(seed.seedQuality(), 345.23f);
}

BOOST_AUTO_TEST_CASE(seed_edm_4d) {
std::array<Acts::Test::SpacePoint, 4> storage{};
Acts::Seed<Acts::Test::SpacePoint, 4> seed(storage[0], storage[1], storage[2],
storage[3]);
const std::array<const Acts::Test::SpacePoint*, 4>& sps = seed.sp();
for (std::size_t i(0ul); i < 4ul; ++i) {
BOOST_CHECK_NE(sps[i], nullptr);
BOOST_CHECK_EQUAL(sps[i], &storage[i]);
}

seed.setVertexZ(-1.2f);
BOOST_CHECK_EQUAL(seed.z(), -1.2f);

seed.setQuality(345.23f);
BOOST_CHECK_EQUAL(seed.seedQuality(), 345.23f);
}

} // namespace Acts::Test

0 comments on commit 0d8ebe5

Please sign in to comment.