G4VPhysicalVolume* dd4hep::sim::Geant4GDMLDetector::Construct() { #ifdef GEANT4_HAS_GDML G4GDMLParser parser; parser.Read( m_fileName ); m_world = parser.GetWorldVolume(); #endif return m_world; }
G4VPhysicalVolume * SetupGeant4Geometry( std::string volumename, Vector3D<Precision> worldbbox) { // ATTENTION: THERE IS A (OR MIGHT BE) UNIT MISSMATCH HERE BETWEEN ROOT AND GEANT // ROOT = cm and GEANT4 = mm; basically a factor of 10 in all dimensions const double UNITCONV=10.; // // take G4 geometry from gdml file G4GDMLParser parser; parser.Read( "cms2015.gdml" ); G4LogicalVolumeStore * store = G4LogicalVolumeStore::GetInstance(); // int found=0; G4LogicalVolume * foundvolume = NULL; for( auto v : *store ) { std::size_t founds = volumename.compare( v->GetName() ); if ( founds==0 ){ found++; foundvolume = v; } } std::cerr << " found logical volume " << volumename << " " << found << " times " << "\n"; // embed logical volume in a Box // create box first G4Box * worldb = new G4Box("BoundingBox", UNITCONV*worldbbox.x(), UNITCONV*worldbbox.y(), UNITCONV*worldbbox.z()); G4LogicalVolume * worldlv = new G4LogicalVolume(worldb, 0, "world", 0,0,0); G4PVPlacement * worldpv = new G4PVPlacement(0,G4ThreeVector(0,0,0),"BoundingBox", worldlv, 0,false, 0,0); // embed found logical volume "foundvolume" into world bounding box new G4PVPlacement( NULL, /* rotation */ G4ThreeVector(0,0,0), /* translation */ foundvolume, /* current logical */ "xrayedpl", worldlv, /* this is where it is placed */ 0,0); G4GeometryManager::GetInstance()->CloseGeometry( voxelize ); return worldpv; }