Handle command line arguments

This commit is contained in:
Gitea 2018-04-03 00:51:12 +02:00
parent e59de3c504
commit db15a03619
1 changed files with 38 additions and 8 deletions

View File

@ -14,13 +14,36 @@
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "QGSP_BERT.hh"
#include "MedtechDetectorConstruction.hh"
#include "MedtechActionInitialization.hh"
#include "Parameters.hh"
int main(int argc,char** argv)
{
//parameter from command line
Parameters *param = Parameters::getInstance();
int NoE=0;
if (argc==2) NoE=atoi(argv[1]);
for(int i=1; i < argc-1; i++)
{
if(!strcmp("-n", argv[i]))
{
NoE = atoi(argv[i+1]);
}
else if(!strcmp("-p", argv[i]))
{
param -> SetParticleEnergy(atoi(argv[i+1]));
}
else if(!strcmp("-d", argv[i]))
{
param -> SetDegree(atoi(argv[i+1]));
}
}
//parameters from command line
#ifdef G4MULTITHREADED
G4MTRunManager* runManager = new G4MTRunManager;
@ -31,21 +54,28 @@ int main(int argc,char** argv)
G4RunManager* runManager = new G4RunManager;
#endif
runManager -> SetUserInitialization(new QGSP_BERT());
runManager -> SetUserInitialization(new MedtechDetectorConstruction());
runManager -> SetUserInitialization(new MedtechActionInitialization());
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
G4UImanager* UImanager = G4UImanager::GetUIpointer();
if (argc==2) {
if (NoE!=0)
{
//batch mode
runManager->Initialize();
runManager->BeamOn(NoE);
}
else {
else
{
//interactive mode
G4UIExecutive* ui = 0;
if ( argc == 1 ) {
ui = new G4UIExecutive(argc, argv);
}
UImanager -> ApplyCommand("/control/macroPath macros"); //Need to set, macros moved to that folder
UImanager -> ApplyCommand("/control/execute gui.mac");
ui->SessionStart();
delete ui;
}