source: trunk/documents/UserDoc/UsersGuides/ForApplicationDeveloper/html/Detector/persistency.html

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

CVS update

File size: 4.1 KB
Line 
1<html><head><title></title><!-- Changed by: Katsuya Amako,  4-Aug-1998 --><!-- Changed by: Dennis Wright, 27-Nov-2001 --><!-- Proof read by: Joe Chuma,  30-Jun-1999 --></head><body>
2<table width="100%"><tbody><tr>
3<td>
4<a href="http://geant4.web.cern.ch/geant4/G4UsersDocuments/Overview/html/index.html">
5<img src="persistency_files/Overview.gif" alt="Overview"></a>
6<a href="http://geant4.web.cern.ch/geant4/G4UsersDocuments/UsersGuides/ForApplicationDeveloper/html/Detector/index.html">
7<img src="persistency_files/Contents.gif" alt="Contents"></a>
8<a href="http://geant4.web.cern.ch/geant4/G4UsersDocuments/UsersGuides/ForApplicationDeveloper/html/Detector/digitization.html">
9<img src="persistency_files/Previous.gif" alt="Previous"></a>
10<a href="http://geant4.web.cern.ch/geant4/G4UsersDocuments/UsersGuides/ForApplicationDeveloper/html/Detector/parallelWorld.html">
11<img src="persistency_files/NextGR.gif" alt="Next"></a>
12</td>
13<td align="right">
14<font color="#238e23" size="-1">
15<b>Geant4 User's Guide</b>
16<br>
17<b>For Application Developers</b>
18<br>
19<b>Detector Definition and Response</b>
20</font>
21</td>
22</tr></tbody></table>
23<br><br>
24
25<p align="center">
26<font color="#238e23" size="+3">
27<b>4.6 Object Persistency</b>
28</font>
29<br><br>
30
31</p><hr align="center" size="7">
32<p>
33
34<a name="4.6.1">
35<h2>4.6.1 Persistency in Geant4</h2></a>
36
37Object persistency is provided by Geant4 as an optional category, so that the
38user may run Geant4 with or without an object database management system
39(ODBMS).
40
41</p><p>When a usual (transient) object is created in C++, the object is placed
42onto the application heap and it ceases to exist when the application
43terminates.  Persistent objects, on the other hand, live beyond the
44termination of the application process and may then be accessed by other
45processes (in some cases, by processes on other machines).
46</p><center><img src="persistency.src/pobject.gif" height="212" width="290"></center>
47
48
49<p>C++ does not have, as an intrinsic part of the language, the ability to
50store and retrieve persistent objects. Geant4 provides an abstract framework
51for persistency of hits, digits and events.
52</p><p>
53An example which demonstrates an implementation of object persistency using one
54of the tools accessible through the available interface, is provided in
55<tt>examples/extended/persistency</tt>.
56
57</p><p>
58
59<a name="4.6.2">
60<h2>4.6.2 Using Reflex for persistency of Geant4 objects</h2></a>
61<p>
62Object persistency of Geant4 objects is also possible by the mean of the
63<b>Reflex</b> library <a href="#Reflex">[1]</a>. Reflex provides, in a
64non-intrusive way, reflection capabilities to C++ classes by generating
65"dictionary information" for them. Those dictionaries can then be loaded
66in memory allowing direct persistency of the given objects without any
67instrumentation of the code. The Reflex library is also part of ROOT
68<a href="#Root">[2]</a> (since release <tt>v5.08</tt>).
69</p>
70<p>
71The basic steps that one needs to do in order to use Reflex with ROOT I/O
72for arbitrary C++ classes is:
73<ol>
74<li>Generate the dictionary for the given classes using the
75    <tt>genreflex</tt> tool from ROOT (this usually is done
76    by adding the appropriate command to the makefile)</li>
77<li>Add initialization of ROOT I/O and loading of the generated
78    dictionary for the given classes in the appropriate part of the
79    code</li>
80<li>Whenever the objects to be persistified are available, call the
81    <tt>WriteObject</tt> method of <tt>TFile</tt> with the pointer to the
82    appropriate object as argument (usually it is some sort of container,
83    like <tt>std::vector</tt> containing the collection of objects to be
84    persistified)</li>
85</ol>
86The example provided in <tt>examples/extended/persistency</tt>
87demonstrates an implementation of object persistency using the Reflex
88mechanism in ROOT I/O.
89
90</p><p>
91
92<hr>
93<p>
94<table>
95<tr><td valign=top><a name="Reflex">[1]</a>
96    <td><a href="http://cern.ch/seal-reflex/">http://cern.ch/seal-reflex</a>
97<tr><td valign=top><a name="Root">[2]</a>
98    <td><a href="http://root.cern.ch/">http://root.cern.ch</a>
99</table>
100</p>
101
102<hr>
103<a href="http://cern.ch/geant4/G4UsersDocuments/Authors/html/subjectsToAuthors.html">
104<i>About the authors</i></a>
105
106
107</body></html>
Note: See TracBrowser for help on using the repository browser.