Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JsonMaterialWriter.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JsonMaterialWriter.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2019 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 
20 
21 #include <cstdint>
22 #include <limits>
23 #include <map>
24 #include <memory>
25 #include <mutex>
26 #include <string>
27 #include <utility>
28 
29 namespace Acts {
30 
31 class TrackingGeometry;
32 class ISurfaceMaterial;
33 class IVolumeMaterial;
34 
35 using SurfaceMaterialMap =
36  std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>>;
37 
38 using VolumeMaterialMap =
39  std::map<GeometryIdentifier, std::shared_ptr<const IVolumeMaterial>>;
40 
41 using DetectorMaterialMaps = std::pair<SurfaceMaterialMap, VolumeMaterialMap>;
42 } // namespace Acts
43 
44 namespace ActsExamples {
45 
46 enum class JsonFormat : uint8_t {
47  NoOutput = 0,
48  Json = 1,
49  Cbor = 2,
50  All = std::numeric_limits<uint8_t>::max()
51 };
52 
54 
55 
56 
57 
58 
60  public:
61  struct Config {
65  std::string fileName = "material";
67  JsonFormat writeFormat = JsonFormat::Json;
68  };
69 
75 
77  ~JsonMaterialWriter() override;
78 
82  void writeMaterial(const Acts::DetectorMaterialMaps& detMaterial) override;
83 
88 
90  const Config& config() const { return m_cfg; }
91 
92  private:
93  const Acts::Logger& logger() const { return *m_logger; }
94 
96  std::unique_ptr<const Acts::Logger> m_logger{nullptr};
97 
100 
102  std::unique_ptr<Acts::MaterialMapJsonConverter> m_converter{nullptr};
103 };
104 
105 } // namespace ActsExamples