forked from alennarz/G4_BGO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBGO.cc~
120 lines (88 loc) · 2.83 KB
/
BGO.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
113
114
115
116
117
118
119
120
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "TrackerSD.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "InputManager.hh"
#include "CascadeGenerator.hh"
#include "DAQManager.hh"
#include "TFile.h"
#ifdef G4VIS_USE
#include "G4VisExecutive.hh"
#endif
#ifdef G4UI_USE
#include "G4UIExecutive.hh"
#endif
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main (int argc,char** argv) {
if (argc<2) {// argc should be more than 1 for correct execution
cerr << "Error in <main>: program " << argv[0] << " requires config filename argument" << endl;
exit(1);
}
InputManager* InMgr = new InputManager();
std::vector<string> filename;
std::vector<string>::iterator it;
for (int i=1; i<argc; i++) {
filename.push_back(argv[i]);//config input filename(s)
}
for (it=filename.begin(); it!=filename.end(); it++) {
InMgr->ReadFile(it->c_str());
}
CascadeGenerator* CasGen = new CascadeGenerator(InMgr);
DAQManager* DAQMgr = new DAQManager(InMgr, CasGen);
// construct the default run manager
G4RunManager* runManager = new G4RunManager;
// Instantiation and initialization of the Visualization Manager
#ifdef G4VIS_USE
// visualization manager
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
#endif
// set mandatory initialization classes
G4VUserDetectorConstruction* detector = new DetectorConstruction(DAQMgr,InMgr);
runManager->SetUserInitialization(detector);
runManager->SetUserInitialization(new PhysicsList);
// runManager->SetUserInitialization(physics);
// set mandatory user action class
// initialize G4 kernel
runManager->Initialize();
G4VUserPrimaryGeneratorAction* gen_action = new PrimaryGeneratorAction(CasGen);
runManager->SetUserAction(gen_action);
G4UserRunAction* run_action = new RunAction(CasGen,DAQMgr);
runManager->SetUserAction(run_action);
G4UserEventAction* event_action = new EventAction(DAQMgr);
runManager->SetUserAction(event_action);
// Get the pointer to the User Interface manager
G4UImanager* UImanager = G4UImanager::GetUIpointer();
#ifdef G4UI_USE
G4UIExecutive * ui = new G4UIExecutive(argc,argv);
#ifdef G4VIS_USE
bool viewer;
InMgr->GetVariable("viewer",viewer);
if (viewer == true) UImanager->ApplyCommand("/control/execute vis.mac");
char beamOn[30];
int N_events;
InMgr->GetVariable("N_events",N_events);
sprintf(beamOn,"/run/beamOn %i", N_events);
for (bool end=false; end!=true; end=CasGen->GetEnd()) {
UImanager->ApplyCommand(beamOn);
}
#endif
ui->SessionStart();
delete ui;
#endif
// Job termination
#ifdef G4VIS_USE
// delete visManager;
#endif
// job termination
delete DAQMgr;
delete runManager;
return 0;
}