File indexing completed on 2025-01-18 09:14:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DDG4/Geant4GeometryInfo.h>
0016 #include <DDG4/Geant4AssemblyVolume.h>
0017 #include <DD4hep/Printout.h>
0018
0019
0020 #include <G4VPhysicalVolume.hh>
0021
0022 using namespace dd4hep::sim;
0023
0024 std::string Geant4GeometryInfo::placementPath(const Geant4PlacementPath& path, bool reverse) {
0025 std::string path_name;
0026 if ( reverse ) {
0027 for (Geant4PlacementPath::const_reverse_iterator pIt = path.rbegin(); pIt != path.rend(); ++pIt) {
0028 path_name += "/"; path_name += (*pIt)->GetName();
0029 }
0030 }
0031 else {
0032 for (Geant4PlacementPath::const_iterator pIt = path.begin(); pIt != path.end(); ++pIt) {
0033 path_name += "/"; path_name += (*pIt)->GetName();
0034 }
0035 }
0036 return path_name;
0037 }
0038
0039
0040 Geant4GeometryInfo::Geant4GeometryInfo()
0041 : TNamed("Geant4GeometryInfo", "Geant4GeometryInfo"), m_world(0), printLevel(DEBUG), valid(false) {
0042 }
0043
0044
0045 Geant4GeometryInfo::~Geant4GeometryInfo() {
0046 for( auto& a : g4AssemblyVolumes )
0047 delete a.second;
0048 g4AssemblyVolumes.clear();
0049 }
0050
0051
0052 G4VPhysicalVolume* Geant4GeometryInfo::world() const {
0053 if ( m_world ) return m_world;
0054 except("Geant4GeometryInfo", "Attempt to access invalid world placement");
0055 return m_world;
0056 }
0057
0058
0059 void Geant4GeometryInfo::setWorld(const TGeoNode* node) {
0060 Geant4GeometryMaps::PlacementMap::const_iterator g4it = g4Placements.find(node);
0061 G4VPhysicalVolume* g4 = (g4it == g4Placements.end()) ? 0 : (*g4it).second;
0062 if (!g4) {
0063 except("Geant4GeometryInfo", "Attempt to SET invalid world placement");
0064 }
0065 m_world = g4;
0066 }