Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 08:19:49

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/Propagator/detail/PointwiseMaterialInteraction.hpp"
0010 
0011 #include "Acts/Material/ISurfaceMaterial.hpp"
0012 #include "Acts/Material/Interactions.hpp"
0013 
0014 namespace Acts {
0015 
0016 MaterialUpdateMode detail::determineMaterialUpdateMode(
0017     const Surface& surface, const Surface* startSurface,
0018     const Surface* targetSurface, MaterialUpdateMode requestedMode) {
0019   // Avoid double counting of the material effects at start and target surfaces
0020   // by restricting the update mode accordingly
0021   MaterialUpdateMode updateMode = requestedMode;
0022   if (&surface == startSurface) {
0023     updateMode &= MaterialUpdateMode::PostUpdate;
0024   } else if (&surface == targetSurface) {
0025     updateMode &= MaterialUpdateMode::PreUpdate;
0026   }
0027 
0028   return updateMode;
0029 }
0030 
0031 Result<MaterialSlab> detail::evaluateMaterialSlab(
0032     const GeometryContext& geoContext, const Surface& surface,
0033     Direction propagationDirection, const Vector3& position,
0034     const Vector3& direction, MaterialUpdateMode updateMode) {
0035   const ISurfaceMaterial* material = surface.surfaceMaterial();
0036   if (material == nullptr) {
0037     return MaterialSlab::Nothing();
0038   }
0039 
0040   const double pathCorrection =
0041       surface.pathCorrection(geoContext, position, direction);
0042   auto lposition = surface.globalToLocal(geoContext, position, direction);
0043   if (!lposition.ok()) {
0044     return lposition.error();
0045   }
0046 
0047   MaterialSlab slab =
0048       surface.materialSlab(lposition.value(), propagationDirection, updateMode);
0049   slab.scaleThickness(pathCorrection);
0050   return slab;
0051 }
0052 
0053 detail::PointwiseMaterialEffects detail::computeMaterialEffects(
0054     const MaterialSlab& slab, const ParticleHypothesis& particleHypothesis,
0055     const Vector3& direction, float qOverP, bool multipleScattering,
0056     bool energyLoss, bool covTransport) {
0057   PointwiseMaterialEffects result;
0058 
0059   const double mass = particleHypothesis.mass();
0060   const PdgParticle absPdg = particleHypothesis.absolutePdg();
0061   const double absQ = particleHypothesis.absoluteCharge();
0062 
0063   if (energyLoss) {
0064     result.eLoss = computeEnergyLossBethe(slab, mass, qOverP, absQ);
0065   }
0066 
0067   if (covTransport) {
0068     if (multipleScattering) {
0069       //! [scattering variance]
0070       const double theta0 =
0071           computeMultipleScatteringTheta0(slab, absPdg, mass, qOverP, absQ);
0072       // sigmaPhi = theta0 / sin(theta)
0073       const double sigmaPhi =
0074           theta0 * (direction.norm() / VectorHelpers::perp(direction));
0075       result.variancePhi = sigmaPhi * sigmaPhi;
0076       // sigmaTheta = theta0
0077       result.varianceTheta = theta0 * theta0;
0078       //! [scattering variance]
0079     }
0080     if (energyLoss) {
0081       //! [energy loss variance]
0082       const double sigmaQoverP =
0083           computeEnergyLossLandauSigmaQOverP(slab, mass, qOverP, absQ);
0084       result.varianceQoverP = sigmaQoverP * sigmaQoverP;
0085       //! [energy loss variance]
0086     }
0087   }
0088 
0089   return result;
0090 }
0091 
0092 }  // namespace Acts