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)
75 Command* commandLine(0);
77 #ifdef G4MULTITHREADED 78 G4MTRunManager* runManager=
new G4MTRunManager;
79 if ((commandLine =
parser->GetCommandIfActive(
"-mt")))
82 if(commandLine->GetOption() ==
"NMAX")
84 nThreads = G4Threading::G4GetNumberOfCores();
88 nThreads = G4UIcommand::ConvertToInt(commandLine->GetOption());
90 G4cout <<
"===== WholeNuclearDNA is started with " 91 << runManager->GetNumberOfThreads()
92 <<
" threads =====" << G4endl;
94 runManager->SetNumberOfThreads(nThreads);
97 G4RunManager* runManager =
new G4RunManager();
102 runManager->SetUserInitialization(detector);
103 runManager->SetUserInitialization(
new PhysicsList);
104 runManager->SetUserInitialization(
new ActionInitialization());
107 runManager->Initialize();
110 G4VisManager* visManager =
new G4VisExecutive;
113 visManager->Initialize();
116 G4UImanager* UImanager = G4UImanager::GetUIpointer();
117 G4UIExecutive* ui(0);
120 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
122 ui =
new G4UIExecutive(argc, argv,
123 commandLine->GetOption());
126 UImanager->ApplyCommand(
"/control/execute gui.mac");
128 if(
parser->GetCommandIfActive(
"-novis") == 0)
131 if((commandLine =
parser->GetCommandIfActive(
"-vis")))
134 UImanager->ApplyCommand(
G4String(
"/vis/open ")+
135 commandLine->GetOption());
140 UImanager->ApplyCommand(
"/vis/open OGL 800x600-0+0");
142 UImanager->ApplyCommand(
"/control/execute vis.mac");
150 if ((commandLine =
parser->GetCommandIfActive(
"-vis")))
152 UImanager->ApplyCommand(
G4String(
"/vis/open ")+commandLine->GetOption());
153 UImanager->ApplyCommand(
"/control/execute vis.mac");
157 if ((commandLine =
parser->GetCommandIfActive(
"-mac")))
159 G4String command =
"/control/execute ";
160 UImanager->ApplyCommand(command + commandLine->GetOption());
164 UImanager->ApplyCommand(
"/control/execute wholeNuclearDNA.in");
167 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
170 G4UIQt* UIQt =
static_cast<G4UIQt*
> (UImanager->GetG4UIWindow());
172 UIQt->AddViewerTabFromFile(
"README",
"README from "+
G4String(argv[0]));
192 std::string aux(argv[0]);
195 #if defined(_WIN32) || defined(WIN32) 196 int pos = aux.rfind(
'\\');
198 int pos = aux.rfind(
'/');
202 path = aux.substr(0, pos + 1);
203 executable = aux.substr(pos + 1);
213 parser = CommandLineParser::GetParser();
215 parser->AddCommand(
"-gui",
216 Command::OptionNotCompulsory,
217 "Select geant4 UI or just launch a geant4 terminal session",
220 parser->AddCommand(
"-mac",
222 "Give a mac file to execute",
231 #ifdef G4MULTITHREADED 234 "Launch in MT mode (events computed in parallel)",
238 parser->AddCommand(
"-vis",
240 "Select a visualization driver",
243 parser->AddCommand(
"-novis",
244 Command::WithoutOption,
245 "Deactivate visualization when using GUI");
251 parser->AddCommand(
"-out",
252 Command::OptionNotCompulsory,
253 "Output files (ROOT is used by default)",
259 if (
parser->Parse(argc, argv) != 0)
263 CommandLineParser::DeleteInstance();
270 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)