[ROOT] New Documentation on Persistence

From: Suzanne Panacek (spanacek@fnal.gov)
Date: Thu May 11 2000 - 20:40:55 MEST


Hi fellow Rooters,
In response to many requests for more user documentation at the last ROOT
workshop, I wrote a paper on
Persistence of ROOT Ojbects. It is now available at:
http://www-pat.fnal.gov/root/Persistence/Persistence.htm

You can also get the different formats (postscipt, A4, zip, etc.) from the
Fermilab Root resource site (this is the same place as the ROOT 101 and ROOT
102 tutorials are):
http://www-pat.fnal.gov/root/

We begin by explaining the ROOT classes used in persistence. Then we put
these classes to use in an example where we build a ROOT file with a tree.
Once we have a tree, we explain how to use it to read the data back and do
analysis.
Each section has a quiz or exercise intended to confirm the understanding of
the material. At the end of the document is an index of basic tasks related
to persistence. If you have a specific question, you can look in the index
first.

To give you a taste, I am including below the test from the chapter on
Streamers. The answers are at the end of the document.

Please send me comments, corrections, questions, etc.

Suzanne Panacek
spanacek@fnal.gov
---------------------------

Note that some questions have multiple answers.
1. A streamers job is to:
a) Write an object to a file
b) Decompose an object into simple data types and write them to a buffer
c) Decompose an object into simple data types and write them to a file

2. A streamer is:
a) Responsible for calling the streamers of all its parents
b) Responsible for calling the streamers of all its object data members
c) Streaming simple data members
d) Responsible for checking the byte count

3. What class contains the TBuffer with the streamed object when the object
is written to a file in the TObject::Write method?
a) The Object's class (i.e. Event)
b) TKey
c) TObject

4. How would you modify the EventLinkDef.h file to let rootcint know NOT to
generate a streamer for the EventHeader class?
a) #pragma link C++ class EventHeader*;
b) #pragma link C++ class EventHeader-;
c) #pragma link C++ class EventHeader+;
d) #pragma link C++ class EventHeader;

5. How would you modify the EventLinkDef.h file to tell rootcint to include
the byte count check in the automatically generated streamer?
a) #pragma link C++ class EventHeader*;
b) #pragma link C++ class EventHeader-;
c) #pragma link C++ class EventHeader+;
d) #pragma link C++ class EventHeader;

6. Assuming the EventLinkDef.h file contains this line:

#pragma link C++ class EventHeader+;

What statements below apply when this call to ClassDef is made:

ClassDef(Event,0)

a) Writes the class version number 0 in the streamer
b) Generates an empty streamer
c) No streamer is generated
d) A streamer with a byte count check is generated

7. Why would you write your own streamer?
a) Because you need to read/write multiple versions of your class
b) Because you have an array of integers for a data member and an older
version of root.
c) Because the streamer generated by rootcint does not stream the parent
classes and your class inherits from multiple classes.

8. How does root react when reading objects without streamers?
a) Using a default streamer.
b) Skipping the object by using the byte count
c) Stop reading and print an error message

9. What does the StreamerInfo string tell us about the class?

"TNamed;TAttLine;TAttFill;TAttMarker;Int_t fScanField;Int_t fUpdate;Int_t
fMaxEntryLoop;Int_t fMaxVirtualSize"

a) It inherits from TObject
b) It inherits from TNamed, TAttLine, and TattFill
c) It has an array of integers.

10. Why do you need to write your own StreamerInfo when you have a
customized streamer?
a) Because root will give you a segmentation fault if you don't.
b) Because root will generate an empty string otherwise.
c) Because the string needs to match the order and contents of what is
streamed out in the streamer method.

The answers are at the end of the document :
http://www-pat.fnal.gov/root/Persistence/Persistence.htm



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:25 MET