Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-11 07:38:35

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/EventData/SeedColumns.hpp"
0012 #include "Acts/EventData/SeedContainer.hpp"
0013 
0014 using namespace Acts;
0015 
0016 namespace ActsTests {
0017 
0018 BOOST_AUTO_TEST_SUITE(EventDataSuite)
0019 
0020 BOOST_AUTO_TEST_CASE(Empty) {
0021   SeedContainer container;
0022 
0023   BOOST_CHECK(container.empty());
0024   BOOST_CHECK_EQUAL(container.size(), 0u);
0025 
0026   for ([[maybe_unused]] auto _ : container) {
0027     BOOST_FAIL("Container should be empty, no space points should be iterated");
0028   }
0029 }
0030 
0031 BOOST_AUTO_TEST_CASE(Create) {
0032   SeedContainer container;
0033   container.reserve(1);
0034 
0035   {
0036     auto seed = container.createSeed();
0037     seed.assignSpacePointIndices(std::array<SpacePointIndex, 3>{0, 1, 2});
0038     seed.quality() = 1.0f;
0039     seed.vertexZ() = 3.0f;
0040   }
0041 
0042   BOOST_CHECK(!container.empty());
0043   BOOST_CHECK_EQUAL(container.size(), 1u);
0044 
0045   auto seed = container.at(0);
0046   BOOST_CHECK_EQUAL(seed.size(), 3u);
0047   BOOST_CHECK_EQUAL(seed.spacePointIndices()[0], 0u);
0048   BOOST_CHECK_EQUAL(seed.spacePointIndices()[1], 1u);
0049   BOOST_CHECK_EQUAL(seed.spacePointIndices()[2], 2u);
0050   BOOST_CHECK_EQUAL(seed.quality(), 1.0f);
0051   BOOST_CHECK_EQUAL(seed.vertexZ(), 3.0f);
0052 }
0053 
0054 BOOST_AUTO_TEST_CASE(Iterate) {
0055   SeedContainer container;
0056   container.reserve(1);
0057 
0058   {
0059     auto seed = container.createSeed();
0060     seed.assignSpacePointIndices(std::array<SpacePointIndex, 3>{0, 1, 2});
0061     seed.quality() = 1.0f;
0062     seed.vertexZ() = 3.0f;
0063   }
0064 
0065   auto it = container.begin();
0066   BOOST_CHECK(it != container.end());
0067   BOOST_CHECK_EQUAL((*it).quality(), 1.0f);
0068   ++it;
0069   BOOST_CHECK(it == container.end());
0070 }
0071 
0072 BOOST_AUTO_TEST_CASE(CopyAndMove) {
0073   SeedContainer container;
0074   container.reserve(1);
0075 
0076   {
0077     auto seed = container.createSeed();
0078     seed.assignSpacePointIndices(std::array<SpacePointIndex, 3>{0, 1, 2});
0079     seed.quality() = 1.0f;
0080     seed.vertexZ() = 3.0f;
0081   }
0082 
0083   SeedContainer containerCopy = container;
0084   BOOST_CHECK(!containerCopy.empty());
0085   BOOST_CHECK_EQUAL(containerCopy.size(), 1u);
0086 
0087   SeedContainer containerMove = std::move(container);
0088   BOOST_CHECK(!containerMove.empty());
0089   BOOST_CHECK_EQUAL(containerMove.size(), 1u);
0090   // copy should be unchanged
0091   BOOST_CHECK(!containerCopy.empty());
0092   BOOST_CHECK_EQUAL(containerCopy.size(), 1u);
0093 }
0094 
0095 BOOST_AUTO_TEST_CASE(Clear) {
0096   SeedContainer container;
0097   container.reserve(1);
0098 
0099   {
0100     auto seed = container.createSeed();
0101     seed.assignSpacePointIndices(std::array<SpacePointIndex, 3>{0, 1, 2});
0102     seed.quality() = 1.0f;
0103     seed.vertexZ() = 3.0f;
0104   }
0105 
0106   container.clear();
0107 
0108   BOOST_CHECK(container.empty());
0109   BOOST_CHECK_EQUAL(container.size(), 0u);
0110   for ([[maybe_unused]] auto _ : container) {
0111     BOOST_FAIL("Container should be empty, no space points should be iterated");
0112   }
0113 }
0114 
0115 BOOST_AUTO_TEST_CASE(CopyFrom) {
0116   SeedContainer container;
0117   container.reserve(1);
0118 
0119   {
0120     auto seed = container.createSeed();
0121     seed.assignSpacePointIndices(std::array<SpacePointIndex, 3>{0, 1, 2});
0122     seed.quality() = 1.0f;
0123     seed.vertexZ() = 3.0f;
0124   }
0125 
0126   {
0127     SeedContainer copyTo;
0128     MutableSeedProxy seed = copyTo.createSeed();
0129     seed.copyFrom(container.at(0), SeedColumns::SpacePointIndices |
0130                                        SeedColumns::Quality |
0131                                        SeedColumns::VertexZ);
0132 
0133     BOOST_CHECK_EQUAL(seed.spacePointIndices()[0], 0u);
0134     BOOST_CHECK_EQUAL(seed.spacePointIndices()[1], 1u);
0135     BOOST_CHECK_EQUAL(seed.spacePointIndices()[2], 2u);
0136     BOOST_CHECK_EQUAL(seed.quality(), 1.0f);
0137     BOOST_CHECK_EQUAL(seed.vertexZ(), 3.0f);
0138   }
0139 
0140   {
0141     SeedContainer copyTo;
0142     MutableSeedProxy seed = copyTo.createSeed();
0143     seed.copyFrom(container.at(0),
0144                   SeedColumns::SpacePointIndices | SeedColumns::Quality);
0145 
0146     BOOST_CHECK_EQUAL(seed.spacePointIndices()[0], 0u);
0147     BOOST_CHECK_EQUAL(seed.spacePointIndices()[1], 1u);
0148     BOOST_CHECK_EQUAL(seed.spacePointIndices()[2], 2u);
0149     BOOST_CHECK_EQUAL(seed.quality(), 1.0f);
0150     BOOST_CHECK_EQUAL(seed.vertexZ(), 0.0f);  // default value since not copied
0151   }
0152 }
0153 
0154 BOOST_AUTO_TEST_SUITE_END()
0155 
0156 }  // namespace ActsTests