Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:19

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2019-2020 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/EventData/TrackParameters.hpp"
0013 #include "Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp"
0014 #include "Acts/Propagator/ConstrainedStep.hpp"
0015 #include "Acts/Surfaces/BoundaryCheck.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "Acts/Utilities/Intersection.hpp"
0018 #include "Acts/Utilities/Logger.hpp"
0019 #include "Acts/Utilities/TypeTraits.hpp"
0020 
0021 namespace Acts {
0022 class Surface;
0023 
0024 namespace Concepts::Stepper {
0025 
0026 template <typename T>
0027 using state_t = typename T::State;
0028 
0029 template <typename T>
0030 using jacobian_t = typename T::Jacobian;
0031 template <typename T>
0032 using covariance_t = typename T::Covariance;
0033 template <typename T>
0034 using bound_state_t = typename T::BoundState;
0035 template <typename T>
0036 using curvilinear_state_t = typename T::CurvilinearState;
0037 
0038 METHOD_TRAIT(reset_state_t, resetState);
0039 METHOD_TRAIT(get_field_t, getField);
0040 METHOD_TRAIT(position_t, position);
0041 METHOD_TRAIT(direction_t, direction);
0042 METHOD_TRAIT(qop_t, qOverP);
0043 METHOD_TRAIT(absolute_momentum_t, absoluteMomentum);
0044 METHOD_TRAIT(momentum_t, momentum);
0045 METHOD_TRAIT(charge_t, charge);
0046 METHOD_TRAIT(time_t, time);
0047 METHOD_TRAIT(overstep_t, overstepLimit);
0048 METHOD_TRAIT(bound_state_method_t, boundState);
0049 METHOD_TRAIT(curvilinear_state_method_t, curvilinearState);
0050 METHOD_TRAIT(update_t, update);
0051 METHOD_TRAIT(covariance_transport_bound_t, transportCovarianceToBound);
0052 METHOD_TRAIT(covariance_transport_curvilinear_t,
0053              transportCovarianceToCurvilinear);
0054 METHOD_TRAIT(step_t, step);
0055 METHOD_TRAIT(update_surface_status_t, updateSurfaceStatus);
0056 METHOD_TRAIT(update_step_size_t, updateStepSize);
0057 METHOD_TRAIT(get_step_size_t, getStepSize);
0058 METHOD_TRAIT(release_step_size_t, releaseStepSize);
0059 METHOD_TRAIT(output_step_size_t, outputStepSize);
0060 
0061 template <typename T>
0062 using cov_transport_t = decltype(std::declval<T>().covTransport);
0063 template <typename T>
0064 using cov_t = decltype(std::declval<T>().cov);
0065 template <typename T>
0066 using path_accumulated_t = decltype(std::declval<T>().pathAccumulated);
0067 template <typename T>
0068 using step_size_t = decltype(std::declval<T>().stepSize);
0069 
0070 // clang-format off
0071     template <typename S>
0072     constexpr bool StepperStateConcept
0073       = require<has_member<S, cov_transport_t, bool>,
0074                 has_member<S, cov_t, BoundSquareMatrix>,
0075                 has_member<S, path_accumulated_t, double>//,
0076 //                 has_member<S, step_size_t, ConstrainedStep>
0077                >;
0078 // clang-format on
0079 
0080 // clang-format off
0081 template <typename S>
0082 constexpr bool MultiStepperStateConcept= require<
0083   has_member<S, cov_transport_t, bool>,
0084   has_member<S, path_accumulated_t, double>
0085 >;
0086 // clang-format on
0087 
0088 // clang-format off
0089     template <typename S, typename state = typename S::State>
0090       struct CommonStepperConcept {
0091         constexpr static bool state_exists = exists<state_t, S>;
0092         static_assert(state_exists, "State type not found");
0093         constexpr static bool jacobian_exists = exists<jacobian_t, S>;
0094         static_assert(jacobian_exists, "Jacobian type not found");
0095         constexpr static bool covariance_exists = exists<covariance_t, S>;
0096         static_assert(covariance_exists, "Covariance type not found");
0097         constexpr static bool bound_state_exists = exists<bound_state_t, S>;
0098         static_assert(bound_state_exists, "BoundState type not found");
0099         constexpr static bool curvilinear_state_exists = exists<curvilinear_state_t, S>;
0100         static_assert(curvilinear_state_exists, "CurvilinearState type not found");
0101         constexpr static bool reset_state_exists = has_method<const S, void, reset_state_t, state&, const BoundVector&, const BoundSquareMatrix&, const Surface&, const double>;
0102         static_assert(reset_state_exists, "resetState method not found");
0103         constexpr static bool position_exists = has_method<const S, Vector3, position_t, const state&>;
0104         static_assert(position_exists, "position method not found");
0105         constexpr static bool direction_exists = has_method<const S, Vector3, direction_t, const state&>;
0106         static_assert(direction_exists, "direction method not found");
0107         constexpr static bool qop_exists = has_method<const S, double, qop_t, const state&>;
0108         static_assert(qop_exists, "qOverP method not found");
0109         constexpr static bool absolute_momentum_exists = has_method<const S, double, absolute_momentum_t, const state&>;
0110         static_assert(absolute_momentum_exists, "absoluteMomentum method not found");
0111         constexpr static bool momentum_exists = has_method<const S, Vector3, momentum_t, const state&>;
0112         static_assert(momentum_exists, "momentum method not found");
0113         constexpr static bool charge_exists = has_method<const S, double, charge_t, const state&>;
0114         static_assert(charge_exists, "charge method not found");
0115         constexpr static bool time_exists = has_method<const S, double, time_t, const state&>;
0116         static_assert(time_exists, "time method not found");
0117         constexpr static bool overstep_exists = has_method<const S, double, overstep_t, const state&>;
0118         static_assert(overstep_exists, "overstepLimit method not found");
0119         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&>;
0120         static_assert(bound_state_method_exists, "boundState method not found");
0121         constexpr static bool curvilinear_state_method_exists = has_method<const S, typename S::CurvilinearState, curvilinear_state_method_t, state&, bool>;
0122         static_assert(curvilinear_state_method_exists, "curvilinearState method not found");
0123         constexpr static bool covariance_transport_exists = require<has_method<const S, void, covariance_transport_curvilinear_t, state&>,
0124                                                                     has_method<const S, void, covariance_transport_bound_t, state&, const Surface&, const FreeToBoundCorrection&>>;
0125         static_assert(covariance_transport_exists, "covarianceTransport method not found");
0126         constexpr static bool update_surface_exists = has_method<const S, Intersection3D::Status, update_surface_status_t, state&, const Surface&, std::uint8_t, Direction, const BoundaryCheck&, ActsScalar, const Logger&>;
0127         static_assert(update_surface_exists, "updateSurfaceStatus method not found");
0128         constexpr static bool update_step_size_exists = has_method<const S, void, update_step_size_t, state&, double, ConstrainedStep::Type, bool>;
0129         static_assert(update_step_size_exists, "updateStepSize method not found");
0130         constexpr static bool get_step_size_exists = has_method<const S, double, get_step_size_t, const state &, ConstrainedStep::Type>;
0131         static_assert(get_step_size_exists, "getStepSize method not found");
0132         constexpr static bool release_step_size_exists = has_method<const S, void, release_step_size_t, state&, ConstrainedStep::Type>;
0133         static_assert(release_step_size_exists, "releaseStepSize method not found");
0134         constexpr static bool output_step_size_exists = has_method<const S, std::string, output_step_size_t, const state&>;
0135         static_assert(output_step_size_exists, "outputStepSize method not found");
0136 
0137         constexpr static bool value = require<state_exists,
0138                                               jacobian_exists,
0139                                               covariance_exists,
0140                                               bound_state_exists,
0141                                               curvilinear_state_exists,
0142                                               position_exists,
0143                                               direction_exists,
0144                                               qop_exists,
0145                                               absolute_momentum_exists,
0146                                               momentum_exists,
0147                                               charge_exists,
0148                                               time_exists,
0149                                               bound_state_method_exists,
0150                                               curvilinear_state_method_exists,
0151                                               covariance_transport_exists,
0152                                               update_surface_exists,
0153                                               update_step_size_exists,
0154                                               release_step_size_exists,
0155                                               output_step_size_exists>;
0156 
0157       };
0158 // clang-format on
0159 
0160 // clang-format off
0161     // NOTE This static_asserts in here must be commented out, since it would break the compilation for the MultiStepper
0162     template <typename S, typename state = typename S::State>
0163       struct SingleStepperConcept {
0164         constexpr static bool common_stepper_concept_fullfilled = CommonStepperConcept<S, state>::value;
0165         static_assert(common_stepper_concept_fullfilled, "Stepper does not fulfill common stepper concept");
0166         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>>;
0167         // static_assert(update_method_exists, "update method not found");
0168         constexpr static bool get_field_exists = has_method<const S, Result<Vector3>, get_field_t, state&, const Vector3&>;
0169         // static_assert(get_field_exists, "getField method not found");
0170 
0171         constexpr static bool value = require<common_stepper_concept_fullfilled,
0172                                               update_method_exists,
0173                                               get_field_exists>;
0174       };
0175 // clang-format on
0176 
0177 // clang-format off
0178     template <typename S, typename state = typename S::State>
0179       struct MultiStepperConcept {
0180         constexpr static bool common_stepper_concept_fullfilled = CommonStepperConcept<S, state>::value;
0181         static_assert(common_stepper_concept_fullfilled, "Common stepper concept not fulfilled");
0182 
0183         // TODO for now we do not check if the ComponentProxy does fulfill a concept
0184         template <typename T> using component_proxy_t = typename T::ComponentProxy;
0185         constexpr static bool component_proxy_exists = exists<component_proxy_t, S>;
0186         // static_assert(component_proxy_exists, "!component_proxy_exists");
0187 
0188         // TODO for now we do not check if the ConstComponentProxy does fulfill a concept
0189         template <typename T> using const_component_proxy_t = typename T::ConstComponentProxy;
0190         constexpr static bool const_component_proxy_exists = exists<const_component_proxy_t, S>;
0191         // static_assert(const_component_proxy_exists, "!const_component_proxy_exists");
0192 
0193         METHOD_TRAIT(number_components_t, numberComponents);
0194         constexpr static bool number_components_exists = has_method<const S, std::size_t, number_components_t, const state&>;
0195         // static_assert(number_components_exists, "!num_components_exists");
0196 
0197         // TODO We cannot check addComponents since it is a template member function
0198 
0199         METHOD_TRAIT(clear_components_t, clearComponents);
0200         constexpr static bool clear_components_exists = has_method<const S, void, clear_components_t, state&>;
0201         // static_assert(clear_components_exists, "!clear_components_exists");
0202 
0203         METHOD_TRAIT(remove_missed_components_t, removeMissedComponents);
0204         constexpr static bool remove_missed_components_exists = has_method<const S, void, remove_missed_components_t, state&>;
0205         // static_assert(remove_missed_components_exists, "!remove_missed_components_exists");
0206 
0207         constexpr static bool value = require<common_stepper_concept_fullfilled,
0208                                               component_proxy_exists,
0209                                               const_component_proxy_exists,
0210                                               number_components_exists,
0211                                               clear_components_exists,
0212                                               remove_missed_components_exists>;
0213         };
0214 // clang-format on
0215 
0216 }  // namespace Concepts::Stepper
0217 
0218 template <typename stepper, typename state = typename stepper::State>
0219 constexpr bool StepperConcept =
0220     Acts::Concepts ::Stepper::SingleStepperConcept<stepper, state>::value ||
0221     Acts::Concepts ::Stepper::MultiStepperConcept<stepper, state>::value;
0222 template <typename stepper>
0223 constexpr bool StepperStateConcept =
0224     Acts::Concepts ::Stepper::StepperStateConcept<stepper> ||
0225     Acts::Concepts ::Stepper::MultiStepperStateConcept<stepper>;
0226 }  // namespace Acts