1 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>2.4. How to Specify Particles</title><link rel="stylesheet" href="../xml/XSLCustomizationLayer/G4HTMLStylesheet.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.71.1"><link rel="start" href="index.html" title="Geant4 User's Guide for Application Developers"><link rel="up" href="ch02.html" title="Chapter 2. Getting Started with Geant4 - Running a Simple Example"><link rel="prev" href="ch02s03.html" title="2.3. How to Specify Materials in the Detector"><link rel="next" href="ch02s05.html" title="2.5. How to Specify Physics Processes"><script language="JavaScript"> |
---|
2 | function remote_win(fName) |
---|
3 | { |
---|
4 | var url = "AllResources/Detector/geometry.src/" + fName; |
---|
5 | RemoteWin=window.open(url,"","resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,copyhistory=0,width=520,height=520") |
---|
6 | RemoteWin.creator=self |
---|
7 | } |
---|
8 | </script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.4. |
---|
9 | How to Specify Particles |
---|
10 | </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02s03.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><th width="60%" align="center">Chapter 2. |
---|
11 | Getting Started with Geant4 - Running a Simple Example |
---|
12 | </th><td width="20%" align="right"> <a accesskey="n" href="ch02s05.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect.HowToSpecParti"></a>2.4. |
---|
13 | How to Specify Particles |
---|
14 | </h2></div></div></div><p> |
---|
15 | <code class="literal">G4VuserPhysicsList</code> is one of the mandatory user base |
---|
16 | classes described in |
---|
17 | <a href="ch02.html#sect.HowToDefMain" title="2.1. |
---|
18 | How to Define the main() Program |
---|
19 | ">Section 2.1</a>. |
---|
20 | Within this class all particles and physics processes to be used in |
---|
21 | your simulation must be defined. The range cut-off parameter should |
---|
22 | also be defined in this class. |
---|
23 | </p><p> |
---|
24 | The user must create a class derived from |
---|
25 | <code class="literal">G4VuserPhysicsList</code> and implement the following pure |
---|
26 | virtual methods: |
---|
27 | |
---|
28 | </p><div class="informalexample"><pre class="programlisting"> |
---|
29 | ConstructParticle(); // construction of particles |
---|
30 | ConstructProcess(); // construct processes and register them to particles |
---|
31 | SetCuts(); // setting a range cut value for all particles |
---|
32 | </pre></div><p> |
---|
33 | </p><p> |
---|
34 | This section provides some simple examples of the |
---|
35 | <code class="literal">ConstructParticle()</code> and <code class="literal">SetCuts()</code> |
---|
36 | methods. |
---|
37 | For information on <code class="literal">ConstructProcess()</code> methods, please see |
---|
38 | <a href="ch02s05.html" title="2.5. |
---|
39 | How to Specify Physics Processes |
---|
40 | ">Section 2.5</a>. |
---|
41 | |
---|
42 | </p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToSpecParti.PartiDef"></a>2.4.1. |
---|
43 | Particle Definition |
---|
44 | </h3></div></div></div><p> |
---|
45 | Geant4 provides various types of particles for use in simulations: |
---|
46 | |
---|
47 | </p><div class="itemizedlist"><ul type="disc" compact><li><p> |
---|
48 | ordinary particles, such as electrons, protons, and gammas |
---|
49 | </p></li><li><p> |
---|
50 | resonant particles with very short lifetimes, such as vector |
---|
51 | mesons and delta baryons |
---|
52 | </p></li><li><p> |
---|
53 | nuclei, such as deuteron, alpha, and heavy ions (including hyper-nuclei) |
---|
54 | </p></li><li><p> |
---|
55 | quarks, di-quarks, and gluon |
---|
56 | </p></li></ul></div><p> |
---|
57 | </p><p> |
---|
58 | Each particle is represented by its own class, which is derived |
---|
59 | from <code class="literal">G4ParticleDefinition</code>. |
---|
60 | (Exception: G4Ions represents all heavy nuclei. Please see |
---|
61 | <a href="ch05s03.html" title="5.3. |
---|
62 | Particles |
---|
63 | ">Section 5.3</a>.) |
---|
64 | Particles are organized into six major categories: |
---|
65 | |
---|
66 | </p><div class="itemizedlist"><ul type="disc" compact><li><p> |
---|
67 | lepton, |
---|
68 | </p></li><li><p> |
---|
69 | meson, |
---|
70 | </p></li><li><p> |
---|
71 | baryon, |
---|
72 | </p></li><li><p> |
---|
73 | boson, |
---|
74 | </p></li><li><p> |
---|
75 | shortlived and |
---|
76 | </p></li><li><p> |
---|
77 | ion, |
---|
78 | </p></li></ul></div><p> |
---|
79 | |
---|
80 | each of which is defined in a corresponding sub-directory under |
---|
81 | <code class="literal">geant4/source/particles</code>. There is also a corresponding |
---|
82 | granular library for each particle category. |
---|
83 | </p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.HowToSpecParti.PartiDef.G4ParticleDefinition"></a>2.4.1.1. |
---|
84 | The <code class="literal">G4ParticleDefinition</code> Class |
---|
85 | </h4></div></div></div><p> |
---|
86 | <code class="literal">G4ParticleDefinition</code> has properties which characterize |
---|
87 | individual particles, such as, name, mass, charge, spin, and so on. |
---|
88 | Most of these properties are "read-only" and can not be changed by |
---|
89 | users without rebuilding the libraries. |
---|
90 | </p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.HowToSpecParti.PartiDef.HowToAccessParti"></a>2.4.1.2. |
---|
91 | How to Access a Particle |
---|
92 | </h4></div></div></div><p> |
---|
93 | Each particle class type represents an individual particle type, |
---|
94 | and each class has a single object. This object can be accessed by |
---|
95 | using the static method of each class. |
---|
96 | There are some exceptions to this rule; please see |
---|
97 | <a href="ch05s03.html" title="5.3. |
---|
98 | Particles |
---|
99 | ">Section 5.3</a> for details. |
---|
100 | </p><p> |
---|
101 | For example, the class <code class="literal">G4Electron</code> represents the |
---|
102 | electron and the member <code class="literal">G4Electron::theInstance</code> |
---|
103 | points its only object. |
---|
104 | The pointer to this object is available |
---|
105 | through the static methods |
---|
106 | <code class="literal">G4Electron::ElectronDefinition()</code>. |
---|
107 | <code class="literal">G4Electron::Definition()</code>. |
---|
108 | </p><p> |
---|
109 | More than 100 types of particles are provided by default, to be |
---|
110 | used in various physics processes. In normal applications, users |
---|
111 | will not need to define their own particles. |
---|
112 | </p><p> |
---|
113 | Because particles are static objects of individual particle |
---|
114 | classes, these objects are instantiated |
---|
115 | when the static method getting the pointer is invoked at the first time |
---|
116 | Therefore, you must explicitly declare the particle classes |
---|
117 | required by your program at the initialization step, |
---|
118 | otherwise no particles will be instantiated. |
---|
119 | </p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.HowToSpecParti.PartiDef.DictOfParti"></a>2.4.1.3. Dictionary of Particles |
---|
120 | </h4></div></div></div><p> |
---|
121 | The <code class="literal">G4ParticleTable</code> class is provided as a dictionary of |
---|
122 | particles. Various utility methods are provided, such as: |
---|
123 | |
---|
124 | </p><div class="informalexample"><pre class="programlisting"> |
---|
125 | FindParticle(G4String name); // find the particle by name |
---|
126 | FindParticle(G4int PDGencoding) // find the particle by PDG encoding . |
---|
127 | </pre></div><p> |
---|
128 | </p><p> |
---|
129 | <code class="literal">G4ParticleTable</code> is defined as a singleton object, |
---|
130 | and the static method <code class="literal">G4ParticleTable::GetParticleTable()</code> |
---|
131 | provides its pointer. |
---|
132 | </p><p> |
---|
133 | As for heavy ions (including hyper-nuclei), objects are created |
---|
134 | dynamically by requests from users and processes. |
---|
135 | The <code class="literal">G4ParticleTable</code> class provides |
---|
136 | methods to create ions, such as: |
---|
137 | </p><div class="informalexample"><pre class="programlisting"> |
---|
138 | G4ParticleDefinition* GetIon( G4int atomicNumber, |
---|
139 | G4int atomicMass, |
---|
140 | G4double excitationEnergy); |
---|
141 | </pre></div><p> |
---|
142 | </p><p> |
---|
143 | Particles are registered automatically during construction. The |
---|
144 | user has no control over particle registration. |
---|
145 | </p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.HowToSpecParti.PartiDef.ConstruParti"></a>2.4.1.4. |
---|
146 | Constructing Particles |
---|
147 | </h4></div></div></div><p> |
---|
148 | <code class="literal">ConstructParticle()</code> is a pure virtual method, in which |
---|
149 | the static member functions for all the particles you require should be called. |
---|
150 | This ensures that objects of these particles are created. |
---|
151 | </p><p> |
---|
152 | WARNING: You must define "All PARTICLE TYPES" which are used in your |
---|
153 | application, except for heavy ions. |
---|
154 | "All PARTICLE TYPES" means not only primary |
---|
155 | particles, but also all other particles which may appear as secondaries |
---|
156 | generated by physics processes you use. Beginning with Geant4 version 8.0, |
---|
157 | you should keep this rule strictly because all particle definitions are |
---|
158 | revised to "non-static" objects. |
---|
159 | </p><p> |
---|
160 | For example, suppose you need a proton and a geantino, which is |
---|
161 | a virtual particle used for simulation and which does not interact |
---|
162 | with materials. The <code class="literal">ConstructParticle()</code> method is |
---|
163 | implemented as below: |
---|
164 | |
---|
165 | </p><div class="example"><a name="programlist_HowToSpecParti_1"></a><p class="title"><b>Example 2.12. |
---|
166 | Construct a proton and a geantino. |
---|
167 | </b></p><div class="example-contents"><pre class="programlisting"> |
---|
168 | void ExN01PhysicsList::ConstructParticle() |
---|
169 | { |
---|
170 | G4Proton::ProtonDefinition(); |
---|
171 | G4Geantino::GeantinoDefinition(); |
---|
172 | } |
---|
173 | </pre></div></div><p><br class="example-break"> |
---|
174 | </p><p> |
---|
175 | Due to the large number of pre-defined particles in Geant4, it |
---|
176 | is cumbersome to list all the particles by this method. If you want |
---|
177 | all the particles in a Geant4 particle category, there are six |
---|
178 | utility classes, corresponding to each of the particle categories, |
---|
179 | which perform this function: |
---|
180 | |
---|
181 | </p><div class="itemizedlist"><ul type="disc" compact><li><p> |
---|
182 | <code class="literal">G4BosonConstructor</code> |
---|
183 | </p></li><li><p> |
---|
184 | <code class="literal">G4LeptonConstructor</code> |
---|
185 | </p></li><li><p> |
---|
186 | <code class="literal">G4MesonConstructor</code> |
---|
187 | </p></li><li><p> |
---|
188 | <code class="literal">G4BarionConstructor</code> |
---|
189 | </p></li><li><p> |
---|
190 | <code class="literal">G4IonConstructor</code> |
---|
191 | </p></li><li><p> |
---|
192 | <code class="literal">G4ShortlivedConstructor</code>. |
---|
193 | </p></li></ul></div><p> |
---|
194 | </p><p> |
---|
195 | An example of this is shown in <code class="literal">ExN05PhysicsList</code>, |
---|
196 | listed below. |
---|
197 | |
---|
198 | </p><div class="example"><a name="programlist_HowToSpecParti_2"></a><p class="title"><b>Example 2.13. |
---|
199 | Construct all leptons. |
---|
200 | </b></p><div class="example-contents"><pre class="programlisting"> |
---|
201 | void ExN05PhysicsList::ConstructLeptons() |
---|
202 | { |
---|
203 | // Construct all leptons |
---|
204 | G4LeptonConstructor pConstructor; |
---|
205 | pConstructor.ConstructParticle(); |
---|
206 | } |
---|
207 | </pre></div></div><p><br class="example-break"> |
---|
208 | </p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToSpecParti.RangeCuts"></a>2.4.2. |
---|
209 | Range Cuts |
---|
210 | </h3></div></div></div><p> |
---|
211 | To avoid infrared divergence, some electromagnetic processes |
---|
212 | require a threshold below which no secondary will be generated. |
---|
213 | Because of this requirement, gammas, electrons and positrons |
---|
214 | require production thresholds which the user should define. This |
---|
215 | threshold should be defined as a distance, or range cut-off, which |
---|
216 | is internally converted to an energy for individual materials. The |
---|
217 | range threshold should be defined in the initialization phase using |
---|
218 | the <code class="literal">SetCuts()</code> method of <code class="literal">G4VUserPhysicsList</code>. |
---|
219 | <a href="ch05s05.html" title="5.5. |
---|
220 | Cuts per Region |
---|
221 | ">Section 5.5</a> discusses threshold and tracking |
---|
222 | cuts in detail. |
---|
223 | </p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sect.HowToSpecParti.RangeCuts.SetCuts"></a>2.4.2.1. |
---|
224 | Setting the cuts |
---|
225 | </h4></div></div></div><p> |
---|
226 | Production threshold values should be defined in <code class="literal">SetCuts()</code> |
---|
227 | which is a pure virtual method of the <code class="literal">G4VUserPhysicsList</code> |
---|
228 | class. Construction of particles, materials, and processes should |
---|
229 | precede the invocation of <code class="literal">SetCuts()</code>. <code class="literal">G4RunManager</code> |
---|
230 | takes care of this sequence in usual applications. |
---|
231 | </p><p> |
---|
232 | The idea of a "unique cut value in range" is one of the |
---|
233 | important features of Geant4 and is used to handle cut values in a |
---|
234 | coherent manner. For most applications, users need to determine |
---|
235 | only one cut value in range, and apply this value to gammas, |
---|
236 | electrons and positrons alike. |
---|
237 | </p><p> |
---|
238 | In such a case, the <code class="literal">SetCutsWithDefault()</code> method may be |
---|
239 | used. It is provided by the <code class="literal">G4VuserPhysicsList</code> base class, |
---|
240 | which has a <code class="literal">defaultCutValue</code> member as the default range |
---|
241 | cut-off value. <code class="literal">SetCutsWithDefault()</code> uses this value. |
---|
242 | </p><p> |
---|
243 | It is possible to set different range cut values for gammas, |
---|
244 | electrons and positrons, and also to set different range cut values |
---|
245 | for each geometrical region. In such cases however, one must be |
---|
246 | careful with physics outputs because Geant4 processes (especially |
---|
247 | energy loss) are designed to conform to the "unique cut value in |
---|
248 | range" scheme. |
---|
249 | |
---|
250 | </p><div class="example"><a name="programlist_HowToSpecParti_3"></a><p class="title"><b>Example 2.14. |
---|
251 | Set cut values by using the default cut value. |
---|
252 | </b></p><div class="example-contents"><pre class="programlisting"> |
---|
253 | void ExN04PhysicsList::SetCuts() |
---|
254 | { |
---|
255 | // the G4VUserPhysicsList::SetCutsWithDefault() method sets |
---|
256 | // the default cut value for all particle types |
---|
257 | SetCutsWithDefault(); |
---|
258 | } |
---|
259 | </pre></div></div><p><br class="example-break"> |
---|
260 | </p><p> |
---|
261 | The <code class="literal">defaultCutValue</code> is set to 1.0 mm by default. Of |
---|
262 | course, you can set the new default cut value in the constructor of |
---|
263 | your physics list class as shown below. |
---|
264 | |
---|
265 | </p><div class="example"><a name="programlist_HowToSpecParti_4"></a><p class="title"><b>Example 2.15. |
---|
266 | Set the default cut value. |
---|
267 | </b></p><div class="example-contents"><pre class="programlisting"> |
---|
268 | ExN04PhysicsList::ExN04PhysicsList(): G4VUserPhysicsList() |
---|
269 | { |
---|
270 | // default cut value (1.0mm) |
---|
271 | defaultCutValue = 1.0*mm; |
---|
272 | } |
---|
273 | </pre></div></div><p><br class="example-break"> |
---|
274 | </p><p> |
---|
275 | The <code class="literal">SetDefaultCutValue()</code> method in |
---|
276 | <code class="literal">G4VUserPhysicsList</code> may also be used, and the "/run/setCut" |
---|
277 | command may be used to change the default cut value |
---|
278 | interactively. |
---|
279 | </p><p> |
---|
280 | WARNING: DO NOT change cut values inside the event loop. Cut |
---|
281 | values may however be changed between runs. |
---|
282 | </p><p> |
---|
283 | An example implementation of <code class="literal">SetCuts()</code> is shown |
---|
284 | below: |
---|
285 | |
---|
286 | </p><div class="example"><a name="programlist_HowToSpecParti_5"></a><p class="title"><b>Example 2.16. |
---|
287 | Example implementation of the <code class="literal">SetCuts()</code> method. |
---|
288 | </b></p><div class="example-contents"><pre class="programlisting"> |
---|
289 | void ExN03PhysicsList::SetCuts() |
---|
290 | { |
---|
291 | // set cut values for gamma at first and for e- second and next for e+, |
---|
292 | // because some processes for e+/e- need cut values for gamma |
---|
293 | SetCutValue(cutForGamma, "gamma"); |
---|
294 | SetCutValue(cutForElectron, "e-"); |
---|
295 | SetCutValue(cutForElectron, "e+"); |
---|
296 | } |
---|
297 | </pre></div></div><p><br class="example-break"> |
---|
298 | </p><p> |
---|
299 | Beginning with Geant4 version 5.1, it is now possible to set |
---|
300 | production thresholds for each geometrical region. This new |
---|
301 | functionality is described in <a href="ch05s05.html" title="5.5. |
---|
302 | Cuts per Region |
---|
303 | ">Section 5.5</a>. |
---|
304 | </p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02s03.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><td width="20%" align="center"><a accesskey="u" href="ch02.html"><img src="AllResources/IconsGIF/up.gif" alt="Up"></a></td><td width="40%" align="right"> <a accesskey="n" href="ch02s05.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">2.3. |
---|
305 | How to Specify Materials in the Detector |
---|
306 | </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="AllResources/IconsGIF/home.gif" alt="Home"></a></td><td width="40%" align="right" valign="top"> 2.5. |
---|
307 | How to Specify Physics Processes |
---|
308 | </td></tr></table></div></body></html> |
---|