File indexing completed on 2025-01-18 09:17:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include "G4RunManagerFactory.hh"
0032 #include "G4SteppingVerbose.hh"
0033 #include "G4Types.hh"
0034 #include "G4UIExecutive.hh"
0035 #include "G4UImanager.hh"
0036 #include "G4VisExecutive.hh"
0037
0038 #include "ActionInitialization.hh"
0039 #include "DetectorConstruction.hh"
0040 #include "PhysicsList.hh"
0041
0042
0043
0044 int main(int argc, char** argv)
0045 {
0046
0047 G4UIExecutive* ui = nullptr;
0048 if (argc == 1) ui = new G4UIExecutive(argc, argv);
0049
0050
0051 G4int precision = 4;
0052 G4SteppingVerbose::UseBestUnit(precision);
0053
0054 if (argc == 2) {
0055 G4Exception("argument", "Fatal error in Argument", FatalErrorInArgument,
0056 "Type of simulation must be precised: either ./stim_pixe_tomography -p "
0057 "pixe3d.mac or ./stim_pixe_tomography -s pixe3d.mac");
0058 }
0059 G4bool isPIXE = false;
0060 if (argc > 2) {
0061 G4String s;
0062 s = argv[1];
0063 if (s == "-p")
0064 isPIXE = true;
0065 else if (s == "-s")
0066 isPIXE = false;
0067 else {
0068 G4Exception("argument", "Fatal error in Argument", FatalErrorInArgument,
0069 "Type of simulation must be precised: /stim_pixe_tomography -p "
0070 "pixe3d.mac or ./stim_pixe_tomography -s pixe3d.mac");
0071 }
0072 }
0073 G4int nThreads = 4;
0074 if (argc == 4) nThreads = G4UIcommand::ConvertToInt(argv[3]);
0075 auto* runManager = G4RunManagerFactory::CreateRunManager();
0076 runManager->SetNumberOfThreads(nThreads);
0077
0078
0079 runManager->SetUserInitialization(new DetectorConstruction());
0080 runManager->SetUserInitialization(new PhysicsList());
0081 runManager->SetUserInitialization(new ActionInitialization(isPIXE));
0082
0083
0084 auto visManager = new G4VisExecutive;
0085 visManager->Initialize();
0086
0087
0088 auto UImanager = G4UImanager::GetUIpointer();
0089
0090
0091
0092 if (ui) {
0093 UImanager->ApplyCommand("/control/execute init_vis.mac");
0094 ui->SessionStart();
0095 delete ui;
0096 }
0097 else {
0098 G4String command;
0099 command = "/control/execute ";
0100 G4String fileName;
0101 fileName = argv[2];
0102 UImanager->ApplyCommand(command + fileName);
0103 }
0104
0105
0106 delete visManager;
0107 delete runManager;
0108 return 0;
0109 }
0110
0111