Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiTrajectoryBackendConcept.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MultiTrajectoryBackendConcept.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 
15 #include "Acts/EventData/Types.hpp"
18 
19 #include <any>
20 #include <type_traits>
21 
22 #if defined(ACTS_CONCEPTS_SUPPORTED)
23 #include <concepts>
24 
25 namespace Acts {
26 
27 namespace detail {
28 using Parameters = Eigen::Map<BoundVector>;
29 using Covariance = Eigen::Map<BoundMatrix>;
30 
31 using ConstParameters = Eigen::Map<const BoundVector>;
32 using ConstCovariance = Eigen::Map<const BoundMatrix>;
33 
34 } // namespace detail
35 
36 template <typename T>
37 concept CommonMultiTrajectoryBackend = requires(const T& cv, HashedString key,
38  TrackIndexType istate) {
39  { cv.calibratedSize_impl(istate) } -> std::same_as<TrackIndexType>;
40 
41  { cv.getUncalibratedSourceLink_impl(istate) } -> std::same_as<SourceLink>;
42 
43  { cv.referenceSurface_impl(istate) } -> std::same_as<const Surface*>;
44 
45  { cv.parameters_impl(istate) } -> std::same_as<detail::ConstParameters>;
46 
47  { cv.covariance_impl(istate) } -> std::same_as<detail::ConstCovariance>;
48 
49  { cv.jacobian_impl(istate) } -> std::same_as<detail::ConstCovariance>;
50 
51  {
52  cv.template measurement_impl<2>(istate)
53  } -> std::same_as<Eigen::Map<const ActsVector<2>>>;
54 
55  {
56  cv.template measurementCovariance_impl<2>(istate)
57  } -> std::same_as<Eigen::Map<const ActsSquareMatrix<2>>>;
58 
59  { cv.has_impl(key, istate) } -> std::same_as<bool>;
60 
61  { cv.size_impl() } -> std::same_as<TrackIndexType>;
62 
63  { cv.component_impl(key, istate) } -> std::same_as<std::any>;
64 
65  { cv.hasColumn_impl(key) } -> std::same_as<bool>;
66 };
67 
68 template <typename T>
69 concept ConstMultiTrajectoryBackend = CommonMultiTrajectoryBackend<T> &&
70  requires(T v, HashedString key, TrackIndexType istate) {
71  { v.parameters_impl(istate) } -> std::same_as<detail::ConstParameters>;
72 
73  { v.covariance_impl(istate) } -> std::same_as<detail::ConstCovariance>;
74 
75  { v.jacobian_impl(istate) } -> std::same_as<detail::ConstCovariance>;
76 
77  {
78  v.template measurement_impl<2>(istate)
79  } -> std::same_as<Eigen::Map<const ActsVector<2>>>;
80 
81  {
82  v.template measurementCovariance_impl<2>(istate)
83  } -> std::same_as<Eigen::Map<const ActsSquareMatrix<2>>>;
84 };
85 
86 template <typename T>
87 concept MutableMultiTrajectoryBackend = CommonMultiTrajectoryBackend<T> &&
88  requires(T v, HashedString key, TrackIndexType istate,
90  SourceLink sl, std::shared_ptr<const Surface> surface) {
91  { v.parameters_impl(istate) } -> std::same_as<detail::Parameters>;
92 
93  { v.covariance_impl(istate) } -> std::same_as<detail::Covariance>;
94 
95  { v.jacobian_impl(istate) } -> std::same_as<detail::Covariance>;
96 
97  {
98  v.template measurement_impl<2>(istate)
99  } -> std::same_as<Eigen::Map<ActsVector<2>>>;
100 
101  {
102  v.template measurementCovariance_impl<2>(istate)
103  } -> std::same_as<Eigen::Map<ActsSquareMatrix<2>>>;
104 
105  { v.addTrackState_impl() } -> std::same_as<TrackIndexType>;
106 
107  {v.shareFrom_impl(istate, istate, mask, mask)};
108 
109  {v.unset_impl(mask, istate)};
110 
111  {v.clear_impl()};
112 
113  // As far as I know there's no good way to assert that there's a generic
114  // template function
115  {v.template addColumn_impl<uint32_t>(col)};
116  {v.template addColumn_impl<uint64_t>(col)};
117  {v.template addColumn_impl<int32_t>(col)};
118  {v.template addColumn_impl<int64_t>(col)};
119  {v.template addColumn_impl<float>(col)};
120  {v.template addColumn_impl<double>(col)};
121 
122  {v.allocateCalibrated_impl(istate, dim)};
123 
124  {v.setUncalibratedSourceLink_impl(istate, sl)};
125 
126  {v.setReferenceSurface_impl(istate, surface)};
127 
128  // @TODO: Add copyDynamicFrom + ensureDynamicColumns for MTJ like in TrackContainer
129 };
130 
131 } // namespace Acts
132 #endif