Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:11:00

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