Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StepperConcept.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file StepperConcept.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 
20 
21 namespace Acts {
22 class Surface;
23 
24 namespace Concepts {
25 namespace Stepper {
26 
27 template <typename T>
28 using state_t = typename T::State;
29 
30 template <typename T>
31 using jacobian_t = typename T::Jacobian;
32 template <typename T>
33 using covariance_t = typename T::Covariance;
34 template <typename T>
35 using bound_state_t = typename T::BoundState;
36 template <typename T>
37 using curvilinear_state_t = typename T::CurvilinearState;
38 
39 METHOD_TRAIT(reset_state_t, resetState);
40 METHOD_TRAIT(get_field_t, getField);
41 METHOD_TRAIT(position_t, position);
42 METHOD_TRAIT(direction_t, direction);
43 METHOD_TRAIT(qop_t, qOverP);
44 METHOD_TRAIT(absolute_momentum_t, absoluteMomentum);
45 METHOD_TRAIT(momentum_t, momentum);
46 METHOD_TRAIT(charge_t, charge);
47 METHOD_TRAIT(time_t, time);
48 METHOD_TRAIT(overstep_t, overstepLimit);
49 METHOD_TRAIT(bound_state_method_t, boundState);
50 METHOD_TRAIT(curvilinear_state_method_t, curvilinearState);
51 METHOD_TRAIT(update_t, update);
52 METHOD_TRAIT(covariance_transport_bound_t, transportCovarianceToBound);
53 METHOD_TRAIT(covariance_transport_curvilinear_t,
55 METHOD_TRAIT(step_t, step);
56 METHOD_TRAIT(update_surface_status_t, updateSurfaceStatus);
57 METHOD_TRAIT(set_step_size_t, setStepSize);
58 METHOD_TRAIT(get_step_size_t, getStepSize);
59 METHOD_TRAIT(release_step_size_t, releaseStepSize);
60 METHOD_TRAIT(output_step_size_t, outputStepSize);
61 
62 template <typename T>
63 using cov_transport_t = decltype(std::declval<T>().covTransport);
64 template <typename T>
65 using cov_t = decltype(std::declval<T>().cov);
66 template <typename T>
67 using path_accumulated_t = decltype(std::declval<T>().pathAccumulated);
68 template <typename T>
69 using step_size_t = decltype(std::declval<T>().stepSize);
70 
71 // clang-format off
72  template <typename S>
73  constexpr bool StepperStateConcept
74  = require<has_member<S, cov_transport_t, bool>,
75  has_member<S, cov_t, BoundSquareMatrix>,
76  has_member<S, path_accumulated_t, double>//,
77 // has_member<S, step_size_t, ConstrainedStep>
78  >;
79 // clang-format on
80 
81 // clang-format off
82 template <typename S>
84  has_member<S, cov_transport_t, bool>,
85  has_member<S, path_accumulated_t, double>
86 >;
87 // clang-format on
88 
89 // clang-format off
90  template <typename S, typename state = typename S::State>
92  constexpr static bool state_exists = exists<state_t, S>;
93  static_assert(state_exists, "State type not found");
94  constexpr static bool jacobian_exists = exists<jacobian_t, S>;
95  static_assert(jacobian_exists, "Jacobian type not found");
96  constexpr static bool covariance_exists = exists<covariance_t, S>;
97  static_assert(covariance_exists, "Covariance type not found");
98  constexpr static bool bound_state_exists = exists<bound_state_t, S>;
99  static_assert(bound_state_exists, "BoundState type not found");
100  constexpr static bool curvilinear_state_exists = exists<curvilinear_state_t, S>;
101  static_assert(curvilinear_state_exists, "CurvilinearState type not found");
102  constexpr static bool reset_state_exists = has_method<const S, void, reset_state_t, state&, const BoundVector&, const BoundSquareMatrix&, const Surface&, const double>;
103  static_assert(reset_state_exists, "resetState method not found");
104  constexpr static bool position_exists = has_method<const S, Vector3, position_t, const state&>;
105  static_assert(position_exists, "position method not found");
106  constexpr static bool direction_exists = has_method<const S, Vector3, direction_t, const state&>;
107  static_assert(direction_exists, "direction method not found");
108  constexpr static bool qop_exists = has_method<const S, double, qop_t, const state&>;
109  static_assert(qop_exists, "qOverP method not found");
110  constexpr static bool absolute_momentum_exists = has_method<const S, double, absolute_momentum_t, const state&>;
111  static_assert(absolute_momentum_exists, "absoluteMomentum method not found");
112  constexpr static bool momentum_exists = has_method<const S, Vector3, momentum_t, const state&>;
113  static_assert(momentum_exists, "momentum method not found");
114  constexpr static bool charge_exists = has_method<const S, double, charge_t, const state&>;
115  static_assert(charge_exists, "charge method not found");
116  constexpr static bool time_exists = has_method<const S, double, time_t, const state&>;
117  static_assert(time_exists, "time method not found");
118  constexpr static bool overstep_exists = has_method<const S, double, overstep_t, const state&>;
119  static_assert(overstep_exists, "overstepLimit method not found");
120  constexpr static bool bound_state_method_exists= has_method<const S, Result<typename S::BoundState>, bound_state_method_t, state&, const Surface&, bool, const FreeToBoundCorrection&>;
121  static_assert(bound_state_method_exists, "boundState method not found");
122  constexpr static bool curvilinear_state_method_exists = has_method<const S, typename S::CurvilinearState, curvilinear_state_method_t, state&, bool>;
123  static_assert(curvilinear_state_method_exists, "curvilinearState method not found");
124  constexpr static bool covariance_transport_exists = require<has_method<const S, void, covariance_transport_curvilinear_t, state&>,
125  has_method<const S, void, covariance_transport_bound_t, state&, const Surface&, const FreeToBoundCorrection&>>;
126  static_assert(covariance_transport_exists, "covarianceTransport method not found");
127  constexpr static bool update_surface_exists = has_method<const S, Intersection3D::Status, update_surface_status_t, state&, const Surface&, Direction, const BoundaryCheck&, ActsScalar, const Logger&>;
128  static_assert(update_surface_exists, "updateSurfaceStatus method not found");
129  constexpr static bool set_step_size_exists = has_method<const S, void, set_step_size_t, state&, double, ConstrainedStep::Type, bool>;
130  static_assert(set_step_size_exists, "setStepSize method not found");
131  constexpr static bool get_step_size_exists = has_method<const S, double, get_step_size_t, const state &, ConstrainedStep::Type>;
132  static_assert(get_step_size_exists, "getStepSize method not found");
133  constexpr static bool release_step_size_exists = has_method<const S, void, release_step_size_t, state&>;
134  static_assert(release_step_size_exists, "releaseStepSize method not found");
135  constexpr static bool output_step_size_exists = has_method<const S, std::string, output_step_size_t, const state&>;
136  static_assert(output_step_size_exists, "outputStepSize method not found");
137 
138  constexpr static bool value = require<state_exists,
145  qop_exists,
149  time_exists,
157 
158  };
159 // clang-format on
160 
161 // clang-format off
162  // NOTE This static_asserts in here must be commented out, since it would break the compilation for the MultiStepper
163  template <typename S, typename state = typename S::State>
166  static_assert(common_stepper_concept_fullfilled, "Stepper does not fulfill common stepper concept");
167  constexpr static bool update_method_exists = require<has_method<const S, void, update_t, state&, const FreeVector&, const BoundVector&, const BoundSquareMatrix&, const Surface&>, has_method<const S, void, update_t, state&, const Vector3&, const Vector3&, double, double>>;
168  // static_assert(update_method_exists, "update method not found");
169  constexpr static bool get_field_exists = has_method<const S, Result<Vector3>, get_field_t, state&, const Vector3&>;
170  // static_assert(get_field_exists, "getField method not found");
171 
175  };
176 // clang-format on
177 
178 // clang-format off
179  template <typename S, typename state = typename S::State>
182  static_assert(common_stepper_concept_fullfilled, "Common stepper concept not fulfilled");
183 
184  // TODO for now we do not check if the ComponentProxy does fulfill a concept
185  template <typename T> using component_proxy_t = typename T::ComponentProxy;
186  constexpr static bool component_proxy_exists = exists<component_proxy_t, S>;
187  // static_assert(component_proxy_exists, "!component_proxy_exists");
188 
189  // TODO for now we do not check if the ConstComponentProxy does fulfill a concept
190  template <typename T> using const_component_proxy_t = typename T::ConstComponentProxy;
191  constexpr static bool const_component_proxy_exists = exists<const_component_proxy_t, S>;
192  // static_assert(const_component_proxy_exists, "!const_component_proxy_exists");
193 
194  METHOD_TRAIT(number_components_t, numberComponents);
195  constexpr static bool number_components_exists = has_method<const S, std::size_t, number_components_t, const state&>;
196  // static_assert(number_components_exists, "!num_components_exists");
197 
198  // TODO We cannot check addComponents since it is a template member function
199 
200  METHOD_TRAIT(clear_components_t, clearComponents);
201  constexpr static bool clear_components_exists = has_method<const S, void, clear_components_t, state&>;
202  // static_assert(clear_components_exists, "!clear_components_exists");
203 
204  METHOD_TRAIT(remove_missed_components_t, removeMissedComponents);
205  constexpr static bool remove_missed_components_exists = has_method<const S, void, remove_missed_components_t, state&>;
206  // static_assert(remove_missed_components_exists, "!remove_missed_components_exists");
207 
214  };
215 // clang-format on
216 
217 } // namespace Stepper
218 } // namespace Concepts
219 
220 template <typename stepper, typename state = typename stepper::State>
221 constexpr bool StepperConcept =
224 template <typename stepper>
225 constexpr bool StepperStateConcept =
226  Acts::Concepts ::Stepper::StepperStateConcept<stepper> ||
227  Acts::Concepts ::Stepper::MultiStepperStateConcept<stepper>;
228 } // namespace Acts