File indexing completed on 2025-01-18 09:10:54
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/EventData/TrackParameters.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0014 #include "Acts/Material/interface/IAssignmentFinder.hpp"
0015 #include "Acts/Propagator/ActorList.hpp"
0016 #include "Acts/Propagator/Propagator.hpp"
0017 #include "Acts/Propagator/SurfaceCollector.hpp"
0018 #include "Acts/Surfaces/Surface.hpp"
0019 #include "Acts/Utilities/Logger.hpp"
0020 #include "Acts/Utilities/VectorHelpers.hpp"
0021
0022 #include <utility>
0023 #include <vector>
0024
0025 namespace Acts {
0026
0027
0028
0029
0030 struct MaterialSurfaceIdentifier {
0031
0032 bool operator()(const Surface& sf) const {
0033 return (sf.surfaceMaterial() != nullptr);
0034 }
0035 };
0036
0037
0038 struct InteractionVolumeCollector {
0039
0040
0041
0042
0043 struct this_result {
0044 std::map<GeometryIdentifier, IAssignmentFinder::VolumeAssignment> collected;
0045 };
0046
0047 using result_type = this_result;
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 template <typename propagator_state_t, typename stepper_t,
0063 typename navigator_t>
0064 void act(propagator_state_t& state, const stepper_t& stepper,
0065 const navigator_t& navigator, result_type& result,
0066 const Logger& ) const {
0067
0068 auto currentVolume = navigator.currentVolume(state.navigation);
0069
0070
0071 if (currentVolume != nullptr) {
0072 auto collIt = result.collected.find(currentVolume->geometryId());
0073
0074 if (collIt == result.collected.end() &&
0075 currentVolume->volumeMaterial() != nullptr) {
0076 Vector3 entryPosition = stepper.position(state.stepping);
0077 Vector3 exitPosition = entryPosition;
0078 IAssignmentFinder::VolumeAssignment vAssignment{
0079 InteractionVolume(currentVolume), entryPosition, exitPosition};
0080 result.collected.emplace(currentVolume->geometryId(), vAssignment);
0081 } else if (collIt != result.collected.end()) {
0082
0083 (collIt->second).exit = stepper.position(state.stepping);
0084 }
0085 }
0086 }
0087 };
0088
0089
0090
0091
0092
0093
0094
0095
0096 template <typename propagator_t>
0097 class PropagatorMaterialAssigner final : public IAssignmentFinder {
0098 public:
0099
0100
0101 PropagatorMaterialAssigner(propagator_t propagator)
0102 : m_propagator(std::move(propagator)) {}
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113 std::pair<std::vector<IAssignmentFinder::SurfaceAssignment>,
0114 std::vector<IAssignmentFinder::VolumeAssignment>>
0115 assignmentCandidates(const GeometryContext& gctx,
0116 const MagneticFieldContext& mctx,
0117 const Vector3& position,
0118 const Vector3& direction) const final {
0119
0120 std::pair<std::vector<IAssignmentFinder::SurfaceAssignment>,
0121 std::vector<IAssignmentFinder::VolumeAssignment>>
0122 candidates;
0123
0124 using VectorHelpers::makeVector4;
0125
0126 NeutralCurvilinearTrackParameters start(
0127 makeVector4(position, 0), direction, 1, std::nullopt,
0128 NeutralParticleHypothesis::geantino());
0129
0130
0131 using MaterialSurfaceCollector =
0132 SurfaceCollector<MaterialSurfaceIdentifier>;
0133 using ActorList = ActorList<MaterialSurfaceCollector,
0134 InteractionVolumeCollector, EndOfWorldReached>;
0135 using PropagatorOptions =
0136 typename propagator_t::template Options<ActorList>;
0137
0138 PropagatorOptions options(gctx, mctx);
0139
0140 const auto& result = m_propagator.propagate(start, options).value();
0141
0142
0143 auto scResult =
0144 result.template get<MaterialSurfaceCollector::result_type>();
0145 auto mappingSurfaces = scResult.collected;
0146
0147 for (auto& mSurface : mappingSurfaces) {
0148 candidates.first.push_back(IAssignmentFinder::SurfaceAssignment{
0149 mSurface.surface, mSurface.position, direction});
0150 }
0151
0152
0153 auto vcResult =
0154 result.template get<InteractionVolumeCollector::result_type>();
0155 for (const auto& [geoId, vIntersection] : vcResult.collected) {
0156 candidates.second.push_back(vIntersection);
0157 }
0158
0159
0160 return candidates;
0161 }
0162
0163 private:
0164 propagator_t m_propagator;
0165 };
0166
0167 }