File indexing completed on 2025-01-18 09:10:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Geometry/TrackingVolume.hpp"
0012
0013 #include <sstream>
0014
0015 namespace Acts {
0016
0017
0018 struct VolumeSelector {
0019 bool selectMaterial = true;
0020 bool selectLayer = false;
0021 bool selectPassive = false;
0022
0023
0024
0025
0026
0027
0028 VolumeSelector(bool sMaterial = true, bool sLayer = false,
0029 bool sPassive = false)
0030 : selectMaterial(sMaterial),
0031 selectLayer(sLayer),
0032 selectPassive(sPassive) {}
0033
0034
0035
0036
0037 bool operator()(const Acts::TrackingVolume& volume) const {
0038 if (selectMaterial && volume.volumeMaterial() != nullptr) {
0039 return true;
0040 }
0041 if (selectLayer && volume.confinedLayers() != nullptr) {
0042 return true;
0043 }
0044 if (selectPassive) {
0045 return true;
0046 }
0047 return false;
0048 }
0049 };
0050
0051
0052 struct VolumeHit {
0053 const TrackingVolume* volume = nullptr;
0054 Vector3 position;
0055 Vector3 direction;
0056 };
0057
0058
0059
0060
0061
0062
0063
0064 template <typename Selector = VolumeSelector>
0065 struct VolumeCollector {
0066
0067 Selector selector;
0068
0069
0070
0071
0072 struct this_result {
0073 std::vector<VolumeHit> collected;
0074 };
0075
0076 using result_type = this_result;
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 template <typename propagator_state_t, typename stepper_t,
0093 typename navigator_t>
0094 void act(propagator_state_t& state, const stepper_t& stepper,
0095 const navigator_t& navigator, result_type& result,
0096 const Logger& logger) const {
0097 auto currentVolume = navigator.currentVolume(state.navigation);
0098
0099
0100 if (currentVolume && selector(*currentVolume)) {
0101
0102 VolumeHit volume_hit;
0103 volume_hit.volume = currentVolume;
0104 volume_hit.position = stepper.position(state.stepping);
0105 volume_hit.direction = stepper.direction(state.stepping);
0106 bool save = true;
0107
0108 for (auto const& res : result.collected) {
0109 if (res.volume == volume_hit.volume) {
0110 save = false;
0111 break;
0112 }
0113 }
0114
0115 if (save) {
0116 result.collected.push_back(volume_hit);
0117
0118 ACTS_VERBOSE("Collect volume " << currentVolume->geometryId());
0119 }
0120 }
0121 }
0122 };
0123
0124 }