00001 /* 00002 * 00003 * RRawStream, input stream for rraw type raw data. 00004 * It provides some similar operations like ifstream to handle root TTree. 00005 * BTW rraw is just root tree. 00006 * 00007 * Zhe Wang 00008 * Feb. 10, 2010 at BNL 00009 * 00010 */ 00011 00012 #ifndef _RRAW_STREAM_H_ 00013 #define _RRAW_STREAM_H_ 00014 00015 #include "IInputStream.h" 00016 #include <iostream> 00017 #include <fstream> 00018 #include "TFile.h" 00019 #include "TTree.h" 00020 00021 using namespace std; 00022 00023 // Must be 32 bits to be consistent with online DAQ system 00024 typedef Int_t Int32; 00025 00026 class RRawStream:public IInputStream 00027 { 00028 public: 00029 RRawStream(); 00030 RRawStream( const char * filename ); 00031 virtual ~RRawStream(); 00032 00034 void close ( ); 00035 void open ( const char * filename ); 00036 bool is_open ( ) const ; 00037 bool good ( ) const; 00038 00039 bool operator ! ( ) const; 00040 00041 RRawStream& read ( char* s, int n ); 00042 RRawStream& ignore ( int n = 1 ); 00043 00044 private: 00045 00046 TFile *m_file; 00047 TTree *m_tree; 00048 00049 Int32 m_buffer[50000]; 00050 Int32 m_size; 00051 00052 // current entry number in the tree 00053 Int32 m_currentEntry; 00054 00055 // current pointer position in current entry counted by char 00056 Int32 m_currentPosi; 00057 00058 // Mark true if reach the end of one entry, and read in anothor new entry. 00059 bool m_entryEnd; 00060 }; 00061 00062 #endif // _RRAW_STREAM_H_ 00063 00064 00065 00066 // Local Variables: ** 00067 // c-basic-offset:2 ** 00068 // indent-tabs-mode:nil ** 00069 // End: **