Handle command line arguments
This commit is contained in:
parent
e59de3c504
commit
db15a03619
46
medtech.cc
46
medtech.cc
|
@ -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
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue