LDMX Software
IndexSourceLink.h
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
11#include <cassert>
12
13#include "Acts/EventData/SourceLink.hpp"
14#include "Acts/Surfaces/Surface.hpp"
15#include "Tracking/Sim/GeometryContainers.h"
16#include "Tracking/Sim/Index.h"
17
18namespace ActsExamples {
19
29class IndexSourceLink final {
30 public:
32 constexpr IndexSourceLink(Acts::GeometryIdentifier gid, Index idx)
33 : m_geometryId(gid), m_index(idx) {}
34
35 // Construct an invalid source link. Must be default constructible to
37 IndexSourceLink() = default;
38 IndexSourceLink(const IndexSourceLink&) = default;
40 IndexSourceLink& operator=(const IndexSourceLink&) = default;
41 IndexSourceLink& operator=(IndexSourceLink&&) = default;
42
44 constexpr Index index() const { return m_index; }
45
46 Acts::GeometryIdentifier geometryId() const { return m_geometryId; }
47
48 private:
49 Acts::GeometryIdentifier m_geometryId;
50 Index m_index = 0;
51
52 friend bool operator==(const IndexSourceLink& lhs,
53 const IndexSourceLink& rhs) {
54 return (lhs.geometryId() == rhs.geometryId()) and
55 (lhs.m_index == rhs.m_index);
56 }
57 friend bool operator!=(const IndexSourceLink& lhs,
58 const IndexSourceLink& rhs) {
59 return not(lhs == rhs);
60 }
61};
62
67using IndexSourceLinkContainer = GeometryIdMultiset<IndexSourceLink>;
73 using BaseIterator = GeometryIdMultisetAccessor<IndexSourceLink>::Iterator;
74
75 using Iterator = Acts::SourceLinkAdapterIterator<BaseIterator>;
76
77 // get the range of elements with requested geoId
78 std::pair<Iterator, Iterator> range(const Acts::Surface& surface) const {
79 assert(container != nullptr);
80 auto [begin, end] = container->equal_range(surface.geometryId());
81 return {Iterator{begin}, Iterator{end}};
82 }
83};
84} // namespace ActsExamples
The accessor for the GeometryIdMultiset container.
Accessor for the above source link container.