// -*- mode: c++ -*- // // $Id: BrEventIO.h,v 1.3 2001/08/21 16:05:38 cholm Exp $ // // /////////////////////////////////////////////////////////////////////// // // // // // Author : K. Hagel // // Created : July 98 // // Version : 1.0 // // Changed : // // // /////////////////////////////////////////////////////////////////////// #ifndef BRAT_BrEventIO #define BRAT_BrEventIO #ifndef WIN32 #include #else #include #endif #ifndef ROOT_TObject #include "TObject.h" #endif #ifndef ROOT_TFile #include "TFile.h" #endif #ifndef ROOT_TTree #include "TTree.h" #endif #ifndef ROOT_TKey #include "TKey.h" #endif #ifndef ROOT_TBrowser #include "TBrowser.h" #endif #ifndef BRAT_BrIOModule #include "BrIOModule.h" #endif #ifndef BRAT_BrDataTable #include "BrDataTable.h" #endif #ifndef BRAT_BrFileTag #include "BrFileTag.h" #endif #define MaxNumEventBranches 50 class BrEventIO : public BrIOModule { private: Bool_t InitializeRootSerialFile(); Bool_t InitializeRootTreeFile(); void ProcessRootSerialFile(BrEvent *event); void ProcessRootTreeFile(BrEvent *event); 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[MaxNumEventBranches]; //Branch for that tree Int_t fBufsize; //Buffer size for tree Int_t fSplit; //Split mode? // Int_t fNumBytesWritten; //Number of bytes written // Int_t fNumBytesRead; //Number of bytes read 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 public: BrEventIO(); BrEventIO(const Char_t *name, const Char_t* title=0); virtual ~BrEventIO(); virtual Bool_t Open(const Char_t *fname,const Option_t *option); virtual Bool_t Close(); virtual void Event(BrEvent* event); virtual Bool_t SkipEvent(Int_t numevt); virtual BrFileTag::EFileMode GetFileMode() const { return fFileMode; } virtual void SetFileMode(BrFileTag::EFileMode mode); virtual void SetTreeParameters(Int_t bufSize=32000, Int_t split=99); virtual TFile* GetROOTFile(void) { return fROOTFile; } virtual Bool_t IsFolder(void) const { return kTRUE; } virtual void Browse(TBrowser* b); virtual void Print(Option_t* option="") const; friend ostream& operator<< (ostream& os,BrEventIO* digio_p); friend ostream& operator<< (ostream& os,BrEventIO& digio_p); ClassDef(BrEventIO, 0) // Read/write GBRAHMS Event data in ROOT format }; #endif // $Log: BrEventIO.h,v $ // Revision 1.3 2001/08/21 16:05:38 cholm // Added a method to set the buffer size and split level on the TTrees. // It turned out, that with the default setting (64000, 1), we (@ nbi) // got serious problems reading back files. An investigation gave: // // buffer // split 100 2000 4000 6400 16000 32000 // 0 n/a n/a ok bad n/a n/a // 2 ok n/a n/a ok ok ok // 99 ok n/a n/a ok ok ok // // n/a means I was lazy and didn't do the test. I've set the default to // 32000/1. See also the ROOT Users Guide chapter 12. // // Revision 1.2 2001/06/22 11:20:07 cholm // Set version number to 0, since this class should not be persistent // // Revision 1.1.1.1 2001/06/21 14:55:07 hagel // Initial revision of brat2 // // Revision 1.11 2001/06/04 13:35:46 cholm // Changes to use BrPathManager, BrVersion, and perpare to use BrFileTag. // // Revision 1.10 2001/03/07 12:15:22 cholm // * Defined standard BrModule methods in BrIOModule. // * Add the (simple) class BrHistIOModule. // * BrAppOptionManager and BrAppOption classes changed to not use // BrExceptions. // * Added the method Int_t BrMainModule::Main() to do EVERYTHING. // * Made the method BrModule::Info() const obsolete in favour of // BrModule::Print(Option_t* option="B") const. Impact on other classes. // // Revision 1.9 2000/10/03 19:29:46 cholm // Made IsFolder() const (since it is in TObject) which was needed for the // objects to be browsable. Aslo, as of ROOT version 2.25.02 there's a list // of special objects, which BrEventIO now is added to. Some doc to // BrEventNode::Clear() added! Added method BrEventNode::SetOwner(). // Christian Holm // // Revision 1.8 2000/06/28 09:03:00 hagel // Added const to various char's in BrEventIO + BrIOMOdule // // Revision 1.7 2000/06/03 18:17:03 videbaek // Changed inheritance of BrIOModule. Added utility to BrDataObject.. See Update message for more info // // Revision 1.6 2000/04/14 21:59:54 cholm // Revisited build system completly. See brahms-dev-l archive // for more information // // Revision 1.5 2000/04/13 00:01:58 cholm // Added methods for browsing BrEvents, either directly or via // a BrEventIO. Also added method GetROOTFile to BrEventIO. // // Revision 1.4 1999/10/22 18:32:53 videbaek // Added code for getting bytes read written properly. // Now all in base Class BrIOModule // // Revision 1.3 1999/01/21 23:23:19 hagel // 1. Changed convention for checking includes. Current convention is: // BRAT_Br...... eg BRAT_BrModule ala ROOT. // 2. Added CVS logs to .h files that didn't have them. // 3. Moved checking of include definition to first line for easier reading // 4. Put checks before all includes in the include files as per BRAT specifications // 5. Added BrGeantHeader to Geant Makefile // 6. All changes have been checked to compile on NT ala Cygnus // // Revision 1.2 1998/09/28 21:03:03 videbaek // Added cvs log id //