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