Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:10:00

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012 #include "Acts/EventData/MultiTrajectoryBackendConcept.hpp"
0013 #include "Acts/EventData/ParticleHypothesis.hpp"
0014 #include "Acts/EventData/Types.hpp"
0015 #include "Acts/Surfaces/Surface.hpp"
0016 #include "Acts/Utilities/HashedString.hpp"
0017 
0018 #include <any>
0019 #include <type_traits>
0020 
0021 #if defined(__cpp_concepts)
0022 #include <concepts>
0023 
0024 namespace Acts {
0025 
0026 namespace detail {
0027 using Parameters = Eigen::Map<BoundVector>;
0028 using Covariance = Eigen::Map<BoundMatrix>;
0029 
0030 using ConstParameters = Eigen::Map<const BoundVector>;
0031 using ConstCovariance = Eigen::Map<const BoundMatrix>;
0032 }  // namespace detail
0033 
0034 template <typename T>
0035 concept ConstTrackContainerBackend = requires(const T& cv, HashedString key,
0036                                               TrackIndexType itrack) {
0037   { cv.size_impl() } -> std::same_as<std::size_t>;
0038 
0039   { cv.component_impl(key, itrack) } -> std::same_as<std::any>;
0040 
0041   { cv.parameters(itrack) } -> std::same_as<detail::ConstParameters>;
0042 
0043   { cv.covariance(itrack) } -> std::same_as<detail::ConstCovariance>;
0044 
0045   { cv.hasColumn_impl(key) } -> std::same_as<bool>;
0046 
0047   { cv.referenceSurface_impl(itrack) } -> std::same_as<const Surface*>;
0048 
0049   { cv.particleHypothesis_impl(itrack) } -> std::same_as<ParticleHypothesis>;
0050 
0051   {cv.dynamicKeys_impl()};
0052   requires detail::RangeLike<decltype(cv.dynamicKeys_impl())>;
0053 };
0054 
0055 template <typename T>
0056 concept MutableTrackContainerBackend = ConstTrackContainerBackend<T> &&
0057     requires(T v, HashedString key, TrackIndexType itrack, std::string col,
0058              const T& other, std::shared_ptr<const Surface> sharedSurface) {
0059   { v.parameters(itrack) } -> std::same_as<detail::Parameters>;
0060 
0061   { v.covariance(itrack) } -> std::same_as<detail::Covariance>;
0062 
0063   { v.addTrack_impl() } -> std::same_as<TrackIndexType>;
0064 
0065   {v.removeTrack_impl(itrack)};
0066 
0067   // As far as I know there's no good way to assert that there's a
0068   // generic template function
0069   {v.template addColumn_impl<uint32_t>(col)};
0070   {v.template addColumn_impl<uint64_t>(col)};
0071   {v.template addColumn_impl<int32_t>(col)};
0072   {v.template addColumn_impl<int64_t>(col)};
0073   {v.template addColumn_impl<float>(col)};
0074   {v.template addColumn_impl<double>(col)};
0075 
0076   {v.copyDynamicFrom_impl(itrack, key, std::declval<const std::any&>())};
0077 
0078   {v.ensureDynamicColumns_impl(other)};
0079 
0080   {v.reserve(itrack)};
0081 
0082   {v.setReferenceSurface_impl(itrack, sharedSurface)};
0083 
0084   {v.setParticleHypothesis_impl(
0085       itrack, std::declval<const Acts::ParticleHypothesis&>())};
0086 
0087   {v.clear()};
0088 };
0089 
0090 template <typename T>
0091 struct IsReadOnlyTrackContainer;
0092 
0093 template <typename T>
0094 concept TrackContainerBackend = ConstTrackContainerBackend<T> &&
0095     (IsReadOnlyTrackContainer<T>::value || MutableTrackContainerBackend<T>);
0096 }  // namespace Acts
0097 
0098 #endif