Back to home page

EIC code displayed by LXR

 
 

    


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

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/ScintillationParams.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/Types.hh"
0011 #include "corecel/data/CollectionMirror.hh"
0012 #include "corecel/data/ParamsDataInterface.hh"
0013 #include "celeritas/io/ImportOpticalMaterial.hh"
0014 
0015 #include "ScintillationData.hh"
0016 
0017 namespace celeritas
0018 {
0019 class ParticleParams;
0020 struct ImportData;
0021 
0022 namespace optical
0023 {
0024 
0025 //---------------------------------------------------------------------------//
0026 /*!
0027  * Build and manage scintillation data.
0028  *
0029  * When not imported from Geant4 (which uses
0030  *  \c G4OpticalParameters::GetScintByParticleType to select what data must be
0031  * stored), the manually constructed \c Input data must store *either* material
0032  * or particle data, never both.
0033  */
0034 class ScintillationParams final : public ParamsDataInterface<ScintillationData>
0035 {
0036   public:
0037     //!@{
0038     //! \name Type aliases
0039     using SPConstParticles = std::shared_ptr<ParticleParams const>;
0040     using ScintillationDataCRef = HostCRef<ScintillationData>;
0041     //!@}
0042 
0043     //! Scintillation data for all materials and particles
0044     struct Input
0045     {
0046         using VecOptMatId = std::vector<OpticalMaterialId>;
0047         using VecSPId = std::vector<ScintillationParticleId>;
0048 
0049         std::vector<double> resolution_scale;
0050 
0051         //! Material-only spectra
0052         std::vector<ImportMaterialScintSpectrum> materials;
0053 
0054         //!< ParticleId to ScintillationParticleId
0055         VecSPId pid_to_scintpid;
0056         //! Particle and material spectra [ParticleScintSpectrumId]
0057         std::vector<ImportParticleScintSpectrum> particles;
0058 
0059         explicit operator bool() const
0060         {
0061             return (pid_to_scintpid.empty() == particles.empty())
0062                    && !resolution_scale.empty()
0063                    && (materials.empty() != particles.empty());
0064         }
0065     };
0066 
0067   public:
0068     // Construct with imported data and particle params
0069     static std::shared_ptr<ScintillationParams>
0070     from_import(ImportData const& data, SPConstParticles particle_params);
0071 
0072     // Construct with scintillation components
0073     explicit ScintillationParams(Input const& input);
0074 
0075     //! Access physics properties on the host
0076     HostRef const& host_ref() const final { return mirror_.host_ref(); }
0077 
0078     //! Access physics properties on the device
0079     DeviceRef const& device_ref() const final { return mirror_.device_ref(); }
0080 
0081   private:
0082     // Host/device storage and reference
0083     CollectionMirror<ScintillationData> mirror_;
0084 };
0085 
0086 //---------------------------------------------------------------------------//
0087 }  // namespace optical
0088 }  // namespace celeritas