BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page

BrIOModule


class description - source file - inheritance tree

class BrIOModule : public BrModule


    protected:
virtual void OpenNext() public:
virtual void ~BrIOModule() virtual void AddFile(const Char_t* filename) virtual void AddFileSet(TObjArray* fileSet) virtual void AddFileSet(const Char_t* dirname, const Char_t* regexp) virtual void Begin() static TClass* Class() virtual Bool_t Close() virtual void End() virtual void Event(BrEvent* event) virtual void Event(BrEventNode* input, BrEventNode* output) virtual void Finish() Int_t GetBytesRead() const Int_t GetBytesWritten() const const Char_t* GetFileName() const virtual UInt_t GetIOMode() const Int_t GetIOStatus() const Int_t GetNoFiles() const Int_t GetNoFilesRead() const virtual void Init() virtual TClass* IsA() const Bool_t IsEof() const Bool_t IsError() const virtual Bool_t Open(const Char_t*, const Option_t* option = "0") virtual void Print(Option_t* option = "B") const virtual void SetIOMode(UInt_t mode = kBrJobFile|kBrRecreateFile) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members


    protected:
UInt_t fIOMode ! Mode of this module TString fFileName ! Current InputFileName Int_t fIOStatus ! Status of Module Action Bool_t fError ! Error - result of transaction Bool_t fEof ! EndOfFile / EndOfData indicator Bool_t fNewFile ! NewFile Long_t fNumBytesWritten ! Number of bytes written Long_t fNumBytesRead ! Number of bytes read Int_t fDebugLevel ! Level for amount of debug information Int_t fVerbose ! Option flag TObjArray fFileList ! List of File (sets) to read/write. Int_t fNoFiles ! Number of files to read. Int_t fNoFilesRead ! Number of files opened so far. TIter* fNextSet ! Iterator for file set list TIter* fNextFile ! Iteraror for file list public:
static const UInt_t kBrJobFile ! For files that's opened @ job-lvl static const UInt_t kBrRunFile ! For files that's opened @ run-lvl static const UInt_t kBrEventFile ! For files that's opened @ event-lvl static const UInt_t kBrReadFile ! For read-only files static const UInt_t kBrWriteFile ! For write-only (new) files static const UInt_t kBrRecreateFile ! For write-only (overwrite) files static const UInt_t kBrUpdateFile ! For write-only (append) files


See also

BrEventIO, BrGeantInput, BrHistIOModule, BrOutputTreeModule, BrRawDataInput, BrRawDataOutput

