39 #include "ActionInitialization.hh" 41 #ifdef G4MULTITHREADED 42 #include "G4MTRunManager.hh" 44 #include "G4RunManager.hh" 47 #include "G4DNAChemistryManager.hh" 48 #include "G4UImanager.hh" 49 #include "G4UIExecutive.hh" 50 #include "G4VisExecutive.hh" 54 #include "CommandLineParser.hh" 68 CommandLineParser*
parser(0);
70 void Parse(
int& argc,
char** argv);
72 int main(
int argc,
char** argv)
82 Command* commandLine(0);
84 #ifdef G4MULTITHREADED 85 G4RunManager* runManager(0);
86 if ((commandLine =
parser->GetCommandIfActive(
"-mt")))
88 runManager =
new G4MTRunManager;
90 const G4String& option = commandLine->GetOption();
93 nThreads = G4UIcommand::ConvertToInt(commandLine->GetDefaultOption());
95 else if(option ==
"NMAX")
97 nThreads = G4Threading::G4GetNumberOfCores();
101 nThreads = G4UIcommand::ConvertToInt(option);
104 G4cout <<
"===== Chem3 is started with " 105 << ((G4MTRunManager*) runManager)->GetNumberOfThreads()
106 <<
" threads =====" << G4endl;
108 ((G4MTRunManager*) runManager)->SetNumberOfThreads(nThreads);
112 runManager =
new G4RunManager();
115 G4RunManager* runManager =
new G4RunManager();
122 runManager->SetUserInitialization(
new PhysicsList);
123 runManager->SetUserInitialization(detector);
124 runManager->SetUserInitialization(
new ActionInitialization());
127 runManager->Initialize();
130 G4VisManager* visManager =
new G4VisExecutive;
133 visManager->Initialize();
136 G4UImanager* UImanager = G4UImanager::GetUIpointer();
137 G4UIExecutive* ui(0);
140 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
142 ui =
new G4UIExecutive(argc, argv, commandLine->GetOption());
144 if (
parser->GetCommandIfActive(
"-novis") == 0)
147 if ((commandLine =
parser->GetCommandIfActive(
"-vis")))
150 UImanager->ApplyCommand(
151 G4String(
"/vis/open ") + commandLine->GetOption());
156 UImanager->ApplyCommand(
"/vis/open OGL 800x600-0+0");
158 UImanager->ApplyCommand(
"/control/execute vis.mac");
161 if (ui->IsGUI()) UImanager->ApplyCommand(
"/control/execute gui.mac");
168 if ((commandLine =
parser->GetCommandIfActive(
"-vis")))
170 UImanager->ApplyCommand(
171 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")))
189 G4UIQt* UIQt =
static_cast<G4UIQt*
> (UImanager->GetG4UIWindow());
191 UIQt->AddViewerTabFromFile(
"README",
"README from "+
G4String(argv[0]));
206 CommandLineParser::DeleteInstance();
216 parser = CommandLineParser::GetParser();
219 "-gui", Command::OptionNotCompulsory,
220 "Select geant4 UI or just launch a geant4 terminal session",
"qt");
222 parser->AddCommand(
"-mac", Command::WithOption,
"Give a mac file to execute",
231 #ifdef G4MULTITHREADED 232 parser->AddCommand(
"-mt", Command::OptionNotCompulsory,
233 "Launch in MT mode (events computed in parallel," 234 " NOT RECOMMANDED WITH CHEMISTRY)",
238 parser->AddCommand(
"-chemOFF", Command::WithoutOption,
239 "Deactivate chemistry");
241 parser->AddCommand(
"-vis", Command::WithOption,
242 "Select a visualization driver",
"OGL 600x600-0+0");
244 parser->AddCommand(
"-novis", Command::WithoutOption,
245 "Deactivate visualization when using GUI");
250 if (
parser->Parse(argc, argv) != 0)
254 CommandLineParser::DeleteInstance();
261 if (
parser->CheckIfNotHandledOptionsExists(argc, argv))
void Parse(int &argc, char **argv)
CommandLineParser * parser(0)
int main(int argc, char **argv)