-
Notifications
You must be signed in to change notification settings - Fork 0
/
ENLTPSim.cc
executable file
·172 lines (128 loc) · 4.63 KB
/
ENLTPSim.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/// ENLTPSim.cc
/// Auteur: Arnaud HUBER for ENL group <[email protected]>
/// Copyright: 2022 (C) Projet RATP - ENL [LP2IB] - CELIA
#include "G4LogicalSkinSurface.hh"
#include "G4OpticalSurface.hh"
#include "G4ThreeVector.hh"
#include "G4MaterialPropertiesTable.hh"
#include "Randomize.hh"
#include "time.h"
#include "G4Timer.hh"
#include "G4UIterminal.hh"
#include "ENLTPSimSteppingAction.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
//#include "G4UIGAG.hh"
#include "ENLTPSimGeometry.hh"
#include "ENLTPSimPhysics.hh"
#include "ENLTPSimPrimaryGeneratorAction.hh"
#include "ENLTPSimRunAction.hh"
#include "ENLTPSimEventAction.hh"
#include "ENLTPSimTrackingAction.hh"
//
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4SteppingVerbose.hh"
// #ifdef G4VIS_USE
// #include "ENLTPSimVisManager.hh"
//#endif
int main(int argc,char** argv){
char* suff = argv[1];
//Use SteppingVerbose with Unit
//G4int precision = 4;
//G4SteppingVerbose::UseBestUnit(precision);
// Construct the default run manager
G4RunManager* runManager = new G4RunManager;
// set mandatory initialization classes
ENLTPSimGeometry* OptGeom = new ENLTPSimGeometry;
G4cout<<"Geometry given to ENLTPSim.cc"<<G4endl;
// initialize the geometry
runManager->SetUserInitialization(OptGeom);
G4cout<<"Geometry set in ENLTPSim.cc given to Runman"<<G4endl;
// initialize the physics
runManager->SetUserInitialization(new ENLTPSimPhysics);
// #ifdef G4VIS_USE
// // visualization manager
// G4VisManager* visManager = new ENLTPSimVisManager;
// visManager->Initialize();
// #endif
// set mandatory user action class
runManager->SetUserAction(new ENLTPSimPrimaryGeneratorAction);
// set Run Event and Stepping action classes
runManager->SetUserAction(new ENLTPSimRunAction(suff));
G4cout<<"Initialized new Run Action"<<G4endl;
runManager->SetUserAction(new ENLTPSimEventAction(suff));
G4cout<<"Initialized new EventAction"<<G4endl;
runManager->SetUserAction(new ENLTPSimSteppingAction);
G4cout<<"Initialized new SteppingAction"<<G4endl;
runManager->SetUserAction(new ENLTPSimTrackingAction);
G4cout<<"Initialized new Tracking Action"<<G4endl;
//#ifdef G4VIS_USE
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
//#endif
// Initialize G4 kernel
runManager->Initialize();
G4cout<<"Initialized new Run Manager"<<G4endl;
// get the pointer to the User Interface manager
G4UImanager* UI = G4UImanager::GetUIpointer();
char movefile[100];
G4UIExecutive *ui = 0;
if (argc==4) // batch mode
{
G4cout << "Batch MODE" << G4endl;
G4String command = "/control/execute ";
G4String fileName = argv[3];
UI->ApplyCommand(command+fileName);
UI->ApplyCommand("control/suppressAbortion");
char startcommand[100];
sprintf(startcommand,"/run/beamOn %s",argv[2]);
UI->ApplyCommand(startcommand);
// G4cout << "3" << G4endl;
// sprintf(writefile,"/control/shell mv %s.root ../Resultats/",argv[2]);
// UI->ApplyCommand(writefile);
sprintf(movefile,"/control/shell mv %s.root ../Resultats", argv[1]);
UI->ApplyCommand(movefile);
G4cout << "Output saved to file " << argv[1] << ".root" << G4endl;
}
else //define visualization and UI terminal for interactive mode
{
G4cout << "Interactive MODE" << G4endl;
//#ifdef G4UI_USE
ui = new G4UIExecutive(argc,argv);
UI->ApplyCommand("/control/execute vis.mac");
ui->SessionStart();
delete ui;
//#endif
sprintf(movefile,"/control/shell mv %s.root ../Resultats", argv[1]);
UI->ApplyCommand(movefile);
G4cout << "Output saved to file " << argv[1] << ".root" << G4endl;
}
#ifdef G4VIS_USE
delete visManager;
#endif
/*
//execute visualization macro
UI->ApplyCommand("/control/execute vis.mac");
UI->ApplyCommand("/control/execute vrml.mac");
UI->ApplyCommand("/control/suppressAbortion");
G4UIsession *session = new G4UIterminal();
if(argc == 1)
//starts G4Terminal
session->SessionStart();
else if(argc == 3){
//automatically executes the specified number of runs and saves to output
char writefile[100],startcommand[100], movefile[100];
sprintf(startcommand,"/run/beamOn %s",argv[1]);
UI->ApplyCommand(startcommand);
sprintf(writefile,"/control/shell mv %s.root ../Resultats/",argv[2]);
UI->ApplyCommand(writefile);
//sprintf(movefile,"/control/shell mv %s.root ../Resultats", argv[2]);
//UI->ApplyCommand(movefile);
G4cout << "Output saved to file " << argv[2] << ".root" << G4endl;
}
delete session;
*/
delete runManager;
return 0;
}