-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqsim.cc
More file actions
206 lines (155 loc) · 5.62 KB
/
Copy pathqsim.cc
File metadata and controls
206 lines (155 loc) · 5.62 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*!
qsim - Quartz Detector Simluation
Seamus Riordan, et al.
riordan@jlab.org
Based on prexsim by Jon Wexler and Luis Mercado
and remoll
*/
#include "CLHEP/Random/Random.h"
#include "qsimRunAction.hh"
#include "qsimPrimaryGeneratorAction.hh"
#include "qsimEventAction.hh"
#include "qsimSteppingAction.hh"
#include "qsimOpticalPhysics.hh"
#include "qsimDetectorConstruction.hh"
#include "qsimIO.hh"
#include "qsimMessenger.hh"
// Standard physics list
#include "G4PhysListFactory.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
#include "G4RunManagerKernel.hh"
//to make gui.mac work
#include <G4UImanager.hh>
#include <G4UIExecutive.hh>
#include <G4UIterminal.hh>
#ifdef G4UI_USE_QT
#include "G4UIQt.hh"
#endif
#ifdef G4UI_USE_XM
#include "G4UIXm.hh"
#endif
#ifdef G4UI_USE_TCSH
#include "G4UItcsh.hh"
#endif
#ifdef G4VIS_USE
#include "G4VisExecutive.hh"
#endif
#include <sys/types.h>
#include <sys/stat.h>
// How do I change the display size of qsim to be smaller for better viewing on small screens?
// How do I get changes of qsim detector construction and primary event generators to affect changes if the main function has already called the default values hardcoded inerDetectorConstruction* detector = new qsimDetectorConstruction();
int main(int argc, char** argv){
// Initialize the CLHEP random engine used by
// "shoot" type functions
unsigned int seed = time(0);
CLHEP::HepRandom::createInstance();
CLHEP::HepRandom::setTheSeed(seed);
qsimIO *io = new qsimIO();
//-------------------------------
// Initialization of Run manager
//-------------------------------
G4cout << "RunManager construction starting...." << G4endl;
G4RunManager * runManager = new G4RunManager;
qsimMessenger *rmmess = new qsimMessenger();
rmmess->SetIO(io);
// Detector geometry
G4VUserDetectorConstruction* detector = new qsimDetectorConstruction();
runManager->SetUserInitialization(detector);
rmmess->SetDetCon( ((qsimDetectorConstruction *) detector) );
// Physics we want to use
G4int verbose = 0;
G4PhysListFactory factory;
G4VModularPhysicsList* physlist = factory.GetReferencePhysList("FTFP_BERT");
physlist->SetVerboseLevel(verbose);
runManager->SetUserInitialization(physlist);
physlist->RegisterPhysics( new qsimOpticalPhysics() );
//-------------------------------
// UserAction classes
//-------------------------------
G4UserRunAction* run_action = new qsimRunAction;
((qsimRunAction *) run_action)->SetIO(io);
runManager->SetUserAction(run_action);
G4VUserPrimaryGeneratorAction* gen_action = new qsimPrimaryGeneratorAction;
((qsimPrimaryGeneratorAction *) gen_action)->SetIO(io);
rmmess->SetPriGen((qsimPrimaryGeneratorAction *)gen_action);
runManager->SetUserAction(gen_action);
G4UserEventAction* event_action = new qsimEventAction;
((qsimEventAction *) event_action)->SetIO(io);
runManager->SetUserAction(event_action);
G4UserSteppingAction* stepping_action = new qsimSteppingAction;
runManager->SetUserAction(stepping_action);
rmmess->SetStepAct((qsimSteppingAction *) stepping_action);
// Initialize Run manager
////////////////////////////////////////////////////////////////////////////
//runManager->Initialize();
// do initialization in all macro files,
//see remoll examples for assistance.
G4UIsession* session = 0;
//----------------
// Visualization:
//----------------
if (argc==1) // Define UI session for interactive mode.
{
// G4UIterminal is a (dumb) terminal.
#if defined(G4UI_USE_QT)
session = new G4UIQt(argc,argv);
#elif defined(G4UI_USE_WIN32)
session = new G4UIWin32();
#elif defined(G4UI_USE_XM)
session = new G4UIXm(argc,argv);
#elif defined(G4UI_USE_TCSH)
session = new G4UIterminal(new G4UItcsh);
#else
session = new G4UIterminal();
#endif
}
#ifdef G4VIS_USE
// Visualization, if you choose to have it!
//
// Simple graded message scheme - give first letter or a digit:
// 0) quiet, // Nothing is printed.
// 1) startup, // Startup and endup messages are printed...
// 2) errors, // ...and errors...
// 3) warnings, // ...and warnings...
// 4) confirmations, // ...and confirming messages...
// 5) parameters, // ...and parameters of scenes and views...
// 6) all // ...and everything available.
//this is the initializing the run manager?? Right?
G4VisManager* visManager = new G4VisExecutive;
//visManager -> SetVerboseLevel (1);
visManager ->Initialize();
#endif
//get the pointer to the User Interface manager
G4UImanager * UI = G4UImanager::GetUIpointer();
if (session) // Define UI session for interactive mode.
{
// G4UIterminal is a (dumb) terminal.
//UI->ApplyCommand("/control/execute myVis.mac");
#if defined(G4UI_USE_XM) || defined(G4UI_USE_WIN32) || defined(G4UI_USE_QT)
// Customize the G4UIXm,Win32 menubar with a macro file :
UI->ApplyCommand("/control/execute macros/gui.mac");
#endif
session->SessionStart();
delete session;
}
else // Batch mode - not using the GUI
{
#ifdef G4VIS_USE
visManager->SetVerboseLevel("quiet");
#endif
//these line will execute a macro without the GUI
//in GEANT4 a macro is executed when it is passed to the command, /control/execute
G4String command = "/control/execute ";
G4String fileName = argv[1];
/* Copy contents of macro into buffer to be written out
* into ROOT file
* */
UI->ApplyCommand(command+fileName);
}
//if one used the GUI then delete it
#ifdef G4VIS_USE
delete visManager;
#endif
return 0;
}