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();
……
}