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
clustering.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file clustering.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
//
32
//
35
36
#include "DetectorConstruction.hh"
37
#include "PhysicsList.hh"
38
#include "ActionInitialization.hh"
39
40
#ifdef G4MULTITHREADED
41
#include "
G4MTRunManager.hh
"
42
#else
43
#include "
G4RunManager.hh
"
44
#endif
45
46
#include "
G4DNAChemistryManager.hh
"
47
#include "
G4UImanager.hh
"
48
#include "
G4UIExecutive.hh
"
49
#include "
G4VisExecutive.hh
"
50
51
#include "CommandLineParser.hh"
52
53
using namespace
G4DNAPARSER;
54
CommandLineParser
*
parser
(0);
55
56
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
58
void
Parse
(
int
& argc,
char
** argv);
59
60
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61
62
int
main
(
int
argc,
char
** argv)
63
{
65
// Parse options given in commandLine
66
//
67
Parse
(argc, argv);
68
70
// Construct the run manager according to whether MT is activated or not
71
//
72
Command
* commandLine(0);
73
74
#ifdef G4MULTITHREADED
75
G4MTRunManager
* runManager=
new
G4MTRunManager
;
76
if
((commandLine =
parser
->
GetCommandIfActive
(
"-mt"
)))
77
{
78
int
nThreads = 2;
79
if
(commandLine->
GetOption
() ==
"NMAX"
)
80
{
81
nThreads =
G4Threading::G4GetNumberOfCores
();
82
}
83
else
84
{
85
nThreads =
G4UIcommand::ConvertToInt
(commandLine->
GetOption
());
86
}
87
G4cout
<<
"===== clustering is started with "
88
<< runManager->
GetNumberOfThreads
()
89
<<
" threads ====="
<<
G4endl
;
90
91
runManager->
SetNumberOfThreads
(nThreads);
92
}
93
#else
94
G4RunManager
* runManager =
new
G4RunManager
();
95
#endif
96
98
// Set mandatory user initialization classes
99
//
100
DetectorConstruction
* detector =
new
DetectorConstruction
;
101
runManager->
SetUserInitialization
(
new
PhysicsList
);
102
runManager->
SetUserInitialization
(detector);
103
runManager->
SetUserInitialization
(
new
ActionInitialization
());
104
105
// Initialize G4 kernel
106
runManager->
Initialize
();
107
108
// Initialize visualization
109
G4VisManager
* visManager =
new
G4VisExecutive
;
110
visManager->
Initialize
();
111
112
// Get the pointer to the User Interface manager
113
G4UImanager
* UImanager =
G4UImanager::GetUIpointer
();
114
G4UIExecutive
* ui(0);
115
116
// interactive mode : define UI session
117
if
((commandLine =
parser
->
GetCommandIfActive
(
"-gui"
)))
118
{
119
ui =
new
G4UIExecutive
(argc, argv, commandLine->
GetOption
());
120
121
if
(ui->
IsGUI
()) UImanager->
ApplyCommand
(
"/control/execute gui.mac"
);
122
123
if
(
parser
->
GetCommandIfActive
(
"-novis"
) == 0)
124
// visualization is used by default
125
{
126
if
((commandLine =
parser
->
GetCommandIfActive
(
"-vis"
)))
127
// select a visualization driver if needed (e.g. HepFile)
128
{
129
UImanager->
ApplyCommand
(
130
G4String
(
"/vis/open "
) + commandLine->
GetOption
());
131
}
132
else
133
// by default OGL is used
134
{
135
UImanager->
ApplyCommand
(
"/vis/open OGL 800x600-0+0"
);
136
}
137
UImanager->
ApplyCommand
(
"/control/execute vis.mac"
);
138
}
139
}
140
else
141
// to be use visualization file (= store the visualization into
142
// an external file:
143
// ASCIITree ; DAWNFILE ; HepRepFile ; VRML(1,2)FILE ; gMocrenFile ...
144
{
145
if
((commandLine =
parser
->
GetCommandIfActive
(
"-vis"
)))
146
{
147
UImanager->
ApplyCommand
(
148
G4String
(
"/vis/open "
) + commandLine->
GetOption
());
149
UImanager->
ApplyCommand
(
"/control/execute vis.mac"
);
150
}
151
}
152
153
if
((commandLine =
parser
->
GetCommandIfActive
(
"-mac"
)))
154
{
155
G4String
command =
"/control/execute "
;
156
UImanager->
ApplyCommand
(command + commandLine->
GetOption
());
157
}
158
else
159
{
160
UImanager->
ApplyCommand
(
"/control/execute run.in"
);
161
}
162
163
if
((commandLine =
parser
->
GetCommandIfActive
(
"-gui"
)))
164
{
165
ui->
SessionStart
();
166
delete
ui;
167
}
168
169
// Job termination
170
// Free the store: user actions, physics_list and detector_description are
171
// owned and deleted by the run manager, so they should not be deleted
172
// in the main() program !
173
174
delete
visManager;
175
delete
runManager;
176
177
CommandLineParser::DeleteInstance
();
178
179
return
0;
180
}
181
182
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
183
184
void
Parse
(
int
& argc,
char
** argv)
185
{
187
// Parse options given in commandLine
188
//
189
parser
=
CommandLineParser::GetParser
();
190
191
parser
->
AddCommand
(
192
"-gui"
,
Command::OptionNotCompulsory
,
193
"Select geant4 UI or just launch a geant4 terminal session"
,
"qt"
);
194
195
parser
->
AddCommand
(
"-mac"
,
Command::WithOption
,
"Give a mac file to execute"
,
196
"macFile.mac"
);
197
198
// You cann your own command, as for instance:
199
// parser->AddCommand("-seed",
200
// Command::WithOption,
201
// "Give a seed value in argument to be tested", "seed");
202
// it is then up to you to manage this option
203
204
#ifdef G4MULTITHREADED
205
parser
->
AddCommand
(
"-mt"
,
206
Command::WithOption
,
207
"Launch in MT mode (events computed in parallel,"
208
" NOT RECOMMENDED WITH CHEMISTRY)"
,
"2"
);
209
#endif
210
211
parser
->
AddCommand
(
"-vis"
,
Command::WithOption
,
212
"Select a visualization driver"
,
"OGL 600x600-0+0"
);
213
214
parser
->
AddCommand
(
"-novis"
,
Command::WithoutOption
,
215
"Deactivate visualization when using GUI"
);
216
218
// If -h or --help is given in option : print help and exit
219
//
220
if
(
parser
->
Parse
(argc, argv) != 0)
// help is being printed
221
{
222
// if you are using ROOT, create a TApplication in this condition in order
223
// to print the help from ROOT as well
224
CommandLineParser::DeleteInstance
();
225
// Exit is kept
226
std::exit
(0);
227
}
228
230
// Kill application if wrong argument in command line
231
//
232
if
(
parser
->
CheckIfNotHandledOptionsExists
(argc, argv))
233
{
234
// if you are using ROOT, you should initialise your TApplication
235
// before this condition
236
abort();
237
}
238
}
geant4
tree
geant4-10.6-release
examples
extended
medical
dna
clustering
clustering.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:08
using
1.8.2 with
ECCE GitHub integration