Geant4的PrimaryGenerator中获取世界大小

 PrimaryGeneratorAction.cc

#include "G4LogicalVolumeStore.hh"
……
void
PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) {
G4LogicalVolume
* worldLV = G4LogicalVolumeStore::GetInstance()->GetVolume("World"); G4Box* worldBox = nullptr; if ( worldLV ) worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid()); if ( worldBox ) worldZHalfLength = worldBox->GetZHalfLength(); …… }

 

posted @ 2023-08-14 21:03  endcase  阅读(16)  评论(0编辑  收藏  举报