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" 55 #include "CommandLineParser.hh" 69 CommandLineParser*
parser(0);
71 void Parse(
int& argc,
char** argv);
73 int main(
int argc,
char** argv)
83 Command* commandLine(0);
85 #ifdef G4MULTITHREADED 86 G4RunManager* runManager(0);
87 if ((commandLine =
parser->GetCommandIfActive(
"-mt")))
89 runManager =
new G4MTRunManager;
91 const G4String& option = commandLine->GetOption();
94 nThreads = G4UIcommand::ConvertToInt(commandLine->GetDefaultOption());
96 else if(option ==
"NMAX")
98 nThreads = G4Threading::G4GetNumberOfCores();
102 nThreads = G4UIcommand::ConvertToInt(option);
105 G4cout <<
"===== Chem3 is started with " 106 << ((G4MTRunManager*) runManager)->GetNumberOfThreads()
107 <<
" threads =====" << G4endl;
109 ((G4MTRunManager*) runManager)->SetNumberOfThreads(nThreads);
113 runManager =
new G4RunManager();
116 G4RunManager* runManager =
new G4RunManager();
123 runManager->SetUserInitialization(
new PhysicsList);
124 runManager->SetUserInitialization(detector);
125 runManager->SetUserInitialization(
new ActionInitialization());
128 runManager->Initialize();
131 G4VisManager* visManager =
new G4VisExecutive;
134 visManager->Initialize();
137 G4UImanager* UImanager = G4UImanager::GetUIpointer();
138 G4UIExecutive* ui(0);
141 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
143 ui =
new G4UIExecutive(argc, argv, commandLine->GetOption());
145 if (
parser->GetCommandIfActive(
"-novis") == 0)
148 if ((commandLine =
parser->GetCommandIfActive(
"-vis")))
151 UImanager->ApplyCommand(
152 G4String(
"/vis/open ") + commandLine->GetOption());
157 UImanager->ApplyCommand(
"/vis/open OGL 800x600-0+0");
159 UImanager->ApplyCommand(
"/control/execute vis.mac");
162 if (ui->IsGUI()) UImanager->ApplyCommand(
"/control/execute gui.mac");
169 if ((commandLine =
parser->GetCommandIfActive(
"-vis")))
171 UImanager->ApplyCommand(
172 G4String(
"/vis/open ") + commandLine->GetOption());
173 UImanager->ApplyCommand(
"/control/execute vis.mac");
177 if ((commandLine =
parser->GetCommandIfActive(
"-mac")))
179 G4String command =
"/control/execute ";
180 UImanager->ApplyCommand(command + commandLine->GetOption());
184 UImanager->ApplyCommand(
"/control/execute beam.in");
187 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
190 G4UIQt* UIQt =
static_cast<G4UIQt*
> (UImanager->GetG4UIWindow());
192 UIQt->AddViewerTabFromFile(
"README",
"README from "+
G4String(argv[0]));
207 CommandLineParser::DeleteInstance();
217 parser = CommandLineParser::GetParser();
220 "-gui", Command::OptionNotCompulsory,
221 "Select geant4 UI or just launch a geant4 terminal session",
"qt");
223 parser->AddCommand(
"-mac", Command::WithOption,
"Give a mac file to execute",
232 #ifdef G4MULTITHREADED 233 parser->AddCommand(
"-mt", Command::OptionNotCompulsory,
234 "Launch in MT mode (events computed in parallel," 235 " NOT RECOMMANDED WITH CHEMISTRY)",
239 parser->AddCommand(
"-chemOFF", Command::WithoutOption,
240 "Deactivate chemistry");
242 parser->AddCommand(
"-vis", Command::WithOption,
243 "Select a visualization driver",
"OGL 600x600-0+0");
245 parser->AddCommand(
"-novis", 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)