Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-04 09:16:13

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 #pragma once
0010 
0011 #include "Acts/EventData/SourceLink.hpp"
0012 #include "Acts/Geometry/TrackingGeometry.hpp"
0013 #include "Acts/Surfaces/Surface.hpp"
0014 #include "ActsExamples/EventData/GeometryContainers.hpp"
0015 #include "ActsExamples/EventData/Index.hpp"
0016 
0017 #include <cassert>
0018 
0019 namespace ActsExamples {
0020 
0021 struct IndexSourceLinkSurfaceAccessor;
0022 
0023 /// A source link that stores just an index.
0024 ///
0025 /// This is intentionally kept as barebones as possible. The source link
0026 /// is just a reference and will be copied, moved around, etc. often.
0027 /// Keeping it small and separate from the actual, potentially large,
0028 /// measurement data should result in better overall performance.
0029 /// Using an index instead of e.g. a pointer, means source link and
0030 /// measurement are decoupled and the measurement representation can be
0031 /// easily changed without having to also change the source link.
0032 class IndexSourceLink final {
0033  public:
0034   using SurfaceAccessor = IndexSourceLinkSurfaceAccessor;
0035 
0036   /// Construct from geometry identifier and index.
0037   constexpr IndexSourceLink(Acts::GeometryIdentifier gid, Index idx)
0038       : m_geometryId(gid), m_index(idx) {}
0039 
0040   // Construct an invalid source link. Must be default constructible to
0041   /// satisfy SourceLinkConcept.
0042   IndexSourceLink() = default;
0043   IndexSourceLink(const IndexSourceLink&) = default;
0044   IndexSourceLink(IndexSourceLink&&) = default;
0045   IndexSourceLink& operator=(const IndexSourceLink&) = default;
0046   IndexSourceLink& operator=(IndexSourceLink&&) = default;
0047 
0048   /// Access the index.
0049   constexpr Index index() const { return m_index; }
0050 
0051   Acts::GeometryIdentifier geometryId() const { return m_geometryId; }
0052 
0053  private:
0054   Acts::GeometryIdentifier m_geometryId;
0055   Index m_index = 0;
0056 
0057   friend bool operator==(const IndexSourceLink& lhs,
0058                          const IndexSourceLink& rhs) {
0059     return (lhs.geometryId() == rhs.geometryId()) &&
0060            (lhs.m_index == rhs.m_index);
0061   }
0062 };
0063 
0064 struct IndexSourceLinkSurfaceAccessor {
0065   const Acts::TrackingGeometry& geometry;
0066 
0067   const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const {
0068     const auto& indexSourceLink = sourceLink.get<IndexSourceLink>();
0069     return geometry.findSurface(indexSourceLink.geometryId());
0070   }
0071 };
0072 
0073 /// Accessor for the above source link container
0074 ///
0075 /// It wraps up a few lookup methods to be used in the Combinatorial Kalman
0076 /// Filter
0077 struct IndexSourceLinkAccessor : GeometryIdMultisetAccessor<IndexSourceLink> {
0078   using BaseIterator = GeometryIdMultisetAccessor<IndexSourceLink>::Iterator;
0079 
0080   using Iterator = Acts::SourceLinkAdapterIterator<BaseIterator>;
0081 
0082   // get the range of elements with requested geoId
0083   std::pair<Iterator, Iterator> range(const Acts::Surface& surface) const {
0084     assert(container != nullptr);
0085     auto [begin, end] = container->equal_range(surface.geometryId());
0086     return {Iterator{begin}, Iterator{end}};
0087   }
0088 };
0089 
0090 }  // namespace ActsExamples