-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-kf-reverse-navigation
- Loading branch information
Showing
3 changed files
with
97 additions
and
52 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
62 changes: 62 additions & 0 deletions
62
Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXBoostTrackBuildingTests.cpp
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,62 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2022 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/Plugins/ExaTrkX/BoostTrackBuilding.hpp" | ||
#include "Acts/Plugins/ExaTrkX/detail/TensorVectorConversion.hpp" | ||
|
||
#include <algorithm> | ||
|
||
BOOST_AUTO_TEST_CASE(test_track_building) { | ||
// Make some spacepoint IDs | ||
// The spacepoint ids are [100, 101, 102, ...] | ||
// They should not be zero based to check if the thing also works if the | ||
// spacepoint IDs do not match the node IDs used for the edges | ||
std::vector<int> spacepointIds(16); | ||
std::iota(spacepointIds.begin(), spacepointIds.end(), 100); | ||
|
||
// Build 4 tracks with 4 hits | ||
std::vector<std::vector<int>> refTracks; | ||
for (auto t = 0ul; t < 4; ++t) { | ||
refTracks.emplace_back(spacepointIds.begin() + 4 * t, | ||
spacepointIds.begin() + 4 * (t + 1)); | ||
} | ||
|
||
// Make edges | ||
std::vector<int64_t> edges; | ||
for (const auto &track : refTracks) { | ||
for (auto it = track.begin(); it != track.end() - 1; ++it) { | ||
// edges must be 0 based, so subtract 100 again | ||
edges.push_back(*it - 100); | ||
edges.push_back(*std::next(it) - 100); | ||
} | ||
} | ||
|
||
auto edgeTensor = | ||
Acts::detail::vectorToTensor2D(edges, 2).t().contiguous().clone(); | ||
auto dummyWeights = torch::ones(edges.size() / 2, torch::kFloat32); | ||
|
||
// Run Track building | ||
auto logger = Acts::getDefaultLogger("TestLogger", Acts::Logging::ERROR); | ||
Acts::BoostTrackBuilding trackBuilder(std::move(logger)); | ||
|
||
auto testTracks = trackBuilder({}, edgeTensor, dummyWeights, spacepointIds); | ||
|
||
// Sort tracks, so we can find them | ||
std::for_each(testTracks.begin(), testTracks.end(), | ||
[](auto &t) { std::sort(t.begin(), t.end()); }); | ||
std::for_each(refTracks.begin(), refTracks.end(), | ||
[](auto &t) { std::sort(t.begin(), t.end()); }); | ||
|
||
// Check what we have here | ||
for (const auto &refTrack : refTracks) { | ||
auto found = std::find(testTracks.begin(), testTracks.end(), refTrack); | ||
BOOST_CHECK(found != testTracks.end()); | ||
} | ||
} |