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" 53 #include "ActionInitialization.hh" 56 #include "CommandLineParser.hh" 61 CommandLineParser*
parser(0);
63 void Parse(
int& argc,
char** argv);
65 int main(
int argc,
char** argv)
69 G4Random::setTheEngine(
new CLHEP::RanecuEngine);
79 Command* commandLine(0);
81 #ifdef G4MULTITHREADED 82 G4MTRunManager* runManager=
new G4MTRunManager;
83 if ((commandLine =
parser->GetCommandIfActive(
"-mt")))
86 if(commandLine->GetOption() ==
"NMAX")
88 nThreads = G4Threading::G4GetNumberOfCores();
92 nThreads = G4UIcommand::ConvertToInt(commandLine->GetOption());
94 G4cout <<
"===== WholeNuclearDNA is started with " 95 << runManager->GetNumberOfThreads()
96 <<
" threads =====" << G4endl;
98 runManager->SetNumberOfThreads(nThreads);
101 G4RunManager* runManager =
new G4RunManager();
106 runManager->SetUserInitialization(detector);
107 runManager->SetUserInitialization(
new PhysicsList);
108 runManager->SetUserInitialization(
new ActionInitialization());
111 runManager->Initialize();
114 G4VisManager* visManager =
new G4VisExecutive;
117 visManager->Initialize();
120 G4UImanager* UImanager = G4UImanager::GetUIpointer();
121 G4UIExecutive* ui(0);
124 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
126 ui =
new G4UIExecutive(argc, argv,
127 commandLine->GetOption());
130 UImanager->ApplyCommand(
"/control/execute gui.mac");
132 if(
parser->GetCommandIfActive(
"-novis") == 0)
135 if((commandLine =
parser->GetCommandIfActive(
"-vis")))
138 UImanager->ApplyCommand(
G4String(
"/vis/open ")+
139 commandLine->GetOption());
144 UImanager->ApplyCommand(
"/vis/open OGL 800x600-0+0");
146 UImanager->ApplyCommand(
"/control/execute vis.mac");
154 if ((commandLine =
parser->GetCommandIfActive(
"-vis")))
156 UImanager->ApplyCommand(
G4String(
"/vis/open ")+commandLine->GetOption());
157 UImanager->ApplyCommand(
"/control/execute vis.mac");
161 if ((commandLine =
parser->GetCommandIfActive(
"-mac")))
163 G4String command =
"/control/execute ";
164 UImanager->ApplyCommand(command + commandLine->GetOption());
168 UImanager->ApplyCommand(
"/control/execute wholeNuclearDNA.in");
171 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
174 G4UIQt* UIQt =
static_cast<G4UIQt*
> (UImanager->GetG4UIWindow());
176 UIQt->AddViewerTabFromFile(
"README",
"README from "+
G4String(argv[0]));
196 std::string aux(argv[0]);
199 #if defined(_WIN32) || defined(WIN32) 200 int pos = aux.rfind(
'\\');
202 int pos = aux.rfind(
'/');
206 path = aux.substr(0, pos + 1);
207 executable = aux.substr(pos + 1);
217 parser = CommandLineParser::GetParser();
219 parser->AddCommand(
"-gui",
220 Command::OptionNotCompulsory,
221 "Select geant4 UI or just launch a geant4 terminal session",
224 parser->AddCommand(
"-mac",
226 "Give a mac file to execute",
235 #ifdef G4MULTITHREADED 238 "Launch in MT mode (events computed in parallel)",
242 parser->AddCommand(
"-vis",
244 "Select a visualization driver",
247 parser->AddCommand(
"-novis",
248 Command::WithoutOption,
249 "Deactivate visualization when using GUI");
255 parser->AddCommand(
"-out",
256 Command::OptionNotCompulsory,
257 "Output files (ROOT is used by default)",
263 if (
parser->Parse(argc, argv) != 0)
267 CommandLineParser::DeleteInstance();
274 if (
parser->CheckIfNotHandledOptionsExists(argc, argv))
int main(int argc, char **argv)
void GetNameAndPathOfExecutable(char **argv, G4String &executable, G4String &path)
CommandLineParser * parser(0)
void Parse(int &argc, char **argv)