|
|
|||
File indexing completed on 2026-05-31 07:47:24
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/Geometry/TrackingVolume.hpp" 0012 0013 namespace Acts { 0014 0015 /// Simple struct to select volumes 0016 struct VolumeSelector { 0017 /// Flag indicating whether to select volumes with material 0018 bool selectMaterial = true; 0019 /// Flag indicating whether to select volumes with layers 0020 bool selectLayer = false; 0021 /// Flag indicating whether to select passive volumes 0022 bool selectPassive = false; 0023 0024 /// VolumeSelector with options 0025 /// 0026 /// @param sMaterial is the directive to select material volumes 0027 /// @param sLayer is the directive to select volumes with layers 0028 /// @param sPassive is the directive to select passive volumes 0029 explicit VolumeSelector(bool sMaterial = true, bool sLayer = false, 0030 bool sPassive = false) 0031 : selectMaterial(sMaterial), 0032 selectLayer(sLayer), 0033 selectPassive(sPassive) {} 0034 0035 /// Call operator to check if a volume should be selected 0036 /// 0037 /// @param volume is the test volume 0038 /// @return true if volume meets selection criteria 0039 bool operator()(const Acts::TrackingVolume& volume) const { 0040 if (selectMaterial && volume.hasMaterial()) { 0041 return true; 0042 } 0043 if (selectLayer && volume.confinedLayers() != nullptr) { 0044 return true; 0045 } 0046 if (selectPassive) { 0047 return true; 0048 } 0049 return false; 0050 } 0051 }; 0052 0053 /// The information to be writtern out per hit volume 0054 struct VolumeHit { 0055 /// Pointer to the tracking volume that was hit 0056 const TrackingVolume* volume = nullptr; 0057 /// Position where the volume was encountered 0058 Vector3 position{}; 0059 /// Direction of propagation when volume was encountered 0060 Vector3 direction{}; 0061 }; 0062 0063 /// A Volume Collector struct 0064 /// templated with a Selector type 0065 /// 0066 /// Whenever a volume is passed in the propagation 0067 /// that satisfies the selector, it is recorded 0068 /// for further usage in the flow. 0069 template <typename Selector = VolumeSelector> 0070 struct VolumeCollector { 0071 /// The selector used for this volume 0072 Selector selector; 0073 0074 /// Simple result struct to be returned 0075 /// It has all the VolumeHit objects that 0076 /// are collected (and thus have been selected) 0077 struct this_result { 0078 /// Container of collected volume hits during propagation 0079 std::vector<VolumeHit> collected; 0080 }; 0081 0082 /// Type alias for collector result type 0083 using result_type = this_result; 0084 0085 /// Collector action for the ActionList of the Propagator 0086 /// It checks if the propagator state has a current volume, 0087 /// in which case the action is performed: 0088 /// - it records the volume given the configuration 0089 /// 0090 /// @tparam propagator_state_t is the type of Propagator state 0091 /// @tparam stepper_t Type of the stepper used for the propagation 0092 /// @tparam navigator_t Type of the navigator used for the propagation 0093 /// 0094 /// @param [in,out] state is the mutable stepper state object 0095 /// @param [in] stepper The stepper in use 0096 /// @param [in] navigator The navigator in use 0097 /// @param [in,out] result is the mutable result object 0098 /// @param logger the logger object 0099 /// @return Result of the action 0100 template <typename propagator_state_t, typename stepper_t, 0101 typename navigator_t> 0102 Result<void> act(propagator_state_t& state, const stepper_t& stepper, 0103 const navigator_t& navigator, result_type& result, 0104 const Logger& logger) const { 0105 auto currentVolume = navigator.currentVolume(state.navigation); 0106 0107 // The current volume has been assigned by the navigator 0108 if (currentVolume && selector(*currentVolume)) { 0109 // Create for recording 0110 VolumeHit volume_hit; 0111 volume_hit.volume = currentVolume; 0112 volume_hit.position = stepper.position(state.stepping); 0113 volume_hit.direction = stepper.direction(state.stepping); 0114 bool save = true; 0115 // Check if the Volume ws already encountered 0116 for (auto const& res : result.collected) { 0117 if (res.volume == volume_hit.volume) { 0118 save = false; 0119 break; 0120 } 0121 } 0122 // Save if in the result if it does not already exist 0123 if (save) { 0124 result.collected.push_back(volume_hit); 0125 // Screen output 0126 ACTS_VERBOSE("Collect volume " << currentVolume->geometryId()); 0127 } 0128 } 0129 0130 return {}; 0131 } 0132 }; 0133 0134 } // namespace Acts
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|