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