|
|
|||
File indexing completed on 2026-05-11 08:42:13
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/GeantGeoUtils.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <iosfwd> 0010 #include <string> 0011 #include <unordered_set> 0012 0013 #include "corecel/Config.hh" 0014 0015 #include "corecel/Assert.hh" 0016 #include "corecel/cont/Span.hh" 0017 0018 //---------------------------------------------------------------------------// 0019 // Forward declarations 0020 class G4Field; 0021 class G4LogicalVolume; 0022 class G4NavigationHistory; 0023 class G4VPhysicalVolume; 0024 0025 #if CELERITAS_GEANT4_VERSION >= 0x0b0200 0026 // Geant4 11.2 removed G4VTouchable 0027 class G4TouchableHistory; 0028 #else 0029 class G4VTouchable; 0030 #endif 0031 0032 namespace celeritas 0033 { 0034 struct GeantPhysicalInstance; 0035 //---------------------------------------------------------------------------// 0036 #if CELERITAS_GEANT4_VERSION >= 0x0b0200 0037 //! Version-independent typedef to Geant4 touchable history 0038 using GeantTouchableBase = G4TouchableHistory; 0039 #else 0040 using GeantTouchableBase = G4VTouchable; 0041 #endif 0042 0043 //---------------------------------------------------------------------------// 0044 //! Wrap around a touchable to get a descriptive output. 0045 struct PrintableNavHistory 0046 { 0047 G4NavigationHistory const* nav{nullptr}; 0048 }; 0049 0050 //---------------------------------------------------------------------------// 0051 //! Wrap around a G4LogicalVolume to get a descriptive output. 0052 struct PrintableLV 0053 { 0054 G4LogicalVolume const* lv{nullptr}; 0055 }; 0056 0057 // Print detailed information about the touchable history. 0058 std::ostream& operator<<(std::ostream&, PrintableNavHistory const&); 0059 0060 // Print the logical volume name, ID, and address. 0061 std::ostream& operator<<(std::ostream&, PrintableLV const&); 0062 0063 //---------------------------------------------------------------------------// 0064 // FREE FUNCTIONS 0065 //---------------------------------------------------------------------------// 0066 // Reset all Geant4 geometry stores if *not* using RunManager 0067 void reset_geant_geometry(); 0068 0069 //---------------------------------------------------------------------------// 0070 // Get a view to the Geant4 LV store 0071 Span<G4LogicalVolume*> geant_logical_volumes(); 0072 0073 //---------------------------------------------------------------------------// 0074 // Get the world volume if the geometry has been set up 0075 G4VPhysicalVolume const* geant_world_volume(); 0076 0077 //---------------------------------------------------------------------------// 0078 // Get the field from the global field manager 0079 G4Field const* geant_field(); 0080 0081 //---------------------------------------------------------------------------// 0082 // Whether the volume is a replica/parameterization 0083 bool is_replica(G4VPhysicalVolume const&); 0084 0085 //---------------------------------------------------------------------------// 0086 // Find Geant4 logical volumes corresponding to a list of names 0087 std::unordered_set<G4LogicalVolume const*> 0088 find_geant_volumes(std::unordered_set<std::string>); 0089 0090 //---------------------------------------------------------------------------// 0091 // Update a nav history to match the given volume instance stack 0092 void set_history(Span<GeantPhysicalInstance const> stack, 0093 G4NavigationHistory* nav); 0094 0095 //---------------------------------------------------------------------------// 0096 // INLINE DEFINITIONS 0097 //---------------------------------------------------------------------------// 0098 #if !CELERITAS_USE_GEANT4 0099 inline void reset_geant_geometry() 0100 { 0101 CELER_NOT_CONFIGURED("Geant4"); 0102 } 0103 0104 inline Span<G4LogicalVolume*> geant_logical_volumes() 0105 { 0106 CELER_NOT_CONFIGURED("Geant4"); 0107 } 0108 0109 inline std::unordered_set<G4LogicalVolume const*> 0110 find_geant_volumes(std::unordered_set<std::string>) 0111 { 0112 CELER_NOT_CONFIGURED("Geant4"); 0113 } 0114 0115 inline std::ostream& operator<<(std::ostream&, PrintableNavHistory const&) 0116 { 0117 CELER_NOT_CONFIGURED("Geant4"); 0118 } 0119 0120 inline std::ostream& operator<<(std::ostream&, PrintableLV const&) 0121 { 0122 CELER_NOT_CONFIGURED("Geant4"); 0123 } 0124 0125 inline bool is_replica(G4VPhysicalVolume const&) 0126 { 0127 CELER_NOT_CONFIGURED("Geant4"); 0128 } 0129 0130 #endif 0131 0132 //---------------------------------------------------------------------------// 0133 } // 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 |
|