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