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