Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:11:38

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/optical/model/MieExecutor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "corecel/io/Logger.hh"
0012 #include "celeritas/geo/GeoFwd.hh"
0013 #include "celeritas/io/ImportOpticalMaterial.hh"
0014 #include "celeritas/optical/CoreTrackView.hh"
0015 #include "celeritas/optical/Interaction.hh"
0016 #include "celeritas/optical/MieData.hh"
0017 #include "celeritas/optical/ParticleTrackView.hh"
0018 #include "celeritas/optical/interactor/MieInteractor.hh"
0019 
0020 namespace celeritas
0021 {
0022 namespace optical
0023 {
0024 //---------------------------------------------------------------------------//
0025 struct MieExecutor
0026 {
0027     inline CELER_FUNCTION Interaction operator()(CoreTrackView const&);
0028 
0029     NativeCRef<MieData> data;
0030 };
0031 
0032 //---------------------------------------------------------------------------//
0033 /*!
0034  * Sample optical Mie interaction from the current track.
0035  */
0036 CELER_FUNCTION Interaction MieExecutor::operator()(CoreTrackView const& track)
0037 {
0038     CELER_EXPECT(data);
0039 
0040     // Access the current particle track (optical photon)
0041     auto particle = track.particle();
0042     // Photon's current direction
0043     auto const& direction = track.geometry().dir();
0044     // RNG stream for sampling scattering
0045     auto rng = track.rng();
0046     // Look up the Mie parameters for this material
0047     auto matid = track.material_record().material_id();
0048     CELER_ASSERT(matid < data.mie_record.size());
0049 
0050     MieInteractor interact{data, particle, direction, matid};
0051 
0052     return interact(rng);
0053 }
0054 
0055 //---------------------------------------------------------------------------//
0056 }  // namespace optical
0057 }  // namespace celeritas