Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
examples
extended
field
field04
field04.cc
Go to the documentation of this file.
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
//
28
//
29
//
30
// --------------------------------------------------------------
31
//
32
// GEANT 4 - Example F04
33
//
34
// --------------------------------------------------------------
35
// Comments
36
//
37
//
38
// --------------------------------------------------------------
39
40
#ifndef WIN32
41
#include <unistd.h>
42
#endif
43
44
#include "
G4RunManager.hh
"
45
#include "
G4UImanager.hh
"
46
47
#include "
Randomize.hh
"
48
49
#include "
F04PhysicsList.hh
"
50
#include "
F04DetectorConstruction.hh
"
51
#include "
F04PrimaryGeneratorAction.hh
"
52
53
#include "
F04RunAction.hh
"
54
#include "
F04EventAction.hh
"
55
#include "
F04TrackingAction.hh
"
56
#include "
F04SteppingAction.hh
"
57
#include "
F04StackingAction.hh
"
58
#include "
F04SteppingVerbose.hh
"
59
60
#ifdef G4VIS_USE
61
#include "
G4VisExecutive.hh
"
62
#endif
63
64
#ifdef G4UI_USE
65
#include "
G4UIExecutive.hh
"
66
#endif
67
68
// argc holds the number of arguments (including the name) on the command line
69
// -> it is ONE when only the name is given !!!
70
// argv[0] is always the name of the program
71
// argv[1] points to the first argument, and so on
72
73
int
main
(
int
argc,
char
** argv)
74
{
75
G4String
physName =
"QGSP_BERT_EMV"
;
76
77
G4int
seed = 123;
78
if
(argc > 2) seed = atoi(argv[argc-1]);
79
80
// Choose the Random engine
81
82
CLHEP::HepRandom::setTheEngine
(
new
CLHEP::RanecuEngine
);
83
CLHEP::HepRandom::setTheSeed
(seed);
84
85
#ifndef WIN32
86
G4int
c
= 0;
87
while
((c=getopt(argc,argv,
"p"
)) != -1)
88
{
89
switch
(c)
90
{
91
case
'p'
:
92
physName =
optarg
;
93
G4cout
<<
"Physics List used is "
<< physName <<
G4endl
;
94
break
;
95
case
':'
:
/* -p without operand */
96
fprintf(stderr,
"Option -%c requires an operand\n"
,
optopt
);
97
break
;
98
case
'?'
:
99
fprintf(stderr,
"Unrecognised option: -%c\n"
,
optopt
);
100
}
101
}
102
#endif
103
104
// My Verbose output class
105
106
G4VSteppingVerbose::SetInstance
(
new
F04SteppingVerbose
);
107
108
// Construct the default run manager
109
110
G4RunManager
* runManager =
new
G4RunManager
;
111
112
// Set mandatory initialization classes
113
114
F04DetectorConstruction
* detector =
new
F04DetectorConstruction
();
115
116
runManager->
SetUserInitialization
(detector);
117
runManager->
SetUserInitialization
(
new
F04PhysicsList
(physName));
118
119
#ifdef G4VIS_USE
120
121
// visualization manager
122
123
G4VisManager
* visManager =
new
G4VisExecutive
();
124
visManager->
Initialize
();
125
126
#endif
127
128
// Set mandatory user action class
129
130
runManager->
SetUserAction
(
new
F04PrimaryGeneratorAction
(detector) );
131
132
F04RunAction
* runAction =
new
F04RunAction
();
133
F04EventAction
* eventAction =
new
F04EventAction
(runAction);
134
135
runManager->
SetUserAction
(runAction);
136
runManager->
SetUserAction
(eventAction);
137
runManager->
SetUserAction
(
new
F04TrackingAction
() );
138
runManager->
SetUserAction
(
new
F04SteppingAction
() );
139
runManager->
SetUserAction
(
new
F04StackingAction
() );
140
141
// runManager->Initialize();
142
143
// Get the pointer to the User Interface manager
144
145
G4UImanager
* UImanager =
G4UImanager::GetUIpointer
();
146
147
#ifndef WIN32
148
G4int
optmax = argc;
149
if
(argc > 2) { optmax = optmax-1; }
150
151
if
(
optind
< optmax)
152
{
153
G4String
command =
"/control/execute "
;
154
for
( ;
optind
< optmax;
optind
++)
155
{
156
G4String
macroFilename = argv[
optind
];
157
UImanager->
ApplyCommand
(command+macroFilename);
158
}
159
}
160
#else // Simple UI for Windows runs, no possibility of additional arguments
161
if
(argc!=1)
162
{
163
G4String
command =
"/control/execute "
;
164
G4String
fileName = argv[1];
165
UImanager->
ApplyCommand
(command+fileName);
166
}
167
#endif
168
else
{
169
// Define (G)UI terminal for interactive mode
170
#ifdef G4UI_USE
171
G4UIExecutive
* ui =
new
G4UIExecutive
(argc,argv);
172
#ifdef G4VIS_USE
173
UImanager->
ApplyCommand
(
"/control/execute vis.mac"
);
174
#endif
175
ui->
SessionStart
();
176
delete
ui;
177
#endif
178
}
179
180
// job termination
181
182
#ifdef G4VIS_USE
183
delete
visManager;
184
#endif
185
delete
runManager;
186
187
return
0;
188
}
Generated on Sat May 25 2013 14:32:25 for Geant4 by
1.8.4