Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 08:20:28

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsExamples/MaterialMapping/MaterialValidation.hpp"
0010 
0011 #include "ActsExamples/Framework/AlgorithmContext.hpp"
0012 
0013 #include <stdexcept>
0014 
0015 namespace ActsExamples {
0016 
0017 MaterialValidation::MaterialValidation(
0018     const MaterialValidation::Config& cfg,
0019     std::unique_ptr<const Acts::Logger> logger)
0020     : IAlgorithm("MaterialValidation", std::move(logger)), m_cfg(cfg) {
0021   // Prepare the I/O collections
0022   m_inputTrackParameters.initialize(m_cfg.inputTrackParameters);
0023   m_outputMaterialTracks.initialize(m_cfg.outputMaterialTracks);
0024   // Check the configuration - material validator
0025   if (m_cfg.materialValidator == nullptr) {
0026     throw std::invalid_argument("Missing material validator.");
0027   }
0028 }
0029 
0030 ProcessCode MaterialValidation::execute(const AlgorithmContext& context) const {
0031   const auto& inputTrackParameters = m_inputTrackParameters(context);
0032 
0033   ACTS_DEBUG("Validation with " << inputTrackParameters.size()
0034                                 << " input trackparameters");
0035 
0036   std::unordered_map<std::size_t, Acts::RecordedMaterialTrack>
0037       recordedMaterialTracks;
0038   recordedMaterialTracks.reserve(inputTrackParameters.size());
0039 
0040   for (const auto& [it, parameters] : Acts::enumerate(inputTrackParameters)) {
0041     // Record the material
0042     auto rMaterial = m_cfg.materialValidator->recordMaterial(
0043         context.recoGeoContext, context.magFieldContext,
0044         parameters.position(context.recoGeoContext),
0045         parameters.momentum().normalized());
0046 
0047     recordedMaterialTracks.try_emplace(recordedMaterialTracks.end(), it,
0048                                        rMaterial);
0049   }
0050 
0051   // Write the mapped and unmapped material tracks to the output
0052   m_outputMaterialTracks(context, std::move(recordedMaterialTracks));
0053 
0054   return ProcessCode::SUCCESS;
0055 }
0056 
0057 }  // namespace ActsExamples