Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IndexSourceLink.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file IndexSourceLink.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 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 
16 
17 #include <cassert>
18 
19 namespace ActsExamples {
20 
30 class IndexSourceLink final {
31  public:
34  : m_geometryId(gid), m_index(idx) {}
35 
36  // Construct an invalid source link. Must be default constructible to
38  IndexSourceLink() = default;
39  IndexSourceLink(const IndexSourceLink&) = default;
40  IndexSourceLink(IndexSourceLink&&) = default;
41  IndexSourceLink& operator=(const IndexSourceLink&) = default;
43 
45  constexpr Index index() const { return m_index; }
46 
48 
49  struct SurfaceAccessor {
51 
52  const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const {
53  const auto& indexSourceLink = sourceLink.get<IndexSourceLink>();
54  return trackingGeometry.findSurface(indexSourceLink.geometryId());
55  }
56  };
57 
58  private:
61 
62  friend bool operator==(const IndexSourceLink& lhs,
63  const IndexSourceLink& rhs) {
64  return (lhs.geometryId() == rhs.geometryId()) and
65  (lhs.m_index == rhs.m_index);
66  }
67  friend bool operator!=(const IndexSourceLink& lhs,
68  const IndexSourceLink& rhs) {
69  return not(lhs == rhs);
70  }
71 };
72 
84 
86 
87  // get the range of elements with requested geoId
88  std::pair<Iterator, Iterator> range(const Acts::Surface& surface) const {
89  assert(container != nullptr);
90  auto [begin, end] = container->equal_range(surface.geometryId());
91  return {Iterator{begin}, Iterator{end}};
92  }
93 };
94 } // namespace ActsExamples