Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MaterialMapJsonConverter.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MaterialMapJsonConverter.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
23 
24 #include <map>
25 #include <memory>
26 #include <string>
27 #include <tuple>
28 #include <utility>
29 #include <vector>
30 
31 #include <nlohmann/json.hpp>
32 
33 namespace Acts {
34 class ISurfaceMaterial;
35 class ITrackingGeometryJsonDecorator;
36 class IVolumeMaterial;
37 class IVolumeMaterialJsonDecorator;
38 class Surface;
39 class TrackingGeometry;
40 class TrackingVolume;
41 
43  std::tuple<std::shared_ptr<const Acts::Surface>,
44  std::shared_ptr<const Acts::ISurfaceMaterial>,
47  std::pair<const Acts::TrackingVolume*,
48  std::shared_ptr<const Acts::IVolumeMaterial>>;
49 
54  public:
55  using SurfaceMaterialMap =
56  std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>>;
57  using VolumeMaterialMap =
58  std::map<GeometryIdentifier, std::shared_ptr<const IVolumeMaterial>>;
59  using DetectorMaterialMaps = std::pair<SurfaceMaterialMap, VolumeMaterialMap>;
60 
63  class Config {
64  public:
67 
69  bool processSensitives = true;
71  bool processApproaches = true;
73  bool processRepresenting = true;
75  bool processBoundaries = true;
77  bool processVolumes = true;
79  bool processDenseVolumes = false;
81  bool processNonMaterial = false;
82  };
83 
89 
91  ~MaterialMapJsonConverter() = default;
92 
96  DetectorMaterialMaps jsonToMaterialMaps(const nlohmann::json& materialmaps);
97 
102  nlohmann::json materialMapsToJson(
103  const DetectorMaterialMaps& maps,
104  const IVolumeMaterialJsonDecorator* decorator = nullptr);
105 
111  nlohmann::json trackingGeometryToJson(
113  const ITrackingGeometryJsonDecorator* decorator = nullptr);
114 
122  void convertToHierarchy(
123  std::vector<std::pair<GeometryIdentifier,
124  Acts::TrackingVolumeAndMaterial>>& volumeHierarchy,
125  std::vector<
126  std::pair<GeometryIdentifier, Acts::SurfaceAndMaterialWithContext>>&
127  surfaceHierarchy,
128  const Acts::TrackingVolume* tVolume);
129 
130  private:
133 
135  std::unique_ptr<const Logger> m_logger{nullptr};
136 
138  std::string m_volumeName = "Material Volume Map";
147 
149  std::string m_surfaceName = "Material Surface Map";
158 
160  const Logger& logger() const { return *m_logger; }
161 };
162 
163 } // namespace Acts