文章目录
一、main( )方法sample
Listing 2.1: main函数最简单的例子
#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
#include "ExG4DetectorConstruction01.hh"
#include "ExG4PhysicsList00.hh"
#include "ExG4ActionInitialization01.hh"
int main()
{
// construct the default run manager
auto runManager = G4RunManagerFactory::CreateRunManager();
// set mandatory initialization classes
runManager->SetUserInitialization(new ExG4DetectorConstruction01);
runManager->SetUserInitialization(new ExG4PhysicsList00);
runManager->SetUserInitialization(new ExG4ActionInitialization01);
// initialize G4 kernel
runManager->Initialize();
// get the pointer to the UI manager and set verbosities
G4UImanager* UI = G4UImanager::GetUIpointer();
UI->ApplyCommand("/run/verbose 1");
UI->ApplyCommand("/event/verbose 1");
UI->