BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page

BrEventIO


class description - source file - inheritance tree

class BrEventIO : public BrIOModule

    private:
Bool_t InitializeRootSerialFile() Bool_t InitializeRootTreeFile() void ProcessRootSerialFile(BrEvent* event) void ProcessRootTreeFile(BrEvent* event) public:
BrEventIO BrEventIO() BrEventIO BrEventIO(const Char_t* name, const Char_t* title = "0") BrEventIO BrEventIO(BrEventIO&) virtual void ~BrEventIO() virtual void Browse(TBrowser* b) static TClass* Class() virtual Bool_t Close() virtual void Event(BrEvent* event) virtual BrFileTag::EFileMode GetFileMode() const virtual TFile* GetROOTFile() virtual TClass* IsA() const virtual Bool_t IsFolder() const virtual Bool_t Open(const Char_t* fname, const Option_t* option) virtual void Print(Option_t* option) const virtual void SetFileMode(BrFileTag::EFileMode mode) virtual void SetTreeParameters(Int_t bufSize = 32000, Int_t split = 99) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual Bool_t SkipEvent(Int_t numevt) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members

    private:
TFile* fROOTFile TFile object TString fFileOption Regular TFile option parameter BrFileTag::EFileMode fFileMode File mode BrFileTag* fTag File tag. TList* fListOfKeys List of Keys in serial file TIter* fNextKey !Key to next event in serial file TTree* fTree Tree to write out TBranch* fBranch[50] Branch for that tree Int_t fBufsize Buffer size for tree Int_t fSplit Split mode? Bool_t fCreateBranch To decide if to create branch or not Int_t fNumBranches Number of branches in the Tree Int_t fNumEntries Number of entries in tree; Int_t fEventNumber Event number we are on. Bool_t fWriteFile Specifies read or write mode Bool_t fTopLevel !Test for level nesting in browser

