Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackContainerBackendConcept.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackContainerBackendConcept.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 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 
12 #include "Acts/EventData/Types.hpp"
15 
16 #include <any>
17 #include <type_traits>
18 
19 #if defined(ACTS_CONCEPTS_SUPPORTED)
20 #include <concepts>
21 
22 namespace Acts {
23 
24 namespace detail {
25 using Parameters = Eigen::Map<BoundVector>;
26 using Covariance = Eigen::Map<BoundMatrix>;
27 
28 using ConstParameters = Eigen::Map<const BoundVector>;
29 using ConstCovariance = Eigen::Map<const BoundMatrix>;
30 } // namespace detail
31 
32 template <typename T>
33 concept ConstTrackContainerBackend = requires(const T& cv, HashedString key,
34  TrackIndexType itrack) {
35  { cv.size_impl() } -> std::same_as<std::size_t>;
36 
37  { cv.component_impl(key, itrack) } -> std::same_as<std::any>;
38 
39  { cv.parameters(itrack) } -> std::same_as<detail::ConstParameters>;
40 
41  { cv.covariance(itrack) } -> std::same_as<detail::ConstCovariance>;
42 
43  { cv.hasColumn_impl(key) } -> std::same_as<bool>;
44 
45  { cv.referenceSurface_impl(itrack) } -> std::same_as<const Surface*>;
46 };
47 
48 template <typename T>
49 concept MutableTrackContainerBackend = ConstTrackContainerBackend<T> &&
50  requires(T v, HashedString key, TrackIndexType itrack, std::string col,
51  const T& other, std::shared_ptr<const Surface> sharedSurface) {
52  { v.parameters(itrack) } -> std::same_as<detail::Parameters>;
53 
54  { v.covariance(itrack) } -> std::same_as<detail::Covariance>;
55 
56  { v.addTrack_impl() } -> std::same_as<TrackIndexType>;
57 
58  {v.removeTrack_impl(itrack)};
59 
60  // As far as I know there's no good way to assert that there's a generic
61  // template function
62  {v.template addColumn_impl<uint32_t>(col)};
63  {v.template addColumn_impl<uint64_t>(col)};
64  {v.template addColumn_impl<int32_t>(col)};
65  {v.template addColumn_impl<int64_t>(col)};
66  {v.template addColumn_impl<float>(col)};
67  {v.template addColumn_impl<double>(col)};
68 
69  {v.copyDynamicFrom_impl(itrack, other, itrack)};
70 
71  {v.ensureDynamicColumns_impl(other)};
72 
73  {v.reserve(itrack)};
74 
75  {v.setReferenceSurface_impl(itrack, sharedSurface)};
76 };
77 
78 template <typename T>
80 
81 template <typename T>
82 concept TrackContainerBackend = ConstTrackContainerBackend<T> &&
83  (IsReadOnlyTrackContainer<T>::value || MutableTrackContainerBackend<T>);
84 
85 } // namespace Acts
86 
87 #endif