-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathQweakSimG4.cc
194 lines (158 loc) · 6.05 KB
/
QweakSimG4.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
// geant4 includes
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIterminal.hh"
#include "G4UItcsh.hh"
#include "G4Version.hh"
#if G4VERSION_NUMBER < 1000
#include "G4StepLimiterBuilder.hh"
#else
#include "G4StepLimiterPhysics.hh"
#endif
#include "G4OpticalPhysics.hh"
#include "G4PhysListFactory.hh"
#include "G4VModularPhysicsList.hh"
// user includes
#include "QweakSimUserInformation.hh"
#include "QweakSimDetectorConstruction.hh"
#include "QweakSimPrimaryGeneratorAction.hh"
#include "QweakSimRunAction.hh"
#include "QweakSimEventAction.hh"
#include "QweakSimStackingAction.hh"
#include "QweakSimSteppingAction.hh"
#include "QweakSimTrackingAction.hh"
#include "QweakSimSteppingVerbose.hh"
#include "QweakSimAnalysis.hh"
#include "QweakSimEPEvent.hh"
#include "G4UIExecutive.hh"
#include <time.h>
//#define G4UI_USE_QT 1
#ifdef G4UI_USE_QT
#include "G4UIQt.hh"
#endif
#ifdef G4UI_USE_XM
#include "G4UIXm.hh"
#endif
#ifdef G4VIS_USE
#include "G4VisExecutive.hh"
#endif
#define USE_CUSTOM_NUCLEAR_SCATTERING 1
#if USE_CUSTOM_NUCLEAR_SCATTERING
//#include "physics_lists/constructors/electromagnetic/QweakSimEmStandardPhysics.hh"
#include "physics_lists/constructors/electromagnetic/QweakSimEmLivermorePhysics.hh"
#endif
#include <vector>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc,char** argv) {
// Verbose output class
//G4VSteppingVerbose::SetInstance( new QweakSimSteppingVerbose() );
clock_t tStart=clock();
// Run manager
G4RunManager * runManager = new G4RunManager();
// UserInitialization classes (mandatory)
QweakSimUserInformation* myQweakSimUserInformation = new QweakSimUserInformation();
QweakSimDetectorConstruction* myQweakSimExperiment = new QweakSimDetectorConstruction(myQweakSimUserInformation);
QweakSimAnalysis* myQweakSimAnalysis = new QweakSimAnalysis(myQweakSimUserInformation);
QweakSimEPEvent* myEPEvent = new QweakSimEPEvent(myQweakSimUserInformation);
runManager->SetUserInitialization(myQweakSimExperiment);
/*
vector to pass asym information around
0: pp = \Pi (1+A_i)
1: pm = \Pi (1-A_i)
2: calculation flag (can be used to stop calculation during event
-- not used now; if needed needs to be set in steppingAction)
3: bitInfo for physProcesses: a*2^0+b*2^1
a=1 for debugPrint;
b=1 for modifyTrajectory;
e.g.: 3:modifyTrajectory is on and will print for debugging
*/
std::vector<double> asymInfo(4,-2);
asymInfo[3]=0;//default false for both
// Calls a reference physics list for the simulation
G4PhysListFactory factory;
G4VModularPhysicsList* physlist = factory.GetReferencePhysList("QGSP_BERT_LIV");
physlist->RegisterPhysics(new G4OpticalPhysics());
#if G4VERSION_NUMBER < 1000
physlist->RegisterPhysics(new G4StepLimiterBuilder());
#else
physlist->RegisterPhysics(new G4StepLimiterPhysics());
#endif
// Replace the standard EM with the customized version to add Pb A_T
#if USE_CUSTOM_NUCLEAR_SCATTERING
physlist->ReplacePhysics(new QweakSimEmLivermorePhysics(0,&asymInfo));
#endif
runManager->SetUserInitialization(physlist);
// UserAction classes
runManager->SetUserAction( new QweakSimPrimaryGeneratorAction(myQweakSimUserInformation, myEPEvent) );
//runManager->SetUserAction( new QweakSimPrimaryGeneratorAction( ) );
runManager->SetUserAction( new QweakSimSteppingAction(myQweakSimUserInformation, myEPEvent,&asymInfo));
runManager->SetUserAction( new QweakSimStackingAction() );
runManager->SetUserAction( new QweakSimTrackingAction(myQweakSimUserInformation) );
runManager->SetUserAction( new QweakSimEventAction(&asymInfo,myQweakSimAnalysis, myQweakSimUserInformation) );
runManager->SetUserAction( new QweakSimRunAction(myQweakSimAnalysis) );
runManager->StoreRandomNumberStatusToG4Event(1);
//Initialize G4 kernel
runManager->Initialize();
G4UIsession* session = 0;
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_XM)
session = new G4UIXm(argc,argv);
#elif defined(G4UI_USE_WIN32)
session = new G4UIWin32();
#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.
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 vis/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 gui.mac");
#endif
session->SessionStart();
delete session;
}
else // Batch mode
{
#ifdef G4VIS_USE
visManager->SetVerboseLevel("quiet");
#endif
G4String command = "/control/execute ";
G4String fileName = argv[1];
UI->ApplyCommand(command+fileName);
}
#ifdef G4VIS_USE
delete visManager;
#endif
delete runManager;
delete myEPEvent;
G4cout<<" Running time[s]: "<< (double) ((clock() - tStart)/CLOCKS_PER_SEC)<<G4endl;
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......