#include "DetectorConstruction.hh" #include "ActionInitialization.hh" #include "PhysicsList.hh" #include "PhysicsListMessenger.hh" #include "G4ScoringManager.hh" #include "G4VScoringMesh.hh" #include "G4VScoreWriter.hh" #include "globals.hh" #include "StackingAction.hh" #include "PrimaryGeneratorAction.hh" #include "SteppingAction.hh" #include "RunAction.hh" #include "EventAction.hh" #include "G4RunManagerFactory.hh" #include "G4UImanager.hh" #include "G4VisExecutive.hh" #include "G4UIExecutive.hh" #include "Randomize.hh" #include "g4analysis.hh" #include "G4MTRunManager.hh" #include // Include for time() //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... int main(int argc, char** argv) { // Detect interactive mode (if no arguments) and define UI session G4UIExecutive* ui = 0; if (argc == 1) { ui = new G4UIExecutive(argc, argv); } // Use the factory to create a run manager for multithreading auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default); // Set the number of threads to use runManager->SetNumberOfThreads(48); // Set up the random number generator G4Random::setTheEngine(new CLHEP::MTwistEngine); G4Random::setTheSeed(time(NULL)); // Activate command-based scoring functionality G4ScoringManager* scManager = G4ScoringManager::GetScoringManager(); scManager->SetVerboseLevel(1); // Set mandatory initialization classes runManager->SetUserInitialization(new DetectorConstruction()); runManager->SetUserInitialization(new PhysicsList()); runManager->SetUserInitialization(new ActionInitialization()); // Initialize visualization G4VisManager* visManager = new G4VisExecutive(); visManager->Initialize(); // 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 UImanager->ApplyCommand("/control/execute init_vis.mac"); ui->SessionStart(); delete ui; } delete visManager; delete runManager; }