40 #include "ActionInitialization.hh" 42 #ifdef G4MULTITHREADED 43 #include "G4MTRunManager.hh" 45 #include "G4RunManager.hh" 48 #include "G4DNAChemistryManager.hh" 49 #include "G4UImanager.hh" 50 #include "G4UIExecutive.hh" 51 #include "G4VisExecutive.hh" 53 #include "CommandLineParser.hh" 67 CommandLineParser*
parser(0);
69 void Parse(
int& argc,
char** argv);
71 int main(
int argc,
char** argv)
81 Command* commandLine(0);
83 #ifdef G4MULTITHREADED 84 G4RunManager* runManager(0);
85 if ((commandLine =
parser->GetCommandIfActive(
"-mt")))
87 runManager =
new G4MTRunManager;
89 const G4String& option = commandLine->GetOption();
92 nThreads = G4UIcommand::ConvertToInt(commandLine->GetDefaultOption());
94 else if(option ==
"NMAX")
96 nThreads = G4Threading::G4GetNumberOfCores();
100 nThreads = G4UIcommand::ConvertToInt(option);
103 G4cout <<
"===== Chem2 is started with " 104 << ((G4MTRunManager*) runManager)->GetNumberOfThreads()
105 <<
" threads =====" << G4endl;
107 ((G4MTRunManager*) runManager)->SetNumberOfThreads(nThreads);
111 runManager =
new G4RunManager();
114 G4RunManager* runManager =
new G4RunManager();
121 runManager->SetUserInitialization(
new PhysicsList);
122 runManager->SetUserInitialization(detector);
123 runManager->SetUserInitialization(
new ActionInitialization());
126 runManager->Initialize();
129 G4VisManager* visManager =
new G4VisExecutive;
132 visManager->Initialize();
135 G4UImanager* UImanager = G4UImanager::GetUIpointer();
136 G4UIExecutive* ui(0);
139 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
141 ui =
new G4UIExecutive(argc, argv,
142 commandLine->GetOption());
144 if(
parser->GetCommandIfActive(
"-novis") == 0)
147 if((commandLine =
parser->GetCommandIfActive(
"-vis")))
150 UImanager->ApplyCommand(
G4String(
"/vis/open ")+
151 commandLine->GetOption());
156 UImanager->ApplyCommand(
"/vis/open OGL 800x600-0+0");
158 UImanager->ApplyCommand(
"/control/execute vis.mac");
162 UImanager->ApplyCommand(
"/control/execute gui.mac");
169 if ((commandLine =
parser->GetCommandIfActive(
"-vis")))
171 UImanager->ApplyCommand(
G4String(
"/vis/open ")+commandLine->GetOption());
172 UImanager->ApplyCommand(
"/control/execute vis.mac");
176 if ((commandLine =
parser->GetCommandIfActive(
"-mac")))
178 G4String command =
"/control/execute ";
179 UImanager->ApplyCommand(command + commandLine->GetOption());
183 UImanager->ApplyCommand(
"/control/execute beam.in");
186 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
200 CommandLineParser::DeleteInstance();
210 parser = CommandLineParser::GetParser();
212 parser->AddCommand(
"-gui",
213 Command::OptionNotCompulsory,
214 "Select geant4 UI or just launch a geant4 terminal session",
217 parser->AddCommand(
"-mac",
219 "Give a mac file to execute",
228 #ifdef G4MULTITHREADED 229 parser->AddCommand(
"-mt", Command::OptionNotCompulsory,
230 "Launch in MT mode (events computed in parallel," 231 " NOT RECOMMANDED WITH CHEMISTRY)",
235 parser->AddCommand(
"-chemOFF",
236 Command::WithoutOption,
237 "Deactivate chemistry");
239 parser->AddCommand(
"-vis",
241 "Select a visualization driver",
244 parser->AddCommand(
"-novis",
245 Command::WithoutOption,
246 "Deactivate visualization when using GUI");
251 if (
parser->Parse(argc, argv) != 0)
255 CommandLineParser::DeleteInstance();
262 if (
parser->CheckIfNotHandledOptionsExists(argc, argv))
void Parse(int &argc, char **argv)
CommandLineParser * parser(0)
int main(int argc, char **argv)