Class Description

 BrIOModule

 BRAHMS IO Module Class

 A standard IO  Module should be derived from this base class. This
 ensure that the general framework is capable of accessing these in
 a common and general way.

 The methods (member functions) consists of a general set for all
 modules; but the user if free to add specific ones for specific
 needs. Ideas for this has been taken from both the PHOBOS tool set
 as well as from the BABAR framework.

 The initial version is derived using the ROOT base classes,

 This module can operate on sets of files and individual files.
 A file set is specified to the module by use of the AddFileSet
 method (currently two of them).

 The idea is, that one level, be it run or job level may need many
 input files for various reasons.

 For example, if one wants to process several runs, each of which
 has several files (sequences), then one may like to keep a tight
 coupling between the different levels of execution (for more on
 this, see The Hitchhikers Guide to BRAT and the BrModule class
 descriptition).  So suppose we wanted to analyse runs {r1, r2},
 each of which has the files {f<r>1, f<r>2, f<r>3}, then we should
 define or input module as:

    BrIOModule io = new <some sub class>
    io->SetIOMode(BrIOModule::kBrRunFile|BrModule::kBrRead);
    TObjArray* r1set = new TObjArray(3);

    // Defining the first set
    r1set->Add(new TObjArray(f11));
    r1set->Add(new TObjArray(f12));
    r1set->Add(new TObjArray(f13));
    // Adding the set to the module
    io->AddFileSet(r1set);

    // Defining the first set
    r2set->Add(new TObjArray(f21));
    r2set->Add(new TObjArray(f22));
    r2set->Add(new TObjArray(f23));
    // Adding the set to the module
    io->AddFileSet(r2set);

 If each run only has one file, then we must define our setup as:

    BrIOModule io = new <some sub class>
    io->SetIOMode(BrIOModule::kBrRunFile|BrModule::kBrRead);
    TObjArray* r1set = new TObjArray(3);

    // Adding the files
    io->AddFile(new TObjArray(f1));
    io->Addfile(new TObjArray(f2));

 Finally, if we have one run that has many files, we setup as

    BrIOModule io = new <some sub class>
    io->SetIOMode(BrIOModule::kBrJobFile|BrModule::kBrRead);
    TObjArray* r1set = new TObjArray(3);

    // Adding the files
    io->AddFile(new TObjArray(f1));
    io->Addfile(new TObjArray(f2));


 For IO modules that write to disk, only single element filesets
 makes sense.

 For the purpose of putting BrIOModules into a BrModuleContanier, we
 define 2 types of IO module:

   Job IO modules (kBrJobFile):
     These modules opens a file set once per job. The file is opened
     at Init time and closed at Finish time in case the module is a
     writer (see BrModule class description).  If the module is a
     reader, then it will open files from the file set in the event
     method as needed.

   Run IO modules (kBrRunFile):
     These modules opens a file set once per run, that is many times
     per job. If the module is a writer the files are opened at
     Begin time and closed at End time (see BrModule class
     description).  If the module is a reader, then it will open
     files from the file set in the event method as needed.

 Further, we also have 4 modes of how to handle the file(s) opened:

   Reader IO Module (kBrReadFile):
     These modules reads data from the file(s) and puts it into a
     BrEvent object (input node, see BrIOModule::Event below).
   Writer IO Module (kBrWriteFile):
     These modules writes passed BrEvent (output node, see
     BrIOModule::Event below) objects to file(s).
   Recreate IO Module (kBrWriteFile):
     Like a writer, but will override old file(s).
   Update IO Module (kBrUpdateFile):
     Like a writer, but will update old file(s).

 Derived classes can define more modes, should they see fit to do
 so.

 The mode of any module can be chosen by SetIOMode, using a bitwise
 or for more then one option e.g.,

   // First a container
   BrModuleContainer* cont =
     new BrModuleContainer("cont", "Container");

   // Then the input module
   BrIOModule* input       = new BrSomeInputModule("in", "Input");
   cont->AddModule(input);
   input->SetIOMode(kBrRunFile|kBrReadFile);
   input->AddFile("input01.root");
   input->AddFile("input02.root");
   // ... add more files
   input->AddFile("inputNN.root");

   // ... Add more modules, for example trackers, pids, and so on

   // Then the output module
   BrIOModule* output      = new BrSomeOutputModule("out", "Output");
   cont->AddModule(output);
   output->SetIOMode(kBrJobFile|kBrRecreateFile);
   output->AddFile("output.root");

   // Job initialise all modules, which includes opening output file
   cont->Init();
   // Check for errors, including open errors
   if (cont->GetStatus() != BrModule::kOk) return 1;

   // Run loop
   while (runs) {
     // Run initialise all modules, including opening input file
     cont->Begin();
     // Check for errors, including open errors
     if (cont->GetStatus() != BrModule::kOk) return 1;

     // Event loop
     while (events) {
        BrEvent* inEv  = new BrEvent("inEv", 0, 0);
        BrEvent* outEv = new BrEvent("outEv", 0, 0);

        // Read from file into inEv, does other modules, writes
        // outEv to output file
        cont->Event(inEv, outEv);
        // Check for errors, including read/write errors
        if (cont->GetStatus() != BrModule::kOk) return 1;
     }
     // Run finish all modules, inclding closing input file
     cont->End();
     // Cehck for errors
     if (cont->GetStatus() != BrModule::kOk) return 1;
   }
   // Job finish all modules, inclding closing output file
   cont->Finish(); // Closes output file
   // Check for errors
   if (cont->GetStatus() != BrModule::kOk) return 1;

	Author :	Flemming Videbaek
	Created:	27/12/97
	Version:	1.0

