-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNP1.cc
More file actions
195 lines (168 loc) · 5.17 KB
/
Copy pathNP1.cc
File metadata and controls
195 lines (168 loc) · 5.17 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
/*
* NanoParticle 1.0
* Copyright (c) 2017 Escuela Colombiana de Carreras Industriales - ECCI
* All Right Reserved.
*
* Developed by Andrés Camilo Sevilla
*
* Use and copying of these libraries and preparation of derivative works
* based upon these libraries are permitted. Any copy of these libraries
* must include this copyright notice.
*
* Bogotá, Colombia.
*
*/
// Geant4 Headers
#include "NP1ActionInitialization.hh"
#include "NP1DetectorConstruction.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#else
#include "G4RunManager.hh"
#endif
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "QGSP_BIC_HP.hh"
#include "Randomize.hh"
#include "G4GenericBiasingPhysics.hh"
#include "G4SystemOfUnits.hh"
// NP1 Headers
#include "NP1Control.hh"
#include "NP1PhysicsListFactory.hh"
namespace {
void PrintUsage() {
G4cerr << " Usage: " << G4endl;
G4cerr << " ./NP1 [-m macro ] "
<< " [-v visualization {'on','off'}]"
<< " [-vm vis_macro ]"
<< " [-b biasing {'on','off'}]"
<< " [-n numberOfEvent ]"
<< "\n or\n ./NP1 [macro.mac]"
<< G4endl;
}
}
int main(int argc,char** argv)
{
// Detect interactive mode (if no arguments) and define UI session
//
G4UIExecutive* ui = 0;
// Evaluate arguments
//
if ( argc > 10 ) {
PrintUsage();
return 1;
}
G4String macro("");
G4String vis_macro("");
G4String onOffBiasing("");
G4String onOffVisualization("");
G4int numberOfEvent(0);
if (argc == 1) {
ui = new G4UIExecutive(argc, argv);
onOffVisualization="on";
}
for ( G4int i=1; i<argc; i=i+2 )
{
if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
else if (G4String(argv[i]) == "-v" ) {
onOffVisualization=argv[i+1];
if(onOffVisualization=="on"){
ui = new G4UIExecutive(argc, argv);
}
}
else if ( G4String(argv[i]) == "-vm" ) {
if(!ui) ui = new G4UIExecutive(argc, argv);
if(G4String(argv[i]) == "-vm") vis_macro = argv[i+1];
onOffVisualization="on";
}
else if ( G4String(argv[i]) == "-b" ) onOffBiasing = argv[i+1];
else if ( G4String(argv[i]) == "-n" ) numberOfEvent = G4UIcommand::ConvertToInt(argv[i+1]);
else{
PrintUsage();
return 1;
}
}
if(macro == "") macro = "mac/init.mac";
if(vis_macro == "") vis_macro = "mac/vis1.mac";
if(onOffBiasing == "") onOffBiasing = "off";
if(onOffVisualization == "") onOffVisualization = "off";
// Construct Control and ControlMessenger
NP1Control::GetInstance();
// Choose the Random engine
//
CLHEP::RanluxEngine defaultEngine( 1234567, 4 );
G4Random::setTheEngine( &defaultEngine );
G4int seed = time( NULL );
G4Random::setTheSeed( seed );
// Construct the default run manager
//
#ifdef G4MULTITHREADED
G4MTRunManager* runManager = new G4MTRunManager;
runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores());
#else
G4RunManager* runManager = new G4RunManager;
#endif
// Set mandatory initialization classes
//
// Detector construction
runManager->SetUserInitialization(new NP1DetectorConstruction());
// Physics list
//G4VModularPhysicsList* physicsList = new NP1PhysicsListFactory();
G4VModularPhysicsList* physicsList = new QGSP_BIC_HP();
physicsList->SetDefaultCutValue(0.01*mm);
//physicsList->SetCutValue(4*um,"e-");
//physicsList->SetCutValue(4*um,"e+");
//physicsList->SetCutValue(4*um,"proton");
//physicsList->SetCutValue(0.01*mm,"gamma");
physicsList->DumpCutValuesTable();
G4GenericBiasingPhysics* biasingPhysics = new G4GenericBiasingPhysics();
if ( onOffBiasing == "on" )
{
//biasingPhysics->NonPhysicsBiasAllCharged();
biasingPhysics->Bias("gamma");
//biasingPhysics->NonPhysicsBias("gamma");
physicsList->RegisterPhysics(biasingPhysics);
G4cout << " ********************************************************* " << G4endl;
G4cout << " ********** processes are wrapped for biasing ************ " << G4endl;
G4cout << " ********************************************************* " << G4endl;
}
else
{
NP1Control::GetInstance()->SetCSBiasFactor(1);
G4cout << " ************************************************* " << G4endl;
G4cout << " ********** processes are not wrapped ************ " << G4endl;
G4cout << " ************************************************* " << G4endl;
}
runManager->SetUserInitialization(physicsList);
// User action initialization
runManager->SetUserInitialization(new NP1ActionInitialization());
// Initialize visualization
//
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
// Get the pointer to the User Interface manager
G4UImanager* UImanager = G4UImanager::GetUIpointer();
// Process macro or start UI session
//
if ( macro != "" )
{
G4String command = "/control/execute ";
UImanager->ApplyCommand(command+macro);
}
if (onOffVisualization=="on"){
// interactive mode
G4String command = "/control/execute ";
UImanager->ApplyCommand(command+vis_macro);
ui->SessionStart();
delete ui;
}else{
if ( numberOfEvent >= 0 ) runManager->BeamOn(numberOfEvent);
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not be deleted
// in the main() program !
delete visManager;
delete runManager;
}