![]() |
|
|||
File indexing completed on 2025-09-15 08:13:41
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/Geometry/GeometryContext.hpp" 0012 #include "Acts/Geometry/GeometryIdentifier.hpp" 0013 #include "Acts/Geometry/TrackingVolume.hpp" 0014 #include "Acts/MagneticField/MagneticFieldContext.hpp" 0015 #include "Acts/Material/AccumulatedSurfaceMaterial.hpp" 0016 #include "Acts/Material/ISurfaceMaterial.hpp" 0017 #include "Acts/Material/MaterialInteraction.hpp" 0018 #include "Acts/Propagator/Navigator.hpp" 0019 #include "Acts/Propagator/Propagator.hpp" 0020 #include "Acts/Propagator/StraightLineStepper.hpp" 0021 #include "Acts/Surfaces/Surface.hpp" 0022 #include "Acts/Utilities/Logger.hpp" 0023 0024 #include <array> 0025 #include <functional> 0026 #include <map> 0027 #include <memory> 0028 #include <vector> 0029 0030 namespace Acts { 0031 0032 class IVolumeMaterial; 0033 class ISurfaceMaterial; 0034 class TrackingGeometry; 0035 struct MaterialInteraction; 0036 0037 /// @brief selector for finding surface 0038 struct MaterialSurface { 0039 bool operator()(const Surface& sf) const { 0040 return (sf.surfaceMaterial() != nullptr); 0041 } 0042 }; 0043 0044 /// @brief selector for finding volume 0045 struct MaterialVolume { 0046 bool operator()(const TrackingVolume& vf) const { 0047 return (vf.volumeMaterial() != nullptr); 0048 } 0049 }; 0050 0051 /// @brief SurfaceMaterialMapper 0052 /// 0053 /// This is the main feature tool to map material information 0054 /// from a 3D geometry onto the TrackingGeometry with its surface 0055 /// material description. 0056 /// 0057 /// The process runs as such: 0058 /// 0059 /// 1) TrackingGeometry is parsed and for each Surface with 0060 /// ProtoSurfaceMaterial a local store is initialized 0061 /// the identification is done hereby through the 0062 /// Surface::GeometryIdentifier 0063 /// 0064 /// 2) A Cache is generated that is used to keep the filling thread local, 0065 /// the filling is protected with std::mutex 0066 /// 0067 /// 3) A number of N material tracks is read in, each track has : 0068 /// origin, direction, material steps < position, step length, x0, l0, a, 0069 /// z, rho > 0070 /// 0071 /// for each track: 0072 /// surfaces along the origin/direction path are collected 0073 /// the closest material steps are assigned 0074 /// 0075 /// 4) Each 'hit' bin per event is counted and averaged at the end of the run 0076 /// 0077 class SurfaceMaterialMapper { 0078 public: 0079 using StraightLinePropagator = Propagator<StraightLineStepper, Navigator>; 0080 0081 /// @struct Config 0082 /// 0083 /// Nested Configuration struct for the material mapper 0084 struct Config { 0085 /// Mapping range 0086 std::array<double, 2> etaRange = {{-6., 6.}}; 0087 /// Correct for empty bins (recommended) 0088 bool emptyBinCorrection = true; 0089 /// Mapping output to debug stream 0090 bool mapperDebugOutput = false; 0091 /// Compute the variance of each material slab (only if using an input map) 0092 bool computeVariance = false; 0093 }; 0094 0095 /// @struct State 0096 /// 0097 /// Nested State struct which is used for the mapping prococess 0098 struct State { 0099 /// @param [in] gctx The geometry context to use 0100 /// @param [in] mctx The magnetic field context to use 0101 State(const GeometryContext& gctx, const MagneticFieldContext& mctx) 0102 : geoContext(gctx), magFieldContext(mctx) {} 0103 0104 /// The accumulated material per geometry ID 0105 std::map<GeometryIdentifier, AccumulatedSurfaceMaterial> 0106 accumulatedMaterial; 0107 0108 /// The created surface material from it 0109 std::map<GeometryIdentifier, std::unique_ptr<const ISurfaceMaterial>> 0110 surfaceMaterial; 0111 0112 /// The surface material of the input tracking geometry 0113 std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>> 0114 inputSurfaceMaterial; 0115 0116 /// The volume material of the input tracking geometry 0117 std::map<GeometryIdentifier, std::shared_ptr<const IVolumeMaterial>> 0118 volumeMaterial; 0119 0120 /// Reference to the geometry context for the mapping 0121 std::reference_wrapper<const GeometryContext> geoContext; 0122 0123 /// Reference to the magnetic field context 0124 std::reference_wrapper<const MagneticFieldContext> magFieldContext; 0125 }; 0126 0127 /// Delete the Default constructor 0128 SurfaceMaterialMapper() = delete; 0129 0130 /// Constructor with config object 0131 /// 0132 /// @param cfg Configuration struct 0133 /// @param propagator The straight line propagator 0134 /// @param slogger The logger 0135 SurfaceMaterialMapper(const Config& cfg, StraightLinePropagator propagator, 0136 std::unique_ptr<const Logger> slogger = 0137 getDefaultLogger("SurfaceMaterialMapper", 0138 Logging::INFO)); 0139 0140 /// @brief helper method that creates the cache for the mapping 0141 /// 0142 /// @param [in] gctx The geometry context to use 0143 /// @param [in] mctx The magnetic field context to use 0144 /// @param[in] tGeometry The geometry which should be mapped 0145 /// 0146 /// This method takes a TrackingGeometry, 0147 /// finds all surfaces with material proxis 0148 /// and returns you a Cache object tO be used 0149 State createState(const GeometryContext& gctx, 0150 const MagneticFieldContext& mctx, 0151 const TrackingGeometry& tGeometry) const; 0152 0153 /// @brief Method to finalize the maps 0154 /// 0155 /// It calls the final run averaging and then transforms 0156 /// the AccumulatedSurface material class to a surface material 0157 /// class type 0158 /// 0159 /// @param mState 0160 void finalizeMaps(State& mState) const; 0161 0162 /// Process/map a single track 0163 /// 0164 /// @param mState The current state map 0165 /// @param mTrack The material track to be mapped 0166 /// 0167 /// @note the RecordedMaterialSlab of the track are assumed 0168 /// to be ordered from the starting position along the starting direction 0169 void mapMaterialTrack(State& mState, RecordedMaterialTrack& mTrack) const; 0170 0171 /// Loop through all the material interactions and add them to the 0172 /// associated surface 0173 /// 0174 /// @param mState The current state map 0175 /// @param mTrack The material track to be mapped 0176 /// 0177 void mapInteraction(State& mState, RecordedMaterialTrack& mTrack) const; 0178 0179 /// Loop through all the material interactions and add them to the 0180 /// associated surface 0181 /// 0182 /// @param mState The current state map 0183 /// @param rMaterial Vector of all the material interactions that will be mapped 0184 /// 0185 /// @note The material interactions are assumed to have an associated surface ID 0186 void mapSurfaceInteraction(State& mState, 0187 std::vector<MaterialInteraction>& rMaterial) const; 0188 0189 private: 0190 /// @brief finds all surfaces with ProtoSurfaceMaterial of a volume 0191 /// 0192 /// @param mState The state to be filled 0193 /// @param tVolume is current TrackingVolume 0194 void resolveMaterialSurfaces(State& mState, 0195 const TrackingVolume& tVolume) const; 0196 0197 /// @brief check and insert 0198 /// 0199 /// @param mState is the map to be filled 0200 /// @param surface is the surface to be checked for a Proxy 0201 void checkAndInsert(State& mState, const Surface& surface) const; 0202 0203 /// @brief check and insert 0204 /// 0205 /// @param mState is the map to be filled 0206 /// @param tVolume is the volume collect from 0207 void collectMaterialVolumes(State& mState, 0208 const TrackingVolume& tVolume) const; 0209 0210 /// Standard logger method 0211 const Logger& logger() const { return *m_logger; } 0212 0213 /// The configuration object 0214 Config m_cfg; 0215 0216 /// The straight line propagator 0217 StraightLinePropagator m_propagator; 0218 0219 /// The logging instance 0220 std::unique_ptr<const Logger> m_logger; 0221 }; 0222 0223 } // 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 |
![]() ![]() |