Class Description

 BrEventIO

 Class to write/read BrEvent data on/from a ROOT TFile.
 The class is derived from the BrIOModule class, so that it conforms
 to the regular BrModule interface.

 Description:
 ------------
 This class is meant to simplify writing BRAHMS output in ROOT
 format.  The user simply creates the object which has defaults that
 work.  Several options are also provided in case they are needed.

 Usage (recommended):
 -------------------
 The recommended way of using the class is like using any other
 BrModule:  Create an object and add it to some module container
 (BrModuleContainer), for example the BrMainModule container
 singleton.

 1 to any number of files to can be specified (See
 BrIOModule::AddFile).  If more than one file is added to the
 module, one should set the BrIOModule::kBrRunFile flag in the file
 IO mode (see BrIOModule::SetIOMode).  If only one file is opened by
 the module, then the BrIOModule::kBrJobFile flag should be set.

 Here's and example using the BrMainModule container object
 mainModule:

   BrEventIO* inputModule = new BrEventIO("input", "");
   inputModule->SetIOMode(BrIOModule::kBrJobFile|BrIOModule::kBrWriteFile);
   inputModule->AddFile("foo.root");
   mainModule->AddModule(inputModule);

   ... other modules follow

   BrEventIO* outputModule = new BrEventIO("output", "");
   outputModule->SetIOMode(BrIOModule::kBrJobFile|BrIOModule::kBrWriteFile);
   outputModule->AddFile("bar.root");
   mainModule->AddModule(outputModule);

 Usage (depreciated):
 -------------------
 The old, and depreciated, way of using this class, is to create an
 object (BrEventIO::BrEventIO), open the file (BrEventIO::Open) and
 then use the BrEventIO::Event(BrEvent* event) method for event by
 event writing of event objects.  Finally, the file must be closed
 using BrEventIO::Close.

 The file can be opened either in READ mode for readonly operations
 or in RECREATE  mode for write operations.  The TFile APPEND option
 is not currently supported.  The default file mode is a ROOT tree.
 The mode can be manually selected using the SetFileMode(option)
 method.

 Example:

   BrEventIO *io = new BrEventIO("input");
   if (!input->Open("foo.root","READ"))
     return;

   ... More modules

   while (kTRUE) {
     BrEvent* inEvent  = new BrEvent("ev,0,0);
     BrEvent* outEvent = new BrEvent("ev,0,0);

     input->Event(inEvent);

     if (input->IsError())
       return;
     if (input->IsEof())
       return;

     ... More follows here

     delete inEvent;
     delete outEvent;
   }
   input->Close();


BrEventIO() : fTopLevel(kTRUE)
 Default constructor

BrEventIO(const Char_t *name, const Char_t* title) : BrIOModule(BREVENTIO_NAME, name), fTopLevel(kTRUE)
 Constructor.
 name becomes Name and Title for the Module.
 No data file is opened this has to be done in
 the Open() method.

 Option can by "READ" "RECREATE"


~BrEventIO()
  Destructor for BrEventIO. Close the file if open. Delete the
  TFile object

Bool_t Open(const Char_t *fname,const Option_t *option)
 Open the file with fname. Returns kFALSE if the file can't be
 opened. Otherwise the fFileName data member is set to the
 corresponding filepointer.

 Options: READ for readonly mode or RECREATE for write mode.

 RECREATE mode:
 If option is RECREATE, a new file is created.  This object is
 written out to indicate the file mode (Tree or Serial). If file
 mode is to be different than the default (Tree), the
 SetFileMode(mode) needs to be used before the Open method.

 READ mode:
 if option is READ, existing file is opened.  This object is read
 in to get information on file mode.

Bool_t InitializeRootSerialFile()
 Routine to Initialize ROOT serial file
 This routine does nothing if in write mode.
 If in read mode, a list of Keys is found from the event file and
 stored in fListOfKeys.  The file header key is removed from the
 list of keys

void SetTreeParameters(Int_t bufSize, Int_t split)
 Set the TTree parameters buffer size and split level.  For the
 exact meaning of these, please refer to the TTree class
 description, and the ROOT Users Guide, chapter 12 [1]. The
 default values should do fine for most applications.
 
  /* 
     References: 

[1] ROOT Users Guide */

Bool_t InitializeRootTreeFile()
 Routine to initialize ROOT tree file (default writing mode)
 if file opened in write mode:
   Create the tree
   Initialize some counters
   Set up a single branch with fSplit=1.  Setting branches by hand
   is not yet supported.

 if file opened in read mode.
   Get the tree object from the file
   Set counter of the number of entries in the file
   Initialize some counters and flags

Bool_t Close()
 Close the file Opened by the object. Return
 kFALSE if no file was open.

Bool_t SkipEvent(Int_t numevt)
 Skip events on input only


void Event(BrEvent* event)
 Reads or writes one event depending on whether we are in read
 mode or write mode

void ProcessRootSerialFile(BrEvent *event)
 Do Serial File specific actions to read or write the file
 depending on mode if write mode, simply write the object and
 increment number of events written. if read mode, get the next
 key, Create a dummy event using key->ReadObj(); Copy the dummy
 event into the event we are passing back. increment number of
 events read

void ProcessRootTreeFile(BrEvent *event)
 Do Tree File specific actions to read or write the file depending
 on mode if Write mode, set the branch address to the event
 argument, then fTree->Fill(); if Read mode, set branch address to
 event argument, then fTree->GetEvent(fEventNumber);

void SetFileMode(BrFileTag::EFileMode mode)
 Set file mode.
 mode can be either BrFileTag::kTree or BrFileTag::kSerial
 mode must be set before opening the file.

void Browse(TBrowser* b)

void Print(Option_t* option) const
 Print information on this module
 Options:
   Z       Print file tag
   T       Print tree info (TTree::Print)
   F       Print file info (TFile::Print)
 See also BrIOModule::Print.



Inline Functions


        BrFileTag::EFileMode GetFileMode() const
                      TFile* GetROOTFile()
                      Bool_t IsFolder() const
                     TClass* Class()
                     TClass* IsA() const
                        void ShowMembers(TMemberInspector& insp, char* parent)
                        void Streamer(TBuffer& b)
                        void StreamerNVirtual(TBuffer& b)
                   BrEventIO BrEventIO(BrEventIO&)

This page automatically generated by script docBrat by Christian Holm

Copyright ; 2002 BRAHMS Collaboration <brahmlib@rcf.rhic.bnl.gov>
Last Update on 2002/08/30 20:48:01 $ by videbaek $

Validate HTML
Validate CSS