source: trunk/documents/UserDoc/UsersGuides/ForApplicationDeveloper/html/GettingStarted/particleDef.html @ 1358

Last change on this file since 1358 was 1208, checked in by garnier, 15 years ago

CVS update

File size: 10.7 KB
Line 
1<HTML>
2<TITLE>
3</TITLE>
4<!-- Changed by: Katsuya Amako,  4-Aug-1998 -->
5<!-- Proof read by: Joe Chuma,  15-Jun-1999 -->
6<!-- Changed by: Hisaya Kurashige, 28-Oct-2001 -->
7<!-- Changed by: Dennis Wright, 29-Nov-2001 -->
8<!-- Changed by: Hisaya Kurashige, 18-Jan-2007 -->
9
10
11<BODY>
12<TABLE WIDTH="100%"><TR>
13<TD>
14
15
16<A HREF="index.html">
17<IMG SRC="../../../../resources/html/IconsGIF/Contents.gif" ALT="Contents"></A>
18<A HREF="materialDef.html">
19<IMG SRC="../../../../resources/html/IconsGIF/Previous.gif" ALT="Previous"></A>
20<A HREF="physicsDef.html">
21<IMG SRC="../../../../resources/html/IconsGIF/Next.gif" ALT="Next"></A>
22</TD>
23<TD ALIGN="Right">
24<FONT SIZE="-1" COLOR="#238E23">
25<B>Geant4 User's Guide</B>
26<BR>
27<B>For Application Developers</B>
28<BR>
29<B>Getting Started with Geant4</B>
30</FONT>
31</TD>
32</TR></TABLE>
33<BR>
34
35<P ALIGN="Center">
36<FONT SIZE="+3" COLOR="#238E23">
37<B>2.4 How to Specify Particles</B>
38</FONT>
39<P><BR>
40
41<HR ALIGN="Center" SIZE="7%">
42 <tt>G4VuserPhysicsList</tt> is one of the mandatory user base classes
43described in <a href="mainProgram.html">Section 2.1</a> .  Within this class
44all particles and physics processes to be used in your simulation must be
45defined.  The range cut-off parameter should also be defined in this class.
46<P>
47 The user must create a class derived from <tt>G4VuserPhysicsList</tt> and
48implement the following pure virtual methods:
49<table>
50<tr>
51<td><TT>ConstructParticle()</TT>:
52<td>construction of particles
53<tr>
54<td><TT>ConstructProcess()</TT>:
55<td>construct processes and register them to particles
56<tr>
57<td><TT>SetCuts()</TT>:
58<td>setting a range cut value for all particles
59</table>
60<p>
61 This section provides some simple examples of the
62<tt>ConstructParticle()</tt> and <tt>SetCuts()</tt> methods.
63For infomation on <tt>ConstructProcess()</tt> methods, please see
64 <a href="physicsDef.html">Section 2.5</a>.
65<P> 
66<HR>
67<a name="2.4.1">
68<H2>2.4.1 Particle Definition</H2></a>
69
70 Geant4 provides various types of particles for use in simulations:
71<UL>
72 <LI>ordinary particles, such as electrons, protons, and gammas
73 <LI>resonant particles with very short lifetimes,
74     such as vector mesons and delta baryons
75 <LI>nuclei, such as deuterons, alphas, and heavy ions
76 <LI>quarks, di-quarks, and gluons
77</UL>
78<p>
79Each particle is represented by its own class, which is derived from
80<tt>G4ParticleDefinition</tt>.  Particles are organized into six major
81categories:
82<ul>
83 <li>lepton,
84 <li>meson,
85 <li>baryon,
86 <li>boson,
87 <li>shortlived and
88 <li>ion,
89</ul>
90each of which is defined in a corresponding sub-directory under
91 <TT>geant4/source/particles</TT>. There is also a corresponding granular
92 library for each particle category.
93</p>
94
95<H4>2.4.1.1 The <tt>G4ParticleDefinition</tt> Class </H4>
96
97 <tt>G4ParticleDefinition</tt> has properties which characterize individual
98particles, such as, name, mass, charge, spin, and so on.  Most of these
99properties are "read-only" and can not be changed by users without rebuilding
100the libraries.
101
102<H4>2.4.1.2 How to Access a Particle</H4>
103<P>
104Each particle class type represents an individual particle type, and each
105class has a single static object.  There are some exceptions to this rule;
106please see <a href="../TrackingAndPhysics/particle.html">Section 5.3</a> for
107details.
108<P>
109For example, the class <tt>G4Electron</tt> represents the electron and its
110only object is <TT>G4Electron::theElectron</TT>. The object is therefore
111referred to as a "singleton" of the <i>G4Electron</i> class.  The pointer to
112this object is available through the static method
113 <TT>G4Electron::ElectronDefinition()</TT>.
114<P>
115 More than 100 types of particles are provided by default, to be used in
116 various physics processes. In normal applications, users will not need to
117 define their own particles.
118<p>
119Because particles are static objects of individual particle classes, these
120objects are instantiated automatically before the <tt>main()</tt> routine is
121executed.  However, you must explicitly declare the particle classes required
122by your program, otherwise the compiler can not recognize which classes you
123need, and no particles will be instantiated.
124<P>
125
126<H4>2.4.1.3 Dictionary of Particles</H4>
127 The <tt>G4ParticleTable</tt> class is provided as a dictionary of particles.
128 Various utility methods are provided, such as:
129<center><table>
130<tr>
131<td><tt>FindParticle(G4String name)</tt>:
132<td>find the particle by name
133<tr>
134<td><tt>FindParticle(G4int PDGencoding)</tt>:
135<td>find the particle by PDG encoding .
136</table></center>
137<p>
138<tt>G4ParticleTable</tt> is also defined as a singleton object, and the
139static method <TT>G4ParticleTable::GetParticleTable()</TT> provides its
140pointer.
141<P>
142 Particles are registered automatically during construction. The user has no
143control over particle registration.
144<p>
145
146<H4>2.4.1.4 Constructing Particles</H4>
147<P>
148<TT>ConstructParticle()</TT> is a pure virtual method, in which the static
149member functions for all the particles you require should be called.  This
150ensures that objects of these particles will be created. 
151
152<p>
153WARNING: You must define "All PARTICLE TYPES" which are used in your application, except for heavy ions.
154"All PARTICLE TYPES" means not only primary particles, but also all other particles which may
155appear as secondaries generated by physics processes you use.
156 Beginning with Geant4 version 8.0, you should keep this rule strictly because all particle definitions are revised to "non-static" objects.
157<p>
158
159 For example, suppose you need a proton and a geantino, which is a virtual
160 particle used for simulation and which does not interact with materials.
161 The <TT>ConstructParticle()</TT> method is implemented as below:
162
163<center>
164<table border=2 cellpadding=10>
165<tr>
166<td>
167<PRE>
168 void ExN01PhysicsList::ConstructParticle()
169 {
170   G4Proton::ProtonDefinition();
171   G4Geantino::GeantinoDefinition();
172 }
173</PRE>
174</td>
175</tr>
176<tr>
177<td align=center>
178 Source listing 2.4.1<BR>
179 Construct a proton and a geantino.
180</td>
181</tr>
182</table></center>
183<P>
184Due to the large number of pre-defined particles in Geant4, it is
185cumbersome to list all the particles by this method.  If you want all the
186particles in a Geant4 particle category, there are six utility classes, 
187corresponding to each of the particle categories, which perform this function:
188<UL>
189 <LI><tt>G4BosonConstructor</tt>
190 <LI><tt>G4LeptonConstructor</tt>
191 <LI><tt>G4MesonConstructor</tt>
192 <LI><tt>G4BarionConstructor</tt> 
193 <LI><tt>G4IonConstructor</tt> 
194 <LI><tt>G4ShortlivedConstructor</tt> .
195</UL>
196<P>
197 An example of this is shown in <tt>ExN05PhysicsList</tt>, listed below.
198<P>
199<center>
200<table border=2 cellpadding=10>
201<tr>
202<td>
203<PRE>
204void ExN05PhysicsList::ConstructLeptons()
205{
206  // Construct all leptons
207  G4LeptonConstructor pConstructor;
208  pConstructor.ConstructParticle();
209}
210</PRE>
211</td>
212</tr>
213<tr>
214<td align=center>
215 Source listing 2.4.2<BR>
216 Construct all leptons.
217</td>
218</tr>
219</table></center>
220<P>
221
222<HR>
223<a name="2.4.2">
224<H2>2.4.2 Range Cuts</H2></a>
225
226To avoid infrared divergence, some electromagnetic processes require a
227threshold below which no secondary will be generated.  Because of this
228requirement, gammas, electrons and positrons require production thresholds
229which the user should define.  This threshold should be defined as a distance,
230or range cut-off, which is internally converted to an energy for individual
231materials.  The range threshold should be defined in the initialization phase
232using the <tt>SetCuts()</tt> method of <tt>G4VUserPhysicsList</tt>.
233<a href="../TrackingAndPhysics/thresholdVScut.html">Section 5.4</a> discusses
234threshold and tracking cuts in detail.
235</P>
236
237<H4>2.4.2.1 Setting the cuts</H4>
238
239Production threshold values should be defined in <TT>SetCuts()</TT> which is a
240pure virtual method of the <tt>G4VUserPhysicsList</tt> class. 
241Construction of particles, materials, and processes should precede the
242invocation of <TT>SetCuts()</TT><tt>G4RunManager</tt> takes care of this
243sequence in usual applications.
244
245<P>
246The idea of a "unique cut value in range" is one of the important features of
247Geant4 and is used to handle cut values in a coherent manner.
248For most applications, users need to determine only one cut value in range,
249and apply this value to gammas, electrons and positrons alike.
250<P>
251In such a case, the <TT>SetCutsWithDefault()</TT> method may be used.  It
252is provided by the <tt>G4VuserPhysicsList</tt> base class, which has a
253<tt>defaultCutValue</tt> member as the default range cut-off value.
254<TT>SetCutsWithDefault()</TT> uses this value.
255<P>
256It is possible to set different range cut values for gammas, electrons and
257positrons, and also to set different range cut values for each geometrical
258region.  In such cases however, one must be careful with physics outputs
259because Geant4 processes (especially energy loss) are designed to conform
260to the "unique cut value in range" scheme.
261<P>
262<center>
263<table border=2 cellpadding=10>
264<tr>
265<td>
266<PRE>
267void ExN04PhysicsList::SetCuts()
268{
269  //   the G4VUserPhysicsList::SetCutsWithDefault() method sets
270  //   the default cut value for all particle types
271  SetCutsWithDefault();   
272}
273</PRE>
274</td>
275</tr>
276<tr>
277<td align=center>
278 Source listing 2.4.3<BR>
279 Set cut values by using the default cut value.
280</td>
281</tr>
282</table></center>
283<P>
284 The <tt>defaultCutValue</tt> is set to 1.0 mm by default.  Of
285 course, you can set the new default cut value in the constructor
286 of your physics list class as shown below.
287<P>
288<center>
289<table border=2 cellpadding=10>
290<tr>
291<td>
292<PRE>
293ExN04PhysicsList::ExN04PhysicsList():  G4VUserPhysicsList()
294{
295  // default cut value  (1.0mm)
296  defaultCutValue = 1.0*mm;
297}
298</PRE>
299</td>
300</tr>
301<tr>
302<td align=center>
303 Source listing 2.4.4<BR>
304 Set the default cut value.
305</td>
306</tr>
307</table></center>
308<P>
309The <TT>SetDefaultCutValue() </TT> method in <tt>G4VUserPhysicsList</tt> may
310also be used, and the "/run/setCut" command may be used to change
311the default cut value interactively.
312<P>
313WARNING: DO NOT change cut values inside the event loop. Cut values may
314however be changed between runs.
315<P>
316 An example implementation of <TT>SetCuts()</TT> is shown below:
317<p>
318<center>
319<table border=2 cellpadding=10>
320<tr>
321<td>
322<PRE>
323void ExN03PhysicsList::SetCuts()
324{
325  // set cut values for gamma at first and for e- second and next for e+,
326  // because some processes for e+/e- need cut values for gamma
327  SetCutValue(cutForGamma, "gamma");
328  SetCutValue(cutForElectron, "e-");
329  SetCutValue(cutForElectron, "e+");
330}
331</PRE>
332</td>
333</tr>
334<tr>
335<td align=center>
336 Source listing 2.4.5<BR>
337 Example implementation of the <tt>SetCuts()</tt> method.
338</td>
339</tr>
340</table></center>
341<P>
342 Beginning with Geant4 version 5.1, it is now possible to set production
343 thresholds for each geometrical region.  This new functionality is described
344 in <a href="../TrackingAndPhysics/cutsPerRegion.html">Section 5.5</a>.
345<P> 
346
347<HR>
348<A HREF="../../../../Authors/html/subjectsToAuthors.html">
349<I>About the authors</I></A>
350
351</BODY>
352</HTML>
353
Note: See TracBrowser for help on using the repository browser.