17 #include <unordered_map>
19 namespace ActsExamples {
20 struct AlgorithmContext;
26 : ActsExamples::
IAlgorithm(
"MaterialMapping", level),
31 throw std::invalid_argument(
"Missing material mapper");
33 throw std::invalid_argument(
"Missing tracking geometry");
39 ACTS_INFO(
"This algorithm requires inter-event information, "
40 <<
"run in single-threaded mode!");
57 if (
m_cfg.materialSurfaceMapper &&
m_cfg.materialVolumeMapper) {
59 m_cfg.materialSurfaceMapper->finalizeMaps(m_mappingState);
60 m_cfg.materialVolumeMapper->finalizeMaps(m_mappingStateVol);
62 for (
auto& [key,
value] : m_mappingState.surfaceMaterial) {
66 for (
auto& [key,
value] : m_mappingStateVol.volumeMaterial) {
70 if (
m_cfg.materialSurfaceMapper) {
72 m_cfg.materialSurfaceMapper->finalizeMaps(m_mappingState);
74 for (
auto& [key,
value] : m_mappingState.surfaceMaterial) {
78 for (
auto& [key,
value] : m_mappingState.volumeMaterial) {
82 if (
m_cfg.materialVolumeMapper) {
84 m_cfg.materialVolumeMapper->finalizeMaps(m_mappingStateVol);
86 for (
auto& [key,
value] : m_mappingStateVol.surfaceMaterial) {
90 for (
auto& [key,
value] : m_mappingStateVol.volumeMaterial) {
96 for (
auto& imw :
m_cfg.materialWriters) {
97 imw->writeMaterial(detectorMaterial);
104 std::unordered_map<size_t, Acts::RecordedMaterialTrack> mtrackCollection =
105 m_inputMaterialTracks(context);
107 if (
m_cfg.materialSurfaceMapper) {
111 for (
auto& [idTrack, mTrack] : mtrackCollection) {
113 m_cfg.materialSurfaceMapper->mapMaterialTrack(*mappingState, mTrack);
116 if (
m_cfg.materialVolumeMapper) {
121 for (
auto& [idTrack, mTrack] : mtrackCollection) {
123 m_cfg.materialVolumeMapper->mapMaterialTrack(*mappingState, mTrack);
127 m_outputMaterialTracks(context,
std::move(mtrackCollection));
131 std::vector<std::pair<double, int>>
133 std::vector<std::pair<double, int>> scoringParameters;
135 if (
m_cfg.materialSurfaceMapper) {
136 auto surfaceAccumulatedMaterial = m_mappingState.accumulatedMaterial.find(
139 if (surfaceAccumulatedMaterial !=
140 m_mappingState.accumulatedMaterial.end()) {
141 auto matrixMaterial =
142 surfaceAccumulatedMaterial->second.accumulatedMaterial();
143 for (
const auto& vectorMaterial : matrixMaterial) {
144 for (
const auto& AccumulatedMaterial : vectorMaterial) {
145 auto totalVariance = AccumulatedMaterial.totalVariance();
146 scoringParameters.push_back(
147 {totalVariance.first, totalVariance.second});
152 return scoringParameters;