source: trunk/documents/UserDoc/DocBookUsersGuides/ForApplicationDeveloper/xml/Detector/persistency.xml @ 905

Last change on this file since 905 was 904, checked in by garnier, 16 years ago

ajout de la doc

File size: 4.2 KB
Line 
1<!-- ******************************************************** -->
2<!--                                                          -->
3<!--  [History]                                               -->
4<!--    Converted to DocBook: Katsuya Amako, Aug-2006         -->
5<!--    Changed by: Katsuya Amako,  4-Aug-1998                -->
6<!--    Changed by: Dennis Wright, 27-Nov-2001                -->
7<!--    Proof read by: Joe Chuma,  30-Jun-1999                -->
8<!--                                                          -->
9<!-- ******************************************************** -->
10
11<!-- ******************* Section (Level#1) ****************** -->
12<sect1 id="sect.ObjPers">
13<title>
14Object Persistency
15</title>
16
17<!-- ******************* Section (Level#2) ****************** -->
18<sect2 id="sect.ObjPers.PersG4">
19<title>
20Persistency in Geant4
21</title>
22
23<para>
24Object persistency is provided by Geant4 as an optional category,
25so that the user may run Geant4 with or without an object database
26management system (ODBMS).
27</para>
28
29<para>
30When a usual (transient) object is created in C++, the object is
31placed onto the application heap and it ceases to exist when the
32application terminates. Persistent objects, on the other hand, live
33beyond the termination of the application process and may then be
34accessed by other processes (in some cases, by processes on other
35machines).
36
37<figure id="fig.ObjPers_1">
38<title>
39Persistent object.
40</title>
41<mediaobject>
42  <imageobject role="fo">
43    <imagedata fileref="./AllResources/Detector/persistency.src/pobject.gif" 
44               format="JPG" contentwidth="7.0cm" align="center" />
45  </imageobject>
46  <imageobject role="html">
47    <imagedata fileref="./AllResources/Detector/persistency.src/pobject.gif" 
48               format="JPG" align="center" />
49  </imageobject>
50</mediaobject>
51</figure>
52</para>
53
54<para>
55C++ does not have, as an intrinsic part of the language, the
56ability to store and retrieve persistent objects. Geant4 provides
57an abstract framework for persistency of hits, digits and
58events.
59</para>
60
61<para>
62Two examples demonstrating an implementation of object
63persistency using one of the tools accessible through the available
64interface, is provided in
65<literal>examples/extended/persistency</literal>.
66</para>
67
68</sect2>
69
70<!-- ******************* Section (Level#2) ****************** -->
71<sect2 id="sect.ObjPers.Reflex">
72<title>
73Using Reflex for persistency of Geant4 objects
74</title>
75
76<para>
77Object persistency of Geant4 objects is also possible by the
78mean of the <ulink url="http://cern.ch/seal-reflex/">
79Reflex library</ulink>.
80Reflex provides, in a non-intrusive way, reflection capabilities to C++
81classes by generating "dictionary information" for them. Those
82dictionaries can then be loaded in memory allowing direct
83persistency of the given objects without any instrumentation of the
84code. The Reflex library is also part of
85<ulink url="http://root.cern.ch/">
86ROOT</ulink> (since release <literal>v5.08</literal>).
87</para>
88
89<para>
90The basic steps that one needs to do in order to use Reflex with
91ROOT I/O for arbitrary C++ classes is:
92
93<orderedlist spacing="compact">
94  <listitem><para>
95    Generate the dictionary for the given classes using the
96    <literal>genreflex</literal> tool from ROOT (this usually is done by adding
97    the appropriate command to the makefile)
98  </para></listitem>
99  <listitem><para>
100    Add initialization of ROOT I/O and loading of the generated
101    dictionary for the given classes in the appropriate part of the
102    code
103  </para></listitem>
104  <listitem><para>
105    Whenever the objects to be persistified are available, call the
106    <literal>WriteObject</literal> method of <literal>TFile</literal> with
107    the pointer to the appropriate object as argument (usually it is some sort
108    of container, like <literal>std::vector</literal> containing the collection
109    of objects to be persistified)
110  </para></listitem>
111</orderedlist>
112</para>
113
114<para>
115The two examples (<literal>P01</literal> and <literal>P02</literal>) provided
116in <literal>examples/extended/persistency</literal>
117demonstrate how to perform object persistency using the
118Reflex mechanism in ROOT I/O for storing hits and geometry description.
119</para>
120
121
122</sect2>
123</sect1>
Note: See TracBrowser for help on using the repository browser.