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