1 | <!-- ******************************************************** --> |
---|
2 | <!-- --> |
---|
3 | <!-- [History] --> |
---|
4 | <!-- Changed by: Katsuya Amako, 21-Sep-1998 --> |
---|
5 | <!-- Changed by: Katsuya Amako, 9-Jul-1998 --> |
---|
6 | <!-- Proof read by: Joe Chuma, 2-Jul-1999 --> |
---|
7 | <!-- Changed by: Katsuya Amako, 15-Jul-2000 --> |
---|
8 | <!-- Changed by: Dennis Wright, 29-Nov-2001 --> |
---|
9 | <!-- Converted to DocBook: Katsuya Amako, Aug-2006 --> |
---|
10 | <!-- --> |
---|
11 | <!-- ******************************************************** --> |
---|
12 | |
---|
13 | |
---|
14 | <!-- ******************* Section (Level#1) ****************** --> |
---|
15 | <sect1 id="sect.GlobClass"> |
---|
16 | <title> |
---|
17 | Global Usage Classes |
---|
18 | </title> |
---|
19 | |
---|
20 | <para> |
---|
21 | The "global" category in Geant4 collects all classes, types, |
---|
22 | structures and constants which are considered of general use within |
---|
23 | the Geant4 toolkit. This category also defines the interface with |
---|
24 | third-party software libraries (CLHEP, STL, etc.) and |
---|
25 | system-related types, by defining, where appropriate, |
---|
26 | <literal>typedef</literal>s according to the Geant4 code conventions. |
---|
27 | </para> |
---|
28 | |
---|
29 | <!-- ******************* Section (Level#2) ****************** --> |
---|
30 | <sect2 id="sect.GlobClass.SignClass"> |
---|
31 | <title> |
---|
32 | Signature of Geant4 classes |
---|
33 | </title> |
---|
34 | |
---|
35 | <para> |
---|
36 | In order to keep an homogeneous naming style, and according to |
---|
37 | the Geant4 coding style conventions, each class part of the Geant4 |
---|
38 | kernel has its name beginning with the prefix <emphasis>G4</emphasis>, e.g., |
---|
39 | <emphasis>G4VHit, G4GeometryManager, G4ProcessVector,</emphasis> etc. Instead of |
---|
40 | the raw C types, <emphasis>G4</emphasis> types are used within the Geant4 code. |
---|
41 | For the basic numeric types (<literal>int, float, double,</literal> etc.), |
---|
42 | different compilers and different platforms provide different value |
---|
43 | ranges. In order to assure portability, the use of <emphasis>G4int, |
---|
44 | G4float, G4double,</emphasis> which are base classes globally defined, is |
---|
45 | preferable. <emphasis>G4</emphasis> types implement the right generic type for a |
---|
46 | given architecture. |
---|
47 | </para> |
---|
48 | |
---|
49 | <!-- ******************* Section (Level#3) ****************** --> |
---|
50 | <sect3 id="sect.GlobClass.SignClass.BasicType"> |
---|
51 | <title> |
---|
52 | Basic types |
---|
53 | </title> |
---|
54 | |
---|
55 | <para> |
---|
56 | The basic types in Geant4 are considered to be the |
---|
57 | following: |
---|
58 | |
---|
59 | <itemizedlist spacing="compact"> |
---|
60 | <listitem><para> |
---|
61 | <emphasis>G4int</emphasis>, |
---|
62 | </para></listitem> |
---|
63 | <listitem><para> |
---|
64 | <emphasis>G4long</emphasis>, |
---|
65 | </para></listitem> |
---|
66 | <listitem><para> |
---|
67 | <emphasis>G4float</emphasis>, |
---|
68 | </para></listitem> |
---|
69 | <listitem><para> |
---|
70 | <emphasis>G4double</emphasis>, |
---|
71 | </para></listitem> |
---|
72 | <listitem><para> |
---|
73 | <emphasis>G4bool</emphasis>, |
---|
74 | </para></listitem> |
---|
75 | <listitem><para> |
---|
76 | <emphasis>G4complex</emphasis>, |
---|
77 | </para></listitem> |
---|
78 | <listitem><para> |
---|
79 | <emphasis>G4String</emphasis>. |
---|
80 | </para></listitem> |
---|
81 | </itemizedlist> |
---|
82 | |
---|
83 | which currently consist of simple <literal>typedef</literal>s to |
---|
84 | respective types defined in the <emphasis role="bold">CLHEP</emphasis>, |
---|
85 | <emphasis role="bold">STL</emphasis> or system |
---|
86 | libraries. Most definitions of these basic types come with the |
---|
87 | inclusion of a single header file, <literal>globals.hh</literal>. This file |
---|
88 | also provides inclusion of required system headers, as well as some |
---|
89 | global utility functions needed and used within the Geant4 |
---|
90 | kernel. |
---|
91 | </para> |
---|
92 | |
---|
93 | </sect3> |
---|
94 | |
---|
95 | <!-- ******************* Section (Level#3) ****************** --> |
---|
96 | <sect3 id="sect.GlobClass.SignClass.Typedefs"> |
---|
97 | <title> |
---|
98 | Typedefs to CLHEP classes and their usage |
---|
99 | </title> |
---|
100 | |
---|
101 | <para> |
---|
102 | The following classes are <literal>typedef</literal>s to the corresponding |
---|
103 | classes of the <emphasis role="bold">CLHEP</emphasis> |
---|
104 | (<emphasis role="bold">Computing Library for High Energy Physics</emphasis>) |
---|
105 | distribution. For more detailed documentation please refer to the |
---|
106 | <ulink url="http://cern.ch/clhep/manual/RefGuide/"> |
---|
107 | <emphasis role="bold">CLHEP reference guide</emphasis> |
---|
108 | </ulink> |
---|
109 | and the |
---|
110 | <ulink url="http://cern.ch/clhep/manual/UserGuide/"> |
---|
111 | <emphasis role="bold">CLHEP user manual</emphasis> |
---|
112 | </ulink> |
---|
113 | . |
---|
114 | |
---|
115 | <itemizedlist spacing="compact"> |
---|
116 | <listitem><para> |
---|
117 | <emphasis>G4ThreeVector, G4RotationMatrix, G4LorentzVector</emphasis> and |
---|
118 | <emphasis>G4LorentzRotation</emphasis> |
---|
119 | <para> |
---|
120 | Vector classes: defining 3-component (x,y,z) vector entities, |
---|
121 | rotation of such objects as 3x3 matrices, |
---|
122 | 4-component (x,y,z,t) vector entities and their rotation as 4x4 matrices. |
---|
123 | </para> |
---|
124 | </para></listitem> |
---|
125 | <listitem><para> |
---|
126 | <emphasis>G4Plane3D, G4Transform3D, G4Normal3D, G4Point3D</emphasis>, and |
---|
127 | <emphasis>G4Vector3D</emphasis> |
---|
128 | <para> |
---|
129 | Geometrical classes: defining geometrical entities and |
---|
130 | transformations in 3D space. |
---|
131 | </para> |
---|
132 | </para></listitem> |
---|
133 | </itemizedlist> |
---|
134 | </para> |
---|
135 | |
---|
136 | </sect3> |
---|
137 | </sect2> |
---|
138 | |
---|
139 | |
---|
140 | <!-- ******************* Section (Level#2) ****************** --> |
---|
141 | <sect2 id="sect.GlobClass.HEPRandom"> |
---|
142 | <title> |
---|
143 | The <emphasis>HEPRandom</emphasis> module in CLHEP |
---|
144 | </title> |
---|
145 | |
---|
146 | <para> |
---|
147 | The <emphasis>HEPRandom</emphasis> module, originally part of the Geant4 |
---|
148 | kernel, and now distributed as a module of <emphasis |
---|
149 | role="bold">CLHEP</emphasis>, |
---|
150 | has been designed and developed starting from the <emphasis>Random</emphasis> |
---|
151 | class of MC++, the original <emphasis role="bold">CLHEP</emphasis>'s |
---|
152 | <emphasis>HepRandom</emphasis> module and the |
---|
153 | <emphasis role="bold">Rogue Wave</emphasis> approach in the |
---|
154 | <emphasis role="bold">Math.h++</emphasis> package. For |
---|
155 | detailed documentation on the <emphasis>HEPRandom</emphasis> classes see the |
---|
156 | |
---|
157 | <ulink url="http://cern.ch/clhep/manual/RefGuide/"> |
---|
158 | <emphasis role="bold">CLHEP reference guide</emphasis> |
---|
159 | </ulink> |
---|
160 | and the |
---|
161 | <ulink url="http://cern.ch/clhep/manual/UserGuide/"> |
---|
162 | <emphasis role="bold">CLHEP user manual</emphasis> |
---|
163 | </ulink> |
---|
164 | . |
---|
165 | </para> |
---|
166 | |
---|
167 | <para> |
---|
168 | Information written in this manual is extracted from the |
---|
169 | original |
---|
170 | <ulink url="http://cern.ch/clhep/manual/UserGuide/Random/Random.html"> |
---|
171 | manifesto |
---|
172 | </ulink> |
---|
173 | distributed with the <emphasis>HEPRandom</emphasis> |
---|
174 | package.</para> |
---|
175 | |
---|
176 | <para> |
---|
177 | The <emphasis>HEPRandom</emphasis> module consists of classes implementing |
---|
178 | different random ``engines'' and different random |
---|
179 | ``distributions''. A distribution associated to an engine |
---|
180 | constitutes a random ``generator''. A distribution class can |
---|
181 | collect different algorithms and different calling sequences for |
---|
182 | each method to define distribution parameters or range-intervals. |
---|
183 | An engine implements the basic algorithm for pseudo-random numbers |
---|
184 | generation. |
---|
185 | </para> |
---|
186 | |
---|
187 | <para> |
---|
188 | There are 3 different ways of shooting random values: |
---|
189 | |
---|
190 | <orderedlist spacing="compact"> |
---|
191 | <listitem><para> |
---|
192 | Using the static generator defined in the <emphasis>HepRandom</emphasis> |
---|
193 | class: random values are shot using static methods <literal>shoot()</literal> |
---|
194 | defined for each distribution class. The static generator will use, |
---|
195 | as default engine, a <emphasis>HepJamesRandom</emphasis> object, and the user can |
---|
196 | set its properties or change it with a new instantiated engine |
---|
197 | object by using the static methods defined in the <emphasis>HepRandom</emphasis> |
---|
198 | class. |
---|
199 | </para></listitem> |
---|
200 | <listitem><para> |
---|
201 | Skipping the static generator and specifying an engine object: |
---|
202 | random values are shot using static methods |
---|
203 | <literal>shoot(*HepRandomEngine)</literal> defined for each distribution |
---|
204 | class. The user must instantiate an engine object and give it as |
---|
205 | argument to the shoot method. The generator mechanism will then be |
---|
206 | by-passed by using the basic <literal>flat()</literal> method of the |
---|
207 | specified engine. The user must take care of the engine objects |
---|
208 | he/she instantiates. |
---|
209 | </para></listitem> |
---|
210 | <listitem><para> |
---|
211 | Skipping the static generator and instantiating a distribution |
---|
212 | object: random values are shot using <literal>fire()</literal> methods (NOT |
---|
213 | static) defined for each distribution class. The user must |
---|
214 | instantiate a distribution object giving as argument to the |
---|
215 | constructor an engine by pointer or by reference. By doing so, the |
---|
216 | engine will be associated to the distribution object and the |
---|
217 | generator mechanism will be by-passed by using the basic |
---|
218 | <literal>flat()</literal> method of that engine. |
---|
219 | </para></listitem> |
---|
220 | </orderedlist> |
---|
221 | </para> |
---|
222 | |
---|
223 | <para> |
---|
224 | In this guide, we'll only focus on the static generator (point |
---|
225 | 1.), since the static interface of <emphasis>HEPRandom</emphasis> is the only one |
---|
226 | used within the Geant4 toolkit. |
---|
227 | </para> |
---|
228 | |
---|
229 | <!-- ******************* Section (Level#3) ****************** --> |
---|
230 | <sect3 id="sect.GlobClass.HEPRandom.Engines"> |
---|
231 | <title> |
---|
232 | <emphasis>HEPRandom</emphasis> engines |
---|
233 | </title> |
---|
234 | |
---|
235 | <para> |
---|
236 | The class <emphasis>HepRandomEngine</emphasis> is the abstract class defining |
---|
237 | the interface for each random engine. It implements the |
---|
238 | <literal>getSeed()</literal> and <literal>getSeeds()</literal> methods which return the |
---|
239 | `initial seed' value and the initial array of seeds (if any) |
---|
240 | respectively. Many concrete random engines can be defined and added |
---|
241 | to the structure, simply making them inheriting from |
---|
242 | <emphasis>HepRandomEngine</emphasis>. Several different engines are currently |
---|
243 | implemented in <emphasis>HepRandom</emphasis>, we describe here five of them: |
---|
244 | |
---|
245 | <itemizedlist spacing="compact"> |
---|
246 | <listitem><para> |
---|
247 | <emphasis>HepJamesRandom</emphasis> |
---|
248 | <para> |
---|
249 | It implements the algorithm described in ``F.James, Comp. Phys. |
---|
250 | Comm. 60 (1990) 329'' for pseudo-random number generation. This is |
---|
251 | the default random engine for the static generator; it will be |
---|
252 | invoked by each distribution class unless the user sets a different one. |
---|
253 | </para> |
---|
254 | </para></listitem> |
---|
255 | <listitem><para> |
---|
256 | <emphasis>DRand48Engine</emphasis> |
---|
257 | <para> |
---|
258 | Random engine using the <literal>drand48()</literal> and |
---|
259 | <literal>srand48()</literal> system functions from C standard library to |
---|
260 | implement the <literal>flat()</literal> basic distribution and for setting |
---|
261 | seeds respectively. <emphasis>DRand48Engine</emphasis> uses the |
---|
262 | <literal>seed48()</literal> |
---|
263 | function from C standard library to retrieve the current internal |
---|
264 | status of the generator, which is represented by 3 short values. |
---|
265 | <emphasis>DRand48Engine</emphasis> is the only engine defined in |
---|
266 | <emphasis>HEPRandom</emphasis> |
---|
267 | which intrinsically works in 32 bits precision. Copies of an object |
---|
268 | of this kind are not allowed. |
---|
269 | </para> |
---|
270 | </para></listitem> |
---|
271 | <listitem><para> |
---|
272 | <emphasis>RandEngine</emphasis> |
---|
273 | <para> |
---|
274 | Simple random engine using the <literal>rand()</literal> and |
---|
275 | <literal>srand()</literal> system functions from the C standard library to |
---|
276 | implement the <literal>flat()</literal> basic distribution and for setting |
---|
277 | seeds respectively. Please note that it's well known that the |
---|
278 | spectral properties of <literal>rand()</literal> leave a great deal to be |
---|
279 | desired, therefore the usage of this engine is not recommended if a |
---|
280 | good randomness quality or a long period is required in your code. |
---|
281 | Copies of an object of this kind are not allowed. |
---|
282 | </para> |
---|
283 | </para></listitem> |
---|
284 | <listitem><para> |
---|
285 | <emphasis>RanluxEngine</emphasis> |
---|
286 | <para> |
---|
287 | The algorithm for <emphasis>RanluxEngine</emphasis> has been taken from the |
---|
288 | original implementation in FORTRAN77 by Fred James, part of the |
---|
289 | <emphasis role="bold">MATHLIB HEP</emphasis> library. The initialisation is |
---|
290 | carried out using |
---|
291 | a Multiplicative Congruential generator using formula constants of |
---|
292 | L'Ecuyer as described in ``F.James, Comp. Phys. Comm. 60 (1990) |
---|
293 | 329-344''. The engine provides five different luxury levels for |
---|
294 | quality of random generation. When instantiating a |
---|
295 | <emphasis>RanluxEngine</emphasis>, the user can specify the luxury level to the |
---|
296 | constructor (if not, the default value 3 is taken). For example: |
---|
297 | |
---|
298 | <informalexample> |
---|
299 | <programlisting> |
---|
300 | RanluxEngine theRanluxEngine(seed,4); |
---|
301 | // instantiates an engine with `seed' and the best luxury-level |
---|
302 | ... or |
---|
303 | RanluxEngine theRanluxEngine; |
---|
304 | // instantiates an engine with default seed value and luxury-level |
---|
305 | ... |
---|
306 | </programlisting> |
---|
307 | </informalexample> |
---|
308 | |
---|
309 | The class provides a <literal>getLuxury()</literal> method to get the |
---|
310 | engine luxury level. |
---|
311 | </para> |
---|
312 | <para> |
---|
313 | The <literal>SetSeed()</literal> and <literal>SetSeeds()</literal> |
---|
314 | methods to set the initial seeds for the engine, can be invoked specifying |
---|
315 | the luxury level. For example: |
---|
316 | |
---|
317 | <informalexample> |
---|
318 | <programlisting> |
---|
319 | // static interface |
---|
320 | HepRandom::setTheSeed(seed,4); // sets the seed to `seed' and luxury to 4 |
---|
321 | HepRandom::setTheSeed(seed); // sets the seed to `seed' keeping |
---|
322 | // the current luxury level |
---|
323 | </programlisting> |
---|
324 | </informalexample> |
---|
325 | </para> |
---|
326 | </para></listitem> |
---|
327 | <listitem><para> |
---|
328 | <emphasis>RanecuEngine</emphasis> |
---|
329 | <para> |
---|
330 | The algorithm for <emphasis>RanecuEngine</emphasis> is taken from the one |
---|
331 | originally written in FORTRAN77 as part of the |
---|
332 | <emphasis role="bold">MATHLIB HEP</emphasis> |
---|
333 | library. The initialisation is carried out using a Multiplicative |
---|
334 | Congruential generator using formula constants of L'Ecuyer as |
---|
335 | described in ``F.James, Comp. Phys. Comm. 60 (1990) 329-344''. |
---|
336 | Handling of seeds for this engine is slightly different than the |
---|
337 | other engines in <emphasis>HEPRandom</emphasis>. Seeds are taken from a seed |
---|
338 | table given an index, the <literal>getSeed()</literal> method returns the |
---|
339 | current index of seed table. The <literal>setSeeds()</literal> method will |
---|
340 | set seeds in the local <literal>SeedTable</literal> at a given position index |
---|
341 | (if the index number specified exceeds the table's size, |
---|
342 | <literal>[index%size]</literal> is taken). For example: |
---|
343 | |
---|
344 | <informalexample> |
---|
345 | <programlisting> |
---|
346 | // static interface |
---|
347 | const G4long* table_entry; |
---|
348 | table_entry = HepRandom::getTheSeeds(); |
---|
349 | // it returns a pointer `table_entry' to the local SeedTable |
---|
350 | // at the current `index' position. The couple of seeds |
---|
351 | // accessed represents the current `status' of the engine itself ! |
---|
352 | ... |
---|
353 | G4int index=n; |
---|
354 | G4long seeds[2]; |
---|
355 | HepRandom::setTheSeeds(seeds,index); |
---|
356 | // sets the new `index' for seeds and modify the values inside |
---|
357 | // the local SeedTable at the `index' position. If the index |
---|
358 | // is not specified, the current index in the table is considered. |
---|
359 | ... |
---|
360 | </programlisting> |
---|
361 | </informalexample> |
---|
362 | </para> |
---|
363 | |
---|
364 | <para> |
---|
365 | The <literal>setSeed()</literal> method resets the current `status' of the |
---|
366 | engine to the original seeds stored in the static table of seeds in |
---|
367 | <emphasis>HepRandom</emphasis>, at the specified index. |
---|
368 | </para> |
---|
369 | </para></listitem> |
---|
370 | </itemizedlist> |
---|
371 | </para> |
---|
372 | |
---|
373 | <para> |
---|
374 | Except for the <emphasis>RanecuEngine</emphasis>, for which the internal |
---|
375 | status is represented by just a couple of longs, all the other |
---|
376 | engines have a much more complex representation of their internal |
---|
377 | status, which currently can be obtained only through the methods |
---|
378 | <literal>saveStatus()</literal>, <literal>restoreStatus()</literal> and |
---|
379 | <literal>showStatus()</literal>, which can also be statically called from |
---|
380 | <emphasis>HepRandom</emphasis>. The status of the generator is needed for example |
---|
381 | to be able to reproduce a run or an event in a run at a given stage |
---|
382 | of the simulation. |
---|
383 | </para> |
---|
384 | |
---|
385 | <para> |
---|
386 | <emphasis>RanecuEngine</emphasis> is probably the most suitable engine for |
---|
387 | this kind of operation, since its internal status can be |
---|
388 | fetched/reset by simply using |
---|
389 | <literal>getSeeds()</literal>/<literal>setSeeds()</literal> |
---|
390 | (<literal>getTheSeeds()</literal>/<literal>setTheSeeds()</literal> for the static |
---|
391 | interface in <emphasis>HepRandom</emphasis>). |
---|
392 | </para> |
---|
393 | |
---|
394 | </sect3> |
---|
395 | |
---|
396 | |
---|
397 | <!-- ******************* Section (Level#3) ****************** --> |
---|
398 | <sect3 id="sect.GlobClass.HEPRandom.StaticInt"> |
---|
399 | <title> |
---|
400 | The static interface in the <emphasis>HepRandom</emphasis> class |
---|
401 | </title> |
---|
402 | |
---|
403 | <para> |
---|
404 | <emphasis>HepRandom</emphasis> a singleton class and using a |
---|
405 | <emphasis>HepJamesRandom</emphasis> engine as default algorithm for pseudo-random |
---|
406 | number generation. <emphasis>HepRandom</emphasis> defines a static private data |
---|
407 | member, <literal>theGenerator</literal>, and a set of static methods to |
---|
408 | manipulate it. By means of <literal>theGenerator</literal>, the user can |
---|
409 | change the underlying engine algorithm, get and set the seeds, and |
---|
410 | use any kind of defined random distribution. The static methods |
---|
411 | <literal>setTheSeed()</literal> and <literal>getTheSeed()</literal> will set and get |
---|
412 | respectively the `initial' seed to the main engine used by the |
---|
413 | static generator. For example: |
---|
414 | |
---|
415 | <informalexample> |
---|
416 | <programlisting> |
---|
417 | HepRandom::setTheSeed(seed); // to change the current seed to 'seed' |
---|
418 | int startSeed = HepRandom::getTheSeed(); // to get the current initial seed |
---|
419 | HepRandom::saveEngineStatus(); // to save the current engine status on file |
---|
420 | HepRandom::restoreEngineStatus(); // to restore the current engine to a previous |
---|
421 | // saved configuration |
---|
422 | HepRandom::showEngineStatus(); // to display the current engine status to stdout |
---|
423 | ... |
---|
424 | int index=n; |
---|
425 | long seeds[2]; |
---|
426 | HepRandom::getTheTableSeeds(seeds,index); |
---|
427 | // fills `seeds' with the values stored in the global |
---|
428 | // seedTable at position `index' |
---|
429 | </programlisting> |
---|
430 | </informalexample> |
---|
431 | </para> |
---|
432 | |
---|
433 | <para> |
---|
434 | Only one random engine can be active at a time, the user can |
---|
435 | decide at any time to change it, define a new one (if not done |
---|
436 | already) and set it. For example: |
---|
437 | |
---|
438 | <informalexample> |
---|
439 | <programlisting> |
---|
440 | RanecuEngine theNewEngine; |
---|
441 | HepRandom::setTheEngine(&theNewEngine); |
---|
442 | ... |
---|
443 | </programlisting> |
---|
444 | </informalexample> |
---|
445 | |
---|
446 | or simply setting it to an old instantiated engine (the old |
---|
447 | engine status is kept and the new random sequence will start |
---|
448 | exactly from the last one previously interrupted). For example: |
---|
449 | |
---|
450 | <informalexample> |
---|
451 | <programlisting> |
---|
452 | HepRandom::setTheEngine(&myOldEngine); |
---|
453 | </programlisting> |
---|
454 | </informalexample> |
---|
455 | </para> |
---|
456 | |
---|
457 | <para> |
---|
458 | Other static methods defined in this class are: |
---|
459 | |
---|
460 | <itemizedlist spacing="compact"> |
---|
461 | <listitem><para> |
---|
462 | <literal>void setTheSeeds(const G4long* seeds, G4int)</literal> |
---|
463 | </para></listitem> |
---|
464 | <listitem><para> |
---|
465 | <literal>const G4long* getTheSeeds()</literal> |
---|
466 | <para> |
---|
467 | To set/get an array of seeds for the generator, in the case of a |
---|
468 | <emphasis>RanecuEngine</emphasis> this corresponds also to set/get the current |
---|
469 | status of the engine. |
---|
470 | </para> |
---|
471 | </para></listitem> |
---|
472 | <listitem><para> |
---|
473 | <literal>HepRandomEngine* getTheEngine()</literal> |
---|
474 | <para> |
---|
475 | To get a pointer to the current engine used by the static |
---|
476 | generator. |
---|
477 | </para> |
---|
478 | </para></listitem> |
---|
479 | </itemizedlist> |
---|
480 | </para> |
---|
481 | |
---|
482 | </sect3> |
---|
483 | |
---|
484 | <!-- ******************* Section (Level#3) ****************** --> |
---|
485 | <sect3 id="sect.GlobClass.HEPRandom.Distri"> |
---|
486 | <title> |
---|
487 | <emphasis>HEPRandom</emphasis> distributions |
---|
488 | </title> |
---|
489 | |
---|
490 | <para> |
---|
491 | A distribution-class can collect different algorithms and |
---|
492 | different calling sequences for each method to define distribution |
---|
493 | parameters or range-intervals; it also collects methods to fill |
---|
494 | arrays, of specified size, of random values, according to the |
---|
495 | distribution. This class collects either static and not static |
---|
496 | methods. A set of distribution classes are defined in |
---|
497 | <emphasis>HEPRandom</emphasis>. Here is the description of some of them: |
---|
498 | |
---|
499 | <itemizedlist spacing="compact"> |
---|
500 | <listitem><para> |
---|
501 | <emphasis>RandFlat</emphasis> |
---|
502 | <para> |
---|
503 | Class to shoot flat random values (integers or double) within a |
---|
504 | specified interval. The class provides also methods to shoot just |
---|
505 | random bits. |
---|
506 | </para> |
---|
507 | </para></listitem> |
---|
508 | <listitem><para> |
---|
509 | <emphasis>RandExponential</emphasis> |
---|
510 | <para> |
---|
511 | Class to shoot exponential distributed random values, given a |
---|
512 | mean (default mean = 1) |
---|
513 | </para> |
---|
514 | </para></listitem> |
---|
515 | <listitem><para> |
---|
516 | <emphasis>RandGauss</emphasis> |
---|
517 | <para> |
---|
518 | Class to shoot Gaussian distributed random values, given a mean |
---|
519 | (default = 0) or specifying also a deviation (default = 1). |
---|
520 | Gaussian random numbers are generated two at the time, so every |
---|
521 | other time a number is shot, the number returned is the one |
---|
522 | generated the time before. |
---|
523 | </para> |
---|
524 | </para></listitem> |
---|
525 | <listitem><para> |
---|
526 | <emphasis>RandBreitWigner</emphasis> |
---|
527 | <para> |
---|
528 | Class to shoot numbers according to the Breit-Wigner |
---|
529 | distribution algorithms (plain or mean^2). |
---|
530 | </para> |
---|
531 | </para></listitem> |
---|
532 | <listitem><para> |
---|
533 | <emphasis>RandPoisson</emphasis> |
---|
534 | <para> |
---|
535 | Class to shoot numbers according to the Poisson distribution, |
---|
536 | given a mean (default = 1) (Algorithm taken from ``W.H.Press et |
---|
537 | al., Numerical Recipes in C, Second Edition''). |
---|
538 | </para> |
---|
539 | </para></listitem> |
---|
540 | </itemizedlist> |
---|
541 | </para> |
---|
542 | |
---|
543 | </sect3> |
---|
544 | </sect2> |
---|
545 | |
---|
546 | |
---|
547 | <!-- ******************* Section (Level#2) ****************** --> |
---|
548 | <sect2 id="sect.HEPNumerics"> |
---|
549 | <title> |
---|
550 | The <emphasis>HEPNumerics</emphasis> module |
---|
551 | </title> |
---|
552 | |
---|
553 | <para> |
---|
554 | A set of classes implementing numerical algorithms has been |
---|
555 | developed in Geant4. Most of the algorithms and methods have been |
---|
556 | implemented mainly based on recommendations given in the books: |
---|
557 | |
---|
558 | <itemizedlist spacing="compact"> |
---|
559 | <listitem><para> |
---|
560 | B.H. Flowers, ``An introduction to Numerical Methods In C++'', |
---|
561 | Claredon Press, Oxford 1995. |
---|
562 | </para></listitem> |
---|
563 | <listitem><para> |
---|
564 | M. Abramowitz, I. Stegun, ``Handbook of mathematical |
---|
565 | functions'', DOVER Publications INC, New York 1965 ; chapters 9, |
---|
566 | 10, and 22. |
---|
567 | </para></listitem> |
---|
568 | </itemizedlist> |
---|
569 | </para> |
---|
570 | |
---|
571 | <para> |
---|
572 | This set of classes includes: |
---|
573 | |
---|
574 | <itemizedlist spacing="compact"> |
---|
575 | <listitem><para> |
---|
576 | <emphasis>G4ChebyshevApproximation</emphasis> |
---|
577 | <para> |
---|
578 | Class creating the Chebyshev approximation for a function |
---|
579 | pointed by fFunction data member. The Chebyshev polynomial |
---|
580 | approximation provides an efficient evaluation of the minimax |
---|
581 | polynomial, which (among all polynomials of the same degree) has |
---|
582 | the smallest maximum deviation from the true function. |
---|
583 | </para> |
---|
584 | </para></listitem> |
---|
585 | <listitem><para> |
---|
586 | <emphasis>G4DataInterpolation</emphasis> |
---|
587 | <para> |
---|
588 | Class providing methods for data interpolations and |
---|
589 | extrapolations: Polynomial, Cubic Spline, ... |
---|
590 | </para> |
---|
591 | </para></listitem> |
---|
592 | <listitem><para> |
---|
593 | <emphasis>G4GaussChebyshevQ</emphasis> |
---|
594 | </para></listitem> |
---|
595 | <listitem><para> |
---|
596 | <emphasis>G4GaussHermiteQ</emphasis> |
---|
597 | </para></listitem> |
---|
598 | <listitem><para> |
---|
599 | <emphasis>G4GaussJacobiQ</emphasis> |
---|
600 | </para></listitem> |
---|
601 | <listitem><para> |
---|
602 | <emphasis>G4GaussLaguerreQ</emphasis> |
---|
603 | <para> |
---|
604 | Classes implementing the Gauss-Chebyshev, Gauss-Hermite, |
---|
605 | Gauss-Jacobi, Gauss-Laguerre and Gauss-Legendre quadrature methods. |
---|
606 | Roots of orthogonal polynomials and corresponding weights are |
---|
607 | calculated based on iteration method (by bisection Newton |
---|
608 | algorithm). |
---|
609 | </para> |
---|
610 | </para></listitem> |
---|
611 | <listitem><para> |
---|
612 | <emphasis>G4Integrator</emphasis> |
---|
613 | <para> |
---|
614 | Template class collecting integrator methods for generic |
---|
615 | functions (Legendre, Simpson, Adaptive Gauss, Laguerre, Hermite, |
---|
616 | Jacobi). |
---|
617 | </para> |
---|
618 | </para></listitem> |
---|
619 | <listitem><para> |
---|
620 | <emphasis>G4SimpleIntegration</emphasis> |
---|
621 | <para> |
---|
622 | Class implementing simple numerical methods (Trapezoidal, |
---|
623 | MidPoint, Gauss, Simpson, Adaptive Gauss, for integration of |
---|
624 | functions with signature: double f(double). |
---|
625 | </para> |
---|
626 | </para></listitem> |
---|
627 | </itemizedlist> |
---|
628 | </para> |
---|
629 | |
---|
630 | </sect2> |
---|
631 | |
---|
632 | <!-- ******************* Section (Level#2) ****************** --> |
---|
633 | <sect2 id="sect.GeneManage"> |
---|
634 | <title> |
---|
635 | General management classes |
---|
636 | </title> |
---|
637 | |
---|
638 | <para> |
---|
639 | The `global' category defines also a set of `utility' classes |
---|
640 | generally used within the kernel of Geant4. These classes |
---|
641 | include: |
---|
642 | |
---|
643 | <itemizedlist spacing="compact"> |
---|
644 | <listitem><para> |
---|
645 | <emphasis>G4Allocator</emphasis> |
---|
646 | <para> |
---|
647 | A class for fast allocation of objects to the heap through |
---|
648 | paging mechanism. It's meant to be used by associating it to the |
---|
649 | object to be allocated and defining for it <literal>new</literal> and |
---|
650 | <literal>delete</literal> operators via <literal>MallocSingle()</literal> and |
---|
651 | <literal>FreeSingle()</literal> methods of <emphasis>G4Allocator</emphasis>. |
---|
652 | </para> |
---|
653 | <para> |
---|
654 | <emphasis role="bold">Note</emphasis>: classes which are handled by |
---|
655 | <literal>G4Allocator</literal> should <emphasis>avoid</emphasis> to be used |
---|
656 | as base classes for others and therefore define their (eventually empty) |
---|
657 | destructors to be virtual (and/or inlined). Such measure is necessary in order |
---|
658 | to prevent bad aliasing optimisations by compilers which may potentially |
---|
659 | lead to crashes in the attempt to free the allocated chunks of memory. |
---|
660 | </para> |
---|
661 | <para> |
---|
662 | The list of allocators implicitely defined and used in Geant4 is reported here: |
---|
663 | <informalexample> |
---|
664 | <programlisting> |
---|
665 | - events (G4Event): anEventAllocator |
---|
666 | - tracks (G4Track): aTrackAllocator |
---|
667 | - stacked tracks (G4StackedTrack): aStackedTrackAllocator |
---|
668 | - primary particles (G4PrimaryParticle): aPrimaryParticleAllocator |
---|
669 | - primary vertices (G4PrimaryVertex): aPrimaryVertexAllocator |
---|
670 | - decay products (G4DecayProducts): aDecayProductsAllocator |
---|
671 | - digits collections of an event (G4DCofThisEvent): anDCoTHAllocator |
---|
672 | - digits collections (G4DigiCollection): aDCAllocator |
---|
673 | - hits collections of an event (G4HCofThisEvent): anHCoTHAllocator |
---|
674 | - hits collections (G4HitsCollection): anHCAllocator |
---|
675 | - trajectories (G4Trajectory): aTrajectoryAllocator |
---|
676 | - trajectory points (G4TrajectoryPoint): aTrajectoryPointAllocator |
---|
677 | - trajectory containers (G4TrajectoryContainer): aTrajectoryContainerAllocator |
---|
678 | - navigation levels (G4NavigationLevel): aNavigationLevelAllocator |
---|
679 | - navigation level nodes (G4NavigationLevelRep): aNavigLevelRepAllocator |
---|
680 | - reference-counted handles (G4ReferenceCountedHandle<X>): aRCHAllocator |
---|
681 | - counted objects (G4CountedObject<X>): aCountedObjectAllocator |
---|
682 | - HEPEvt primary particles (G4HEPEvtParticle): aHEPEvtParticleAllocator |
---|
683 | - electron occupancy objects(G4ElectronOccupancy): aElectronOccupancyAllocator |
---|
684 | - "rich" trajectories (G4RichTrajectory): aRichTrajectoryAllocator |
---|
685 | - "rich" trajectory points (G4RichTrajectoryPoint): aRichTrajectoryPointAllocator |
---|
686 | - "smooth" trajectories (G4SmoothTrajectory): aSmoothTrajectoryAllocator |
---|
687 | - "smooth" trajectory points (G4SmoothTrajectoryPoint): aSmoothTrajectoryPointAllocator |
---|
688 | - "ray" trajectories (G4RayTrajectory): G4RayTrajectoryAllocator |
---|
689 | - "ray" trajectory points (G4RayTrajectoryPoint): G4RayTrajectoryPointAllocator |
---|
690 | </programlisting> |
---|
691 | </informalexample> |
---|
692 | For each of these allocators, accessible from the global namespace, it is |
---|
693 | possible to monitor the allocation in their memory pools or force them to |
---|
694 | release the allocated memory (for example at the end of a run): |
---|
695 | <informalexample> |
---|
696 | <programlisting> |
---|
697 | // Return the size of the total memory allocated for tracks |
---|
698 | // |
---|
699 | aTrackAllocator.GetAllocatedSize(); |
---|
700 | |
---|
701 | // Return allocated storage for tracks to the free store |
---|
702 | // |
---|
703 | aTrackAllocator.ResetStorage(); |
---|
704 | </programlisting> |
---|
705 | </informalexample> |
---|
706 | </para> |
---|
707 | </para></listitem> |
---|
708 | <listitem><para> |
---|
709 | <emphasis>G4ReferenceCountedHandle</emphasis> |
---|
710 | <para> |
---|
711 | Template class acting as a smart pointer and wrapping the type |
---|
712 | to be counted. It performs the reference counting during the |
---|
713 | life-time of the counted object. |
---|
714 | </para> |
---|
715 | </para></listitem> |
---|
716 | <listitem><para> |
---|
717 | <emphasis>G4FastVector</emphasis> |
---|
718 | <para> |
---|
719 | Template class defining a vector of pointers, not performing |
---|
720 | boundary checking. |
---|
721 | </para> |
---|
722 | </para></listitem> |
---|
723 | <listitem><para> |
---|
724 | <emphasis>G4PhysicsVector</emphasis> |
---|
725 | <para> |
---|
726 | Defines a physics vector which has values of energy-loss, |
---|
727 | cross-section, and other physics values of a particle in matter in |
---|
728 | a given range of the energy, momentum, etc. This class serves as |
---|
729 | the base class for a vector having various energy scale, for |
---|
730 | example like 'log' (<emphasis>G4PhysicsLogVector</emphasis>) 'linear' |
---|
731 | (<emphasis>G4PhysicsLinearVector</emphasis>), 'free' |
---|
732 | (<emphasis>G4PhysicsFreeVector</emphasis>), etc. |
---|
733 | </para> |
---|
734 | </para></listitem> |
---|
735 | <listitem><para> |
---|
736 | <emphasis>G4LPhysicsFreeVector</emphasis> |
---|
737 | <para> |
---|
738 | Implements a free vector for low energy physics cross-section |
---|
739 | data. A subdivision method is used to find the energy|momentum |
---|
740 | bin. |
---|
741 | </para> |
---|
742 | </para></listitem> |
---|
743 | <listitem><para> |
---|
744 | <emphasis>G4PhysicsOrderedFreeVector</emphasis> |
---|
745 | <para> |
---|
746 | A physics ordered free vector inherits from |
---|
747 | <emphasis>G4PhysicsVector</emphasis>. It provides, in addition, a method |
---|
748 | for the user to insert energy/value pairs in sequence. Methods to retrieve |
---|
749 | the max and min energies and values from the vector are also |
---|
750 | provided. |
---|
751 | </para> |
---|
752 | </para></listitem> |
---|
753 | <listitem><para> |
---|
754 | <emphasis>G4Timer</emphasis> |
---|
755 | <para> |
---|
756 | Utility class providing methods to measure elapsed user/system |
---|
757 | process time. |
---|
758 | Uses <literal><sys/times.h></literal> and <literal><unistd.h></literal> - |
---|
759 | POSIX.1. |
---|
760 | </para> |
---|
761 | </para></listitem> |
---|
762 | <listitem><para> |
---|
763 | <emphasis>G4UserLimits</emphasis> |
---|
764 | <para> |
---|
765 | Class collecting methods for get and set any kind of step |
---|
766 | limitation allowed in Geant4. |
---|
767 | </para> |
---|
768 | </para></listitem> |
---|
769 | <listitem><para> |
---|
770 | <emphasis>G4UnitsTable</emphasis> |
---|
771 | <para> |
---|
772 | Placeholder for the system of units in Geant4. |
---|
773 | </para> |
---|
774 | </para></listitem> |
---|
775 | </itemizedlist> |
---|
776 | </para> |
---|
777 | |
---|
778 | |
---|
779 | </sect2> |
---|
780 | </sect1> |
---|