File indexing completed on 2025-10-13 08:25:11
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 #include "ActionInitialization.hh"
0031 #include "DetectorConstruction.hh"
0032 #include "PhysicsList.hh"
0033
0034 #include "G4DNAChemistryManager.hh"
0035 #include "G4MoleculeGun.hh"
0036 #include "G4RunManagerFactory.hh"
0037 #include "G4UIExecutive.hh"
0038 #include "G4UImanager.hh"
0039 #include "G4VisExecutive.hh"
0040
0041 #include <ctime>
0042
0043
0044
0045 namespace
0046 {
0047 void PrintUsage()
0048 {
0049 G4cout << " Usage: " << G4endl;
0050 G4cout << " molecular [-m macro ] [-t nThreads] [-p PhysicsList] [-v vis]" << G4endl;
0051 G4cout << " -p is the G4DNA Physics List option. Default (0) is"
0052 << " G4EmDNAPhysics" << G4endl;
0053 G4cout << " note: -t option is available only for multi-threaded mode." << G4endl;
0054 }
0055 }
0056
0057 int main(int argc, char** argv)
0058 {
0059 if (argc > 10) {
0060 PrintUsage();
0061 return 1;
0062 }
0063
0064 G4String macro;
0065 G4int phys_option = 2;
0066 G4int vis_option = 0;
0067
0068 G4int nThreads = 2;
0069 for (G4int ii = 1; ii < argc; ii = ii + 2) {
0070 if (G4String(argv[ii]) == "-m") {
0071 macro = argv[ii + 1];
0072 }
0073 else if (G4String(argv[ii]) == "-p") {
0074 phys_option = G4UIcommand::ConvertToInt(argv[ii + 1]);
0075 }
0076 else if (G4String(argv[ii]) == "-t") {
0077 nThreads = G4UIcommand::ConvertToInt(argv[ii + 1]);
0078 }
0079 else if (G4String(argv[ii]) == "-v") {
0080 vis_option = G4UIcommand::ConvertToInt(argv[ii + 1]);
0081 }
0082 else {
0083 PrintUsage();
0084 return 1;
0085 }
0086 }
0087
0088 G4UIExecutive* ui = nullptr;
0089 if (!macro.size()) {
0090 ui = new G4UIExecutive(argc, argv);
0091 }
0092
0093
0094
0095
0096
0097
0098
0099
0100 auto* runManager = G4RunManagerFactory::CreateRunManager();
0101 if (nThreads > 0) {
0102 runManager->SetNumberOfThreads(nThreads);
0103 }
0104
0105 runManager->SetUserInitialization(new DetectorConstruction(vis_option));
0106 G4VModularPhysicsList* physicsList = new PhysicsList(phys_option, vis_option);
0107 runManager->SetUserInitialization(physicsList);
0108 runManager->SetUserInitialization(new ActionInitialization());
0109 G4DNAChemistryManager::Instance()->Initialize();
0110
0111 G4VisExecutive* visManager = nullptr;
0112
0113
0114 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0115 if (!macro.empty()) {
0116
0117 G4String command = "/control/execute ";
0118 UImanager->ApplyCommand(command + macro);
0119 }
0120 else {
0121 visManager = new G4VisExecutive;
0122 visManager->Initialize();
0123 UImanager->ApplyCommand("/control/execute vis.mac");
0124 ui->SessionStart();
0125 delete ui;
0126 delete visManager;
0127 }
0128 delete runManager;
0129 return 0;
0130 }
0131
0132