Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:42

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2017-2019 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 http://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/Plugins/Json/MaterialMapJsonConverter.hpp"
0016 #include "Acts/Surfaces/Surface.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       std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>>;
0034 
0035   using VolumeMaterialMap =
0036       std::map<GeometryIdentifier, std::shared_ptr<const IVolumeMaterial>>;
0037 
0038   JsonMaterialDecorator(const MaterialMapJsonConverter::Config& rConfig,
0039                         const std::string& jFileName,
0040                         Acts::Logging::Level level,
0041                         bool clearSurfaceMaterial = true,
0042                         bool clearVolumeMaterial = true);
0043 
0044   /// Decorate a surface
0045   ///
0046   /// @param surface the non-cost surface that is decorated
0047   void decorate(Surface& surface) const final;
0048 
0049   /// Decorate a TrackingVolume
0050   ///
0051   /// @param volume the non-cost volume that is decorated
0052   void decorate(TrackingVolume& volume) const final;
0053 
0054  private:
0055   MaterialMapJsonConverter::Config m_readerConfig;
0056   SurfaceMaterialMap m_surfaceMaterialMap;
0057   VolumeMaterialMap m_volumeMaterialMap;
0058 
0059   bool m_clearSurfaceMaterial{true};
0060   bool m_clearVolumeMaterial{true};
0061 
0062   std::unique_ptr<const Logger> m_logger;
0063 
0064   const Logger& logger() const { return *m_logger; }
0065 };
0066 }  // namespace Acts