|
|
|||
File indexing completed on 2026-09-01 08:17:58
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/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 /// @brief VolumeMaterialMapper 0040 /// 0041 /// This maps material information from a 3D geometry onto the TrackingGeometry 0042 /// with its volume material description, driven by a propagation through the 0043 /// geometry. 0044 /// 0045 /// @deprecated Use @ref Acts::MaterialMapper instead, composed with an 0046 /// @ref Acts::IAssignmentFinder and an @ref Acts::ISurfaceMaterialAccumulator. 0047 /// See @ref material_mapping for the current, navigation-independent procedure. 0048 /// 0049 /// The process runs as such: 0050 /// 0051 /// 1) TrackingGeometry is parsed and for each Volume with 0052 /// ProtoVolumeMaterial a local store is initialized 0053 /// the identification is done hereby through the Volume::GeometryIdentifier 0054 /// 0055 /// 2) A number of N material tracks is read in, each track has : 0056 /// origin, direction, material steps (< position, step length, x0, l0, a, 0057 /// z, rho >, thichness) 0058 /// 0059 /// for each track: 0060 /// volume along the origin/direction path are collected. 0061 /// the step are then associated to volume inside which they are. 0062 /// Additional step are created along the track direction. 0063 /// 0064 /// 3) Each 'hit' bin per event is counted and averaged at the end of the run 0065 /// 0066 /// @ingroup material_mapping 0067 class VolumeMaterialMapper { 0068 public: 0069 /// Type alias for straight line propagator used in material mapping 0070 using StraightLinePropagator = Propagator<StraightLineStepper, Navigator>; 0071 0072 /// @struct Config 0073 /// 0074 /// Nested Configuration struct for the material mapper 0075 struct Config { 0076 /// Size of the step for the step extrapolation 0077 float mappingStep = 1.; 0078 }; 0079 0080 /// @struct State 0081 /// 0082 /// Nested State struct which is used for the mapping prococess 0083 struct State { 0084 /// Constructor of the State with contexts 0085 /// @param gctx Geometry context for volume material mapping 0086 /// @param mctx Magnetic field context for volume material mapping 0087 State(const GeometryContext& gctx, const MagneticFieldContext& mctx) 0088 : geoContext(gctx), magFieldContext(mctx) {} 0089 0090 /// The recorded material per geometry ID 0091 std::map<const GeometryIdentifier, Acts::AccumulatedVolumeMaterial> 0092 homogeneousGrid; 0093 0094 /// The recorded 2D transform associated the grid for each geometry ID 0095 std::map<const GeometryIdentifier, 0096 std::function<Acts::Vector2(Acts::Vector3)>> 0097 transform2D; 0098 0099 /// The 2D material grid for each geometry ID 0100 std::map<const GeometryIdentifier, Grid2D> grid2D; 0101 0102 /// The recorded 3D transform associated the material grid for each geometry 0103 /// ID 0104 std::map<const GeometryIdentifier, 0105 std::function<Acts::Vector3(Acts::Vector3)>> 0106 transform3D; 0107 0108 /// The 3D material grid for each geometry ID 0109 std::map<const GeometryIdentifier, Grid3D> grid3D; 0110 0111 /// The binning for each geometry ID 0112 std::map<const GeometryIdentifier, BinUtility> materialBin; 0113 0114 /// The surface material of the input tracking geometry 0115 std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>> 0116 surfaceMaterial; 0117 0118 /// The created volume material from it 0119 std::map<GeometryIdentifier, std::unique_ptr<const IVolumeMaterial>> 0120 volumeMaterial; 0121 0122 /// Reference to the geometry context for the mapping 0123 std::reference_wrapper<const GeometryContext> geoContext; 0124 0125 /// Reference to the magnetic field context 0126 std::reference_wrapper<const MagneticFieldContext> magFieldContext; 0127 }; 0128 0129 /// Delete the Default constructor 0130 VolumeMaterialMapper() = delete; 0131 0132 /// Constructor with config object 0133 /// 0134 /// @param cfg Configuration struct 0135 /// @param propagator The straight line propagator 0136 /// @param slogger The logger 0137 /// @deprecated Material mapping with propagation is deprecated. Use 0138 /// MaterialMapper instead. 0139 [[deprecated( 0140 "Material mapping with propagation is deprecated. Use MaterialMapper " 0141 "instead.")]] 0142 VolumeMaterialMapper(const Config& cfg, StraightLinePropagator propagator, 0143 std::unique_ptr<const Logger> slogger = getDefaultLogger( 0144 "VolumeMaterialMapper", Logging::INFO)); 0145 0146 /// @brief helper method that creates the cache for the mapping 0147 /// 0148 /// @param[in] gctx The geometry context to use 0149 /// @param[in] mctx The magnetic field context to use 0150 /// @param[in] tGeometry The geometry which should be mapped 0151 /// 0152 /// This method takes a TrackingGeometry, 0153 /// finds all surfaces with material proxis 0154 /// and returns you a Cache object tO be used 0155 /// @return State object configured for volume material mapping 0156 State createState(const GeometryContext& gctx, 0157 const MagneticFieldContext& mctx, 0158 const TrackingGeometry& tGeometry) const; 0159 0160 /// @brief Method to finalize the maps 0161 /// 0162 /// It calls the final run averaging and then transforms 0163 /// the Homogeneous material into HomogeneousVolumeMaterial and 0164 /// the 2D and 3D grid into a InterpolatedMaterialMap 0165 /// 0166 /// @param mState 0167 void finalizeMaps(State& mState) const; 0168 0169 /// Process/map a single track 0170 /// 0171 /// @note the RecordedMaterialSlab of the track are assumed 0172 /// to be ordered from the starting position along the starting direction 0173 /// 0174 /// @param mState The current state map 0175 /// @param mTrack The material track to be mapped 0176 /// @return Result of the mapping process 0177 Result<void> mapMaterialTrack(State& mState, 0178 RecordedMaterialTrack& mTrack) const; 0179 0180 private: 0181 /// selector for finding surface 0182 struct BoundSurfaceSelector { 0183 bool operator()(const Surface& sf) const { 0184 return (sf.geometryId().boundary() != 0); 0185 } 0186 }; 0187 0188 /// selector for finding 0189 struct MaterialVolumeSelector { 0190 bool operator()(const TrackingVolume& vf) const { return vf.hasMaterial(); } 0191 }; 0192 0193 /// @brief finds all surfaces with ProtoVolumeMaterial of a volume 0194 /// 0195 /// @param mState The state to be filled 0196 /// @param tVolume is current TrackingVolume 0197 void resolveMaterialVolume(State& mState, 0198 const TrackingVolume& tVolume) const; 0199 0200 /// @brief check and insert 0201 /// 0202 /// @param mState is the map to be filled 0203 /// @param volume is the surface to be checked for a Proxy 0204 void checkAndInsert(State& mState, const TrackingVolume& volume) const; 0205 0206 /// @brief check and insert 0207 /// 0208 /// @param mState is the map to be filled 0209 /// @param tVolume is the surface to collect from 0210 void collectMaterialSurfaces(State& mState, 0211 const TrackingVolume& tVolume) const; 0212 0213 /// Create extra material point for the mapping and add them to the grid 0214 /// 0215 /// @param mState The state to be filled 0216 /// @param currentBinning a pair containing the current geometry ID and the current binning 0217 /// @param properties material properties of the original hit 0218 /// @param position position of the original hit 0219 /// @param direction direction of the track 0220 void createExtraHits( 0221 State& mState, 0222 std::pair<const GeometryIdentifier, BinUtility>& currentBinning, 0223 Acts::MaterialSlab properties, const Vector3& position, 0224 Vector3 direction) const; 0225 0226 /// Standard logger method 0227 const Logger& logger() const { return *m_logger; } 0228 0229 /// The configuration object 0230 Config m_cfg; 0231 0232 /// The straight line propagator 0233 StraightLinePropagator m_propagator; 0234 0235 /// The logging instance 0236 std::unique_ptr<const Logger> m_logger; 0237 }; 0238 0239 } // 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 |
|