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.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]
1 -------------------------------------------------------------------
2
3 =========================================================
4 Geant4 - an Object-Oriented Toolkit for Simulation in HEP
5 =========================================================
6
7 ParticleGun
8 -----------
9
10 History:
11 10-06-2010 : Makoto Asai - merge into one example
12 13-05-2010 : Michel Maire - create as three examples
13
14 This example demonstrates 5 ways of the use of G4ParticleGun shooting
15 primary particles in different cases. These are
16 0) uniform particle direction in a given solid angle
17 1) Generate several vertices and particles per event
18 2) Show how to sample a tabulated function (eg. energy spectrum)
19 3) Divergent beam in an arbitrary direction
20 4) Shooting primaries in spherical coordinates with rotation matrix.
21
22 These use cases can be chosen by a UI command
23 /gunExample/selectGunAction <actionID>
24 where <actionID> corresponds to the above cases.
25
26 1- Geometry construction
27 ---------------------
28
29 It is a simple box which represents an 'infinite' homogeneous medium.
30
31 2- Physics list
32 ------------
33
34 PhysicsList.cc defines only geantino and transportation process.
35
36 3- Primary generator
37 -----------------
38
39 There are 5 concrete primary generator action classes
40 (PrimaryGeneratorActionN, N=0,1,2,3,4) which can be used as an independent sample
41 code.
42 PrimaryGeneratorAction is the class which uses and switches between these
43 5 concrete action classes. Each concrete generator action shoots geantinoes
44 in a distribution decribed below.
45
46 3.0- uniform particle direction in a given solid angle
47 -------------------------------------------------
48 spherical angles (alpha,psi) respective to z axis
49 Histograms 5,6 show momentum direction in master frame.
50
51 3.1- Generate several vertices and particles per event
52 -------------------------------------------------
53
54 particle 1 : a geantino uniformly randomized on a cylinder surface.
55 particle 2 and 3 : symetric to particle 1.
56 In addition, time_zero of each event is randomized.
57
58 3.2- Show how to sample a tabulated function (energy spectrum)
59 ---------------------------------------------------------
60
61 Energy is sampled from a tabulated function defined in InitFunction().
62 The function is assumed positive, linear per segment, continuous.
63 Two sampling methods are illustrated : RejectAccept() and InverseCumul()
64 (see Particle Data Group: pdg.lbl.gov --> Monte Carlo techniques)
65 Histogram 1 shows generated energy spectrum.
66
67 3.3- Divergent beam in an arbitrary direction with rotation matrix
68 -------------------------------------------------------------
69
70 A geantino uniformly randomized around a given direction (theta, phi).
71 One wants to limit particle direction uniformly around this direction.
72 First, one generates momentum direction in the master frame (eg. World).
73 AlphaMax = opening angle around z axis.
74 Then one rotates momentum in local frame, using rotateUz() function.
75 RotateUz() transforms uz to newUz. It is composition of two simple rotations:
76 theta around oy, then phi around oz (non commutative).
77 http://proj-clhep.web.cern.ch/proj-clhep/manual/UserGuide/VectorDefs/node49.html
78 Histograms 5,6 show momentum direction in local frame.
79
80 3.4- Shooting primaries in spherical coordinates with rotation matrix
81 ----------------------------------------------------------------
82
83 a geantino uniformly randomized within a spherical shell.
84
85 a) Vertex position
86 One wishes to shoot uniformly within a spherical shell.
87 One works in spherical coordinates. One uses inverse cumulative method with
88 analytical formulae.
89 Histograms 2,3,4 demonstrate uniform distribution of vertex position.
90
91 b) Momentum direction
92 One wants to limit particle direction uniformly within (alphaMin, alphaMax).
93 First, one generates momentum direction in the master frame (eg. World).
94 Then, one rotates momentum in vertex_position frame, using rotateUz() function.
95 RotateUz() transforms uz to ur. It is composition of two elementary rotations:
96 theta around oy, then phi around oz (non commutative).
97 http://proj-clhep.web.cern.ch/proj-clhep/manual/UserGuide/VectorDefs/node49.html
98 Histograms 5,6 show momentum direction in vertex_position frame.
99
100 4- Visualisation
101 -------------
102
103 Visualization Manager is set in the main().
104 Initialisation of the drawing is done via the commands
105 /vis/.. in the macro vis.mac. This macro is automatically read from the main
106 in case of interactive running mode.
107
108 5- How to start ?
109 --------------
110
111 - execute particleGun in 'batch' mode from macro files
112 % ParticleGun run1.mac
113
114 - execute particleGun in 'interactive mode' with visualization
115 % particleGun
116 ....
117 Idle> ---> type your commands. For instance:
118 Idle> /gunExample/selectGunAction 1
119 Idle> /run/beamOn 10
120 ....
121 Idle> exit
122
123 - Macros provided in this example:
124 - run0.mac: see above primaryGenerator, case 0
125 - run1.mac: see above primaryGenerator, case 1
126 - run2.mac: see above primaryGenerator, case 2
127 - run3.mac: see above primaryGenerator, case 3
128 - run4.mac: see above primaryGenerator, case 4
129 - particleGun.in: macro used in Geant4 testing (similar to run0.mac)
130
131 6- Histograms
132 ----------
133
134 particleGun produces several 1D histograms which are saved as
135 particleGun.root by default.
136
137 1 : energy spectrum dN/dE = f(E)
138 2 : vertex position: radial distr dN/dv = f(r)
139 3 : vertex position: cos(theta)
140 4 : vertex position: phi
141 5 : particle direction in local frame: cos(alpha)
142 6 : particle direction in local frame: psi
143
144 Please note that histogram 1 will be filled only if you use
145 PrimaryGeneratorAction2, histos 5,6 with PrimaryGeneratorAction0 and 3
146 and 2 through 6 will be filled with PrimaryGeneratorAction4.
147
148 The histograms are managed by the HistoManager class and its Messenger.
149 The histos can be individually activated with the command :
150 /analysis/h1/set id nbBins valMin valMax unit
151 where unit is the desired unit for the histo (MeV or keV, deg or mrad, etc..)
152
153 One can control the name of the histograms file with the command:
154 /analysis/h1/setFileName name (default particleGun)
155
156 It is possible to choose the format of the histogram file : root (default),
157 xml, csv, by using namespace in HistoManager.hh
158
159 It is also possible to print selected histograms on an ascii file:
160 /analysis/h1/setAscii id
161 All selected histos will be written on a file name.ascii (default gunExample)