Back to home page

EIC code displayed by LXR

 
 

    


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

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