Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-07 10:01:43

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/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 //---------------------------------------------------------------------------//
0022 /*!
0023  * Build and manage scintillation data.
0024  *
0025  * When not imported from Geant4 (which uses
0026  *  \c G4OpticalParameters::GetScintByParticleType to select what data must be
0027  * stored), the manually constructed \c Input data must store *either* material
0028  * or particle data, never both.
0029  */
0030 class ScintillationParams final : public ParamsDataInterface<ScintillationData>
0031 {
0032   public:
0033     //!@{
0034     //! \name Type aliases
0035     using SPConstParticles = std::shared_ptr<ParticleParams const>;
0036     //!@}
0037 
0038     //! Scintillation data for all materials and particles
0039     struct Input
0040     {
0041         std::vector<double> resolution_scale;
0042 
0043         //! Material-only spectra
0044         std::vector<ImportMaterialScintSpectrum> materials;
0045 
0046         //! Particle and material spectra [ParScintSpectrumId]
0047         std::vector<ImportParticleScintSpectrum> particles;
0048         //! Map \c ParticleId to \c ScintParticleId
0049         std::vector<ScintParticleId> pid_to_scintpid;
0050 
0051         explicit operator bool() const
0052         {
0053             return (pid_to_scintpid.empty() == particles.empty())
0054                    && !resolution_scale.empty()
0055                    && (materials.empty() != particles.empty());
0056         }
0057     };
0058 
0059   public:
0060     // Construct with imported data and particle params
0061     static std::shared_ptr<ScintillationParams>
0062     from_import(ImportData const& data, SPConstParticles particle_params);
0063 
0064     // Construct with scintillation components
0065     explicit ScintillationParams(Input const& input);
0066 
0067     //! Access physics properties on the host
0068     HostRef const& host_ref() const final { return mirror_.host_ref(); }
0069 
0070     //! Access physics properties on the device
0071     DeviceRef const& device_ref() const final { return mirror_.device_ref(); }
0072 
0073   private:
0074     // Host/device storage and reference
0075     CollectionMirror<ScintillationData> mirror_;
0076 };
0077 
0078 //---------------------------------------------------------------------------//
0079 }  // namespace celeritas