Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SurfaceMaterialMapper.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SurfaceMaterialMapper.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018-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 
29 
30 #include <array>
31 #include <functional>
32 #include <map>
33 #include <memory>
34 #include <vector>
35 
36 namespace Acts {
37 
38 class IVolumeMaterial;
39 class ISurfaceMaterial;
40 class TrackingGeometry;
41 struct MaterialInteraction;
42 
45  bool operator()(const Surface& sf) const {
46  return (sf.surfaceMaterial() != nullptr);
47  }
48 };
49 
52  bool operator()(const TrackingVolume& vf) const {
53  return (vf.volumeMaterial() != nullptr);
54  }
55 };
56 
84  public:
86 
90  struct Config {
92  std::array<double, 2> etaRange = {{-6., 6.}};
94  bool emptyBinCorrection = true;
96  bool mapperDebugOutput = false;
98  bool computeVariance = false;
99  };
100 
104  struct State {
108  : geoContext(gctx), magFieldContext(mctx) {}
109 
111  std::map<GeometryIdentifier, AccumulatedSurfaceMaterial>
113 
115  std::map<GeometryIdentifier, std::unique_ptr<const ISurfaceMaterial>>
117 
119  std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>>
121 
123  std::map<GeometryIdentifier, std::shared_ptr<const IVolumeMaterial>>
125 
127  std::reference_wrapper<const GeometryContext> geoContext;
128 
130  std::reference_wrapper<const MagneticFieldContext> magFieldContext;
131  };
132 
134  SurfaceMaterialMapper() = delete;
135 
142  std::unique_ptr<const Logger> slogger =
143  getDefaultLogger("SurfaceMaterialMapper",
144  Logging::INFO));
145 
156  const MagneticFieldContext& mctx,
157  const TrackingGeometry& tGeometry) const;
158 
166  void finalizeMaps(State& mState) const;
167 
175  void mapMaterialTrack(State& mState, RecordedMaterialTrack& mTrack) const;
176 
183  void mapInteraction(State& mState, RecordedMaterialTrack& mTrack) const;
184 
192  void mapSurfaceInteraction(State& mState,
193  std::vector<MaterialInteraction>& rMaterial) const;
194 
195  private:
200  void resolveMaterialSurfaces(State& mState,
201  const TrackingVolume& tVolume) const;
202 
207  void checkAndInsert(State& mState, const Surface& surface) const;
208 
213  void collectMaterialVolumes(State& mState,
214  const TrackingVolume& tVolume) const;
215 
217  const Logger& logger() const { return *m_logger; }
218 
221 
224 
226  std::unique_ptr<const Logger> m_logger;
227 };
228 } // namespace Acts