File indexing completed on 2025-01-18 09:13:09
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Plugins/ExaTrkX/BoostTrackBuilding.hpp"
0012 #include "Acts/Plugins/ExaTrkX/detail/TensorVectorConversion.hpp"
0013 #include "Acts/Utilities/Helpers.hpp"
0014
0015 #include <algorithm>
0016
0017 BOOST_AUTO_TEST_CASE(test_track_building) {
0018
0019
0020
0021
0022 std::vector<int> spacepointIds(16);
0023 std::iota(spacepointIds.begin(), spacepointIds.end(), 100);
0024
0025
0026 std::vector<std::vector<int>> refTracks;
0027 for (auto t = 0ul; t < 4; ++t) {
0028 refTracks.emplace_back(spacepointIds.begin() + 4 * t,
0029 spacepointIds.begin() + 4 * (t + 1));
0030 }
0031
0032
0033 std::vector<std::int64_t> edges;
0034 for (const auto &track : refTracks) {
0035 for (auto it = track.begin(); it != track.end() - 1; ++it) {
0036
0037 edges.push_back(*it - 100);
0038 edges.push_back(*std::next(it) - 100);
0039 }
0040 }
0041
0042 auto edgeTensor =
0043 Acts::detail::vectorToTensor2D(edges, 2).t().contiguous().clone();
0044 auto dummyWeights = torch::ones(edges.size() / 2, torch::kFloat32);
0045
0046
0047 auto logger = Acts::getDefaultLogger("TestLogger", Acts::Logging::ERROR);
0048 Acts::BoostTrackBuilding trackBuilder(std::move(logger));
0049
0050 auto testTracks = trackBuilder({}, edgeTensor, dummyWeights, spacepointIds);
0051
0052
0053 std::for_each(testTracks.begin(), testTracks.end(),
0054 [](auto &t) { std::ranges::sort(t); });
0055 std::for_each(refTracks.begin(), refTracks.end(),
0056 [](auto &t) { std::ranges::sort(t); });
0057
0058
0059 for (const auto &refTrack : refTracks) {
0060 BOOST_CHECK(Acts::rangeContainsValue(testTracks, refTrack));
0061 }
0062 }