-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME_ExampleB5
294 lines (232 loc) · 11.9 KB
/
README_ExampleB5
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
$Id: README 103553 2017-04-18 09:00:54Z gcosmo $
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Extended Example B5
--------------------
Example B5 implements a double-arm spectrometer with wire chambers,
hodoscopes and calorimeters. Event simulation and collection are
enabled, as well as event display and analysis.
1- GEOMETRY
The spectrometer consists of two detector arms
(see B5DetectorConstruction). One arm provides
position and timing information of the incident particle while the
other collects position, timing and energy information of the particle
after it has been deflected by a magnetic field centered at the
spectrometer pivot point.
- First arm: box filled with air, also containing:
1 hodoscope (15 vertical strips of plastic scintillator)
1 drift chamber (5 horizontal argon gas layers with a
"virtual wire" at the center of each layer)
- Second arm: box filled with air, also containing:
1 hodoscope (25 vertical strips of plastic scintillator)
1 drift chamber (5 horizontal argon gas layers with a
"virtual wire" at the center of each layer)
1 electromagnetic calorimeter:
a box sub-divided along x,y and z
axes into cells of CsI
1 hadronic calorimeter:
a box sub-divided along x,y, and z axes
into cells of lead, with a layer of
plastic scintillator placed at the center
of each cell
- Magnetic field region: air-filled cylinder which contains
the field (see B5MagneticField)
The maximum step limit in the magnetic field region is also set
via the G4UserLimits class in a similar way as in Example B2.
The rotation angle of the second arm and the magnetic field value
can be set via the interactive command defined using the G4GenericMessenger
class.
2- PHYSICS
This example uses the reference hadronic physics list, FTFP_BERT,
and also adds the G4StepLimiter process.
3- ACTION INITALIZATION
B5ActionInitialization class
instantiates and registers to Geant4 kernel all user action classes.
While in sequential mode the action classes are instatiated just once,
via invoking the method:
B5ActionInitialization::Build()
in multi-threading mode the same method is invoked for each thread worker
and so all user action classes are defined thread-local.
A run action class is instantiated both thread-local
and global that's why its instance is created also in the method
B5ActionInitialization::BuildForMaster()
which is invoked only in multi-threading mode.
4- PRIMARY GENERATOR
The primary generator action class employs the G4ParticleGun.
The primary kinematics consists of a single particle which is
is sent in the direction of the first spectrometer arm.
The type of the particle and its several properties can be changed
via the G4 built-in commands of the G4ParticleGun class or
this example command defined using the G4GenericMessenger class.
5- EVENT
An event consists of the generation of a single particle which is
transported through the first spectrometer arm. Here, a scintillator
hodoscope records the reference time of the particle before it passes
through a drift chamber where the particle position is measured.
Momentum analysis is performed as the particle passes through a magnetic
field at the spectrometer pivot and then into the second spectrometer
arm. In the second arm, the particle passes through another hodoscope
and drift chamber before interacting in the electromagnetic calorimeter.
Here it is likely that particles will induce electromagnetic showers.
The shower energy is recorded in a three-dimensional array of CsI
crystals. Secondary particles from the shower, as well as primary
particles which do not interact in the CsI crystals, pass into the
hadronic calorimeter. Here, the remaining energy is collected in a
three-dimensional array of scintillator-lead sandwiches.
Several aspects of the event may be changed interactively by the user:
- angle of the second spectrometer arm
- strength of magnetic field
- initial particle type
- initial momentum and angle
- momentum and angle spreads
- type of initial particle may be randomized
The initial particle type can be changed using the G4ParticleGun command:
/gun/particle particleName
The UI commands specific to this example are available in /B5 command
directory:
/B5/detector/armAngle angle unit
/B5/field/value field unit
/B5/generator/momentum value unit
/B5/generator/sigmaMomentum value unit
/B5/generator/sigmaAngle value unit
/B5/generator/randomizePrimary [true|false]
They are implemented in
B5DetectorConstruction::DefineCommands(),
B5MagneticField::DefineCommands() and
B5PrimaryGeneratorAction::DefineCommands() methods
using G4GenericMessenger class.
In first execution of BeginOfEventAction()
the hits collections identifiers are saved in data members of the class
and used in EndOfEventAction() for accessing
the hists collections and filling the accounted information in defined
histograms and ntuples and printing its summary in a log file.
The frequency of printing can be tuned with the built-in command
/run/printProgress frequency
6- DETECTOR RESPONSE:
All the information required to simulate and analyze an event is
recorded in hits. This information is recorded in the following
sensitive detectors:
- hodoscope:
particle time
strip ID, position and rotation
(see B5HodoscopeSD, B5HodoscopeHit classes)
- drift chamber:
particle time
particle position
layer ID
(see B5DriftChamberSD, B5DriftChamberHit classes)
- electromagnetic calorimeter:
energy deposited in cell
cell ID, position and rotation
(see B5EMCalorimeterSD, B5EMCalorimeterHit classes)
- hadronic calorimeter:
energy deposited in cell
cell column ID and row ID, position and rotation
(see B5HadCalorimeterSD, B5HadCalorimeterHit classes)
The hit classes include methods GetAttDefs and CreateAttValues to define
and then fill extra "HepRep-style" Attributes that the visualization system
can use to present extra information about the hits.
For example, if you pick a B5HadCalorimeterHit in OpenGL or a HepRep viewer,
you will be shown the hit's "Hit Type", "Column ID", "Row ID",
"Energy Deposited" and "Position".
These attributes are essentially arbitrary extra pieces of information
(integers, doubles or strings) that are carried through the visualization.
Each attribute is defined once in G4AttDef object and then is filled for
each hit in a G4AttValue object.
These attributes can also be used by commands to filter which hits are drawn:
/vis/filtering/hits/drawByAttribute
Detector Geometry and trajectories also carry HepRep-style attributes,
but these are filled automatically in the base classes.
HepRep is further described at: http://www.slac.stanford.edu/~perl/heprep/
7- ANALYSIS:
The analysis tools are used to accumulate statistics.
Histograms and an ntuple are created in B5RunAction::B5RunAction()
constructor for the following quantities:
1D histograms:
- Number of hits in Chamber 1
- Number of hits in Chamber 2
2D histograms:
- Drift Chamber 1 X vs Y positions
- Drift Chamber 2 X vs Y positions
Ntuple:
- Number of hits in Chamber 1
- Number of hits in Chamber 2
- Total energy deposit in EM calorimeter
- Total energy deposit in Hadronic calorimeter
- Time of flight in Hodoscope 1
- Time of flight in Hodoscope 2
- Vector of energy deposits in EM calorimeter cells
- Vector of energy deposits in Hadronic calorimeter cells
The histograms and ntuple are saved in the output file in a format
according to a technology selected in B5Analysis.hh.
When running in multi-threading mode, the histograms and ntuple accumulated
on threads are automatically merged in a single output file.
8- BUILD OPTIONS:
This example can be built with excluding visualization and/or
Geant4 user interface via G4VIS_USE and G4UI_USE compiler options
(see exampleB5.cc).
These options are defined by default with Geant4 configuration;
they can be switched off at compilation time via the CMake options
G4VIS_NONE or G4UI_NONE or via the environment variables of the
same name if using GNUmake build.
The following paragraphs are common to all basic examples
A- VISUALISATION
The visualization manager is set via the G4VisExecutive class
in the main() function in exampleB5.cc.
The initialisation of the drawing is done via a set of /vis/ commands
in the macro vis.mac. This macro is automatically read from
the main function when the example is used in interactive running mode.
By default, vis.mac opens an OpenGL viewer (/vis/open OGL).
The user can change the initial viewer by commenting out this line
and instead uncommenting one of the other /vis/open statements, such as
HepRepFile or DAWNFILE (which produce files that can be viewed with the
HepRApp and DAWN viewers, respectively). Note that one can always
open new viewers at any time from the command line. For example, if
you already have a view in, say, an OpenGL window with a name
"viewer-0", then
/vis/open DAWNFILE
then to get the same view
/vis/viewer/copyView viewer-0
or to get the same view *plus* scene-modifications
/vis/viewer/set/all viewer-0
then to see the result
/vis/viewer/flush
The DAWNFILE, HepRepFile drivers are always available
(since they require no external libraries), but the OGL driver requires
that the Geant4 libraries have been built with the OpenGL option.
vis.mac has additional commands that demonstrate additional functionality
of the vis system, such as displaying text, axes, scales, date, logo and
shows how to change viewpoint and style.
To see even more commands use help or ls or browse the available UI commands
in the Application Developers Guide.
For more information on visualization, including information on how to
install and run DAWN, OpenGL and HepRApp, see the visualization tutorials,
for example,
http://geant4.slac.stanford.edu/Presentations/vis/G4[VIS]Tutorial/G4[VIS]Tutorial.html
(where [VIS] can be replaced by DAWN, OpenGL and HepRApp)
The tracks are automatically drawn at the end of each event, accumulated
for all events and erased at the beginning of the next run.
B- USER INTERFACES
The user command interface is set via the G4UIExecutive class
in the main() function in exampleB5.cc
The selection of the user command interface is then done automatically
according to the Geant4 configuration or it can be done explicitly via
the third argument of the G4UIExecutive constructor (see exampleB4a.cc).
C- HOW TO RUN
- Execute exampleB5 in the 'interactive mode' with visualization:
% ./exampleB5
and type in the commands from run1.mac line by line:
Idle> /control/verbose 2
Idle> /tracking/verbose 1
Idle> /run/beamOn 10
Idle> ...
Idle> exit
or
Idle> /control/execute run1.mac
....
Idle> exit
- Execute exampleB5 in the 'batch' mode from macro files
(without visualization)
% ./exampleB5 run2.mac
% ./exampleB5 exampleB5.in > exampleB5.out