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/PrimaryGeneratorAction.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/AuxStateVec.hh"
0014 #include "corecel/data/ParamsDataStore.hh"
0015 #include "corecel/random/data/DistributionData.hh"
0016 #include "celeritas/inp/Events.hh"
0017 #include "celeritas/optical/action/ActionInterface.hh"
0018 #include "celeritas/phys/GeneratorInterface.hh"
0019 
0020 #include "GeneratorBase.hh"
0021 #include "OffloadData.hh"
0022 #include "PrimaryGeneratorData.hh"
0023 
0024 namespace celeritas
0025 {
0026 class CoreParams;
0027 
0028 namespace optical
0029 {
0030 class CoreStateBase;
0031 
0032 //---------------------------------------------------------------------------//
0033 /*!
0034  * Generate optical primaries from user-configurable distributions.
0035  *
0036  * This reproducibly samples and initializes optical photons directly in track
0037  * slots.
0038  */
0039 class PrimaryGeneratorAction final : public GeneratorBase
0040 {
0041   public:
0042     //!@{
0043     //! \name Type aliases
0044     using Input = inp::OpticalPrimaryGenerator;
0045     //!@}
0046 
0047   public:
0048     // Construct and add to core params
0049     static std::shared_ptr<PrimaryGeneratorAction> make_and_insert(CoreParams&,
0050                                                                    Input&&);
0051 
0052     // Construct with IDs and distributions
0053     PrimaryGeneratorAction(ActionId, AuxId, GeneratorId, Input);
0054 
0055     // Set the number of pending tracks
0056     void insert(CoreStateBase&) const;
0057 
0058     //!@{
0059     //! \name Aux interface
0060 
0061     // Build state data for a stream
0062     UPState create_state(MemSpace, StreamId, size_type) const final;
0063     //!@}
0064 
0065     //!@{
0066     //! \name StepAction interface
0067 
0068     // Launch kernel with host data
0069     void step(CoreParams const&, CoreStateHost&) const final;
0070     // Launch kernel with device data
0071     void step(CoreParams const&, CoreStateDevice&) const final;
0072     //!@}
0073 
0074   private:
0075     //// DATA ////
0076 
0077     PrimaryDistributionData data_;
0078     ParamsDataStore<DistributionParamsData> params_;
0079 
0080     //// HELPER FUNCTIONS ////
0081 
0082     template<MemSpace M>
0083     void insert_impl(CoreState<M>&) const;
0084 
0085     template<MemSpace M>
0086     void step_impl(CoreParams const&, CoreState<M>&) const;
0087 
0088     void generate(CoreParams const&, CoreStateHost&) const;
0089     void generate(CoreParams const&, CoreStateDevice&) const;
0090 };
0091 
0092 //---------------------------------------------------------------------------//
0093 }  // namespace optical
0094 }  // namespace celeritas