Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:55

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://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 = Direction::Forward();
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   /// Note that this is the total number of trials including the previous steps
0042   std::size_t nTotalTrials = 0;
0043 };
0044 
0045 /// @brief a step length logger for debugging the stepping
0046 ///
0047 /// It simply logs the constrained step length per step
0048 struct SteppingLogger {
0049   /// Simple result struct to be returned
0050   struct this_result {
0051     std::vector<Step> steps;
0052   };
0053 
0054   using result_type = this_result;
0055 
0056   /// Set the Logger to sterile
0057   bool sterile = false;
0058 
0059   /// SteppingLogger action for the ActionList of the Propagator
0060   ///
0061   /// @tparam propagator_state_t is the type of Propagator state
0062   /// @tparam stepper_t is the type of the Stepper
0063   /// @tparam navigator_t is the type of the Navigator
0064   ///
0065   /// @param [in,out] state is the mutable stepper state object
0066   /// @param [in] stepper the stepper in use
0067   /// @param [in] navigator the navigator in use
0068   /// @param [in,out] result is the mutable result object
0069   template <typename propagator_state_t, typename stepper_t,
0070             typename navigator_t>
0071   void act(propagator_state_t& state, const stepper_t& stepper,
0072            const navigator_t& navigator, result_type& result,
0073            const Logger& /*logger*/) const {
0074     // Don't log if you have reached the target or are sterile
0075     if (sterile || state.stage == PropagatorStage::postPropagation) {
0076       return;
0077     }
0078 
0079     // Record the propagation state
0080     Step step;
0081     step.stepSize = state.stepping.stepSize;
0082     step.navDir = state.options.direction;
0083     step.position = stepper.position(state.stepping);
0084     step.momentum = stepper.momentum(state.stepping);
0085     step.nTotalTrials = state.stepping.nStepTrials;
0086 
0087     // Record the information about the surface
0088     if (navigator.currentSurface(state.navigation) != nullptr) {
0089       step.surface = navigator.currentSurface(state.navigation)->getSharedPtr();
0090       step.geoID = step.surface->geometryId();
0091     } else if (navigator.currentVolume(state.navigation) != nullptr) {
0092       // If there's no surface but a volume, this sets the geoID
0093       step.geoID = navigator.currentVolume(state.navigation)->geometryId();
0094     }
0095     result.steps.push_back(std::move(step));
0096   }
0097 };
0098 
0099 }  // namespace detail
0100 }  // namespace Acts