1 | |
---|
2 | ========================================================= |
---|
3 | Geant4 - an Object-Oriented Toolkit for Simulation in HEP |
---|
4 | ========================================================= |
---|
5 | |
---|
6 | ExampleP01 |
---|
7 | ---------- |
---|
8 | |
---|
9 | General description |
---|
10 | ------------------- |
---|
11 | |
---|
12 | This example shows how to store produced hits in a file using |
---|
13 | the 'reflection' technique for persistency provided by the Reflex tool |
---|
14 | also included in ROOT. The Reflex tool allows to create a dictionary |
---|
15 | for the hit class, making then possible to save hit objects in a .root |
---|
16 | file. The general simulation setup (geometry, physics list, user |
---|
17 | actions, etc...) is taken from ExampleN02. |
---|
18 | |
---|
19 | The provided makefile produces two executables: 'persEx02' and |
---|
20 | 'readHits'. The first one is the actual Geant4 simulation application |
---|
21 | with hits persistency. The second one, is just a simple 'reader' for |
---|
22 | the produced .root file (you need to specify the name of the .root |
---|
23 | file as argument). |
---|
24 | |
---|
25 | |
---|
26 | Building and running the example |
---|
27 | -------------------------------- |
---|
28 | |
---|
29 | Before buidling and/or running the example you need to set the |
---|
30 | following environment variables: |
---|
31 | |
---|
32 | ROOTSYS - ROOT installation directory, it is required to run ROOT |
---|
33 | |
---|
34 | GCCXMLPATH - gccxml binary directory, it is needed by ROOT for the |
---|
35 | dictionary generation |
---|
36 | LD_LIBRARY_PATH - to include the ROOT library path and the path to |
---|
37 | the dictionary library, i.e., for tcsh UNIX shell: |
---|
38 | setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$ROOTSYS/lib: |
---|
39 | $G4WORKDIR/tmp/$G4SYSTEM/exampleP01 |
---|
40 | |
---|
41 | The present version of the example requires that Geant4 headers are |
---|
42 | installed in a single directory referenced by G4INCLUDE, as the standard |
---|
43 | Geant4 installation procedure allows to do. |
---|
44 | |
---|
45 | Once those variables are set (together with the standard Geant4 setup) |
---|
46 | the example can be build by issueing the 'make' command. The final |
---|
47 | executable file can be found in the usual directory: |
---|
48 | |
---|
49 | $G4WORKDIR/bin/$G4SYSTEM/ |
---|
50 | |
---|
51 | Ten events will be generated and the produced hits will be stored in |
---|
52 | the hits.root file. In addition, the hits will be printed out on the |
---|
53 | screen so one can then compare them with the 'reader' output. |
---|
54 | |
---|
55 | In order to read the persistified hits, a small 'reader' application |
---|
56 | has been implemented. It is build by the same makefile as the example |
---|
57 | executable. It can be run in the following way: |
---|
58 | |
---|
59 | readHits hits.root |
---|
60 | |
---|
61 | where the argument is the name of the file to be read. All the hits |
---|
62 | saved in that file will be then read and printed on the screen. |
---|
63 | |
---|
64 | |
---|
65 | Remark on dictionary generation |
---|
66 | ------------------------------- |
---|
67 | |
---|
68 | The dictionary is generated by ${ROOTSYS}/bin/genreflex |
---|
69 | tool. The header file including headers for all the classes we want to |
---|
70 | generate the dictionary for should be given as argument. Additionally, |
---|
71 | a so called selection file (xml) should be provided (with -s flag) to |
---|
72 | the genreflex tool (see the GNUmakefile). The role of this file is to |
---|
73 | specify which classes we want to generate the dictionary for. The |
---|
74 | selection file for our dictionary is in xml/ directory. Please refer |
---|
75 | to genreflex manual for more details concerning the usage of that |
---|
76 | tool. |
---|
77 | |
---|
78 | Concerning generating dictionary for the Geant4 objects, there are |
---|
79 | also two technical remarks that need to be made here. The gccxml tool |
---|
80 | (version 0.6.0_patch1) requires all the templated classes to be |
---|
81 | explicitely used somewhere in the included header files in order for |
---|
82 | the generation of the dictionary to be possible. For those templated |
---|
83 | classes for which it is not the case, the problem can be very easily |
---|
84 | solved by instaciating them in the headerfile which is given to |
---|
85 | genreflex (see includes/Classes.h) as argument. |
---|
86 | The second remark is that there is an unfortunate clash of names as |
---|
87 | far as G4String class is concerned. The header of G4String class |
---|
88 | defines __G4String which happens to be the name of a variable used |
---|
89 | within the generated dictionary code. The solution for that is to do |
---|
90 | #undef __G4String in include/Classes.h file. |
---|
91 | |
---|
92 | |
---|