EIC 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 
14 
15 namespace Acts {
16 
17 class Surface;
18 
19 namespace Concepts {
20 
21 // nested types that must be available
22 template <typename T>
23 using TypeScalar = typename T::Scalar;
24 template <typename T>
25 using TypeParametersVector = typename T::ParametersVector;
26 template <typename T>
27 using TypeCovarianceMatrix = typename T::CovarianceMatrix;
28 
29 template <typename T>
30 using ReturnTypeParameters = decltype(std::declval<T>().parameters());
31 template <typename T>
32 using ReturnTypeCovariance = decltype(std::declval<T>().covariance());
33 template <typename T>
35  decltype(std::declval<T>().fourPosition(std::declval<GeometryContext>()));
36 template <typename T>
37 using ReturnTypeFourPosition = decltype(std::declval<T>().fourPosition());
38 template <typename T>
40  decltype(std::declval<T>().position(std::declval<GeometryContext>()));
41 template <typename T>
42 using ReturnTypePosition = decltype(std::declval<T>().position());
43 template <typename T>
44 using ReturnTypeTime = decltype(std::declval<T>().time());
45 template <typename T>
46 using ReturnTypeUnitDirection = decltype(std::declval<T>().unitDirection());
47 template <typename T>
49  decltype(std::declval<T>().absoluteMomentum());
50 template <typename T>
51 using ReturnTypeCharge = decltype(std::declval<T>().charge());
52 template <typename T>
54  decltype(std::declval<T>().referenceSurface());
55 
56 template <typename T>
58  // check for required nested types
59  constexpr static bool hasTypeScalar = exists<TypeScalar, const T>;
60  constexpr static bool hasTypeParametersVector =
61  exists<TypeParametersVector, const T>;
62  constexpr static bool hasTypeCovarianceMatrix =
63  exists<TypeCovarianceMatrix, const T>;
64 
65  // check for required methods
66  constexpr static bool hasMethodParameters =
67  identical_to<BoundVector, ReturnTypeParameters, const T>;
68  constexpr static bool hasMethodCovariance =
69  identical_to<const std::optional<BoundSymMatrix>&, ReturnTypeCovariance,
70  const T>;
71  constexpr static bool hasMethodFourPositionFromContext =
72  identical_to<Vector4D, ReturnTypeFourPositionFromContext, const T>;
73  constexpr static bool hasMethodPositionFromContext =
74  identical_to<Vector3D, ReturnTypePositionFromContext, const T>;
75  constexpr static bool hasMethodTime =
76  identical_to<double, ReturnTypeTime, const T>;
77  constexpr static bool hasMethodUnitDirection =
78  identical_to<Vector3D, ReturnTypeUnitDirection, const T>;
79  constexpr static bool hasMethodAbsoluteMomentum =
80  identical_to<double, ReturnTypeAbsoluteMomentum, const T>;
81  constexpr static bool hasMethodCharge =
82  identical_to<double, ReturnTypeCharge, const T>;
83  constexpr static bool hasMethodReferenceSurface =
84  identical_to<const Surface&, ReturnTypeReferenceSurface, const T>;
85 
86  // provide meaningful error messages in case of non-compliance
87  static_assert(hasTypeScalar, "Scalar type is missing");
88  static_assert(hasTypeParametersVector, "Parameters vector type is missing");
89  static_assert(hasTypeCovarianceMatrix, "Covariance matrix type is missing");
90  static_assert(hasMethodParameters, "Missing or invalid 'parameters' method");
91  static_assert(hasMethodCovariance, "Missing or invalid 'covariance' method");
93  "Missing or invalid 'fourPosition' method");
94  static_assert(hasMethodPositionFromContext,
95  "Missing or invalid 'position' method");
96  static_assert(hasMethodTime, "Missing or invalid 'time' method");
97  static_assert(hasMethodUnitDirection,
98  "Missing or invalid 'unitDirection' method");
99  static_assert(hasMethodAbsoluteMomentum,
100  "Missing or invalid 'absoluteMomentum' method");
101  static_assert(hasMethodCharge, "Missing or invalid 'charge' method");
102  static_assert(hasMethodReferenceSurface,
103  "Missing or invalid 'referenceSurface' method");
104 
105  constexpr static bool value =
111 };
112 
113 template <typename T>
115  // check for required nested types
116  constexpr static bool hasTypeScalar = exists<TypeScalar, const T>;
117  constexpr static bool hasTypeParametersVector =
118  exists<TypeParametersVector, const T>;
119  constexpr static bool hasTypeCovarianceMatrix =
120  exists<TypeCovarianceMatrix, const T>;
121 
122  // check for required methods
123  constexpr static bool hasMethodParameters =
124  identical_to<FreeVector, ReturnTypeParameters, const T>;
125  constexpr static bool hasMethodCovariance =
126  identical_to<const std::optional<FreeSymMatrix>&, ReturnTypeCovariance,
127  const T>;
128  constexpr static bool hasMethodFourPosition =
129  identical_to<Vector4D, ReturnTypeFourPosition, const T>;
130  constexpr static bool hasMethodPosition =
131  identical_to<Vector3D, ReturnTypePosition, const T>;
132  constexpr static bool hasMethodTime =
133  identical_to<double, ReturnTypeTime, const T>;
134  constexpr static bool hasMethodUnitDirection =
135  identical_to<Vector3D, ReturnTypeUnitDirection, const T>;
136  constexpr static bool hasMethodAbsoluteMomentum =
137  identical_to<double, ReturnTypeAbsoluteMomentum, const T>;
138  constexpr static bool hasMethodCharge =
139  identical_to<double, ReturnTypeCharge, const T>;
140 
141  // provide meaningful error messages in case of non-compliance
142  static_assert(hasTypeScalar, "Scalar type is missing");
143  static_assert(hasTypeParametersVector, "Parameters vector type is missing");
144  static_assert(hasTypeCovarianceMatrix, "Covariance matrix type is missing");
145  static_assert(hasMethodParameters, "Missing or invalid 'parameters' method");
146  static_assert(hasMethodCovariance, "Missing or invalid 'covariance' method");
147  static_assert(hasMethodFourPosition,
148  "Missing or invalid 'fourPosition' method");
149  static_assert(hasMethodPosition, "Missing or invalid 'position' method");
150  static_assert(hasMethodTime, "Missing or invalid 'time' method");
151  static_assert(hasMethodUnitDirection,
152  "Missing or invalid 'unitDirection' method");
153  static_assert(hasMethodAbsoluteMomentum,
154  "Missing or invalid 'absoluteMomentum' method");
155  static_assert(hasMethodCharge, "Missing or invalid 'charge' method");
156 
157  constexpr static bool value =
162 };
163 
164 template <typename parameters_t>
167 
168 template <typename parameters_t>
171 
172 } // namespace Concepts
173 } // namespace Acts