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) 2021 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/Definitions/Algebra.hpp"
0012 #include "Acts/Material/ISurfaceMaterial.hpp"
0013 #include "Acts/Material/IVolumeMaterial.hpp"
0014 #include "Acts/Material/Material.hpp"
0015 #include "Acts/Material/MaterialSlab.hpp"
0016 #include "Acts/Plugins/Json/ActsJson.hpp"
0017 
0018 #include <nlohmann/json.hpp>
0019 
0020 // Custom Json encoder/decoders. Naming is mandated by nlohmann::json and thus
0021 // can not match our naming guidelines.
0022 namespace Acts {
0023 
0024 class ISurfaceMaterial;
0025 class IVolumeMaterial;
0026 class BinUtility;
0027 
0028 using volumeMaterialPointer = const Acts::IVolumeMaterial*;
0029 using surfaceMaterialPointer = const Acts::ISurfaceMaterial*;
0030 
0031 void to_json(nlohmann::json& j, const Material& t);
0032 
0033 void from_json(const nlohmann::json& j, Material& t);
0034 
0035 void to_json(nlohmann::json& j, const MaterialSlab& t);
0036 
0037 void from_json(const nlohmann::json& j, MaterialSlab& t);
0038 
0039 void from_json(const nlohmann::json& j, MaterialSlabMatrix& t);
0040 
0041 void to_json(nlohmann::json& j, const volumeMaterialPointer& material);
0042 
0043 void from_json(const nlohmann::json& j, volumeMaterialPointer& material);
0044 
0045 void to_json(nlohmann::json& j, const surfaceMaterialPointer& material);
0046 
0047 void from_json(const nlohmann::json& j, surfaceMaterialPointer& material);
0048 
0049 // This macro create a conversion for the mapping type enum
0050 NLOHMANN_JSON_SERIALIZE_ENUM(Acts::MappingType,
0051                              {
0052                                  {Acts::MappingType::PreMapping, "PreMapping"},
0053                                  {Acts::MappingType::Default, "Default"},
0054                                  {Acts::MappingType::PostMapping,
0055                                   "PostMapping"},
0056                                  {Acts::MappingType::Sensor, "Sensor"},
0057                              })
0058 
0059 namespace MaterialJsonConverter {
0060 
0061 /// @brief Convert a surface material to json - detray format
0062 ///
0063 /// @param surfaceMaterial is the surface material to be converted
0064 /// @param surface is the surface the material is attached to
0065 /// @param surfaceIndex is the index of the surface
0066 /// @param gridLink [in, out] is the grid index in the volume
0067 ///
0068 /// @note the surface is needed to shift the z boundaries for concentric cylinders
0069 ///
0070 /// @return a json object representing the surface material in detray format
0071 nlohmann::json toJsonDetray(const ISurfaceMaterial& material,
0072                             const Acts::Surface& surface,
0073                             std::size_t surfaceIndex,
0074                             std::map<std::size_t, std::size_t>& gridLink);
0075 
0076 /// @brief Convert a bin utility to json - detray format
0077 ///
0078 /// @param binUtility is the bin utility to be converted
0079 /// @param surface is the surface the material is attached to
0080 ///
0081 /// @note the surface is needed to shift the z boundaries for concentric cylinders
0082 ///
0083 /// @return a json object representing the bin utility in detray format
0084 nlohmann::json toJsonDetray(const Acts::BinUtility& binUtility,
0085                             const Acts::Surface& surface);
0086 
0087 }  // namespace MaterialJsonConverter
0088 
0089 }  // namespace Acts