![]() |
|
|||
File indexing completed on 2025-09-17 08:53:37
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/ext/detail/GeoOpticalIdMap.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <vector> 0010 #include <G4MaterialTable.hh> 0011 0012 #include "geocel/Types.hh" 0013 #include "celeritas/Types.hh" 0014 0015 namespace celeritas 0016 { 0017 namespace detail 0018 { 0019 //---------------------------------------------------------------------------// 0020 /*! 0021 * Construct optical material IDs and map from a geometry material ID. 0022 * 0023 * This construct a material -> optical material mapping based on whether the 0024 * \c RINDEX table is present on a Geant4 material. 0025 * 0026 * As a reminder, \em geometry materials correspond to \c G4Material and 0027 * \em physics materials correspond to \c G4MaterialCutsCouple . 0028 */ 0029 class GeoOpticalIdMap 0030 { 0031 public: 0032 //! Construct without optical materials 0033 GeoOpticalIdMap() = default; 0034 0035 // Construct from underlying Geant4 objects 0036 explicit GeoOpticalIdMap(G4MaterialTable const&); 0037 0038 // Return the optical ID corresponding to a geo ID 0039 inline OptMatId operator[](GeoMatId) const; 0040 0041 //! True if no optical materials are present 0042 bool empty() const { return geo_to_opt_.empty(); } 0043 0044 //! Number of geometry materials 0045 GeoMatId::size_type num_geo() const { return geo_to_opt_.size(); } 0046 0047 //! Number of optical materials 0048 OptMatId::size_type num_optical() const { return num_optical_; } 0049 0050 private: 0051 std::vector<OptMatId> geo_to_opt_; 0052 OptMatId::size_type num_optical_{}; 0053 }; 0054 0055 //---------------------------------------------------------------------------// 0056 // INLINE DEFINITIONS 0057 //---------------------------------------------------------------------------// 0058 /*! 0059 * Return the optical ID corresponding to a geo ID. 0060 * 0061 * The result \em may be a "null" ID if there's no associated optical physics. 0062 */ 0063 OptMatId GeoOpticalIdMap::operator[](GeoMatId m) const 0064 { 0065 CELER_EXPECT(!this->empty()); 0066 CELER_EXPECT(m < this->num_geo()); 0067 0068 return geo_to_opt_[m.get()]; 0069 } 0070 0071 //---------------------------------------------------------------------------// 0072 } // namespace detail 0073 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |