|
|
|||
File indexing completed on 2026-10-29 09:13:54
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 geocel/VolumeIdBuilder.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <string> 0010 0011 #include "geocel/Types.hh" 0012 0013 class G4LogicalVolume; 0014 0015 namespace celeritas 0016 { 0017 class GeantGeoParams; 0018 class VolumeParams; 0019 struct Label; 0020 0021 //---------------------------------------------------------------------------// 0022 /*! 0023 * Map a string or Geant4 volume pointer to a volume ID. 0024 * 0025 * This \c std::visit -compatible class will convert input types to a canonical 0026 * volume ID depending on what metadata (constructed Geant4 geometry, volume 0027 * parameters) are available. A "null" ID can be returned (and warning/error 0028 * message emitted) if the mapping fails. 0029 * 0030 * This helper class should only have *temporary* scope. 0031 */ 0032 class VolumeIdBuilder 0033 { 0034 public: 0035 //!@{ 0036 //! \name Type aliases 0037 using G4LV = G4LogicalVolume; 0038 //!@} 0039 0040 public: 0041 // Construct using geant4 params and/or volume params 0042 inline VolumeIdBuilder(VolumeParams const*, GeantGeoParams const*); 0043 0044 // Map from a string using VolumeParams 0045 VolumeId operator()(std::string const& s) const; 0046 0047 // Map from a label using VolumeParams 0048 VolumeId operator()(Label const& lab) const; 0049 0050 // Map from Geant4 volume pointer using geant_geo 0051 VolumeId operator()(G4LogicalVolume const* lv) const; 0052 0053 private: 0054 VolumeParams const* volumes_{nullptr}; 0055 GeantGeoParams const* geant_geo_{nullptr}; 0056 }; 0057 0058 //---------------------------------------------------------------------------// 0059 // INLINE DEFINITIONS 0060 //---------------------------------------------------------------------------// 0061 /*! 0062 * Construct using geant4 params and/or volume params. 0063 * 0064 * If both are null, this class will be nonfunctional. 0065 */ 0066 VolumeIdBuilder::VolumeIdBuilder(VolumeParams const* v, 0067 GeantGeoParams const* gg) 0068 : volumes_{v}, geant_geo_{gg} 0069 { 0070 } 0071 0072 //---------------------------------------------------------------------------// 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 |
|