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