Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:35

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2022-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file geocel/GeantGeoUtils.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <iosfwd>
0011 #include <string>
0012 #include <unordered_set>
0013 
0014 #include "corecel/Config.hh"
0015 
0016 #include "corecel/Assert.hh"
0017 #include "corecel/cont/Span.hh"
0018 
0019 //---------------------------------------------------------------------------//
0020 // Forward declarations
0021 class G4LogicalVolume;
0022 class G4VPhysicalVolume;
0023 class G4Navigator;
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 //---------------------------------------------------------------------------//
0035 #if CELERITAS_GEANT4_VERSION >= 0x0b0200
0036 //! Version-independent typedef to Geant4 touchable history
0037 using GeantTouchableBase = G4TouchableHistory;
0038 #else
0039 using GeantTouchableBase = G4VTouchable;
0040 #endif
0041 
0042 //---------------------------------------------------------------------------//
0043 //! Wrap around a touchable to get a descriptive output.
0044 struct PrintableNavHistory
0045 {
0046     GeantTouchableBase const* touch{nullptr};
0047 };
0048 
0049 //---------------------------------------------------------------------------//
0050 //! Wrap around a G4LogicalVolume to get a descriptive output.
0051 struct PrintableLV
0052 {
0053     G4LogicalVolume const* lv{nullptr};
0054 };
0055 
0056 // Print detailed information about the touchable history.
0057 std::ostream& operator<<(std::ostream& os, PrintableNavHistory const& pnh);
0058 
0059 // Print the logical volume name, ID, and address.
0060 std::ostream& operator<<(std::ostream& os, PrintableLV const& pnh);
0061 
0062 //---------------------------------------------------------------------------//
0063 // FREE FUNCTIONS
0064 //---------------------------------------------------------------------------//
0065 // Load a GDML file and return the world volume (Geant4 owns!)
0066 G4VPhysicalVolume* load_geant_geometry(std::string const& gdml_filename);
0067 
0068 // Load a GDML file, stripping pointers
0069 G4VPhysicalVolume* load_geant_geometry_native(std::string const& gdml_filename);
0070 
0071 //---------------------------------------------------------------------------//
0072 // Reset all Geant4 geometry stores if *not* using RunManager
0073 void reset_geant_geometry();
0074 
0075 //---------------------------------------------------------------------------//
0076 // Get a view to the Geant4 LV store
0077 Span<G4LogicalVolume*> geant_logical_volumes();
0078 
0079 //---------------------------------------------------------------------------//
0080 // Find Geant4 logical volumes corresponding to a list of names
0081 std::unordered_set<G4LogicalVolume const*>
0082     find_geant_volumes(std::unordered_set<std::string>);
0083 
0084 //---------------------------------------------------------------------------//
0085 // Generate the GDML name for a Geant4 logical volume
0086 std::string make_gdml_name(G4LogicalVolume const&);
0087 
0088 //---------------------------------------------------------------------------//
0089 // INLINE DEFINITIONS
0090 //---------------------------------------------------------------------------//
0091 #if !CELERITAS_USE_GEANT4
0092 inline G4VPhysicalVolume* load_geant_geometry(std::string const&)
0093 {
0094     CELER_NOT_CONFIGURED("Geant4");
0095 }
0096 
0097 inline G4VPhysicalVolume* load_geant_geometry_native(std::string const&)
0098 {
0099     CELER_NOT_CONFIGURED("Geant4");
0100 }
0101 
0102 inline void reset_geant_geometry()
0103 {
0104     CELER_NOT_CONFIGURED("Geant4");
0105 }
0106 
0107 inline Span<G4LogicalVolume*> geant_logical_volumes()
0108 {
0109     CELER_NOT_CONFIGURED("Geant4");
0110 }
0111 
0112 inline std::unordered_set<G4LogicalVolume const*>
0113 find_geant_volumes(std::unordered_set<std::string>)
0114 {
0115     CELER_NOT_CONFIGURED("Geant4");
0116 }
0117 
0118 inline std::string make_gdml_name(G4LogicalVolume const&)
0119 {
0120     CELER_NOT_CONFIGURED("Geant4");
0121 }
0122 #endif
0123 
0124 //---------------------------------------------------------------------------//
0125 }  // namespace celeritas