Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:42

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/detail/CherenkovGeneratorAction.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 
0011 #include "corecel/Macros.hh"
0012 #include "corecel/data/AuxInterface.hh"
0013 #include "corecel/data/Collection.hh"
0014 #include "celeritas/global/ActionInterface.hh"
0015 
0016 #include "../GeneratorDistributionData.hh"
0017 
0018 namespace celeritas
0019 {
0020 namespace optical
0021 {
0022 class CherenkovParams;
0023 class MaterialParams;
0024 }  // namespace optical
0025 
0026 namespace detail
0027 {
0028 class OffloadParams;
0029 //---------------------------------------------------------------------------//
0030 /*!
0031  * Generate Cherenkov photons from optical distribution data.
0032  *
0033  * This samples and buffers new optical track initializers in a reproducible
0034  * way. Rather than let each thread generate all initializers from one
0035  * distribution, the work is split as evenly as possible among threads:
0036  * multiple threads may generate initializers from a single distribution.
0037  */
0038 class CherenkovGeneratorAction final : public CoreStepActionInterface
0039 {
0040   public:
0041     //!@{
0042     //! \name Type aliases
0043     using SPConstCherenkov
0044         = std::shared_ptr<celeritas::optical::CherenkovParams const>;
0045     using SPConstMaterial
0046         = std::shared_ptr<celeritas::optical::MaterialParams const>;
0047     using SPOffloadParams = std::shared_ptr<OffloadParams>;
0048     //!@}
0049 
0050   public:
0051     // Construct with action ID, data IDs, and optical properties
0052     CherenkovGeneratorAction(ActionId id,
0053                             AuxId offload_id,
0054                             AuxId optical_id,
0055                             SPConstMaterial material,
0056                             SPConstCherenkov cherenkov,
0057                             size_type auto_flush);
0058 
0059     // Launch kernel with host data
0060     void step(CoreParams const&, CoreStateHost&) const final;
0061 
0062     // Launch kernel with device data
0063     void step(CoreParams const&, CoreStateDevice&) const final;
0064 
0065     //! ID of the model
0066     ActionId action_id() const final { return id_; }
0067 
0068     //! Short name for the action
0069     std::string_view label() const final
0070     {
0071         return "generate-cherenkov-photons";
0072     }
0073 
0074     // Name of the action (for user output)
0075     std::string_view description() const final;
0076 
0077     //! Dependency ordering of the action
0078     StepActionOrder order() const final { return StepActionOrder::user_post; }
0079 
0080   private:
0081     //// DATA ////
0082 
0083     ActionId id_;
0084     AuxId offload_id_;
0085     AuxId optical_id_;
0086     SPConstMaterial material_;
0087     SPConstCherenkov cherenkov_;
0088     size_type auto_flush_;
0089 
0090     //// HELPER FUNCTIONS ////
0091 
0092     template<MemSpace M>
0093     void step_impl(CoreParams const&, CoreState<M>&) const;
0094 
0095     void generate(CoreParams const&, CoreStateHost&) const;
0096     void generate(CoreParams const&, CoreStateDevice&) const;
0097 };
0098 
0099 //---------------------------------------------------------------------------//
0100 }  // namespace detail
0101 }  // namespace celeritas