source: trunk/examples/extended/persistency/P01/README @ 1252

Last change on this file since 1252 was 807, checked in by garnier, 16 years ago

update

File size: 3.9 KB
Line 
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
13the 'reflection' technique for persistency provided by the Reflex tool
14also included in ROOT. The Reflex tool allows to create a dictionary
15for the hit class, making then possible to save hit objects in a .root
16file.  The general simulation setup (geometry, physics list, user
17actions, etc...) is taken from ExampleN02.
18
19The provided makefile produces two executables: 'persEx02' and
20'readHits'. The first one is the actual Geant4 simulation application
21with hits persistency. The second one, is just a simple 'reader' for
22the produced .root file (you need to specify the name of the .root
23file 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
30following environment variables:
31
32ROOTSYS - ROOT installation directory, it is required to run ROOT
33
34GCCXMLPATH - gccxml binary directory, it is needed by ROOT for the
35             dictionary generation
36LD_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
41The present version of the example requires that Geant4 headers are
42installed in a single directory referenced by G4INCLUDE, as the standard
43Geant4 installation procedure allows to do.
44
45Once those variables are set (together with the standard Geant4 setup)
46the example can be build by issueing the 'make' command. The final
47executable file can be found in the usual directory:
48
49$G4WORKDIR/bin/$G4SYSTEM/
50
51Ten events will be generated and the produced hits will be stored in
52the hits.root file. In addition, the hits will be printed out on the
53screen so one can then compare them with the 'reader' output.
54       
55In order to read the persistified hits, a small 'reader' application
56has been implemented. It is build by the same makefile as the example
57executable. It can be run in the following way:
58
59readHits hits.root
60
61where the argument is the name of the file to be read. All the hits
62saved 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
69tool. The header file including headers for all the classes we want to
70generate the dictionary for should be given as argument. Additionally,
71a so called selection file (xml) should be provided (with -s flag) to
72the genreflex tool (see the GNUmakefile). The role of this file is to
73specify which classes we want to generate the dictionary for. The
74selection file for our dictionary is in xml/ directory. Please refer
75to genreflex manual for more details concerning the usage of that
76tool. 
77
78Concerning generating dictionary for the Geant4 objects, there are
79also 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
81explicitely used somewhere in the included header files in order for
82the generation of the dictionary to be possible. For those templated
83classes for which it is not the case, the problem can be very easily
84solved by instaciating them in the headerfile which is given to
85genreflex (see includes/Classes.h) as argument. 
86The second remark is that there is an unfortunate clash of names as
87far as G4String class is concerned. The header of G4String class
88defines __G4String which happens to be the name of a variable used
89within the generated dictionary code. The solution for that is to do
90#undef __G4String in include/Classes.h file.
91
92 
Note: See TracBrowser for help on using the repository browser.