ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
microdosimetry.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file microdosimetry.cc
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
// This example is provided by the Geant4-DNA collaboration
27
// Any report or published results obtained using the Geant4-DNA software
28
// shall cite the following Geant4-DNA collaboration publication:
29
// Med. Phys. 37 (2010) 4692-4708
30
// The Geant4-DNA web site is available at http://geant4-dna.org
31
//
34
//
35
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
36
#include "
G4Types.hh
"
37
38
#ifdef G4MULTITHREADED
39
#include "
G4MTRunManager.hh
"
40
#else
41
#include "
G4RunManager.hh
"
42
#endif
43
44
#include "
G4UImanager.hh
"
45
#include "
G4UIExecutive.hh
"
46
#include "
G4UIterminal.hh
"
47
#include "
G4UItcsh.hh
"
48
#include "
G4VisExecutive.hh
"
49
#ifdef G4UI_USE_QT
50
#include "
G4UIQt.hh
"
51
#endif
52
53
#include "ActionInitialization.hh"
54
#include "DetectorConstruction.hh"
55
#include "PhysicsList.hh"
56
#include "CommandLineParser.hh"
57
58
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59
60
using namespace
G4DNAPARSER;
61
CommandLineParser
*
parser
(0);
62
63
void
Parse
(
int
& argc,
char
** argv);
64
65
int
main
(
int
argc,
char
** argv)
66
{
68
// Parse options given in commandLine
69
//
70
Parse
(argc, argv);
71
73
// Construct the run manager according to whether MT is activated or not
74
//
75
Command
* commandLine(0);
76
77
#ifdef G4MULTITHREADED
78
G4MTRunManager
* runManager=
new
G4MTRunManager
;
79
if
((commandLine =
parser
->
GetCommandIfActive
(
"-mt"
)))
80
{
81
int
nThreads = 2;
82
if
(commandLine->
GetOption
() ==
"NMAX"
)
83
{
84
nThreads =
G4Threading::G4GetNumberOfCores
();
85
}
86
else
87
{
88
nThreads =
G4UIcommand::ConvertToInt
(commandLine->
GetOption
());
89
}
90
G4cout
<<
"===== Microdosimetry is started with "
91
<< runManager->
GetNumberOfThreads
()
92
<<
" threads ====="
<<
G4endl
;
93
94
runManager->
SetNumberOfThreads
(nThreads);
95
}
96
#else
97
G4RunManager
* runManager =
new
G4RunManager
();
98
#endif
99
100
// Set mandatory user initialization classes
101
102
DetectorConstruction
* detector =
new
DetectorConstruction
;
103
runManager->
SetUserInitialization
(detector);
104
105
runManager->
SetUserInitialization
(
new
PhysicsList
);
106
107
// User action initialization
108
109
runManager->
SetUserInitialization
(
new
ActionInitialization
());
110
111
// Initialize G4 kernel
112
113
runManager->
Initialize
();
114
115
// Initialize visualization
116
117
G4VisManager
* visManager =
new
G4VisExecutive
;
118
visManager->
Initialize
();
119
120
// Get the pointer to the User Interface manager
121
122
G4UImanager
* UImanager =
G4UImanager::GetUIpointer
();
123
G4UIExecutive
* ui(0);
124
125
// interactive mode : define UI session
126
127
if
((commandLine =
parser
->
GetCommandIfActive
(
"-gui"
)))
128
{
129
ui =
new
G4UIExecutive
(argc, argv,
130
commandLine->
GetOption
());
131
132
if
(ui->
IsGUI
())
133
UImanager->
ApplyCommand
(
"/control/execute gui.mac"
);
134
135
if
(
parser
->
GetCommandIfActive
(
"-novis"
) == 0)
136
// visualization is used by default
137
{
138
if
((commandLine =
parser
->
GetCommandIfActive
(
"-vis"
)))
139
// select a visualization driver if needed (e.g. HepFile)
140
{
141
UImanager->
ApplyCommand
(
G4String
(
"/vis/open "
)+
142
commandLine->
GetOption
());
143
}
144
else
145
// by default OGL is used
146
{
147
UImanager->
ApplyCommand
(
"/vis/open OGL 800x600-0+0"
);
148
}
149
UImanager->
ApplyCommand
(
"/control/execute vis.mac"
);
150
}
151
}
152
else
153
// to be use visualization file (= store the visualization into
154
// an external file:
155
// ASCIITree ; DAWNFILE ; HepRepFile ; VRML(1,2)FILE ; gMocrenFile ...
156
{
157
if
((commandLine =
parser
->
GetCommandIfActive
(
"-vis"
)))
158
{
159
UImanager->
ApplyCommand
(
G4String
(
"/vis/open "
)+commandLine->
GetOption
());
160
UImanager->
ApplyCommand
(
"/control/execute vis.mac"
);
161
}
162
}
163
164
if
((commandLine =
parser
->
GetCommandIfActive
(
"-mac"
)))
165
{
166
G4String
command =
"/control/execute "
;
167
UImanager->
ApplyCommand
(command + commandLine->
GetOption
());
168
}
169
else
170
{
171
UImanager->
ApplyCommand
(
"/control/execute microdosimetry.in"
);
172
}
173
174
if
((commandLine =
parser
->
GetCommandIfActive
(
"-gui"
)))
175
{
176
#ifdef G4UI_USE_QT
177
G4UIQt* UIQt =
static_cast<
G4UIQt*
>
(UImanager->
GetG4UIWindow
());
178
if
( UIQt) {
179
UIQt->AddViewerTabFromFile(
"README"
,
"README from "
+
G4String
(argv[0]));
180
}
181
#endif
182
ui->
SessionStart
();
183
delete
ui;
184
}
185
186
delete
visManager;
187
delete
runManager;
188
189
return
0;
190
}
191
192
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
193
194
void
GetNameAndPathOfExecutable
(
char
** argv,
195
G4String
& executable,
196
G4String
& path)
197
{
198
// Get the last position of '/'
199
std::string aux(argv[0]);
200
201
// get '/' or '\\' depending on unix/mac or windows.
202
#if defined(_WIN32) || defined(WIN32)
203
int
pos
= aux.rfind(
'\\'
);
204
#else
205
int
pos = aux.rfind(
'/'
);
206
#endif
207
208
// Get the path and the name
209
path = aux.substr(0, pos + 1);
210
executable = aux.substr(pos + 1);
211
}
212
213
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
214
215
void
Parse
(
int
& argc,
char
** argv)
216
{
218
// Parse options given in commandLine
219
//
220
parser
=
CommandLineParser::GetParser
();
221
222
parser
->
AddCommand
(
"-gui"
,
223
Command::OptionNotCompulsory
,
224
"Select geant4 UI or just launch a geant4 terminal session"
,
225
"qt"
);
226
227
parser
->
AddCommand
(
"-mac"
,
228
Command::WithOption
,
229
"Give a mac file to execute"
,
230
"macFile.mac"
);
231
232
// You cann your own command, as for instance:
233
// parser->AddCommand("-seed",
234
// Command::WithOption,
235
// "Give a seed value in argument to be tested", "seed");
236
// it is then up to you to manage this option
237
238
#ifdef G4MULTITHREADED
239
parser
->
AddCommand
(
"-mt"
,
240
Command::WithOption
,
241
"Launch in MT mode (events computed in parallel)"
,
242
"2"
);
243
#endif
244
245
parser
->
AddCommand
(
"-vis"
,
246
Command::WithOption
,
247
"Select a visualization driver"
,
248
"OGL 600x600-0+0"
);
249
250
parser
->
AddCommand
(
"-novis"
,
251
Command::WithoutOption
,
252
"Deactivate visualization when using GUI"
);
253
254
G4String
exec;
255
G4String
path;
256
GetNameAndPathOfExecutable
(argv,exec, path);
257
258
parser
->
AddCommand
(
"-out"
,
259
Command::OptionNotCompulsory
,
260
"Output files"
,
261
exec);
262
264
// If -h or --help is given in option : print help and exit
265
//
266
if
(
parser
->
Parse
(argc, argv) != 0)
// help is being printed
267
{
268
// if you are using ROOT, create a TApplication in this condition in order
269
// to print the help from ROOT as well
270
CommandLineParser::DeleteInstance
();
271
std::exit
(0);
272
}
273
275
// Kill application if wrong argument in command line
276
//
277
if
(
parser
->
CheckIfNotHandledOptionsExists
(argc, argv))
278
{
279
// if you are using ROOT, you should initialise your TApplication
280
// before this condition
281
abort();
282
}
283
}
geant4
tree
geant4-10.6-release
examples
extended
medical
dna
microdosimetry
microdosimetry.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:08
using
1.8.2 with
ECCE GitHub integration