| 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>
|
|---|
| 14 | Object Persistency
|
|---|
| 15 | </title>
|
|---|
| 16 |
|
|---|
| 17 | <!-- ******************* Section (Level#2) ****************** -->
|
|---|
| 18 | <sect2 id="sect.ObjPers.PersG4">
|
|---|
| 19 | <title>
|
|---|
| 20 | Persistency in Geant4
|
|---|
| 21 | </title>
|
|---|
| 22 |
|
|---|
| 23 | <para>
|
|---|
| 24 | Object persistency is provided by Geant4 as an optional category,
|
|---|
| 25 | so that the user may run Geant4 with or without an object database
|
|---|
| 26 | management system (ODBMS).
|
|---|
| 27 | </para>
|
|---|
| 28 |
|
|---|
| 29 | <para>
|
|---|
| 30 | When a usual (transient) object is created in C++, the object is
|
|---|
| 31 | placed onto the application heap and it ceases to exist when the
|
|---|
| 32 | application terminates. Persistent objects, on the other hand, live
|
|---|
| 33 | beyond the termination of the application process and may then be
|
|---|
| 34 | accessed by other processes (in some cases, by processes on other
|
|---|
| 35 | machines).
|
|---|
| 36 |
|
|---|
| 37 | <figure id="fig.ObjPers_1">
|
|---|
| 38 | <title>
|
|---|
| 39 | Persistent object.
|
|---|
| 40 | </title>
|
|---|
| 41 | <mediaobject>
|
|---|
| 42 | <imageobject role="fo">
|
|---|
| 43 | <imagedata fileref="./AllResources/Detector/persistency.src/pobject.jpg"
|
|---|
| 44 | format="JPG" contentwidth="7.0cm" align="center" />
|
|---|
| 45 | </imageobject>
|
|---|
| 46 | <imageobject role="html">
|
|---|
| 47 | <imagedata fileref="./AllResources/Detector/persistency.src/pobject.jpg"
|
|---|
| 48 | format="JPG" align="center" />
|
|---|
| 49 | </imageobject>
|
|---|
| 50 | </mediaobject>
|
|---|
| 51 | </figure>
|
|---|
| 52 | </para>
|
|---|
| 53 |
|
|---|
| 54 | <para>
|
|---|
| 55 | C++ does not have, as an intrinsic part of the language, the
|
|---|
| 56 | ability to store and retrieve persistent objects. Geant4 provides
|
|---|
| 57 | an abstract framework for persistency of hits, digits and
|
|---|
| 58 | events.
|
|---|
| 59 | </para>
|
|---|
| 60 |
|
|---|
| 61 | <para>
|
|---|
| 62 | Two examples demonstrating an implementation of object
|
|---|
| 63 | persistency using one of the tools accessible through the available
|
|---|
| 64 | interface, 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>
|
|---|
| 73 | Using Reflex for persistency of Geant4 objects
|
|---|
| 74 | </title>
|
|---|
| 75 |
|
|---|
| 76 | <para>
|
|---|
| 77 | Object persistency of Geant4 objects is also possible by the
|
|---|
| 78 | mean of the <ulink url="http://cern.ch/seal-reflex/">
|
|---|
| 79 | Reflex library</ulink>.
|
|---|
| 80 | Reflex provides, in a non-intrusive way, reflection capabilities to C++
|
|---|
| 81 | classes by generating "dictionary information" for them. Those
|
|---|
| 82 | dictionaries can then be loaded in memory allowing direct
|
|---|
| 83 | persistency of the given objects without any instrumentation of the
|
|---|
| 84 | code. The Reflex library is also part of
|
|---|
| 85 | <ulink url="http://root.cern.ch/">
|
|---|
| 86 | ROOT</ulink> (since release <literal>v5.08</literal>).
|
|---|
| 87 | </para>
|
|---|
| 88 |
|
|---|
| 89 | <para>
|
|---|
| 90 | The basic steps that one needs to do in order to use Reflex with
|
|---|
| 91 | ROOT 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>
|
|---|
| 115 | The two examples (<literal>P01</literal> and <literal>P02</literal>) provided
|
|---|
| 116 | in <literal>examples/extended/persistency</literal>
|
|---|
| 117 | demonstrate how to perform object persistency using the
|
|---|
| 118 | Reflex mechanism in ROOT I/O for storing hits and geometry description.
|
|---|
| 119 | </para>
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 | </sect2>
|
|---|
| 123 | </sect1>
|
|---|