38 #ifdef G4MULTITHREADED 39 #include "G4MTRunManager.hh" 41 #include "G4RunManager.hh" 44 #include "G4UImanager.hh" 45 #include "G4UIExecutive.hh" 46 #include "G4UIterminal.hh" 47 #include "G4UItcsh.hh" 48 #include "G4VisExecutive.hh" 50 #include "ActionInitialization.hh" 53 #include "CommandLineParser.hh" 59 CommandLineParser*
parser(0);
61 void Parse(
int& argc,
char** argv);
63 int main(
int argc,
char** argv)
66 G4Random::setTheEngine(
new CLHEP::RanecuEngine);
76 Command* commandLine(0);
78 #ifdef G4MULTITHREADED 79 G4MTRunManager* runManager=
new G4MTRunManager;
80 if ((commandLine =
parser->GetCommandIfActive(
"-mt")))
83 if(commandLine->GetOption() ==
"NMAX")
85 nThreads = G4Threading::G4GetNumberOfCores();
89 nThreads = G4UIcommand::ConvertToInt(commandLine->GetOption());
91 G4cout <<
"===== Microdosimetry is started with " 92 << runManager->GetNumberOfThreads()
93 <<
" threads =====" << G4endl;
95 runManager->SetNumberOfThreads(nThreads);
98 G4RunManager* runManager =
new G4RunManager();
103 runManager->SetUserInitialization(detector);
105 runManager->SetUserInitialization(
new PhysicsList);
109 runManager->SetUserInitialization(
new ActionInitialization());
113 runManager->Initialize();
116 G4VisManager* visManager =
new G4VisExecutive;
119 visManager->Initialize();
122 G4UImanager* UImanager = G4UImanager::GetUIpointer();
123 G4UIExecutive* ui(0);
126 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
128 ui =
new G4UIExecutive(argc, argv,
129 commandLine->GetOption());
132 UImanager->ApplyCommand(
"/control/execute gui.mac");
134 if(
parser->GetCommandIfActive(
"-novis") == 0)
137 if((commandLine =
parser->GetCommandIfActive(
"-vis")))
140 UImanager->ApplyCommand(
G4String(
"/vis/open ")+
141 commandLine->GetOption());
146 UImanager->ApplyCommand(
"/vis/open OGL 800x600-0+0");
148 UImanager->ApplyCommand(
"/control/execute vis.mac");
156 if ((commandLine =
parser->GetCommandIfActive(
"-vis")))
158 UImanager->ApplyCommand(
G4String(
"/vis/open ")+commandLine->GetOption());
159 UImanager->ApplyCommand(
"/control/execute vis.mac");
163 if ((commandLine =
parser->GetCommandIfActive(
"-mac")))
165 G4String command =
"/control/execute ";
166 UImanager->ApplyCommand(command + commandLine->GetOption());
170 UImanager->ApplyCommand(
"/control/execute microdosimetry.in");
173 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
176 G4UIQt* UIQt =
static_cast<G4UIQt*
> (UImanager->GetG4UIWindow());
178 UIQt->AddViewerTabFromFile(
"README",
"README from "+
G4String(argv[0]));
198 std::string aux(argv[0]);
201 #if defined(_WIN32) || defined(WIN32) 202 int pos = aux.rfind(
'\\');
204 int pos = aux.rfind(
'/');
208 path = aux.substr(0, pos + 1);
209 executable = aux.substr(pos + 1);
219 parser = CommandLineParser::GetParser();
221 parser->AddCommand(
"-gui",
222 Command::OptionNotCompulsory,
223 "Select geant4 UI or just launch a geant4 terminal session",
226 parser->AddCommand(
"-mac",
228 "Give a mac file to execute",
237 #ifdef G4MULTITHREADED 240 "Launch in MT mode (events computed in parallel)",
244 parser->AddCommand(
"-vis",
246 "Select a visualization driver",
249 parser->AddCommand(
"-novis",
250 Command::WithoutOption,
251 "Deactivate visualization when using GUI");
257 parser->AddCommand(
"-out",
258 Command::OptionNotCompulsory,
265 if (
parser->Parse(argc, argv) != 0)
269 CommandLineParser::DeleteInstance();
276 if (
parser->CheckIfNotHandledOptionsExists(argc, argv))
void Parse(int &argc, char **argv)
void GetNameAndPathOfExecutable(char **argv, G4String &executable, G4String &path)
CommandLineParser * parser(0)
int main(int argc, char **argv)