EIC 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 
18 
19 namespace Acts {
20 class Surface;
21 
22 namespace Concepts {
23 namespace Stepper {
24 
25 template <typename T>
26 using state_t = typename T::State;
27 
28 template <typename T>
29 using jacobian_t = typename T::Jacobian;
30 template <typename T>
31 using covariance_t = typename T::Covariance;
32 template <typename T>
33 using bound_state_t = typename T::BoundState;
34 template <typename T>
35 using curvilinear_state_t = typename T::CurvilinearState;
36 template <typename T>
37 using bfield_t = typename T::BField;
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(momentum_t, momentum);
44 METHOD_TRAIT(charge_t, charge);
45 METHOD_TRAIT(time_t, time);
46 METHOD_TRAIT(overstep_t, overstepLimit);
47 METHOD_TRAIT(bound_state_method_t, boundState);
48 METHOD_TRAIT(curvilinear_state_method_t, curvilinearState);
49 METHOD_TRAIT(update_t, update);
50 METHOD_TRAIT(covariance_transport_t, covarianceTransport);
51 METHOD_TRAIT(step_t, step);
52 METHOD_TRAIT(update_surface_status_t, updateSurfaceStatus);
53 METHOD_TRAIT(set_step_size_t, setStepSize);
54 METHOD_TRAIT(release_step_size_t, releaseStepSize);
55 METHOD_TRAIT(output_step_size_t, outputStepSize);
56 
57 template <typename T>
58 using cov_transport_t = decltype(std::declval<T>().covTransport);
59 template <typename T>
60 using cov_t = decltype(std::declval<T>().cov);
61 template <typename T>
62 using nav_dir_t = decltype(std::declval<T>().navDir);
63 template <typename T>
64 using path_accumulated_t = decltype(std::declval<T>().pathAccumulated);
65 template <typename T>
66 using step_size_t = decltype(std::declval<T>().stepSize);
67 
68 // clang-format off
69  template <typename S>
70  constexpr bool StepperStateConcept
71  = require<has_member<S, cov_transport_t, bool>,
72  has_member<S, cov_t, BoundSymMatrix>,
73  has_member<S, nav_dir_t, NavigationDirection>,
74  has_member<S, path_accumulated_t, double>,
75  has_member<S, step_size_t, ConstrainedStep>
76  >;
77 // clang-format on
78 
79 // clang-format off
80  template <typename S, typename state = typename S::State>
81  struct StepperConcept {
82  constexpr static bool state_exists = exists<state_t, S>;
83  static_assert(state_exists, "State type not found");
84  constexpr static bool jacobian_exists = exists<jacobian_t, S>;
85  static_assert(jacobian_exists, "Jacobian type not found");
86  constexpr static bool covariance_exists = exists<covariance_t, S>;
87  static_assert(covariance_exists, "Covariance type not found");
88  constexpr static bool bound_state_exists = exists<bound_state_t, S>;
89  static_assert(bound_state_exists, "BoundState type not found");
90  constexpr static bool curvilinear_state_exists = exists<curvilinear_state_t, S>;
91  static_assert(curvilinear_state_exists, "CurvilinearState type not found");
92  constexpr static bool bfield_exists = exists<bfield_t, S>;
93  static_assert(bfield_exists, "BField type not found");
94  constexpr static bool reset_state_exists = has_method<const S, void, reset_state_t, state&, const BoundVector&, const BoundSymMatrix&, const Surface&, const NavigationDirection, const double>;
95  static_assert(reset_state_exists, "resetState method not found");
96  constexpr static bool get_field_exists = has_method<const S, Vector3D, get_field_t, state&, const Vector3D&>;
97  static_assert(get_field_exists, "getField method not found");
98  constexpr static bool position_exists = has_method<const S, Vector3D, position_t, const state&>;
99  static_assert(position_exists, "position method not found");
100  constexpr static bool direction_exists = has_method<const S, Vector3D, direction_t, const state&>;
101  static_assert(direction_exists, "direction method not found");
102  constexpr static bool momentum_exists = has_method<const S, double, momentum_t, const state&>;
103  static_assert(momentum_exists, "momentum method not found");
104  constexpr static bool charge_exists = has_method<const S, double, charge_t, const state&>;
105  static_assert(charge_exists, "charge method not found");
106  constexpr static bool time_exists = has_method<const S, double, time_t, const state&>;
107  static_assert(time_exists, "time method not found");
108  constexpr static bool overstep_exists = has_method<const S, double, overstep_t, const state&>;
109  static_assert(overstep_exists, "overstepLimit method not found");
110  constexpr static bool bound_state_method_exists= has_method<const S, typename S::BoundState, bound_state_method_t, state&, const Surface&>;
111  static_assert(bound_state_method_exists, "boundState method not found");
112  constexpr static bool curvilinear_state_method_exists = has_method<const S, typename S::CurvilinearState, curvilinear_state_method_t, state&>;
113  static_assert(curvilinear_state_method_exists, "curvilinearState method not found");
114  constexpr static bool update_method_exists = require<has_method<const S, void, update_t, state&, const FreeVector&, const BoundSymMatrix&>,
115  has_method<const S, void, update_t, state&, const Vector3D&, const Vector3D&, double, double>>;
116  static_assert(update_method_exists, "update method not found");
117  constexpr static bool covariance_transport_exists = require<has_method<const S, void, covariance_transport_t, state&>,
118  has_method<const S, void, covariance_transport_t, state&, const Surface&>>;
119  static_assert(covariance_transport_exists, "covarianceTransport method not found");
120  constexpr static bool update_surface_exists = has_method<const S, Intersection3D::Status, update_surface_status_t, state&, const Surface&, const BoundaryCheck&>;
121  static_assert(update_surface_exists, "updateSurfaceStatus method not found");
122  constexpr static bool set_step_size_exists = has_method<const S, void, set_step_size_t, state&, double, ConstrainedStep::Type>;
123  static_assert(set_step_size_exists, "setStepSize method not found");
124  constexpr static bool release_step_size_exists = has_method<const S, void, release_step_size_t, state&>;
125  static_assert(release_step_size_exists, "releaseStepSize method not found");
126  constexpr static bool output_step_size_exists = has_method<const S, std::string, output_step_size_t, const state&>;
127  static_assert(output_step_size_exists, "outputStepSize method not found");
128 
129  constexpr static bool value = require<state_exists,
140  time_exists,
149  };
150 // clang-format on
151 } // namespace Stepper
152 } // namespace Concepts
153 
154 template <typename stepper, typename state = typename stepper::State>
155 constexpr bool StepperConcept =
157 template <typename stepper>
158 constexpr bool StepperStateConcept =
159  Acts::Concepts ::Stepper::StepperStateConcept<stepper>;
160 } // namespace Acts