Medtech/medtech.cc

98 lines
2.4 KiB
C++
Raw Normal View History

2018-03-30 18:54:24 +02:00
//
// medtech.cc
// CERN MedTech:Hack
//
// Created by Baranyai David on 2018. 03. 30..
// Copyright © 2018. Baranyai David. All rights reserved.
//
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#else
#include "G4RunManager.hh"
#endif
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
2018-04-03 00:51:12 +02:00
#include "QGSP_BERT.hh"
#include "MedtechDetectorConstruction.hh"
#include "MedtechActionInitialization.hh"
#include "Parameters.hh"
#include "G4SteppingManager.hh"
2018-03-30 18:54:24 +02:00
int main(int argc,char** argv)
{
2018-04-03 00:51:12 +02:00
Parameters *param = Parameters::getInstance();
2018-03-30 18:54:24 +02:00
int NoE=0;
2018-04-03 00:51:12 +02:00
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("-h", argv[i]))
2018-04-03 00:51:12 +02:00
{
param -> SetHDegree(atoi(argv[i+1]));
}
else if(!strcmp("-v", argv[i]))
{
param -> SetVDegree(atoi(argv[i+1]));
2018-04-03 00:51:12 +02:00
}
else if(!strcmp("-s", argv[i]))
{
param -> SetBoxSize(atof(argv[i+1]));
}
2018-04-03 00:51:12 +02:00
}
//parameters from command line
2018-03-30 18:54:24 +02:00
#ifdef G4MULTITHREADED
G4MTRunManager* runManager = new G4MTRunManager;
unsigned nthreads = sysconf(_SC_NPROCESSORS_ONLN); //Use all available cores
std::cout << "Using all cores (" << nthreads << ")\n";
runManager->SetNumberOfThreads(nthreads);
#else
G4RunManager* runManager = new G4RunManager;
#endif
2018-04-03 00:51:12 +02:00
runManager -> SetUserInitialization(new QGSP_BERT());
runManager -> SetUserInitialization(new MedtechDetectorConstruction());
runManager -> SetUserInitialization(new MedtechActionInitialization());
2018-03-30 18:54:24 +02:00
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
G4UImanager* UImanager = G4UImanager::GetUIpointer();
2018-04-03 00:51:12 +02:00
if (NoE!=0)
{
2018-03-30 18:54:24 +02:00
//batch mode
runManager->Initialize();
runManager->BeamOn(NoE);
}
2018-04-03 00:51:12 +02:00
else
{
2018-03-30 18:54:24 +02:00
//interactive mode
G4UIExecutive* ui = 0;
2018-04-03 00:51:12 +02:00
ui = new G4UIExecutive(argc, argv);
UImanager -> ApplyCommand("/control/macroPath macros"); //Need to set, macros moved to that folder
UImanager -> ApplyCommand("/control/execute gui.mac");
2018-03-30 18:54:24 +02:00
ui->SessionStart();
delete ui;
}
delete visManager;
delete runManager;
}