Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:27

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file celeritas/optical/OpticalCollector.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 
0012 #include "corecel/data/AuxInterface.hh"
0013 #include "celeritas/Types.hh"
0014 
0015 #include "OffloadData.hh"
0016 
0017 namespace celeritas
0018 {
0019 //---------------------------------------------------------------------------//
0020 class ActionRegistry;
0021 class CoreParams;
0022 
0023 namespace optical
0024 {
0025 class CerenkovParams;
0026 class MaterialParams;
0027 class ScintillationParams;
0028 }  // namespace optical
0029 
0030 namespace detail
0031 {
0032 class CerenkovOffloadAction;
0033 class CerenkovGeneratorAction;
0034 class OffloadGatherAction;
0035 class OpticalLaunchAction;
0036 class OffloadParams;
0037 class ScintOffloadAction;
0038 class ScintGeneratorAction;
0039 }  // namespace detail
0040 
0041 //---------------------------------------------------------------------------//
0042 /*!
0043  * Generate and track optical photons.
0044  *
0045  * This class is the interface between the main stepping loop and the photon
0046  * stepping loop and constructs kernel actions for:
0047  * - gathering the pre-step data needed to generate the optical distributions,
0048  * - generating the scintillation and Cerenkov optical distributions at the
0049  *   end of the step, and
0050  * - launching the photon stepping loop.
0051  *
0052  * The photon stepping loop will then generate optical primaries.
0053  *
0054  * The "collector" (TODO: rename?) will "own" the optical state data and
0055  * optical params since it's the only thing that launches the optical stepping
0056  * loop.
0057  *
0058  * \todo Rename to OpticalOffload
0059  */
0060 class OpticalCollector
0061 {
0062   public:
0063     //!@{
0064     //! \name Type aliases
0065     using SPConstCerenkov = std::shared_ptr<optical::CerenkovParams const>;
0066     using SPConstMaterial = std::shared_ptr<optical::MaterialParams const>;
0067     using SPConstScintillation
0068         = std::shared_ptr<optical::ScintillationParams const>;
0069     //!@}
0070 
0071     struct Input
0072     {
0073         //! Optical physics material for materials
0074         SPConstMaterial material;
0075         SPConstCerenkov cerenkov;
0076         SPConstScintillation scintillation;
0077 
0078         //! Number of steps that have created optical particles
0079         size_type buffer_capacity{};
0080 
0081         //! Maximum number of buffered initializers in optical tracking loop
0082         size_type primary_capacity{};
0083 
0084         //! Threshold number of initializers for launching optical loop
0085         size_type auto_flush{};
0086 
0087         //! True if all input is assigned and valid
0088         explicit operator bool() const
0089         {
0090             return material && (scintillation || cerenkov)
0091                    && buffer_capacity > 0 && primary_capacity > 0
0092                    && auto_flush > 0;
0093         }
0094     };
0095 
0096   public:
0097     // Construct with core data and optical params
0098     OpticalCollector(CoreParams const&, Input&&);
0099 
0100     // Aux ID for optical offload data
0101     AuxId offload_aux_id() const;
0102 
0103     // Aux ID for optical state data
0104     AuxId optical_aux_id() const;
0105 
0106   private:
0107     //// TYPES ////
0108 
0109     using SPOffloadParams = std::shared_ptr<detail::OffloadParams>;
0110     using SPCerenkovAction = std::shared_ptr<detail::CerenkovOffloadAction>;
0111     using SPScintAction = std::shared_ptr<detail::ScintOffloadAction>;
0112     using SPGatherAction = std::shared_ptr<detail::OffloadGatherAction>;
0113     using SPCerenkovGenAction
0114         = std::shared_ptr<detail::CerenkovGeneratorAction>;
0115     using SPScintGenAction = std::shared_ptr<detail::ScintGeneratorAction>;
0116     using SPLaunchAction = std::shared_ptr<detail::OpticalLaunchAction>;
0117 
0118     //// DATA ////
0119 
0120     SPOffloadParams offload_params_;
0121 
0122     SPGatherAction gather_action_;
0123     SPCerenkovAction cerenkov_action_;
0124     SPScintAction scint_action_;
0125     SPCerenkovGenAction cerenkov_gen_action_;
0126     SPScintGenAction scint_gen_action_;
0127     SPLaunchAction launch_action_;
0128 
0129     // TODO: tracking loop launch action
0130 };
0131 
0132 //---------------------------------------------------------------------------//
0133 }  // namespace celeritas