Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-25 07:55:17

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/Propagator/Propagator.hpp"
0012 #include "Acts/Surfaces/Surface.hpp"
0013 
0014 #include <sstream>
0015 
0016 namespace Acts {
0017 
0018 /// Simple struct to select surfaces
0019 struct SurfaceSelector {
0020   /// Flag indicating whether to select sensitive surfaces
0021   bool selectSensitive = true;
0022   /// Flag indicating whether to select surfaces with material
0023   bool selectMaterial = false;
0024   /// Flag indicating whether to select passive surfaces
0025   bool selectPassive = false;
0026 
0027   /// SurfaceSelector with options
0028   ///
0029   /// @param sSensitive is the directive to select sensitive surfaces
0030   /// @param sMaterial is the directive to select material surfaces
0031   /// @param sPassive is the directive to select passive surfaces
0032   explicit SurfaceSelector(bool sSensitive = true, bool sMaterial = false,
0033                            bool sPassive = false)
0034       : selectSensitive(sSensitive),
0035         selectMaterial(sMaterial),
0036         selectPassive(sPassive) {}
0037 
0038   /// Call operator to check if a surface should be selected
0039   ///
0040   /// @param surface is the test surface
0041   /// @return true if surface meets selection criteria
0042   bool operator()(const Acts::Surface& surface) const {
0043     if (selectSensitive && surface.associatedDetectorElement() != nullptr) {
0044       return true;
0045     }
0046     if (selectMaterial && surface.surfaceMaterial() != nullptr) {
0047       return true;
0048     }
0049     if (selectPassive) {
0050       return true;
0051     }
0052     return false;
0053   }
0054 };
0055 
0056 /// The information to be writtern out per hit surface
0057 struct SurfaceHit {
0058   /// Pointer to the surface that was hit
0059   const Surface* surface = nullptr;
0060   /// Position where the surface was encountered
0061   Vector3 position;
0062   /// Direction of propagation when surface was encountered
0063   Vector3 direction;
0064 };
0065 
0066 /// A Surface Collector struct
0067 /// templated with a Selector type
0068 ///
0069 /// Whenever a surface is passed in the propagation
0070 /// that satisfies the selector, it is recorded
0071 /// for further usage in the flow.
0072 template <typename Selector = SurfaceSelector>
0073 struct SurfaceCollector {
0074   /// The selector used for this surface
0075   Selector selector;
0076 
0077   /// Simple result struct to be returned
0078   /// It has all the SurfaceHit objects that
0079   /// are collected (and thus have been selected)
0080   struct this_result {
0081     /// Container of collected surface hits during propagation
0082     std::vector<SurfaceHit> collected;
0083   };
0084 
0085   /// Type alias for collector result type
0086   using result_type = this_result;
0087 
0088   /// Collector action for the ActionList of the Propagator
0089   /// It checks if the propagator state has a current surface,
0090   /// in which case the action is performed:
0091   /// - it records the surface given the configuration
0092   ///
0093   /// @tparam propagator_state_t is the type of Propagator state
0094   /// @tparam stepper_t Type of the stepper used for the propagation
0095   /// @tparam navigator_t Type of the navigator used for the propagation
0096   ///
0097   /// @param [in,out] state is the mutable stepper state object
0098   /// @param [in] stepper The stepper in use
0099   /// @param [in] navigator The navigator in use
0100   /// @param [in,out] result is the mutable result object
0101   /// @param logger a logger instance
0102   template <typename propagator_state_t, typename stepper_t,
0103             typename navigator_t>
0104   void act(propagator_state_t& state, const stepper_t& stepper,
0105            const navigator_t& navigator, result_type& result,
0106            const Logger& logger) const {
0107     if (state.stage == PropagatorStage::postPropagation) {
0108       return;
0109     }
0110 
0111     auto currentSurface = navigator.currentSurface(state.navigation);
0112 
0113     // The current surface has been assigned by the navigator
0114     if (currentSurface && selector(*currentSurface)) {
0115       // Create for recording
0116       SurfaceHit surface_hit;
0117       surface_hit.surface = currentSurface;
0118       surface_hit.position = stepper.position(state.stepping);
0119       surface_hit.direction = stepper.direction(state.stepping);
0120       // Save if in the result
0121       result.collected.push_back(surface_hit);
0122       // Screen output
0123       ACTS_VERBOSE("Collect surface  " << currentSurface->geometryId());
0124     }
0125   }
0126 };
0127 
0128 }  // namespace Acts