File indexing completed on 2025-02-23 09:21:51
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
0032
0033
0034
0035
0036 #include "ActionInitialization.hh"
0037 #include "CommandLineParser.hh"
0038 #include "DetectorConstruction.hh"
0039 #include "PhysicsList.hh"
0040
0041 #include "G4DNAChemistryManager.hh"
0042 #include "G4RunManagerFactory.hh"
0043 #include "G4UIExecutive.hh"
0044 #include "G4UImanager.hh"
0045 #include "G4VisExecutive.hh"
0046
0047 using namespace G4DNAPARSER;
0048 CommandLineParser* parser(0);
0049
0050
0051
0052 void Parse(int& argc, char** argv);
0053
0054
0055
0056 int main(int argc, char** argv)
0057 {
0058
0059
0060
0061 Parse(argc, argv);
0062
0063
0064
0065
0066 Command* commandLine(0);
0067
0068 auto* runManager = G4RunManagerFactory::CreateRunManager();
0069 if ((commandLine = parser->GetCommandIfActive("-mt"))) {
0070 int nThreads = 2;
0071 if (commandLine->GetOption() == "NMAX") {
0072 nThreads = G4Threading::G4GetNumberOfCores();
0073 }
0074 else {
0075 nThreads = G4UIcommand::ConvertToInt(commandLine->GetOption());
0076 }
0077 runManager->SetNumberOfThreads(nThreads);
0078
0079 G4cout << "===== clustering is started with " << runManager->GetNumberOfThreads()
0080 << " threads =====" << G4endl;
0081 }
0082
0083
0084
0085
0086 DetectorConstruction* detector = new DetectorConstruction;
0087 runManager->SetUserInitialization(new PhysicsList);
0088 runManager->SetUserInitialization(detector);
0089 runManager->SetUserInitialization(new ActionInitialization());
0090
0091
0092 runManager->Initialize();
0093
0094
0095 G4VisManager* visManager = new G4VisExecutive;
0096 visManager->Initialize();
0097
0098
0099 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0100 G4UIExecutive* ui(0);
0101
0102
0103 if ((commandLine = parser->GetCommandIfActive("-gui"))) {
0104 ui = new G4UIExecutive(argc, argv, commandLine->GetOption());
0105
0106 if (ui->IsGUI()) UImanager->ApplyCommand("/control/execute gui.mac");
0107
0108 if (parser->GetCommandIfActive("-novis") == 0)
0109
0110 {
0111 if ((commandLine = parser->GetCommandIfActive("-vis")))
0112
0113 {
0114 UImanager->ApplyCommand(G4String("/vis/open ") + commandLine->GetOption());
0115 }
0116 else
0117
0118 {
0119 UImanager->ApplyCommand("/vis/open OGL 800x600-0+0");
0120 }
0121 UImanager->ApplyCommand("/control/execute vis.mac");
0122 }
0123 }
0124 else
0125
0126
0127
0128 {
0129 if ((commandLine = parser->GetCommandIfActive("-vis"))) {
0130 UImanager->ApplyCommand(G4String("/vis/open ") + commandLine->GetOption());
0131 UImanager->ApplyCommand("/control/execute vis.mac");
0132 }
0133 }
0134
0135 if ((commandLine = parser->GetCommandIfActive("-mac"))) {
0136 G4String command = "/control/execute ";
0137 UImanager->ApplyCommand(command + commandLine->GetOption());
0138 }
0139 else {
0140 UImanager->ApplyCommand("/control/execute run.in");
0141 }
0142
0143 if ((commandLine = parser->GetCommandIfActive("-gui"))) {
0144 ui->SessionStart();
0145 delete ui;
0146 }
0147
0148
0149
0150
0151
0152
0153 delete visManager;
0154 delete runManager;
0155
0156 CommandLineParser::DeleteInstance();
0157
0158 return 0;
0159 }
0160
0161
0162
0163 void Parse(int& argc, char** argv)
0164 {
0165
0166
0167
0168 parser = CommandLineParser::GetParser();
0169
0170 parser->AddCommand("-gui", Command::OptionNotCompulsory,
0171 "Select geant4 UI or just launch a geant4 terminal session", "qt");
0172
0173 parser->AddCommand("-mac", Command::WithOption, "Give a mac file to execute", "macFile.mac");
0174
0175
0176
0177
0178
0179
0180
0181 parser->AddCommand("-mt", Command::WithOption,
0182 "Launch in MT mode (events computed in parallel,"
0183 " NOT RECOMMENDED WITH CHEMISTRY)",
0184 "2");
0185
0186 parser->AddCommand("-vis", Command::WithOption, "Select a visualization driver",
0187 "OGL 600x600-0+0");
0188
0189 parser->AddCommand("-novis", Command::WithoutOption, "Deactivate visualization when using GUI");
0190
0191
0192
0193
0194 if (parser->Parse(argc, argv) != 0)
0195 {
0196
0197
0198 CommandLineParser::DeleteInstance();
0199
0200 std::exit(0);
0201 }
0202
0203
0204
0205
0206 if (parser->CheckIfNotHandledOptionsExists(argc, argv)) {
0207
0208
0209 abort();
0210 }
0211 }