File indexing completed on 2025-02-23 09:22:03
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]" << 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 > 7) {
0060 PrintUsage();
0061 return 1;
0062 }
0063
0064 G4String macro;
0065 G4int phys_option = 2;
0066
0067 G4int nThreads = 2;
0068 for (G4int ii = 1; ii < argc; ii = ii + 2) {
0069 if (G4String(argv[ii]) == "-m") {
0070 macro = argv[ii + 1];
0071 }
0072 else if (G4String(argv[ii]) == "-p") {
0073 phys_option = G4UIcommand::ConvertToInt(argv[ii + 1]);
0074 }
0075 else if (G4String(argv[ii]) == "-t") {
0076 nThreads = G4UIcommand::ConvertToInt(argv[ii + 1]);
0077 }
0078 else {
0079 PrintUsage();
0080 return 1;
0081 }
0082 }
0083
0084 G4UIExecutive* ui = nullptr;
0085 if (!macro.size()) {
0086 ui = new G4UIExecutive(argc, argv);
0087 }
0088
0089
0090
0091
0092
0093
0094
0095
0096 auto* runManager = G4RunManagerFactory::CreateRunManager();
0097 if (nThreads > 0) {
0098 runManager->SetNumberOfThreads(nThreads);
0099 }
0100
0101 runManager->SetUserInitialization(new DetectorConstruction());
0102 G4VModularPhysicsList* physicsList = new PhysicsList(phys_option);
0103 runManager->SetUserInitialization(physicsList);
0104 runManager->SetUserInitialization(new ActionInitialization());
0105 G4DNAChemistryManager::Instance()->Initialize();
0106
0107 G4VisExecutive* visManager = nullptr;
0108
0109
0110 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0111 if (!macro.empty()) {
0112
0113 G4String command = "/control/execute ";
0114 UImanager->ApplyCommand(command + macro);
0115 }
0116 else {
0117 visManager = new G4VisExecutive;
0118 visManager->Initialize();
0119 UImanager->ApplyCommand("/control/execute vis.mac");
0120 ui->SessionStart();
0121 delete ui;
0122 delete visManager;
0123 }
0124 delete runManager;
0125 return 0;
0126 }
0127
0128