Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-11 09:40:22

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/TrackingVolume.hpp"
0012 #include "Acts/Material/IMaterialDecorator.hpp"
0013 #include "Acts/Material/ISurfaceMaterial.hpp"
0014 #include "Acts/Material/IVolumeMaterial.hpp"
0015 #include "Acts/Surfaces/Surface.hpp"
0016 #include "ActsPlugins/Json/MaterialMapJsonConverter.hpp"
0017 
0018 #include <fstream>
0019 #include <map>
0020 #include <mutex>
0021 
0022 // Convenience shorthand
0023 
0024 namespace Acts {
0025 
0026 /// @brief Material decorator from Json format
0027 ///
0028 /// This reads in material maps for surfaces and volumes
0029 /// from a json file
0030 class JsonMaterialDecorator : public IMaterialDecorator {
0031  public:
0032   using SurfaceMaterialMap
0033       [[deprecated("Use Acts::SurfaceMaterialMaps directly")]] =
0034           SurfaceMaterialMaps;
0035   using VolumeMaterialMap
0036       [[deprecated("Use Acts::VolumeMaterialMaps directly")]] =
0037           VolumeMaterialMaps;
0038 
0039   /// Constructor with configuration
0040   /// @param rConfig the configuration for the material map reader
0041   /// @param jFileName the json file name to read
0042   /// @param level the logging level
0043   /// @param clearSurfaceMaterial if true, clear the surface material before
0044   /// decorating, this means if there is no material for a certain surface
0045   /// within the json file, the surface WILL NOT have any material, eventually
0046   /// assigned (proto-/)material will be cleared
0047   /// @param clearVolumeMaterial if true, clear the volume material before
0048   /// decorating, same as above, but for volumes
0049   JsonMaterialDecorator(const MaterialMapJsonConverter::Config& rConfig,
0050                         const std::string& jFileName,
0051                         Acts::Logging::Level level,
0052                         bool clearSurfaceMaterial = true,
0053                         bool clearVolumeMaterial = true);
0054 
0055   /// Decorate a surface
0056   ///
0057   /// @param surface the non-cost surface that is decorated
0058   void decorate(Surface& surface) const final;
0059 
0060   /// Decorate a TrackingVolume
0061   ///
0062   /// @param volume the non-cost volume that is decorated
0063   void decorate(TrackingVolume& volume) const final;
0064 
0065  private:
0066   MaterialMapJsonConverter::Config m_readerConfig;
0067   SurfaceMaterialMaps m_surfaceMaterialMap;
0068   VolumeMaterialMaps m_volumeMaterialMap;
0069 
0070   bool m_clearSurfaceMaterial{true};
0071   bool m_clearVolumeMaterial{true};
0072 
0073   std::unique_ptr<const Logger> m_logger;
0074 
0075   const Logger& logger() const { return *m_logger; }
0076 };
0077 }  // namespace Acts