EIC 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 <mutex>
23 
24 class TFile;
25 
26 namespace Acts {
27 using SurfaceMaterialMap =
28  std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>>;
29 using VolumeMaterialMap =
30  std::map<GeometryIdentifier, std::shared_ptr<const IVolumeMaterial>>;
31 } // namespace Acts
32 
33 namespace ActsExamples {
34 
39  public:
42  class Config {
43  public:
45  std::string folderNameBase = "Material";
47  std::string voltag = "_vol";
49  std::string boutag = "_bou";
51  std::string laytag = "_lay";
53  std::string apptag = "_app";
55  std::string sentag = "_sen";
57  std::string ntag = "n";
59  std::string vtag = "v";
61  std::string otag = "o";
63  std::string mintag = "min";
65  std::string maxtag = "max";
67  std::string ttag = "t";
69  std::string x0tag = "x0";
71  std::string l0tag = "l0";
73  std::string atag = "A";
75  std::string ztag = "Z";
77  std::string rhotag = "rho";
79  std::string fileName = "material-maps.root";
81  std::shared_ptr<const Acts::Logger> logger;
82  // The name of the writer
83  std::string name = "";
84 
89  Config(const std::string& lname = "MaterialReader",
91  : logger(Acts::getDefaultLogger(lname, lvl)), name(lname) {}
92  };
93 
97  RootMaterialDecorator(const Config& cfg);
98 
101 
105  void decorate(Acts::Surface& surface) const final {
106  // Null out the material for this surface
108  surface.assignSurfaceMaterial(nullptr);
109  }
110  // Try to find the surface in the map
111  auto sMaterial = m_surfaceMaterialMap.find(surface.geometryId());
112  if (sMaterial != m_surfaceMaterialMap.end()) {
113  surface.assignSurfaceMaterial(sMaterial->second);
114  }
115  }
116 
120  void decorate(Acts::TrackingVolume& volume) const final {
121  // Null out the material for this volume
123  volume.assignVolumeMaterial(nullptr);
124  }
125  // Try to find the surface in the map
126  auto vMaterial = m_volumeMaterialMap.find(volume.geometryId());
127  if (vMaterial != m_volumeMaterialMap.end()) {
128  volume.assignVolumeMaterial(vMaterial->second);
129  }
130  }
131 
132  private:
135 
137  TFile* m_inputFile{nullptr};
138 
141 
144 
146 
148  const Acts::Logger& logger() const { return *m_cfg.logger; }
149 };
150 
151 } // namespace ActsExamples