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 acts_examples {
19
29class IndexSourceLink final {
30 public:
32 constexpr IndexSourceLink(Acts::GeometryIdentifier gid, Index idx)
33 : m_geometry_id_(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_geometry_id_; }
47
48 private:
49 Acts::GeometryIdentifier m_geometry_id_;
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 =
68 acts_examples::GeometryIdMultiset<IndexSourceLink>;
75 using BaseIterator = GeometryIdMultisetAccessor<IndexSourceLink>::Iterator;
76
77 using Iterator = Acts::SourceLinkAdapterIterator<BaseIterator>;
78
79 // get the range of elements with requested geoId
80 std::pair<Iterator, Iterator> range(const Acts::Surface& surface) const {
81 assert(container_ != nullptr);
82 auto [begin, end] = container_->equal_range(surface.geometryId());
83 return {Iterator{begin}, Iterator{end}};
84 }
85};
86} // namespace acts_examples
The accessor for the GeometryIdMultiset container.
Accessor for the above source link container.