Geant4 Cross Reference |
1 1 2 ========================================= 2 ========================================================= 3 Geant4 - an Object-Oriented Toolkit for S 3 Geant4 - an Object-Oriented Toolkit for Simulation in HEP 4 ========================================= 4 ========================================================= 5 5 6 ExampleP02 6 ExampleP02 7 ---------- 7 ---------- 8 8 9 General description << 9 General description 10 ------------------- << 10 ------------------- 11 11 12 This example shows how to store in a binary fi << 12 This example shows how to store in a binary file and how to 13 read back the geometry tree using the 'reflect 13 read back the geometry tree using the 'reflection' technique for 14 persistency provided by the Reflex tool also i 14 persistency provided by the Reflex tool also included in ROOT. The 15 Reflex tool allows to create a dictionary for 15 Reflex tool allows to create a dictionary for the geometry classes, 16 making then possible to save the entire tree i 16 making then possible to save the entire tree in a .root file. 17 17 18 The provided makefile produces the executable: 18 The provided makefile produces the executable: 'exampleP02'. In order 19 to run it one has to specify the argument, eit 19 to run it one has to specify the argument, either 'write' or 20 'read'. In the first case the geometry is inst 20 'read'. In the first case the geometry is instaciated in the standard 21 way and then saved into the root file (geo.roo 21 way and then saved into the root file (geo.root). In the second case, 22 the geometry is read from geo.root file. 22 the geometry is read from geo.root file. 23 23 24 24 25 Building and running the example << 25 Building and running the example 26 -------------------------------- << 26 -------------------------------- 27 27 28 This examples requires the ROOT toolkit of ver << 28 This example requires the ROOT toolkit to be installed in the 29 provided CMake file checks for the existence o << 29 system as well as GCCXML package which is used by the Reflex tool. The >> 30 provided CMake file checks for the existance of those packages. 30 Once the CMake configuration has been succesfu 31 Once the CMake configuration has been succesfully done, the executable 31 for this example should be built using make << 32 for this example should be build using make (in your CMake build 32 (in your CMake build directory): << 33 directory): 33 34 34 make 35 make 35 36 36 Remark on dictionary generation << 37 Remark on dictionary generation 37 ------------------------------- << 38 ------------------------------- 38 39 39 The dictionary is generated by ${ROOTSYS}/bin/ << 40 The dictionary is generated by ${ROOTSYS}/bin/genreflex 40 tool. The arguments that will be used by this << 41 tool. The header file including headers for all the classes we want to 41 in CMakeLists.txt using the CMake function REF << 42 generate the dictionary for should be given as argument. Additionally, 42 provided by ROOT. They include the header file << 43 a so called selection file (xml) should be provided (with -s flag) to 43 all the classes we want to generate the dictio << 44 the genreflex tool (see the GNUmakefile). The role of this file is to 44 a so called selection file (xml). The role of << 45 specify which classes we want to generate the 45 specify which classes we want to generate the dictionary for. The 46 selection file for our dictionary is in xml/ d 46 selection file for our dictionary is in xml/ directory. Please refer 47 to genreflex manual for more details concernin 47 to genreflex manual for more details concerning the usage of that 48 tool. 48 tool. 49 49 50 Concerning generating dictionary for the Geant 50 Concerning generating dictionary for the Geant4 objects, there are 51 also two technical remarks that need to be mad << 51 also two technical remarks that need to be made here. The gccxml tool 52 The Reflex tool requires all the templated cla << 52 (version 0.6.0_patch1) requires all the templated classes to be 53 explicitely used somewhere in the included hea 53 explicitely used somewhere in the included header files in order for 54 the generation of the dictionary to be possibl 54 the generation of the dictionary to be possible. For those templated 55 classes for which it is not the case, the prob 55 classes for which it is not the case, the problem can be very easily 56 solved by instaciating them in the headerfile 56 solved by instaciating them in the headerfile which is given to 57 genreflex (see includes/ExP02Classes.hh) as ar << 57 genreflex (see includes/Classes.h) as argument. 58 The second remark is that there is an unfortun 58 The second remark is that there is an unfortunate clash of names as 59 far as G4String class is concerned. The header 59 far as G4String class is concerned. The header of G4String class 60 defines __G4String which happens to be the nam 60 defines __G4String which happens to be the name of a variable used 61 within the generated dictionary code. The solu 61 within the generated dictionary code. The solution for that is to do 62 #undef __G4String in include/ExP02Classes.hh f << 62 #undef __G4String in include/Classes.h file. >> 63 >> 64