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/gen/GeneratorAction.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 
0011 #include "corecel/cont/Span.hh"
0012 #include "corecel/data/AuxInterface.hh"
0013 #include "celeritas/optical/action/ActionInterface.hh"
0014 #include "celeritas/phys/GeneratorInterface.hh"
0015 
0016 #include "GeneratorBase.hh"
0017 #include "GeneratorData.hh"
0018 
0019 namespace celeritas
0020 {
0021 class CoreParams;
0022 class CherenkovParams;
0023 class ScintillationParams;
0024 
0025 namespace optical
0026 {
0027 class CoreStateBase;
0028 
0029 //---------------------------------------------------------------------------//
0030 /*!
0031  * Generate photons from optical distribution data.
0032  *
0033  * This samples and initializes optical photons directly in a track slot in a
0034  * reproducible way. Multiple threads may generate initializers from a single
0035  * distribution.
0036  */
0037 class GeneratorAction final : public GeneratorBase
0038 {
0039   public:
0040     //!@{
0041     //! \name Type aliases
0042     using SpanConstData = Span<GeneratorDistributionData const>;
0043     //!@}
0044 
0045   public:
0046     // Construct and add to core params
0047     static std::shared_ptr<GeneratorAction> make_and_insert(
0048         CoreParams const&, size_type capacity);
0049 
0050     // Construct with action ID, data IDs, and optical properties
0051     GeneratorAction(ActionId, AuxId, GeneratorId, size_type capacity);
0052 
0053     // Add user-provided host distribution data
0054     void insert(CoreStateBase&, SpanConstData) const;
0055 
0056     //!@{
0057     //! \name Aux interface
0058 
0059     // Build state data for a stream
0060     UPState create_state(MemSpace, StreamId, size_type) const final;
0061     //!@}
0062 
0063     //!@{
0064     //! \name StepAction interface
0065 
0066     // Launch kernel with host data
0067     void step(CoreParams const&, CoreStateHost&) const final;
0068     // Launch kernel with device data
0069     void step(CoreParams const&, CoreStateDevice&) const final;
0070     //!@}
0071 
0072   private:
0073     //// DATA ////
0074 
0075     // Starting distribution buffer capacity
0076     size_type initial_capacity_;
0077 
0078     //// HELPER FUNCTIONS ////
0079 
0080     template<MemSpace M>
0081     void insert_impl(CoreState<M>& state, SpanConstData data) const;
0082 
0083     template<MemSpace M>
0084     void step_impl(CoreParams const&, CoreState<M>&) const;
0085 
0086     void generate(CoreParams const&, CoreStateHost&) const;
0087     void generate(CoreParams const&, CoreStateDevice&) const;
0088 };
0089 
0090 //---------------------------------------------------------------------------//
0091 }  // namespace optical
0092 }  // namespace celeritas