00001 00015 #ifndef ROOTINPUTFILE_H 00016 #define ROOTINPUTFILE_H 00017 00018 #include "DybKernel/MsgStreamMember.h" 00019 00020 #include <string> 00021 #include <vector> 00022 00023 class TFile; 00024 class TTree; 00025 00026 class RootInputFile { 00027 std::string m_filename; 00028 std::string m_treepath; 00029 std::string m_branchname; 00030 TFile* m_file; 00031 TTree* m_tree; 00032 int m_entry, m_entries; 00033 void* m_addr; 00034 00035 Dyb::MsgStreamMember log; 00036 00037 public: 00038 // Return list of all treepaths found in given file. 00039 static std::vector<std::string> TreePaths(const std::string& filename); 00040 00041 // Return non zero if a branch of the given name at the given 00042 // treepath in the given file is found and is a subclass of 00043 // RootIOBaseObject. The non zero return value is the object's 00044 // class ID. 00045 static int TestForObject(const std::string& filename, 00046 const std::string& treepath, 00047 const std::string& branchname); 00048 00049 00050 RootInputFile(const std::string& filename, 00051 const std::string& treepath, 00052 const std::string& branchname); 00053 ~RootInputFile(); 00054 00055 const std::string& treepath() { return m_treepath; } 00056 const std::string& branchname() { return m_branchname; } 00057 const std::string& filename() { return m_filename; } 00058 00060 bool open(); 00061 00063 bool leave(); 00064 00066 int entry(); 00067 00069 bool setEntry(int entry); 00070 00073 bool read(void* addr); 00074 00076 bool read(void* addr, int& nbytes); 00077 00079 bool setAddr(void* addr); 00080 00082 int entries(); 00083 00085 bool next(int steps = 1); 00086 00088 bool beginning(); 00090 bool ending(); 00091 00093 bool prev(int steps = 1); 00094 00095 }; 00096 00097 class RootInputFileList : public std::vector<RootInputFile*> { 00098 int m_index; // current 00099 Dyb::MsgStreamMember log; 00100 public: 00101 RootInputFileList(); 00102 ~RootInputFileList(); 00103 00105 int index(); 00106 00108 RootInputFile* current(); 00109 00111 bool next(); 00112 00114 bool prev(); 00115 00117 bool last(); 00118 00120 bool first(); 00121 00123 bool jump(int index); 00124 00127 int entriesBefore(int index); 00128 00129 }; 00130 00131 #endif // ROOTINPUTFILE_H