File indexing completed on 2025-09-17 08:01:39
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/Geometry/GeometryIdentifier.hpp"
0014 #include "Acts/Geometry/TrackingVolume.hpp"
0015 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0016 #include "Acts/Material/AccumulatedVolumeMaterial.hpp"
0017 #include "Acts/Material/MaterialGridHelper.hpp"
0018 #include "Acts/Material/MaterialInteraction.hpp"
0019 #include "Acts/Material/MaterialSlab.hpp"
0020 #include "Acts/Propagator/Navigator.hpp"
0021 #include "Acts/Propagator/Propagator.hpp"
0022 #include "Acts/Propagator/StraightLineStepper.hpp"
0023 #include "Acts/Surfaces/Surface.hpp"
0024 #include "Acts/Utilities/BinUtility.hpp"
0025 #include "Acts/Utilities/Logger.hpp"
0026
0027 #include <functional>
0028 #include <map>
0029 #include <memory>
0030 #include <utility>
0031
0032 namespace Acts {
0033
0034 class ISurfaceMaterial;
0035 class IVolumeMaterial;
0036 class TrackingGeometry;
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 class VolumeMaterialMapper {
0063 public:
0064 using StraightLinePropagator = Propagator<StraightLineStepper, Navigator>;
0065
0066
0067
0068
0069 struct Config {
0070
0071 float mappingStep = 1.;
0072 };
0073
0074
0075
0076
0077 struct State {
0078
0079 State(const GeometryContext& gctx, const MagneticFieldContext& mctx)
0080 : geoContext(gctx), magFieldContext(mctx) {}
0081
0082
0083 std::map<const GeometryIdentifier, Acts::AccumulatedVolumeMaterial>
0084 homogeneousGrid;
0085
0086
0087 std::map<const GeometryIdentifier,
0088 std::function<Acts::Vector2(Acts::Vector3)>>
0089 transform2D;
0090
0091
0092 std::map<const GeometryIdentifier, Grid2D> grid2D;
0093
0094
0095
0096 std::map<const GeometryIdentifier,
0097 std::function<Acts::Vector3(Acts::Vector3)>>
0098 transform3D;
0099
0100
0101 std::map<const GeometryIdentifier, Grid3D> grid3D;
0102
0103
0104 std::map<const GeometryIdentifier, BinUtility> materialBin;
0105
0106
0107 std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>>
0108 surfaceMaterial;
0109
0110
0111 std::map<GeometryIdentifier, std::unique_ptr<const IVolumeMaterial>>
0112 volumeMaterial;
0113
0114
0115 std::reference_wrapper<const GeometryContext> geoContext;
0116
0117
0118 std::reference_wrapper<const MagneticFieldContext> magFieldContext;
0119 };
0120
0121
0122 VolumeMaterialMapper() = delete;
0123
0124
0125
0126
0127
0128
0129 VolumeMaterialMapper(const Config& cfg, StraightLinePropagator propagator,
0130 std::unique_ptr<const Logger> slogger = getDefaultLogger(
0131 "VolumeMaterialMapper", Logging::INFO));
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 State createState(const GeometryContext& gctx,
0143 const MagneticFieldContext& mctx,
0144 const TrackingGeometry& tGeometry) const;
0145
0146
0147
0148
0149
0150
0151
0152
0153 void finalizeMaps(State& mState) const;
0154
0155
0156
0157
0158
0159
0160
0161
0162 void mapMaterialTrack(State& mState, RecordedMaterialTrack& mTrack) const;
0163
0164 private:
0165
0166 struct BoundSurfaceSelector {
0167 bool operator()(const Surface& sf) const {
0168 return (sf.geometryId().boundary() != 0);
0169 }
0170 };
0171
0172
0173 struct MaterialVolumeSelector {
0174 bool operator()(const TrackingVolume& vf) const {
0175 return (vf.volumeMaterial() != nullptr);
0176 }
0177 };
0178
0179
0180
0181
0182
0183 void resolveMaterialVolume(State& mState,
0184 const TrackingVolume& tVolume) const;
0185
0186
0187
0188
0189
0190 void checkAndInsert(State& mState, const TrackingVolume& volume) const;
0191
0192
0193
0194
0195
0196 void collectMaterialSurfaces(State& mState,
0197 const TrackingVolume& tVolume) const;
0198
0199
0200
0201
0202
0203
0204
0205
0206 void createExtraHits(
0207 State& mState,
0208 std::pair<const GeometryIdentifier, BinUtility>& currentBinning,
0209 Acts::MaterialSlab properties, const Vector3& position,
0210 Vector3 direction) const;
0211
0212
0213 const Logger& logger() const { return *m_logger; }
0214
0215
0216 Config m_cfg;
0217
0218
0219 StraightLinePropagator m_propagator;
0220
0221
0222 std::unique_ptr<const Logger> m_logger;
0223 };
0224
0225 }