Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VolumeMaterialMapper.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VolumeMaterialMapper.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019-2020 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 
11 // Workaround for building on clang+libstdc++
13 
30 
31 #include <functional>
32 #include <map>
33 #include <memory>
34 #include <utility>
35 #include <vector>
36 
37 namespace Acts {
38 
39 class ISurfaceMaterial;
40 class IVolumeMaterial;
41 class TrackingGeometry;
42 
43 //
66 
68  public:
70 
74  struct Config {
76  float mappingStep = 1.;
77  };
78 
82  struct State {
85  : geoContext(gctx), magFieldContext(mctx) {}
86 
88  std::map<const GeometryIdentifier, Acts::AccumulatedVolumeMaterial>
90 
92  std::map<const GeometryIdentifier,
93  std::function<Acts::Vector2(Acts::Vector3)>>
95 
97  std::map<const GeometryIdentifier, Grid2D> grid2D;
98 
101  std::map<const GeometryIdentifier,
102  std::function<Acts::Vector3(Acts::Vector3)>>
104 
106  std::map<const GeometryIdentifier, Grid3D> grid3D;
107 
109  std::map<const GeometryIdentifier, BinUtility> materialBin;
110 
112  std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>>
114 
116  std::map<GeometryIdentifier, std::unique_ptr<const IVolumeMaterial>>
118 
120  std::reference_wrapper<const GeometryContext> geoContext;
121 
123  std::reference_wrapper<const MagneticFieldContext> magFieldContext;
124  };
125 
127  VolumeMaterialMapper() = delete;
128 
135  std::unique_ptr<const Logger> slogger = getDefaultLogger(
136  "VolumeMaterialMapper", Logging::INFO));
137 
148  const MagneticFieldContext& mctx,
149  const TrackingGeometry& tGeometry) const;
150 
158  void finalizeMaps(State& mState) const;
159 
167  void mapMaterialTrack(State& mState, RecordedMaterialTrack& mTrack) const;
168 
169  private:
172  bool operator()(const Surface& sf) const {
173  return (sf.geometryId().boundary() != 0);
174  }
175  };
176 
179  bool operator()(const TrackingVolume& vf) const {
180  return (vf.volumeMaterial() != nullptr);
181  }
182  };
183 
188  void resolveMaterialVolume(State& mState,
189  const TrackingVolume& tVolume) const;
190 
195  void checkAndInsert(State& mState, const TrackingVolume& volume) const;
196 
201  void collectMaterialSurfaces(State& mState,
202  const TrackingVolume& tVolume) const;
203 
211  void createExtraHits(
212  State& mState,
213  std::pair<const GeometryIdentifier, BinUtility>& currentBinning,
214  Acts::MaterialSlab properties, const Vector3& position,
215  Vector3 direction) const;
216 
218  const Logger& logger() const { return *m_logger; }
219 
222 
225 
227  std::unique_ptr<const Logger> m_logger;
228 };
229 
230 } // namespace Acts