9 #include <boost/test/unit_test.hpp>
62 #include <system_error>
63 #include <unordered_map>
73 using namespace Acts::Test;
74 using namespace Acts::UnitLiterals;
80 size_t numMeasurements = 6
u;
84 std::shared_ptr<const Acts::TrackingGeometry>
geometry;
103 template <
typename container_t>
104 struct TestContainerAccessor {
106 using Key =
typename container_t::key_type;
107 using Value =
typename container_t::mapped_type;
112 using BaseIterator =
typename container_t::const_iterator;
114 using iterator_category =
typename BaseIterator::iterator_category;
116 using difference_type =
typename BaseIterator::difference_type;
117 using pointer =
typename BaseIterator::pointer;
118 using reference =
typename BaseIterator::reference;
120 Iterator& operator++() {
125 bool operator==(
const Iterator& other)
const {
126 return m_iterator == other.m_iterator;
129 bool operator!=(
const Iterator& other)
const {
return !(*
this == other); }
132 const auto& sl = m_iterator->second;
136 BaseIterator m_iterator;
146 return {Iterator{
begin}, Iterator{
end}};
161 using CombinatorialKalmanFilter =
163 using TestSourceLinkContainer =
164 std::unordered_multimap<Acts::GeometryIdentifier, TestSourceLink>;
165 using TestSourceLinkAccessor = TestContainerAccessor<TestSourceLinkContainer>;
166 using CombinatorialKalmanFilterOptions =
170 KalmanUpdater kfUpdater;
171 KalmanSmoother kfSmoother;
180 std::vector<Acts::CurvilinearTrackParameters> startParameters;
181 std::vector<Acts::CurvilinearTrackParameters> endParameters;
184 TestSourceLinkContainer sourceLinks;
187 CombinatorialKalmanFilter ckf;
192 {{}, {std::numeric_limits<double>::max()}, {1
u}}},
200 .template connect<&testSourceLinkCalibrator<Trajectory>>();
201 extensions.
updater.template connect<&KalmanUpdater::operator()<Trajectory>>(
204 .template connect<&KalmanSmoother::operator()<Trajectory>>(&kfSmoother);
206 .template connect<&Acts::MeasurementSelector::select<Trajectory>>(
211 std::unique_ptr<const Acts::Logger>
logger;
233 {mStartPos0, 0_degree, 90_degree, 1_e / 1_GeV,
cov,
pion},
234 {mStartPos1, -1_degree, 91_degree, 1_e / 1_GeV,
cov,
pion},
235 {mStartPos2, 1_degree, 89_degree, -1_e / 1_GeV,
cov,
pion},
241 {mEndPos0, 0_degree, 90_degree, 1_e / 1_GeV, cov * 100,
pion},
242 {mEndPos1, -1_degree, 91_degree, 1_e / 1_GeV, cov * 100,
pion},
243 {mEndPos2, 1_degree, 89_degree, -1_e / 1_GeV, cov * 100,
pion},
248 std::default_random_engine
rng(421235);
249 for (
size_t trackId = 0
u; trackId < startParameters.size(); ++trackId) {
253 for (
auto& sl : measurements.sourceLinks) {
254 sourceLinks.emplace(sl.m_geometryId,
std::move(sl));
261 std::shared_ptr<const Acts::TrackingGeometry> geo) {
263 cfg.resolvePassive =
false;
264 cfg.resolveMaterial =
true;
265 cfg.resolveSensitive =
true;
273 std::shared_ptr<const Acts::TrackingGeometry> geo,
double bz) {
275 cfg.resolvePassive =
false;
276 cfg.resolveMaterial =
true;
277 cfg.resolveSensitive =
true;
280 std::make_shared<Acts::ConstantBField>(
Acts::Vector3(0.0, 0.0, bz));
285 CombinatorialKalmanFilterOptions makeCkfOptions()
const {
286 return CombinatorialKalmanFilterOptions(
289 TestSourceLinkAccessor::Iterator>{},
298 BOOST_AUTO_TEST_SUITE(TrackFindingCombinatorialKalmanFilter)
303 auto options = f.makeCkfOptions();
307 auto pSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(
312 Fixture::TestSourceLinkAccessor slAccessor;
313 slAccessor.container = &f.sourceLinks;
314 options.sourcelinkAccessor.connect<&Fixture::TestSourceLinkAccessor::range>(
321 for (
size_t trackId = 0
u; trackId < f.startParameters.size(); ++trackId) {
322 auto res = f.ckf.findTracks(f.startParameters.at(trackId),
options,
tc);
324 BOOST_TEST_INFO(res.error() <<
" " << res.error().message());
326 BOOST_REQUIRE(res.ok());
330 BOOST_CHECK_EQUAL(
tc.size(), 3
u);
333 for (
size_t trackId = 0
u; trackId < f.startParameters.size(); ++trackId) {
334 const auto track =
tc.getTrack(trackId);
335 const auto& params = f.startParameters[trackId];
336 BOOST_TEST_INFO(
"initial parameters before detector:\n" << params);
338 BOOST_CHECK_EQUAL(track.nTrackStates(), f.detector.numMeasurements);
343 size_t nummismatchedHits = 0
u;
344 for (
const auto trackState : track.trackStatesReversed()) {
347 trackState.getUncalibratedSourceLink().template get<TestSourceLink>();
348 if (trackId != sl.sourceId) {
353 BOOST_CHECK_EQUAL(numHits, f.detector.numMeasurements);
354 BOOST_CHECK_EQUAL(nummismatchedHits, 0
u);
361 auto options = f.makeCkfOptions();
364 auto pSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(
369 Fixture::TestSourceLinkAccessor slAccessor;
370 slAccessor.container = &f.sourceLinks;
371 options.sourcelinkAccessor.connect<&Fixture::TestSourceLinkAccessor::range>(
378 for (
size_t trackId = 0
u; trackId < f.startParameters.size(); ++trackId) {
379 auto res = f.ckf.findTracks(f.endParameters.at(trackId),
options,
tc);
381 BOOST_TEST_INFO(res.error() <<
" " << res.error().message());
383 BOOST_REQUIRE(res.ok());
386 BOOST_CHECK_EQUAL(
tc.size(), 3
u);
389 for (
size_t trackId = 0
u; trackId < f.endParameters.size(); ++trackId) {
390 const auto track =
tc.getTrack(trackId);
391 const auto& params = f.endParameters[trackId];
392 BOOST_TEST_INFO(
"initial parameters after detector:\n" << params);
394 BOOST_CHECK_EQUAL(track.nTrackStates(), f.detector.numMeasurements);
399 size_t nummismatchedHits = 0
u;
400 for (
const auto trackState : track.trackStatesReversed()) {
403 trackState.getUncalibratedSourceLink().template get<TestSourceLink>();
404 if (trackId != sl.sourceId) {
409 BOOST_CHECK_EQUAL(numHits, f.detector.numMeasurements);
410 BOOST_CHECK_EQUAL(nummismatchedHits, 0
u);
414 BOOST_AUTO_TEST_SUITE_END()