Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:26

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 "Acts/Material/MaterialValidater.hpp"
0010 
0011 #include "Acts/Material/ISurfaceMaterial.hpp"
0012 #include "Acts/Material/interface/IAssignmentFinder.hpp"
0013 #include "Acts/Utilities/StringHelpers.hpp"
0014 
0015 Acts::MaterialValidater::MaterialValidater(
0016     const Acts::MaterialValidater::Config& cfg,
0017     std::unique_ptr<const Acts::Logger> mlogger)
0018     : m_cfg(cfg), m_logger(std::move(mlogger)) {
0019   if (m_cfg.materialAssigner == nullptr) {
0020     throw std::invalid_argument("Missing material assigner");
0021   }
0022 }
0023 
0024 Acts::RecordedMaterialTrack Acts::MaterialValidater::recordMaterial(
0025     const GeometryContext& gctx, const MagneticFieldContext& mctx,
0026     const Vector3& position, const Vector3& direction) const {
0027   ACTS_DEBUG("MaterialValidater::recordMaterial with position "
0028              << toString(position) << " and direction " << toString(direction));
0029 
0030   // Prepare the material track
0031   Acts::RecordedMaterialTrack mTrack{{position, direction}, {}};
0032 
0033   auto [surfaceAssignments, volumeAssignments] =
0034       m_cfg.materialAssigner->assignmentCandidates(gctx, mctx, position,
0035                                                    direction);
0036 
0037   for (const auto& [surface, sposition, sdirection] : surfaceAssignments) {
0038     // The slab and the path correction
0039     auto materialSlab = surface->surfaceMaterial()->materialSlab(sposition);
0040     auto pathCorrection = surface->pathCorrection(gctx, sposition, sdirection);
0041     // Get the material information
0042     Acts::MaterialInteraction mInteraction;
0043     mInteraction.surface = surface;
0044     mInteraction.position = sposition;
0045     mInteraction.direction = sdirection;
0046     mInteraction.materialSlab = MaterialSlab(
0047         materialSlab.material(), materialSlab.thickness() * pathCorrection);
0048     mInteraction.pathCorrection = pathCorrection;
0049     mInteraction.intersection = sposition;
0050     mInteraction.intersectionID = surface->geometryId();
0051     // Assemble the recorded material track
0052     mTrack.second.materialInX0 += mInteraction.materialSlab.thicknessInX0();
0053     mTrack.second.materialInL0 += mInteraction.materialSlab.thicknessInL0();
0054     mTrack.second.materialInteractions.push_back(mInteraction);
0055   }
0056 
0057   ACTS_VERBOSE("Recorded material track with "
0058                << mTrack.second.materialInteractions.size()
0059                << " material interactions.");
0060 
0061   return mTrack;
0062 }