Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:25:17

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/Utilities/Grid.hpp"
0012 #include "Acts/Utilities/GridBinFinder.hpp"
0013 #include "Acts/Utilities/GridIterator.hpp"
0014 
0015 #include <array>
0016 #include <utility>
0017 #include <vector>
0018 
0019 using namespace Acts;
0020 
0021 namespace ActsTests {
0022 
0023 BOOST_AUTO_TEST_SUITE(UtilitiesSuite)
0024 
0025 BOOST_AUTO_TEST_CASE(grid_binfinder_boundTypes) {
0026   const std::size_t nBins = 10ul;
0027   GridBinFinder<1ul> binFinder(1);
0028 
0029   // take a look at the boundaries of the axes
0030   std::array<std::size_t, 1ul> lowerBound({1ul});
0031   std::array<std::size_t, 1ul> upperBound({10ul});
0032 
0033   // For Closed Boundary: out-of-bounds lookups wrap-around to the other side of
0034   // the axis.
0035   Axis xAxisClosed(AxisClosed, 0, 100, nBins);
0036   Grid gridClosed(Type<double>, std::move(xAxisClosed));
0037 
0038   auto lowerClosedNeighbours = binFinder.findBins(lowerBound, gridClosed);
0039   BOOST_CHECK_EQUAL(lowerClosedNeighbours.size(), 3ul);
0040   BOOST_CHECK_EQUAL(lowerClosedNeighbours[0ul], 10ul);
0041   BOOST_CHECK_EQUAL(lowerClosedNeighbours[1ul], 1ul);
0042   BOOST_CHECK_EQUAL(lowerClosedNeighbours[2ul], 2ul);
0043 
0044   auto upperClosedNeighbours = binFinder.findBins(upperBound, gridClosed);
0045   BOOST_CHECK_EQUAL(upperClosedNeighbours.size(), 3ul);
0046   BOOST_CHECK_EQUAL(upperClosedNeighbours[0ul], 9ul);
0047   BOOST_CHECK_EQUAL(upperClosedNeighbours[1ul], 10ul);
0048   BOOST_CHECK_EQUAL(upperClosedNeighbours[2ul], 1ul);
0049 
0050   // For Open Boundary [default]: out-of-bounds lookups resolve to dedicated
0051   // underflow and overflow bins.
0052   Axis xAxisOpen(AxisOpen, 0, 100, nBins);
0053   Grid gridOpen(Type<double>, std::move(xAxisOpen));
0054 
0055   auto lowerOpenNeighbours = binFinder.findBins(lowerBound, gridOpen);
0056   BOOST_CHECK_EQUAL(lowerOpenNeighbours.size(), 3ul);
0057   BOOST_CHECK_EQUAL(lowerOpenNeighbours[0ul], 0ul);
0058   BOOST_CHECK_EQUAL(lowerOpenNeighbours[1ul], 1ul);
0059   BOOST_CHECK_EQUAL(lowerOpenNeighbours[2ul], 2ul);
0060 
0061   auto upperOpenNeighbours = binFinder.findBins(upperBound, gridOpen);
0062   BOOST_CHECK_EQUAL(upperOpenNeighbours.size(), 3ul);
0063   BOOST_CHECK_EQUAL(upperOpenNeighbours[0ul], 9ul);
0064   BOOST_CHECK_EQUAL(upperOpenNeighbours[1ul], 10ul);
0065   BOOST_CHECK_EQUAL(upperOpenNeighbours[2ul], 11ul);
0066 
0067   // For Bound Boundary: out-of-bounds lookups resolve to the closest valid bin.
0068   Axis xAxisBound(AxisBound, 0, 100, nBins);
0069   Grid gridBound(Type<double>, std::move(xAxisBound));
0070 
0071   auto lowerBoundNeighbours = binFinder.findBins(lowerBound, gridBound);
0072   BOOST_CHECK_EQUAL(lowerBoundNeighbours.size(), 2ul);
0073   BOOST_CHECK_EQUAL(lowerBoundNeighbours[0ul], 1ul);
0074   BOOST_CHECK_EQUAL(lowerBoundNeighbours[1ul], 2ul);
0075 
0076   auto upperBoundNeighbours = binFinder.findBins(upperBound, gridBound);
0077   BOOST_CHECK_EQUAL(upperBoundNeighbours.size(), 2ul);
0078   BOOST_CHECK_EQUAL(upperBoundNeighbours[0ul], 9ul);
0079   BOOST_CHECK_EQUAL(upperBoundNeighbours[1ul], 10ul);
0080 }
0081 
0082 BOOST_AUTO_TEST_CASE(grid_binfinder_constructor) {
0083   using list_t = std::vector<std::pair<int, int>>;
0084   GridBinFinder<1ul> binFinder_1d_1(1);
0085   GridBinFinder<1ul> binFinder_1d_2(list_t({}));
0086   GridBinFinder<1ul> binFinder_1d_3(list_t({{0, 2}, {-1, 1}}));
0087   GridBinFinder<1ul> binFinder_1d_4(std::make_pair(1, 1));
0088 
0089   GridBinFinder<2ul> binFinder_2d_1(1, 5);
0090   GridBinFinder<2ul> binFinder_2d_2(list_t({}), list_t({{0, 2}, {-1, 1}}));
0091   GridBinFinder<2ul> binFinder_2d_3(list_t({}), 2);
0092   GridBinFinder<2ul> binFinder_2d_4(std::make_pair(1, 2), 2);
0093 
0094   GridBinFinder<3ul> binFinder_3d_1(1, 1, 5);
0095 
0096   GridBinFinder<10ul> binFinder_10d_1(1, 1, 5, 0, 4, 2, 3, 1, 1, 9);
0097 }
0098 
0099 BOOST_AUTO_TEST_CASE(grid_binfinder_test_1d_ints) {
0100   const std::size_t nBins = 10ul;
0101   Axis xAxis(0, 100, nBins);
0102   Grid grid(Type<double>, std::move(xAxis));
0103 
0104   std::array<std::size_t, 1ul> locPosition({3ul});
0105 
0106   GridBinFinder<1ul> binFinder_1(1);
0107   auto neighbours_1 = binFinder_1.findBins(locPosition, grid);
0108   BOOST_CHECK_EQUAL(neighbours_1.size(), 3ul);
0109 
0110   for (const std::size_t neighbour : neighbours_1) {
0111     std::array<std::size_t, 1ul> neighboutLocPosition =
0112         grid.localBinsFromGlobalBin(neighbour);
0113     std::size_t distance = locPosition[0ul] <= neighboutLocPosition[0ul]
0114                                ? neighboutLocPosition[0ul] - locPosition[0ul]
0115                                : locPosition[0ul] - neighboutLocPosition[0ul];
0116     BOOST_CHECK(distance <= 1ul);
0117   }
0118 
0119   GridBinFinder<1ul> binFinder_2(2);
0120   auto neighbours_2 = binFinder_2.findBins(locPosition, grid);
0121   BOOST_CHECK_EQUAL(neighbours_2.size(), 5ul);
0122 
0123   for (const std::size_t neighbour : neighbours_2) {
0124     std::array<std::size_t, 1ul> neighboutLocPosition =
0125         grid.localBinsFromGlobalBin(neighbour);
0126     std::size_t distance = locPosition[0ul] <= neighboutLocPosition[0ul]
0127                                ? neighboutLocPosition[0ul] - locPosition[0ul]
0128                                : locPosition[0ul] - neighboutLocPosition[0ul];
0129     BOOST_CHECK(distance <= 2ul);
0130   }
0131 }
0132 
0133 BOOST_AUTO_TEST_CASE(grid_binfinder_test_2d_ints) {
0134   const std::size_t nBinsX = 10ul;
0135   const std::size_t nBinsY = 10ul;
0136   Axis xAxis(0, 100, nBinsX);
0137   Axis yAxis(0, 100, nBinsY);
0138   Grid grid(Type<double>, std::move(xAxis), std::move(yAxis));
0139 
0140   std::array<std::size_t, 2ul> locPosition({3ul, 6ul});
0141 
0142   GridBinFinder<2ul> binFinder_1(1, 3);
0143   std::array<std::size_t, 2ul> dims_1({1, 3});
0144   auto neighbours_1 = binFinder_1.findBins(locPosition, grid);
0145   BOOST_CHECK_EQUAL(neighbours_1.size(), 3ul * 7ul);
0146 
0147   for (const std::size_t neighbour : neighbours_1) {
0148     std::array<std::size_t, 2ul> neighboutLocPosition =
0149         grid.localBinsFromGlobalBin(neighbour);
0150     for (std::size_t dim(0ul); dim < 2ul; ++dim) {
0151       std::size_t distance = locPosition[dim] <= neighboutLocPosition[dim]
0152                                  ? neighboutLocPosition[dim] - locPosition[dim]
0153                                  : locPosition[dim] - neighboutLocPosition[dim];
0154       BOOST_CHECK(distance <= dims_1[dim]);
0155     }
0156   }
0157 
0158   GridBinFinder<2ul> binFinder_2(2, 1);
0159   std::array<std::size_t, 2ul> dims_2({2, 1});
0160   auto neighbours_2 = binFinder_2.findBins(locPosition, grid);
0161   BOOST_CHECK_EQUAL(neighbours_2.size(), 5ul * 3ul);
0162 
0163   for (const std::size_t neighbour : neighbours_2) {
0164     std::array<std::size_t, 2ul> neighboutLocPosition =
0165         grid.localBinsFromGlobalBin(neighbour);
0166     for (std::size_t dim(0ul); dim < 2ul; ++dim) {
0167       std::size_t distance = locPosition[dim] <= neighboutLocPosition[dim]
0168                                  ? neighboutLocPosition[dim] - locPosition[dim]
0169                                  : locPosition[dim] - neighboutLocPosition[dim];
0170       BOOST_CHECK(distance <= dims_2[dim]);
0171     }
0172   }
0173 }
0174 
0175 BOOST_AUTO_TEST_CASE(grid_binfinder_test_3d_ints) {
0176   const std::size_t nBinsX = 10ul;
0177   const std::size_t nBinsY = 10ul;
0178   const std::size_t nBinsZ = 3ul;
0179   Axis xAxis(0, 100, nBinsX);
0180   Axis yAxis(0, 100, nBinsY);
0181   Axis zAxis(0, 100, nBinsZ);
0182   Grid grid(Type<double>, std::move(xAxis), std::move(yAxis), std::move(zAxis));
0183 
0184   std::array<std::size_t, 3ul> locPosition({3ul, 6ul, 2ul});
0185 
0186   GridBinFinder<3ul> binFinder(1, 2, 0);
0187   std::array<std::size_t, 3ul> dims({1, 2, 0});
0188   auto neighbours = binFinder.findBins(locPosition, grid);
0189   BOOST_CHECK_EQUAL(neighbours.size(), 3ul * 5ul * 1ul);
0190 
0191   for (const std::size_t neighbour : neighbours) {
0192     std::array<std::size_t, 3ul> neighboutLocPosition =
0193         grid.localBinsFromGlobalBin(neighbour);
0194     for (std::size_t dim(0ul); dim < 3ul; ++dim) {
0195       std::size_t distance = locPosition[dim] <= neighboutLocPosition[dim]
0196                                  ? neighboutLocPosition[dim] - locPosition[dim]
0197                                  : locPosition[dim] - neighboutLocPosition[dim];
0198       BOOST_CHECK(distance <= dims[dim]);
0199     }
0200   }
0201 }
0202 
0203 BOOST_AUTO_TEST_CASE(grid_binfinder_test_1d_pair) {
0204   const std::size_t nBins = 10ul;
0205   Axis xAxis(0, 100, nBins);
0206   Grid grid(Type<double>, std::move(xAxis));
0207 
0208   std::array<std::size_t, 1ul> locPosition({3ul});
0209 
0210   GridBinFinder<1ul> binFinder_1(std::make_pair(1, 1));
0211   auto neighbours_1 = binFinder_1.findBins(locPosition, grid);
0212   BOOST_CHECK_EQUAL(neighbours_1.size(), 3ul);
0213 
0214   for (const std::size_t neighbour : neighbours_1) {
0215     std::array<std::size_t, 1ul> neighboutLocPosition =
0216         grid.localBinsFromGlobalBin(neighbour);
0217     std::size_t distance = locPosition[0ul] <= neighboutLocPosition[0ul]
0218                                ? neighboutLocPosition[0ul] - locPosition[0ul]
0219                                : locPosition[0ul] - neighboutLocPosition[0ul];
0220     BOOST_CHECK(distance <= 1ul);
0221   }
0222 
0223   GridBinFinder<1ul> binFinder_2(std::make_pair(2, 2));
0224   auto neighbours_2 = binFinder_2.findBins(locPosition, grid);
0225   BOOST_CHECK_EQUAL(neighbours_2.size(), 5ul);
0226 
0227   for (const std::size_t neighbour : neighbours_2) {
0228     std::array<std::size_t, 1ul> neighboutLocPosition =
0229         grid.localBinsFromGlobalBin(neighbour);
0230     std::size_t distance = locPosition[0ul] <= neighboutLocPosition[0ul]
0231                                ? neighboutLocPosition[0ul] - locPosition[0ul]
0232                                : locPosition[0ul] - neighboutLocPosition[0ul];
0233     BOOST_CHECK(distance <= 2ul);
0234   }
0235 }
0236 
0237 BOOST_AUTO_TEST_CASE(grid_binfinder_test_1d_pair_asymmetric) {
0238   const std::size_t nBins = 10ul;
0239   Axis xAxis(0, 100, nBins);
0240   Grid grid(Type<double>, std::move(xAxis));
0241 
0242   std::array<std::size_t, 1ul> locPosition({3ul});
0243 
0244   GridBinFinder<1ul> binFinder_1(std::make_pair(1, 2));
0245   auto neighbours_1 = binFinder_1.findBins(locPosition, grid);
0246   BOOST_CHECK_EQUAL(neighbours_1.size(), 4ul);
0247 
0248   std::array<std::size_t, 4ul> expected({2ul, 3ul, 4ul, 5ul});
0249   for (std::size_t i(0ul); i < 4ul; ++i) {
0250     BOOST_CHECK_EQUAL(neighbours_1[i], expected[i]);
0251   }
0252 }
0253 
0254 BOOST_AUTO_TEST_CASE(grid_binfinder_test_2d_pair) {
0255   const std::size_t nBinsX = 10ul;
0256   const std::size_t nBinsY = 10ul;
0257   Axis xAxis(0, 100, nBinsX);
0258   Axis yAxis(0, 100, nBinsY);
0259   Grid grid(Type<double>, std::move(xAxis), std::move(yAxis));
0260 
0261   std::array<std::size_t, 2ul> locPosition({3ul, 6ul});
0262 
0263   GridBinFinder<2ul> binFinder_1(std::make_pair(1, 1), std::make_pair(3, 3));
0264   std::array<std::size_t, 2ul> dims_1({1, 3});
0265   auto neighbours_1 = binFinder_1.findBins(locPosition, grid);
0266   BOOST_CHECK_EQUAL(neighbours_1.size(), 3ul * 7ul);
0267 
0268   for (const std::size_t neighbour : neighbours_1) {
0269     std::array<std::size_t, 2ul> neighboutLocPosition =
0270         grid.localBinsFromGlobalBin(neighbour);
0271     for (std::size_t dim(0ul); dim < 2ul; ++dim) {
0272       std::size_t distance = locPosition[dim] <= neighboutLocPosition[dim]
0273                                  ? neighboutLocPosition[dim] - locPosition[dim]
0274                                  : locPosition[dim] - neighboutLocPosition[dim];
0275       BOOST_CHECK(distance <= dims_1[dim]);
0276     }
0277   }
0278 
0279   GridBinFinder<2ul> binFinder_2(std::make_pair(2, 2), std::make_pair(1, 1));
0280   std::array<std::size_t, 2ul> dims_2({2, 1});
0281   auto neighbours_2 = binFinder_2.findBins(locPosition, grid);
0282   BOOST_CHECK_EQUAL(neighbours_2.size(), 5ul * 3ul);
0283 
0284   for (const std::size_t neighbour : neighbours_2) {
0285     std::array<std::size_t, 2ul> neighboutLocPosition =
0286         grid.localBinsFromGlobalBin(neighbour);
0287     for (std::size_t dim(0ul); dim < 2ul; ++dim) {
0288       std::size_t distance = locPosition[dim] <= neighboutLocPosition[dim]
0289                                  ? neighboutLocPosition[dim] - locPosition[dim]
0290                                  : locPosition[dim] - neighboutLocPosition[dim];
0291       BOOST_CHECK(distance <= dims_2[dim]);
0292     }
0293   }
0294 }
0295 
0296 BOOST_AUTO_TEST_CASE(grid_binfinder_test_1d_pattern) {
0297   const std::size_t nBins = 5ul;
0298   Axis xAxis(0, 100, nBins);
0299   Grid grid(Type<double>, std::move(xAxis));
0300 
0301   std::array<std::vector<std::size_t>, 1ul> navigation;
0302   navigation[0ul].resize(nBins);
0303   std::iota(navigation[0ul].begin(), navigation[0ul].end(), 1ul);
0304 
0305   std::vector<std::pair<int, int>> neighbours;
0306   neighbours.push_back(std::make_pair(0, 2));
0307   neighbours.push_back(std::make_pair(-1, 1));
0308   neighbours.push_back(std::make_pair(-1, 2));
0309   neighbours.push_back(std::make_pair(-2, 1));
0310   neighbours.push_back(std::make_pair(-1, 0));
0311 
0312   BOOST_CHECK_EQUAL(neighbours.size(), grid.numLocalBins()[0ul]);
0313 
0314   auto startGrid = grid.begin(navigation);
0315   auto stopGrid = grid.end(navigation);
0316 
0317   GridBinFinder<1ul> binFinder(std::move(neighbours));
0318 
0319   std::size_t counter = 0ul;
0320   std::vector<std::size_t> expectedNeighbours = {3, 3, 4, 4, 2};
0321 
0322   for (; startGrid != stopGrid; startGrid++) {
0323     std::array<std::size_t, 1ul> locPosition = startGrid.localBinsIndices();
0324     auto all_neigh = binFinder.findBins(locPosition, grid);
0325     BOOST_CHECK_EQUAL(all_neigh.size(), expectedNeighbours[counter++]);
0326   }
0327 
0328   std::vector<std::pair<int, int>> anotherNeighbours;
0329   anotherNeighbours.push_back(std::make_pair(1, 2));
0330   anotherNeighbours.push_back(std::make_pair(-1, 1));
0331   anotherNeighbours.push_back(std::make_pair(-1, 2));
0332   anotherNeighbours.push_back(std::make_pair(-2, 1));
0333   anotherNeighbours.push_back(std::make_pair(-1, 0));
0334 
0335   GridBinFinder<1ul> anotherBinFinder(std::move(anotherNeighbours));
0336   std::array<std::size_t, 1ul> locPosition = {1ul};
0337 
0338   auto neighs = anotherBinFinder.findBins(locPosition, grid);
0339   BOOST_CHECK_EQUAL(neighs.size(), 2ul);
0340 
0341   for (const std::size_t neighbour : neighs) {
0342     std::array<std::size_t, 1ul> neighboutLocPosition =
0343         grid.localBinsFromGlobalBin(neighbour);
0344     std::size_t distance = locPosition[0ul] <= neighboutLocPosition[0ul]
0345                                ? neighboutLocPosition[0ul] - locPosition[0ul]
0346                                : locPosition[0ul] - neighboutLocPosition[0ul];
0347     BOOST_CHECK(distance <= 2ul);
0348     BOOST_CHECK(distance >= 1ul);
0349   }
0350 }
0351 
0352 BOOST_AUTO_TEST_CASE(grid_binfinder_test_2d_pattern) {
0353   const std::size_t nBinsX = 5ul;
0354   const std::size_t nBinsY = 3ul;
0355   Axis xAxis(0, 100, nBinsX);
0356   Axis yAxis(0, 100, nBinsY);
0357   Grid grid(Type<double>, std::move(xAxis), std::move(yAxis));
0358 
0359   std::array<std::vector<std::size_t>, 2ul> navigation;
0360   navigation[0ul].resize(nBinsX);
0361   navigation[1ul].resize(nBinsY);
0362   std::iota(navigation[0ul].begin(), navigation[0ul].end(), 1ul);
0363   std::iota(navigation[1ul].begin(), navigation[1ul].end(), 1ul);
0364 
0365   std::vector<std::pair<int, int>> neighboursX;
0366   neighboursX.push_back(std::make_pair(0, 2));
0367   neighboursX.push_back(std::make_pair(-1, 1));
0368   neighboursX.push_back(std::make_pair(-1, 2));
0369   neighboursX.push_back(std::make_pair(-2, 1));
0370   neighboursX.push_back(std::make_pair(-1, 0));
0371 
0372   std::vector<std::pair<int, int>> neighboursY;
0373   neighboursY.push_back(std::make_pair(0, 1));
0374   neighboursY.push_back(std::make_pair(-1, 1));
0375   neighboursY.push_back(std::make_pair(-1, 0));
0376 
0377   BOOST_CHECK_EQUAL(neighboursX.size(), grid.numLocalBins()[0ul]);
0378   BOOST_CHECK_EQUAL(neighboursY.size(), grid.numLocalBins()[1ul]);
0379 
0380   auto startGrid = grid.begin(navigation);
0381   auto stopGrid = grid.end(navigation);
0382 
0383   std::size_t counter = 0ul;
0384   std::vector<std::size_t> expectedNeighbours = {6, 9, 6,  6, 9, 6, 8, 12,
0385                                                  8, 8, 12, 8, 4, 6, 4};
0386 
0387   BOOST_CHECK_EQUAL(expectedNeighbours.size(),
0388                     neighboursX.size() * neighboursY.size());
0389 
0390   GridBinFinder<2ul> binFinder(std::move(neighboursX), std::move(neighboursY));
0391 
0392   for (; startGrid != stopGrid; startGrid++) {
0393     std::array<std::size_t, 2ul> locPosition = startGrid.localBinsIndices();
0394     auto all_neigh = binFinder.findBins(locPosition, grid);
0395     BOOST_CHECK_EQUAL(all_neigh.size(), expectedNeighbours[counter++]);
0396   }
0397 }
0398 
0399 BOOST_AUTO_TEST_CASE(grid_binfinder_test_2d_empty_pattern) {
0400   const std::size_t nBinsX = 5ul;
0401   const std::size_t nBinsY = 3ul;
0402   Axis xAxis(0, 100, nBinsX);
0403   Axis yAxis(0, 100, nBinsY);
0404   Grid grid(Type<double>, std::move(xAxis), std::move(yAxis));
0405 
0406   std::array<std::vector<std::size_t>, 2ul> navigation;
0407   navigation[0ul].resize(nBinsX);
0408   navigation[1ul].resize(nBinsY);
0409   std::iota(navigation[0ul].begin(), navigation[0ul].end(), 1ul);
0410   std::iota(navigation[1ul].begin(), navigation[1ul].end(), 1ul);
0411 
0412   std::vector<std::pair<int, int>> neighboursX;
0413   std::vector<std::pair<int, int>> neighboursY;
0414 
0415   auto startGrid = grid.begin(navigation);
0416   auto stopGrid = grid.end(navigation);
0417 
0418   GridBinFinder<2ul> binFinder(std::move(neighboursX), std::move(neighboursY));
0419 
0420   for (; startGrid != stopGrid; startGrid++) {
0421     std::array<std::size_t, 2ul> locPosition = startGrid.localBinsIndices();
0422     auto all_neigh = binFinder.findBins(locPosition, grid);
0423     BOOST_CHECK_EQUAL(all_neigh.size(), 9ul);
0424   }
0425 }
0426 
0427 BOOST_AUTO_TEST_CASE(grid_binfinder_test_2d_mixed) {
0428   const std::size_t nBinsX = 5ul;
0429   const std::size_t nBinsY = 3ul;
0430   Axis xAxis(0, 100, nBinsX);
0431   Axis yAxis(0, 100, nBinsY);
0432   Grid grid(Type<double>, std::move(xAxis), std::move(yAxis));
0433 
0434   std::array<std::vector<std::size_t>, 2ul> navigation;
0435   navigation[0ul].resize(nBinsX);
0436   navigation[1ul].resize(nBinsY);
0437   std::iota(navigation[0ul].begin(), navigation[0ul].end(), 1ul);
0438   std::iota(navigation[1ul].begin(), navigation[1ul].end(), 1ul);
0439 
0440   std::vector<std::pair<int, int>> neighboursX;
0441   neighboursX.push_back(std::make_pair(0, 2));
0442   neighboursX.push_back(std::make_pair(-1, 1));
0443   neighboursX.push_back(std::make_pair(-1, 2));
0444   neighboursX.push_back(std::make_pair(-2, 1));
0445   neighboursX.push_back(std::make_pair(-1, 0));
0446 
0447   BOOST_CHECK_EQUAL(neighboursX.size(), grid.numLocalBins()[0ul]);
0448 
0449   auto startGrid = grid.begin(navigation);
0450   auto stopGrid = grid.end(navigation);
0451 
0452   std::size_t counter = 0ul;
0453   std::vector<std::size_t> expectedNeighbours = {9,  9,  9,  9,  9, 9, 12, 12,
0454                                                  12, 12, 12, 12, 6, 6, 6};
0455 
0456   BOOST_CHECK_EQUAL(expectedNeighbours.size(), neighboursX.size() * nBinsY);
0457 
0458   GridBinFinder<2ul> binFinder(std::move(neighboursX), 1);
0459 
0460   for (; startGrid != stopGrid; startGrid++) {
0461     std::array<std::size_t, 2ul> locPosition = startGrid.localBinsIndices();
0462     auto all_neigh = binFinder.findBins(locPosition, grid);
0463     BOOST_CHECK_EQUAL(all_neigh.size(), expectedNeighbours[counter++]);
0464   }
0465 }
0466 
0467 BOOST_AUTO_TEST_SUITE_END()
0468 
0469 }  // namespace ActsTests