source: trunk/Documentation/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch04s06.html@ 901

Last change on this file since 901 was 901, checked in by garnier, 17 years ago

Add Geant4 Documentation at 8.12.2008

File size: 5.7 KB
Line 
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>4.6.  Object Persistency</title><link rel="stylesheet" href="../xml/XSLCustomizationLayer/G4HTMLStylesheet.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.71.1"><link rel="start" href="index.html" title="Geant4 User's Guide for Application Developers"><link rel="up" href="ch04.html" title="Chapter 4.  Detector Definition and Response"><link rel="prev" href="ch04s05.html" title="4.5.  Digitization"><link rel="next" href="ch04s07.html" title="4.7.  Parallel Geometries"><script language="JavaScript">
2function remote_win(fName)
3{
4 var url = "AllResources/Detector/geometry.src/" + fName;
5 RemoteWin=window.open(url,"","resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,copyhistory=0,width=520,height=520")
6 RemoteWin.creator=self
7}
8</script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.6. 
9Object Persistency
10</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04s05.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><th width="60%" align="center">Chapter 4. 
11Detector Definition and Response
12</th><td width="20%" align="right"> <a accesskey="n" href="ch04s07.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect.ObjPers"></a>4.6. 
13Object Persistency
14</h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.ObjPers.PersG4"></a>4.6.1. 
15Persistency in Geant4
16</h3></div></div></div><p>
17Object persistency is provided by Geant4 as an optional category,
18so that the user may run Geant4 with or without an object database
19management system (ODBMS).
20</p><p>
21When a usual (transient) object is created in C++, the object is
22placed onto the application heap and it ceases to exist when the
23application terminates. Persistent objects, on the other hand, live
24beyond the termination of the application process and may then be
25accessed by other processes (in some cases, by processes on other
26machines).
27
28</p><div class="figure"><a name="fig.ObjPers_1"></a><div class="figure-contents"><div class="mediaobject" align="center"><img src="./AllResources/Detector/persistency.src/pobject.gif" align="middle" alt="Persistent object."></div></div><p class="title"><b>Figure 4.9. 
29Persistent object.
30</b></p></div><p><br class="figure-break">
31</p><p>
32C++ does not have, as an intrinsic part of the language, the
33ability to store and retrieve persistent objects. Geant4 provides
34an abstract framework for persistency of hits, digits and
35events.
36</p><p>
37Two examples demonstrating an implementation of object
38persistency using one of the tools accessible through the available
39interface, is provided in
40<code class="literal">examples/extended/persistency</code>.
41</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.ObjPers.Reflex"></a>4.6.2. 
42Using Reflex for persistency of Geant4 objects
43</h3></div></div></div><p>
44Object persistency of Geant4 objects is also possible by the
45mean of the <a href="http://cern.ch/seal-reflex/" target="_top">
46Reflex library</a>.
47Reflex provides, in a non-intrusive way, reflection capabilities to C++
48classes by generating "dictionary information" for them. Those
49dictionaries can then be loaded in memory allowing direct
50persistency of the given objects without any instrumentation of the
51code. The Reflex library is also part of
52<a href="http://root.cern.ch/" target="_top">
53ROOT</a> (since release <code class="literal">v5.08</code>).
54</p><p>
55The basic steps that one needs to do in order to use Reflex with
56ROOT I/O for arbitrary C++ classes is:
57
58</p><div class="orderedlist"><ol type="1" compact><li><p>
59 Generate the dictionary for the given classes using the
60 <code class="literal">genreflex</code> tool from ROOT (this usually is done by adding
61 the appropriate command to the makefile)
62 </p></li><li><p>
63 Add initialization of ROOT I/O and loading of the generated
64 dictionary for the given classes in the appropriate part of the
65 code
66 </p></li><li><p>
67 Whenever the objects to be persistified are available, call the
68 <code class="literal">WriteObject</code> method of <code class="literal">TFile</code> with
69 the pointer to the appropriate object as argument (usually it is some sort
70 of container, like <code class="literal">std::vector</code> containing the collection
71 of objects to be persistified)
72 </p></li></ol></div><p>
73</p><p>
74The two examples provided in <code class="literal">examples/extended/persistency</code>
75demonstrate how to perform object persistency using the
76Reflex mechanism in ROOT I/O for storing hits and geometry description.
77</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04s05.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><td width="20%" align="center"><a accesskey="u" href="ch04.html"><img src="AllResources/IconsGIF/up.gif" alt="Up"></a></td><td width="40%" align="right"> <a accesskey="n" href="ch04s07.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">4.5. 
78Digitization
79 </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="AllResources/IconsGIF/home.gif" alt="Home"></a></td><td width="40%" align="right" valign="top"> 4.7. 
80Parallel Geometries
81</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.