Medtech/medtech.cc

122 lines
3.2 KiB
C++
Raw Permalink 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"
#include "QGSP_BIC.hh"
2018-04-03 00:51:12 +02:00
#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-04-12 14:43:05 +02:00
bool visualization = true;
int NoE=1;
2018-04-03 00:51:12 +02:00
for(int i=1; i < argc-1; i++)
{
if(!strcmp("-n", argv[i])) //number of events
2018-04-03 00:51:12 +02:00
{
NoE = atoi(argv[i+1]);
}
else if(!strcmp("-p", argv[i])) //particle energy
2018-04-03 00:51:12 +02:00
{
param -> SetParticleEnergy(atoi(argv[i+1]));
}
else if(!strcmp("-h", argv[i])) //H degree
2018-04-03 00:51:12 +02:00
{
param -> SetHDegree(atoi(argv[i+1]));
}
else if(!strcmp("-v", argv[i])) //V degree
{
param -> SetVDegree(atoi(argv[i+1]));
2018-04-03 00:51:12 +02:00
}
else if(!strcmp("-s", argv[i])) //windows size
{
param -> SetBoxSize(atof(argv[i+1]));
}
else if(!strcmp("-x", argv[i])) //visualization
{
visualization = false;
}
else if(!strcmp("-t", argv[i])) //tube size
{
param -> SetTubeSize(atof(argv[i+1]));
}
else if(!strcmp("-c", argv[i])) //Cone size
{
param -> SetConeSize(atof(argv[i+1]));
}
2018-04-12 14:43:05 +02:00
else if(!strcmp("-g", argv[i])) //Globe size
{
param -> SetGlobeSize(atof(argv[i+1]));
}
else if(!strcmp("-gp", argv[i])) //Globe placement
{
param -> SetGlonePlacement(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;
2018-04-12 14:43:05 +02:00
unsigned int nthreads = (int)sysconf(_SC_NPROCESSORS_ONLN); //Use all available cores
2018-03-30 18:54:24 +02:00
std::cout << "Using all cores (" << nthreads << ")\n";
runManager->SetNumberOfThreads(nthreads);
#else
G4RunManager* runManager = new G4RunManager;
#endif
runManager -> SetUserInitialization(new QGSP_BIC);
runManager -> SetUserInitialization(new MedtechDetectorConstruction);
runManager -> SetUserInitialization(new MedtechActionInitialization);
2018-04-03 00:51:12 +02:00
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 (visualization)
2018-04-03 00:51:12 +02:00
{
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;
}