Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2018 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/Definitions/Common.hpp"
0013 #include "Acts/Definitions/Direction.hpp"
0014 #include "Acts/Geometry/GeometryIdentifier.hpp"
0015 #include "Acts/Propagator/ConstrainedStep.hpp"
0016 #include "Acts/Propagator/Propagator.hpp"
0017 #include "Acts/Surfaces/Surface.hpp"
0018 #include "Acts/Utilities/Logger.hpp"
0019 
0020 #include <memory>
0021 #include <vector>
0022 
0023 namespace Acts {
0024 
0025 class Surface;
0026 
0027 namespace detail {
0028 
0029 /// @brief The step information for recording
0030 ///
0031 /// The surface object could be a temporarily created object
0032 /// and as the Step vector is collected and written out at a
0033 /// later stage, the surface is referenced counted here.
0034 struct Step {
0035   ConstrainedStep stepSize;
0036   Direction navDir;
0037   Vector3 position = Vector3(0., 0., 0.);
0038   Vector3 momentum = Vector3(0., 0., 0.);
0039   std::shared_ptr<const Surface> surface = nullptr;
0040   GeometryIdentifier geoID = 0;
0041 };
0042 
0043 /// @brief a step length logger for debugging the stepping
0044 ///
0045 /// It simply logs the constrained step length per step
0046 struct SteppingLogger {
0047   /// Simple result struct to be returned
0048   struct this_result {
0049     std::vector<Step> steps;
0050   };
0051 
0052   using result_type = this_result;
0053 
0054   /// Set the Logger to sterile
0055   bool sterile = false;
0056 
0057   /// SteppingLogger action for the ActionList of the Propagator
0058   ///
0059   /// @tparam propagator_state_t is the type of Propagator state
0060   /// @tparam stepper_t is the type of the Stepper
0061   /// @tparam navigator_t is the type of the Navigator
0062   ///
0063   /// @param [in,out] state is the mutable stepper state object
0064   /// @param [in] stepper the stepper in use
0065   /// @param [in] navigator the navigator in use
0066   /// @param [in,out] result is the mutable result object
0067   template <typename propagator_state_t, typename stepper_t,
0068             typename navigator_t>
0069   void operator()(propagator_state_t& state, const stepper_t& stepper,
0070                   const navigator_t& navigator, result_type& result,
0071                   const Logger& /*logger*/) const {
0072     // Don't log if you have reached the target or are sterile
0073     if (sterile || state.stage == PropagatorStage::postPropagation) {
0074       return;
0075     }
0076 
0077     // Record the propagation state
0078     Step step;
0079     step.stepSize = state.stepping.stepSize;
0080     step.navDir = state.options.direction;
0081     step.position = stepper.position(state.stepping);
0082     step.momentum = stepper.momentum(state.stepping);
0083 
0084     // Record the information about the surface
0085     if (navigator.currentSurface(state.navigation) != nullptr) {
0086       step.surface = navigator.currentSurface(state.navigation)->getSharedPtr();
0087       step.geoID = step.surface->geometryId();
0088     } else if (navigator.currentVolume(state.navigation) != nullptr) {
0089       // If there's no surface but a volume, this sets the geoID
0090       step.geoID = navigator.currentVolume(state.navigation)->geometryId();
0091     }
0092     result.steps.push_back(std::move(step));
0093   }
0094 };
0095 
0096 }  // namespace detail
0097 }  // namespace Acts