File indexing completed on 2025-01-18 09:27:42
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/Geometry/GeometryIdentifier.hpp"
0013 #include "Acts/Geometry/TrackingGeometry.hpp"
0014 #include "Acts/Material/ISurfaceMaterial.hpp"
0015 #include "Acts/Material/IVolumeMaterial.hpp"
0016 #include "Acts/Plugins/Json/ActsJson.hpp"
0017 #include "Acts/Plugins/Json/GeometryHierarchyMapJsonConverter.hpp"
0018 #include "Acts/Plugins/Json/ITrackingGeometryJsonDecorator.hpp"
0019 #include "Acts/Plugins/Json/IVolumeMaterialJsonDecorator.hpp"
0020 #include "Acts/Utilities/Logger.hpp"
0021 #include <Acts/Geometry/TrackingVolume.hpp>
0022 #include <Acts/Surfaces/Surface.hpp>
0023
0024 #include <map>
0025 #include <memory>
0026 #include <string>
0027 #include <tuple>
0028 #include <utility>
0029 #include <vector>
0030
0031 #include <nlohmann/json.hpp>
0032
0033 namespace Acts {
0034 class ISurfaceMaterial;
0035 class ITrackingGeometryJsonDecorator;
0036 class IVolumeMaterial;
0037 class IVolumeMaterialJsonDecorator;
0038 class Surface;
0039 class TrackingGeometry;
0040 class TrackingVolume;
0041
0042 using SurfaceAndMaterialWithContext =
0043 std::tuple<std::shared_ptr<const Acts::Surface>,
0044 std::shared_ptr<const Acts::ISurfaceMaterial>,
0045 Acts::GeometryContext>;
0046 using TrackingVolumeAndMaterial =
0047 std::pair<const Acts::TrackingVolume*,
0048 std::shared_ptr<const Acts::IVolumeMaterial>>;
0049
0050
0051
0052
0053 class MaterialMapJsonConverter {
0054 public:
0055 using SurfaceMaterialMap =
0056 std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>>;
0057 using VolumeMaterialMap =
0058 std::map<GeometryIdentifier, std::shared_ptr<const IVolumeMaterial>>;
0059 using DetectorMaterialMaps = std::pair<SurfaceMaterialMap, VolumeMaterialMap>;
0060
0061
0062
0063 class Config {
0064 public:
0065
0066 GeometryContext context = GeometryContext();
0067
0068
0069 bool processSensitives = true;
0070
0071 bool processApproaches = true;
0072
0073 bool processRepresenting = true;
0074
0075 bool processBoundaries = true;
0076
0077 bool processVolumes = true;
0078
0079 bool processDenseVolumes = false;
0080
0081 bool processNonMaterial = false;
0082 };
0083
0084
0085
0086
0087
0088 MaterialMapJsonConverter(const Config& config, Acts::Logging::Level level);
0089
0090
0091 ~MaterialMapJsonConverter() = default;
0092
0093
0094
0095
0096 DetectorMaterialMaps jsonToMaterialMaps(const nlohmann::json& materialmaps);
0097
0098
0099
0100
0101
0102 nlohmann::json materialMapsToJson(
0103 const DetectorMaterialMaps& maps,
0104 const IVolumeMaterialJsonDecorator* decorator = nullptr);
0105
0106
0107
0108
0109
0110
0111 nlohmann::json trackingGeometryToJson(
0112 const TrackingGeometry& tGeometry,
0113 const ITrackingGeometryJsonDecorator* decorator = nullptr);
0114
0115
0116
0117
0118
0119
0120
0121
0122 void convertToHierarchy(
0123 std::vector<std::pair<GeometryIdentifier,
0124 Acts::TrackingVolumeAndMaterial>>& volumeHierarchy,
0125 std::vector<
0126 std::pair<GeometryIdentifier, Acts::SurfaceAndMaterialWithContext>>&
0127 surfaceHierarchy,
0128 const Acts::TrackingVolume* tVolume);
0129
0130 private:
0131
0132 Config m_cfg;
0133
0134
0135 std::unique_ptr<const Logger> m_logger{nullptr};
0136
0137
0138 std::string m_volumeName = "Material Volume Map";
0139
0140 Acts::GeometryHierarchyMapJsonConverter<const IVolumeMaterial*,
0141 Acts::IVolumeMaterialJsonDecorator>
0142 m_volumeMaterialConverter;
0143
0144 Acts::GeometryHierarchyMapJsonConverter<Acts::TrackingVolumeAndMaterial,
0145 Acts::ITrackingGeometryJsonDecorator>
0146 m_volumeConverter;
0147
0148
0149 std::string m_surfaceName = "Material Surface Map";
0150
0151 Acts::GeometryHierarchyMapJsonConverter<const ISurfaceMaterial*,
0152 Acts::IVolumeMaterialJsonDecorator>
0153 m_surfaceMaterialConverter;
0154
0155 Acts::GeometryHierarchyMapJsonConverter<Acts::SurfaceAndMaterialWithContext,
0156 Acts::ITrackingGeometryJsonDecorator>
0157 m_surfaceConverter;
0158
0159
0160 const Logger& logger() const { return *m_logger; }
0161 };
0162
0163 }