Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackParametersConcept.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackParametersConcept.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019-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 
15 
16 #include <optional>
17 #include <type_traits>
18 
19 namespace Acts {
20 
21 class Surface;
22 
23 namespace Concepts {
24 
25 // nested types that must be available
26 template <typename T>
27 using TypeScalar = typename T::Scalar;
28 template <typename T>
29 using TypeParametersVector = typename T::ParametersVector;
30 template <typename T>
31 using TypeCovarianceMatrix = typename T::CovarianceMatrix;
32 
33 template <typename T>
34 using ReturnTypeParameters = decltype(std::declval<T>().parameters());
35 template <typename T>
36 using ReturnTypeCovariance = decltype(std::declval<T>().covariance());
37 template <typename T>
39  decltype(std::declval<T>().fourPosition(std::declval<GeometryContext>()));
40 template <typename T>
41 using ReturnTypeFourPosition = decltype(std::declval<T>().fourPosition());
42 template <typename T>
44  decltype(std::declval<T>().position(std::declval<GeometryContext>()));
45 template <typename T>
46 using ReturnTypePosition = decltype(std::declval<T>().position());
47 template <typename T>
48 using ReturnTypeTime = decltype(std::declval<T>().time());
49 template <typename T>
50 using ReturnTypeDirection = decltype(std::declval<T>().direction());
51 template <typename T>
53  decltype(std::declval<T>().absoluteMomentum());
54 template <typename T>
55 using ReturnTypeCharge = decltype(std::declval<T>().charge());
56 template <typename T>
58  decltype(std::declval<T>().referenceSurface());
59 
60 template <typename T>
62  // check for required nested types
63  constexpr static bool hasTypeScalar = exists<TypeScalar, const T>;
64  constexpr static bool hasTypeParametersVector =
65  exists<TypeParametersVector, const T>;
66  constexpr static bool hasTypeCovarianceMatrix =
67  exists<TypeCovarianceMatrix, const T>;
68 
69  // check for required methods
70  constexpr static bool hasMethodParameters =
71  std::is_convertible_v<ReturnTypeParameters<T>, BoundVector>;
72  constexpr static bool hasMethodCovariance =
73  std::is_convertible_v<ReturnTypeCovariance<T>,
74  std::optional<BoundSquareMatrix>>;
75  constexpr static bool hasMethodFourPositionFromContext =
76  identical_to<Vector4, ReturnTypeFourPositionFromContext, const T>;
77  constexpr static bool hasMethodPositionFromContext =
78  identical_to<Vector3, ReturnTypePositionFromContext, const T>;
79  constexpr static bool hasMethodTime =
80  identical_to<TypeScalar<T>, ReturnTypeTime, const T>;
81  constexpr static bool hasMethodDirection =
82  identical_to<Vector3, ReturnTypeDirection, const T>;
83  constexpr static bool hasMethodAbsoluteMomentum =
84  identical_to<TypeScalar<T>, ReturnTypeAbsoluteMomentum, const T>;
85  constexpr static bool hasMethodCharge =
86  identical_to<TypeScalar<T>, ReturnTypeCharge, const T>;
87  constexpr static bool hasMethodReferenceSurface =
88  identical_to<const Surface&, ReturnTypeReferenceSurface, const T>;
89 
90  // provide meaningful error messages in case of non-compliance
91  static_assert(hasTypeScalar, "Scalar type is missing");
92  static_assert(hasTypeParametersVector, "Parameters vector type is missing");
93  static_assert(hasTypeCovarianceMatrix, "Covariance matrix type is missing");
94  static_assert(hasMethodParameters, "Missing or invalid 'parameters' method");
95  static_assert(hasMethodCovariance, "Missing or invalid 'covariance' method");
97  "Missing or invalid 'fourPosition' method");
98  static_assert(hasMethodPositionFromContext,
99  "Missing or invalid 'position' method");
100  static_assert(hasMethodTime, "Missing or invalid 'time' method");
101  static_assert(hasMethodDirection, "Missing or invalid 'direction' method");
102  static_assert(hasMethodAbsoluteMomentum,
103  "Missing or invalid 'absoluteMomentum' method");
104  static_assert(hasMethodCharge, "Missing or invalid 'charge' method");
105  static_assert(hasMethodReferenceSurface,
106  "Missing or invalid 'referenceSurface' method");
107 
108  constexpr static bool value =
114 };
115 
116 template <typename T>
118  // check for required nested types
119  constexpr static bool hasTypeScalar = exists<TypeScalar, const T>;
120  constexpr static bool hasTypeParametersVector =
121  exists<TypeParametersVector, const T>;
122  constexpr static bool hasTypeCovarianceMatrix =
123  exists<TypeCovarianceMatrix, const T>;
124 
125  // check for required methods
126  constexpr static bool hasMethodParameters =
127  std::is_convertible_v<ReturnTypeParameters<T>, FreeVector>;
128  constexpr static bool hasMethodCovariance =
129  std::is_convertible_v<ReturnTypeCovariance<T>,
130  std::optional<FreeSquareMatrix>>;
131  constexpr static bool hasMethodFourPosition =
132  identical_to<Vector4, ReturnTypeFourPosition, const T>;
133  constexpr static bool hasMethodPosition =
134  identical_to<Vector3, ReturnTypePosition, const T>;
135  constexpr static bool hasMethodTime =
136  identical_to<TypeScalar<T>, ReturnTypeTime, const T>;
137  constexpr static bool hasMethodDirection =
138  identical_to<Vector3, ReturnTypeDirection, const T>;
139  constexpr static bool hasMethodAbsoluteMomentum =
140  identical_to<TypeScalar<T>, ReturnTypeAbsoluteMomentum, const T>;
141  constexpr static bool hasMethodCharge =
142  identical_to<TypeScalar<T>, ReturnTypeCharge, const T>;
143 
144  // provide meaningful error messages in case of non-compliance
145  static_assert(hasTypeScalar, "Scalar type is missing");
146  static_assert(hasTypeParametersVector, "Parameters vector type is missing");
147  static_assert(hasTypeCovarianceMatrix, "Covariance matrix type is missing");
148  static_assert(hasMethodParameters, "Missing or invalid 'parameters' method");
149  static_assert(hasMethodCovariance, "Missing or invalid 'covariance' method");
150  static_assert(hasMethodFourPosition,
151  "Missing or invalid 'fourPosition' method");
152  static_assert(hasMethodPosition, "Missing or invalid 'position' method");
153  static_assert(hasMethodTime, "Missing or invalid 'time' method");
154  static_assert(hasMethodDirection, "Missing or invalid 'direction' method");
155  static_assert(hasMethodAbsoluteMomentum,
156  "Missing or invalid 'absoluteMomentum' method");
157  static_assert(hasMethodCharge, "Missing or invalid 'charge' method");
158 
159  constexpr static bool value =
164 };
165 
166 template <typename parameters_t>
169 
170 template <typename parameters_t>
173 
174 } // namespace Concepts
175 } // namespace Acts