// M Hentz, 2016 #include "G4RunManager.hh" #include "G4UImanager.hh" #include "Randomize.hh" #include "DetectorConstruction.hh" #include "PhysicsList.hh" #include "PrimaryGeneratorAction.hh" #include "G4PhysListFactory.hh" #include "G4VModularPhysicsList.hh" #include "G4ScoringManager.hh" #include "RunAction.hh" #include "EventAction.hh" #include "SteppingAction.hh" #include "SteppingVerbose.hh" #include "G4ParallelWorldPhysics.hh" #include "ParallelWorldConstruction.hh" #ifdef G4VIS_USE #include "G4VisExecutive.hh" #endif #ifdef G4UI_USE #include "G4UIExecutive.hh" #endif int main(int argc,char** argv) { // Detect interactive mode (if no arguments) and define UI session G4UIExecutive* ui = nullptr; if ( argc == 1 ) { ui = new G4UIExecutive( argc, argv ); } // Choose the Random engine CLHEP::HepRandom::setTheEngine( new CLHEP::RanecuEngine ); // my Verbose output class G4VSteppingVerbose::SetInstance( new SteppingVerbose ); // Construct the default run manager G4RunManager* runManager = new G4RunManager; // Set mandatory initialization classes DetectorConstruction* det = new DetectorConstruction(); // Register parallel world G4String parallelWorldName = "ParallelWorld"; det->RegisterParallelWorld( new ParallelWorldConstruction(parallelWorldName) ); runManager->SetUserInitialization(det); // Set physics list PhysicsList* phys = new PhysicsList(); runManager->SetUserInitialization(phys); // Set UI-command base scorer G4ScoringManager * scManager = G4ScoringManager::GetScoringManager(); scManager->SetVerboseLevel(1); // Set user action classes PrimaryGeneratorAction* kin = new PrimaryGeneratorAction(); EventAction* event = new EventAction(); RunAction* run = new RunAction( det, phys, kin ); SteppingAction* step = new SteppingAction( det, run ); runManager->SetUserAction(kin); runManager->SetUserAction(run); runManager->SetUserAction(event); runManager->SetUserAction(step); #ifdef G4VIS_USE G4VisManager* visManager = new G4VisExecutive; visManager->Initialize(); #endif // Get the pointer to the User Interface manager G4UImanager* UImanager = G4UImanager::GetUIpointer(); if ( !ui ){ // Batch mode G4String command = "/control/execute "; G4String fileName = argv[1]; UImanager->ApplyCommand( command+fileName ); } else { // Interactive mode #ifdef G4UI_USE UImanager->ApplyCommand( "/control/execute init_vis.mac" ); ui->SessionStart(); delete ui; #endif } #ifdef G4VIS_USE delete visManager; #endif // Job termination delete runManager; return 0; }