Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RootMaterialDecorator.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RootMaterialDecorator.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 <map>
22 #include <memory>
23 #include <mutex>
24 #include <string>
25 #include <utility>
26 
27 class TFile;
28 
29 namespace Acts {
30 class ISurfaceMaterial;
31 class IVolumeMaterial;
32 
33 using SurfaceMaterialMap =
34  std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>>;
35 using VolumeMaterialMap =
36  std::map<GeometryIdentifier, std::shared_ptr<const IVolumeMaterial>>;
37 } // namespace Acts
38 
39 namespace ActsExamples {
40 
45  public:
48  class Config {
49  public:
51  std::string folderSurfaceNameBase = "SurfaceMaterial";
53  std::string folderVolumeNameBase = "VolumeMaterial";
55  std::string voltag = "_vol";
57  std::string boutag = "_bou";
59  std::string laytag = "_lay";
61  std::string apptag = "_app";
63  std::string sentag = "_sen";
87  std::string fileName = "material-maps.root";
88  };
89 
94 
96  ~RootMaterialDecorator() override;
97 
101  void decorate(Acts::Surface& surface) const final {
102  // Null out the material for this surface
104  surface.assignSurfaceMaterial(nullptr);
105  }
106  // Try to find the surface in the map
107  auto sMaterial = m_surfaceMaterialMap.find(surface.geometryId());
108  if (sMaterial != m_surfaceMaterialMap.end()) {
109  surface.assignSurfaceMaterial(sMaterial->second);
110  }
111  }
112 
116  void decorate(Acts::TrackingVolume& volume) const final {
117  // Null out the material for this volume
119  volume.assignVolumeMaterial(nullptr);
120  }
121  // Try to find the surface in the map
122  auto vMaterial = m_volumeMaterialMap.find(volume.geometryId());
123  if (vMaterial != m_volumeMaterialMap.end()) {
124  volume.assignVolumeMaterial(vMaterial->second);
125  }
126  }
127 
129  const Config& config() const { return m_cfg; }
130 
131  private:
134 
135  std::unique_ptr<const Acts::Logger> m_logger{nullptr};
136 
138  TFile* m_inputFile{nullptr};
139 
142 
145 
147 
149  const Acts::Logger& logger() const { return *m_logger; }
150 };
151 
152 } // namespace ActsExamples