-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsipm.cc
113 lines (99 loc) · 3.16 KB
/
sipm.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
// sipm.cpp
//
//
// Created by Baranyai David on 2018. 08. 22..
//
#include "SiPMDetectorConstruction.hh"
#include "SiPMActionInitialization.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#else
#include "G4RunManager.hh"
#endif
#include "QGSP_BIC_HP.hh"
#include "G4UImanager.hh"
#include "QBBC.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.hh"
#include "Randomize.hh"
#include "QGSP_BIC.hh"
#include "G4OpticalPhysics.hh"
#include "G4OpticalProcessIndex.hh"
#include "LXePhysicsList.hh"
#include "SiPMParameters.hh"
#include "SiPMAnalysis.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc, char** argv)
{
SiPMParameters& parameters = SiPMParameters::GetInstance();
SiPMAnalysis& analysis = SiPMAnalysis::getInstance();
bool visualization = true;
int NoE=0;
// parameter from command line
for(int i = 1; i < argc; i++)
{
if(!strcmp("-df", argv[i])) //number of events
{
std::cout << "Settings will be read from the default file." << std::endl;
parameters.ParseConfigFile();
}
else if(!strcmp("-f", argv[i])) //number of events
{
std::string filename;
if(argc-1 >= i+1)
{
filename = argv[i+1];
std::cout << "Settings will be read from " << filename << "." << std::endl;
parameters.ParseConfigFile(filename);
}
if(filename.empty())
{
std::cout << "File name not given, using the default values" << std::endl;
}
}
else if(!strcmp("-v", argv[i])) //number of events
{
std::cout << "Visualization disabled." << std::endl;
visualization = false;
}
}
NoE = parameters.GetNumberOfEvents();
#ifdef G4MULTITHREADED
G4MTRunManager* runManager = new G4MTRunManager;
unsigned nthreads = 8;
runManager->SetNumberOfThreads(nthreads);
#else
G4RunManager* runManager = new G4RunManager;
#endif
runManager->SetUserInitialization(new LXePhysicsList());
runManager->SetUserInitialization(new SiPMDetectorConstruction());
//runManager->SetUserInitialization(new QGSP_BIC);
runManager->SetUserInitialization(new SiPMActionInitialization());
///////////////
//Initialize the analysis instance here first to avoid crash
//SiPMAnalysis *analysis = SiPMAnalysis::getInstance();
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
G4UImanager* UImanager = G4UImanager::GetUIpointer();
if (visualization == false)
{
// batch mode
runManager->Initialize();
runManager->BeamOn(NoE);
}
else
{
// interactive mode
G4UIExecutive* ui = 0;
ui = new G4UIExecutive(argc, argv);
UImanager->ApplyCommand("/control/macroPath ./macros"); //set for your environment
UImanager->ApplyCommand("/control/execute gui.mac");
ui->SessionStart();
delete ui;
}
delete visManager;
delete runManager;
}