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" 52 #include "CommandLineParser.hh" 66 CommandLineParser*
parser(0);
68 void Parse(
int& argc,
char** argv);
70 int main(
int argc,
char** argv)
80 Command* commandLine(
nullptr);
82 #ifdef G4MULTITHREADED 83 G4RunManager* runManager(
nullptr);
84 if ((commandLine =
parser->GetCommandIfActive(
"-mt")))
86 runManager =
new G4MTRunManager();
88 const G4String& option = commandLine->GetOption();
91 nThreads = G4UIcommand::ConvertToInt(commandLine->GetDefaultOption());
93 else if(option ==
"NMAX")
95 nThreads = G4Threading::G4GetNumberOfCores();
99 nThreads = G4UIcommand::ConvertToInt(option);
102 G4cout <<
"===== Chem2 is started with " << nThreads
103 <<
" threads =====" << G4endl;
105 ((G4MTRunManager*) runManager)->SetNumberOfThreads(nThreads);
109 runManager =
new G4RunManager();
112 G4RunManager* runManager =
new G4RunManager();
119 runManager->SetUserInitialization(
new PhysicsList);
120 runManager->SetUserInitialization(detector);
121 runManager->SetUserInitialization(
new ActionInitialization());
124 G4VisManager* visManager =
nullptr;
127 G4UImanager* UImanager = G4UImanager::GetUIpointer();
128 G4UIExecutive* ui(
nullptr);
131 if ((commandLine =
parser->GetCommandIfActive(
"-gui")))
133 visManager =
new G4VisExecutive;
134 visManager->Initialize();
136 ui =
new G4UIExecutive(argc, argv, commandLine->GetOption());
138 if(
parser->GetCommandIfActive(
"-novis") == 0)
141 if((commandLine =
parser->GetCommandIfActive(
"-vis")))
144 UImanager->ApplyCommand(
G4String(
"/vis/open ")+
145 commandLine->GetOption());
150 UImanager->ApplyCommand(
"/vis/open OGL 800x600-0+0");
152 UImanager->ApplyCommand(
"/control/execute vis.mac");
157 UImanager->ApplyCommand(
"/control/execute gui.mac");
160 else if ((commandLine =
parser->GetCommandIfActive(
"-vis")))
165 visManager =
new G4VisExecutive;
166 visManager->Initialize();
168 ui =
new G4UIExecutive(argc, argv, commandLine->GetOption());
169 UImanager->ApplyCommand(
G4String(
"/vis/open ")+commandLine->GetOption());
170 UImanager->ApplyCommand(
"/control/execute vis.mac");
173 if ((commandLine =
parser->GetCommandIfActive(
"-mac")))
175 G4String command =
"/control/execute ";
176 UImanager->ApplyCommand(command + commandLine->GetOption());
180 UImanager->ApplyCommand(
"/control/execute beam.in");
196 CommandLineParser::DeleteInstance();
206 parser = CommandLineParser::GetParser();
208 parser->AddCommand(
"-gui",
209 Command::OptionNotCompulsory,
210 "Select geant4 UI or just launch a geant4 terminal session",
213 parser->AddCommand(
"-mac",
215 "Give a mac file to execute",
224 #ifdef G4MULTITHREADED 225 parser->AddCommand(
"-mt", Command::OptionNotCompulsory,
226 "Launch in MT mode (events computed in parallel," 227 " NOT RECOMMANDED WITH CHEMISTRY)",
231 parser->AddCommand(
"-chemOFF",
232 Command::WithoutOption,
233 "Deactivate chemistry");
235 parser->AddCommand(
"-vis",
237 "Select a visualization driver",
240 parser->AddCommand(
"-novis",
241 Command::WithoutOption,
242 "Deactivate visualization when using GUI");
247 if (
parser->Parse(argc, argv) != 0)
251 CommandLineParser::DeleteInstance();
258 if (
parser->CheckIfNotHandledOptionsExists(argc, argv))
void Parse(int &argc, char **argv)
CommandLineParser * parser(0)
int main(int argc, char **argv)