| 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">
|
|---|
| 2 | function 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.
|
|---|
| 9 | Object 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.
|
|---|
| 11 | Detector 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.
|
|---|
| 13 | Object 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.
|
|---|
| 15 | Persistency in Geant4
|
|---|
| 16 | </h3></div></div></div><p>
|
|---|
| 17 | Object persistency is provided by Geant4 as an optional category,
|
|---|
| 18 | so that the user may run Geant4 with or without an object database
|
|---|
| 19 | management system (ODBMS).
|
|---|
| 20 | </p><p>
|
|---|
| 21 | When a usual (transient) object is created in C++, the object is
|
|---|
| 22 | placed onto the application heap and it ceases to exist when the
|
|---|
| 23 | application terminates. Persistent objects, on the other hand, live
|
|---|
| 24 | beyond the termination of the application process and may then be
|
|---|
| 25 | accessed by other processes (in some cases, by processes on other
|
|---|
| 26 | machines).
|
|---|
| 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.
|
|---|
| 29 | Persistent object.
|
|---|
| 30 | </b></p></div><p><br class="figure-break">
|
|---|
| 31 | </p><p>
|
|---|
| 32 | C++ does not have, as an intrinsic part of the language, the
|
|---|
| 33 | ability to store and retrieve persistent objects. Geant4 provides
|
|---|
| 34 | an abstract framework for persistency of hits, digits and
|
|---|
| 35 | events.
|
|---|
| 36 | </p><p>
|
|---|
| 37 | Two examples demonstrating an implementation of object
|
|---|
| 38 | persistency using one of the tools accessible through the available
|
|---|
| 39 | interface, 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.
|
|---|
| 42 | Using Reflex for persistency of Geant4 objects
|
|---|
| 43 | </h3></div></div></div><p>
|
|---|
| 44 | Object persistency of Geant4 objects is also possible by the
|
|---|
| 45 | mean of the <a href="http://cern.ch/seal-reflex/" target="_top">
|
|---|
| 46 | Reflex library</a>.
|
|---|
| 47 | Reflex provides, in a non-intrusive way, reflection capabilities to C++
|
|---|
| 48 | classes by generating "dictionary information" for them. Those
|
|---|
| 49 | dictionaries can then be loaded in memory allowing direct
|
|---|
| 50 | persistency of the given objects without any instrumentation of the
|
|---|
| 51 | code. The Reflex library is also part of
|
|---|
| 52 | <a href="http://root.cern.ch/" target="_top">
|
|---|
| 53 | ROOT</a> (since release <code class="literal">v5.08</code>).
|
|---|
| 54 | </p><p>
|
|---|
| 55 | The basic steps that one needs to do in order to use Reflex with
|
|---|
| 56 | ROOT 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>
|
|---|
| 74 | The two examples provided in <code class="literal">examples/extended/persistency</code>
|
|---|
| 75 | demonstrate how to perform object persistency using the
|
|---|
| 76 | Reflex 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.
|
|---|
| 78 | Digitization
|
|---|
| 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.
|
|---|
| 80 | Parallel Geometries
|
|---|
| 81 | </td></tr></table></div></body></html>
|
|---|