_____________________________________________________________________

~BrIOModule()
 Default destructor

void AddFile(const Char_t* filename)
 Add a file to list of file to process.

void AddFileSet(TObjArray* fileSet)
 Add a file to list of file to process.

void AddFileSet(const Char_t* dirname, const Char_t* regexp)
 Add all files in directory dirname that matches the regular
 expression regexp.  Syntax of regular expressions can be found in
 Emacs info pages.

 A prime example of use could be

   BrIOModule* io = new BrEventIO("input");
   io->SetIOMode(BrIOModule::kBrRunFile|BrIOModule::kBrReadFile);
   io->AddFileSet("/brahms/data03/crash/bm/seq",
                  "run0058[0-9]2\.root");

 Which will create a file set of all sequences of runs 5800 to
 5899 present in /brahms/data03/crash/bm/seq - quick way of
 crashing your computer :-)

void SetIOMode(UInt_t mode)
 Set the IO mode of this module. Should be a bitwise or of one of
   kBrJobFile        For files that last a full job
   kBrRunFile        For files that last only a run
   kBrEventFile      For files that last a subset of a run (EXPERIMENTAL)
 And one of
   kBrReadFile       For read-only files
   kBrWriteFile      For write-only (new) files
   kBrRecreateFile   For write-only (overwrite) files
   kBrUpdateFile     For write-only (append) files


void OpenNext()
 Private method: Open next file in list.  The name is stored in
 the internal member fFileName

void Init()
 If this is a Job IO module, try to open file

void Begin()
 Try to open file if this is a run io module

void Event(BrEvent* event)
 Default Event method with in/out Data objects. In normal
 application to be called once per event.
 Method should also be overwritten in the concrete class. A dummy
 routine is supplied in case a module for some strange reason is
 not called per event.


void Event(BrEventNode* inNode, BrEventNode* outNode)
 BrModule:Event() method with two BrEventNode arguments. This is
 done so that we may put BrIOModule in a module pipeline i.e., a
 BrModuleContainer.
 Which node is passes on to BrIOModule::Event is dependent on the
 kind of BrIOModule, as set by BrIOModule::SetIOMode().

  kBrWriteFile or kBrRecreateFile: The output node is passed on
  kBrReadFile or kBrUpdateFile:    The input node is passed on

 Please note, that the input and output node should be BrEvents,
 not just BrEventNodes.


void End()
 Try to close file if this is a run io module. We check to see if
 there's more sets to deal with.

void Finish()
 Try to close file if this is a job io module

void Print(Option_t* option) const
 Information module. In the final implementation this should be
 overwritten by the derived class. Here a default behaviour is
 implemented.



Inline Functions


               Bool_t Open(const Char_t*, const Option_t* option = "0")
               Bool_t Close()
               UInt_t GetIOMode() const
                Int_t GetIOStatus() const
                Int_t GetBytesRead() const
                Int_t GetBytesWritten() const
        const Char_t* GetFileName() const
                Int_t GetNoFiles() const
                Int_t GetNoFilesRead() const
               Bool_t IsEof() const
               Bool_t IsError() const
              TClass* Class()
              TClass* IsA() const
                 void ShowMembers(TMemberInspector& insp, char* parent)
                 void Streamer(TBuffer& b)
                 void StreamerNVirtual(TBuffer& b)

This page automatically generated by script docBrat by Christian Holm

Copyright ; 2002 BRAHMS Collaboration <brahmlib@rcf.rhic.bnl.gov>
Last Update on 2002/06/13 17:22:58 $ by videbaek $

Validate HTML
Validate CSS