Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Neighbour.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Neighbour.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
12 
13 namespace Acts {
14 
29 
30 template <typename external_spacepoint_t>
31 struct Neighbour {
33  Neighbour() = delete;
34 
40  const float lowerBound) = delete;
41 
47  std::size_t idx, const float lowerBound);
48 
50  std::size_t index;
53  typename Acts::SpacePointGrid<
54  external_spacepoint_t>::value_type::const_iterator itr;
55 };
56 
57 template <typename external_spacepoint_t>
60  const float lowerBound)
61  : index(idx) {
63  const auto& collection = grid.at(idx);
66  if (collection.size() == 0) {
67  itr = collection.begin();
68  return;
69  }
70 
73  if (collection.front()->radius() > lowerBound) {
74  itr = collection.begin();
75  }
80  else if (collection.back()->radius() < lowerBound) {
81  itr = collection.end();
82  }
85  else {
86  itr = std::lower_bound(collection.begin(), collection.end(), lowerBound,
87  [](const auto& sp, const float target) -> bool {
88  return sp->radius() < target;
89  });
90  }
91 }
92 
93 } // namespace Acts