source: trunk/Documentation/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch02s04.html @ 902

Last change on this file since 902 was 901, checked in by garnier, 16 years ago

Add Geant4 Documentation at 8.12.2008

File size: 15.5 KB
Line 
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">
2function 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. 
9How 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. 
11Getting 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. 
13How to Specify Particles
14</h2></div></div></div><p>
15<code class="literal">G4VuserPhysicsList</code> is one of the mandatory user base
16classes described in
17<a href="ch02.html#sect.HowToDefMain" title="2.1. 
18How to Define the main() Program
19">Section 2.1</a>.
20Within this class all particles and physics processes to be used in
21your simulation must be defined. The range cut-off parameter should
22also be defined in this class.
23</p><p>
24The user must create a class derived from
25<code class="literal">G4VuserPhysicsList</code> and implement the following pure
26virtual methods:
27
28</p><div class="informalexample"><pre class="programlisting">
29ConstructParticle();      // construction of particles
30ConstructProcess();       // construct processes and register them to particles
31SetCuts();                // setting a range cut value for all particles
32</pre></div><p>
33</p><p>
34This section provides some simple examples of the
35<code class="literal">ConstructParticle()</code> and <code class="literal">SetCuts()</code>
36methods.
37For information on <code class="literal">ConstructProcess()</code> methods, please see
38<a href="ch02s05.html" title="2.5. 
39How 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. 
43Particle Definition
44</h3></div></div></div><p>
45Geant4 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>
58Each particle is represented by its own class, which is derived
59from <code class="literal">G4ParticleDefinition</code>.
60(Exception: G4Ions represents all heavy nuclei. Please see
61<a href="ch05s03.html" title="5.3. 
62Particles
63">Section 5.3</a>.)
64Particles 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
80each of which is defined in a corresponding sub-directory under
81<code class="literal">geant4/source/particles</code>. There is also a corresponding
82granular 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. 
84The <code class="literal">G4ParticleDefinition</code> Class
85</h4></div></div></div><p>
86<code class="literal">G4ParticleDefinition</code> has properties which characterize
87individual particles, such as, name, mass, charge, spin, and so on.
88Most of these properties are "read-only" and can not be changed by
89users 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. 
91How to Access a Particle
92</h4></div></div></div><p>
93Each particle class type represents an individual particle type,
94and each class has a single object. This object can be accessed by
95using the static method of each class.
96There are some exceptions to this rule; please see
97<a href="ch05s03.html" title="5.3. 
98Particles
99">Section 5.3</a> for details.
100</p><p>
101For example, the class <code class="literal">G4Electron</code> represents the
102electron and the member <code class="literal">G4Electron::theInstance</code> 
103points its only object.
104The pointer to this object is available
105through the static methods
106<code class="literal">G4Electron::ElectronDefinition()</code>.
107<code class="literal">G4Electron::Definition()</code>.
108</p><p>
109More than 100 types of particles are provided by default, to be
110used in various physics processes. In normal applications, users
111will not need to define their own particles.
112</p><p>
113Because particles are static objects of individual particle
114classes, these objects are instantiated
115when the static method getting the pointer is invoked at the first time
116Therefore, you must explicitly declare the particle classes
117required by your program at the initialization step,
118otherwise 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>
121The <code class="literal">G4ParticleTable</code> class is provided as a dictionary of
122particles. Various utility methods are provided, such as:
123
124</p><div class="informalexample"><pre class="programlisting">
125FindParticle(G4String name);         // find the particle by name
126FindParticle(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,
130and the static method <code class="literal">G4ParticleTable::GetParticleTable()</code>
131provides its pointer.
132</p><p>
133As for heavy ions (including hyper-nuclei), objects are created
134dynamically by requests from users and processes. 
135The <code class="literal">G4ParticleTable</code> class provides
136methods to create ions, such as:
137</p><div class="informalexample"><pre class="programlisting">
138G4ParticleDefinition* GetIon(  G4int    atomicNumber, 
139                               G4int    atomicMass,
140                               G4double   excitationEnergy);
141</pre></div><p>
142</p><p>
143Particles are registered automatically during construction. The
144user 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. 
146Constructing Particles
147</h4></div></div></div><p>
148<code class="literal">ConstructParticle()</code> is a pure virtual method, in which
149the static member functions for all the particles you require should be called.
150This ensures that objects of these particles are created.
151</p><p>
152WARNING: You must define "All PARTICLE TYPES" which are used in your
153application, except for heavy ions.
154"All PARTICLE TYPES" means not only primary
155particles, but also all other particles which may appear as secondaries
156generated by physics processes you use. Beginning with Geant4 version 8.0,
157you should keep this rule strictly because all particle definitions are
158revised to "non-static" objects.
159</p><p>
160For example, suppose you need a proton and a geantino, which is
161a virtual particle used for simulation and which does not interact
162with materials. The <code class="literal">ConstructParticle()</code> method is
163implemented as below:
164
165</p><div class="example"><a name="programlist_HowToSpecParti_1"></a><p class="title"><b>Example 2.12. 
166Construct 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>
175Due to the large number of pre-defined particles in Geant4, it
176is cumbersome to list all the particles by this method. If you want
177all the particles in a Geant4 particle category, there are six
178utility classes, corresponding to each of the particle categories,
179which 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>
195An example of this is shown in <code class="literal">ExN05PhysicsList</code>,
196listed below.
197
198</p><div class="example"><a name="programlist_HowToSpecParti_2"></a><p class="title"><b>Example 2.13. 
199Construct all leptons.
200</b></p><div class="example-contents"><pre class="programlisting">
201void 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. 
209Range Cuts
210</h3></div></div></div><p>
211To avoid infrared divergence, some electromagnetic processes
212require a threshold below which no secondary will be generated.
213Because of this requirement, gammas, electrons and positrons
214require production thresholds which the user should define. This
215threshold should be defined as a distance, or range cut-off, which
216is internally converted to an energy for individual materials. The
217range threshold should be defined in the initialization phase using
218the <code class="literal">SetCuts()</code> method of <code class="literal">G4VUserPhysicsList</code>.
219<a href="ch05s05.html" title="5.5. 
220Cuts per Region
221">Section 5.5</a> discusses threshold and tracking
222cuts 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. 
224Setting the cuts
225</h4></div></div></div><p>
226Production threshold values should be defined in <code class="literal">SetCuts()</code>
227which is a pure virtual method of the <code class="literal">G4VUserPhysicsList</code>
228class. Construction of particles, materials, and processes should
229precede the invocation of <code class="literal">SetCuts()</code>. <code class="literal">G4RunManager</code>
230takes care of this sequence in usual applications.
231</p><p>
232The idea of a "unique cut value in range" is one of the
233important features of Geant4 and is used to handle cut values in a
234coherent manner. For most applications, users need to determine
235only one cut value in range, and apply this value to gammas,
236electrons and positrons alike.
237</p><p>
238In such a case, the <code class="literal">SetCutsWithDefault()</code> method may be
239used. It is provided by the <code class="literal">G4VuserPhysicsList</code> base class,
240which has a <code class="literal">defaultCutValue</code> member as the default range
241cut-off value. <code class="literal">SetCutsWithDefault()</code> uses this value.
242</p><p>
243It is possible to set different range cut values for gammas,
244electrons and positrons, and also to set different range cut values
245for each geometrical region. In such cases however, one must be
246careful with physics outputs because Geant4 processes (especially
247energy loss) are designed to conform to the "unique cut value in
248range" scheme.
249
250</p><div class="example"><a name="programlist_HowToSpecParti_3"></a><p class="title"><b>Example 2.14. 
251Set cut values by using the default cut value.
252</b></p><div class="example-contents"><pre class="programlisting">
253void 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>
261The <code class="literal">defaultCutValue</code> is set to 1.0 mm by default. Of
262course, you can set the new default cut value in the constructor of
263your 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. 
266Set the default cut value.
267</b></p><div class="example-contents"><pre class="programlisting">
268ExN04PhysicsList::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>
275The <code class="literal">SetDefaultCutValue()</code> method in
276<code class="literal">G4VUserPhysicsList</code> may also be used, and the "/run/setCut"
277command may be used to change the default cut value
278interactively.
279</p><p>
280WARNING: DO NOT change cut values inside the event loop. Cut
281values may however be changed between runs.
282</p><p>
283An example implementation of <code class="literal">SetCuts()</code> is shown
284below:
285
286</p><div class="example"><a name="programlist_HowToSpecParti_5"></a><p class="title"><b>Example 2.16. 
287Example implementation of the <code class="literal">SetCuts()</code> method.
288</b></p><div class="example-contents"><pre class="programlisting">
289void 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>
299Beginning with Geant4 version 5.1, it is now possible to set
300production thresholds for each geometrical region. This new
301functionality is described in <a href="ch05s05.html" title="5.5. 
302Cuts 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. 
305How 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. 
307How to Specify Physics Processes
308</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.