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/MaterialParams.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <vector>
0010 
0011 #include "corecel/Types.hh"
0012 #include "corecel/data/CollectionMirror.hh"
0013 #include "corecel/data/ParamsDataInterface.hh"
0014 #include "celeritas/io/ImportOpticalMaterial.hh"
0015 
0016 #include "MaterialData.hh"
0017 #include "MaterialView.hh"
0018 
0019 namespace celeritas
0020 {
0021 struct ImportData;
0022 class MaterialParams;
0023 class GeoMaterialParams;
0024 
0025 namespace optical
0026 {
0027 //---------------------------------------------------------------------------//
0028 /*!
0029  * Manage properties for optical materials.
0030  *
0031  * Each "physics material" (the combination of a geometry-specified material
0032  * and a user-specified region) can map to a single optical material. Many
0033  * materials---especially those in mechanical structures and components not
0034  * optically connected to the detector---may have no optical properties at all.
0035  *
0036  * Optical volume properties are imported from Geant4 into the \c
0037  * ImportData container. The \c celeritas::MaterialParams class loads the
0038  * mapping of \c PhysMatId to \c OptMatId and makes it
0039  * accessible via the main loop's material view. By combining that with the \c
0040  * GeoMaterialParams which maps volumes to \c PhysMatId, this class
0041  * maps the geometry volumes to optical materials for use in the optical
0042  * tracking loop.
0043  *
0044  * When surface models are implemented, surface properties will also be added
0045  * to this class.
0046  */
0047 class MaterialParams final : public ParamsDataInterface<MaterialParamsData>
0048 {
0049   public:
0050     struct Input
0051     {
0052         //! Shared optical material, indexed by \c OptMatId
0053         std::vector<ImportOpticalProperty> properties;
0054         //! Map logical volume ID to optical material ID
0055         std::vector<OptMatId> volume_to_mat;
0056         //! Map optical material ID to core material ID
0057         std::vector<PhysMatId> optical_to_core;
0058     };
0059 
0060   public:
0061     // Construct with imported data, materials
0062     static std::shared_ptr<MaterialParams>
0063     from_import(ImportData const& data,
0064                 ::celeritas::GeoMaterialParams const& geo_mat,
0065                 ::celeritas::MaterialParams const& mat);
0066 
0067     // Construct with optical property data
0068     explicit MaterialParams(Input const& inp);
0069 
0070     // Number of optical materials
0071     inline OptMatId::size_type num_materials() const;
0072 
0073     // Construct a material view for the given identifier
0074     MaterialView get(OptMatId mat) const;
0075 
0076     //! Access optical material on the host
0077     HostRef const& host_ref() const final { return data_.host_ref(); }
0078 
0079     //! Access optical material on the device
0080     DeviceRef const& device_ref() const final { return data_.device_ref(); }
0081 
0082   private:
0083     CollectionMirror<MaterialParamsData> data_;
0084 };
0085 
0086 //---------------------------------------------------------------------------//
0087 // INLINE DEFINITIONS
0088 //---------------------------------------------------------------------------//
0089 /*!
0090  * Number of optical materials.
0091  */
0092 OptMatId::size_type MaterialParams::num_materials() const
0093 {
0094     return this->host_ref().refractive_index.size();
0095 }
0096 
0097 //---------------------------------------------------------------------------//
0098 }  // namespace optical
0099 }  // namespace celeritas