StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTree.h
1 #ifndef ROOT_StTree
2 #define ROOT_StTree
3 
4 
5 
6 #include "TSystem.h"
7 #include "TROOT.h"
8 #include "TFile.h"
9 #include "TList.h"
10 #include "TDataSet.h"
11 #include "St_ObjectSet.h"
12 #include "TDataSetIter.h"
13 #include "StFileI.h"
14 
15 
16 
17 class StIO
18 {
19 
20  public:
21 
22  static Int_t Write (TFile *file, const StUKey &ukey, TObject *obj);
23  static TObject *Read (TFile *file, const char *name);
24  static TObject *Read (TFile *file, const StUKey &ukey);
25  static Int_t GetNextKey(TFile *file, StUKey &ukey, ULong_t &handle);
26  static TObject *ReadNext (TFile *file, StUKey &ukey, ULong_t &handle);
27  static TString RFIOName (const char *name);
28  static TFile *Open (const char *name, Option_t *option="",const char *title="",Int_t compress=1);
29  static Int_t IfExi(const char *file);
30  static void SetDebug(Int_t dblev=1){fgDebug=dblev;}
31  static Int_t fgDebug;
32 };
33 
34 class StTree;
35 class StBranch : public TDataSet {
36 //friend class StBranch;
37 friend class StTree;
38 public:
39  StBranch(const char *name="", StTree* parent=0,Option_t *opt=0);
40  ~StBranch();
41 
42  virtual void SetIOMode(Option_t *iomode="0");
43  virtual Option_t *GetIOMode();
44  virtual void SetOption(Option_t *opt);
45  virtual Option_t *GetOption() const {return fOption;};
46  virtual Bool_t IsOption(Option_t *opt) const
47  {return fOption.Contains(opt,TString::kIgnoreCase);};
48  virtual Int_t UpdateFile(const char *file);
49  virtual const char *GetFile();
50  virtual Int_t SetFile(const char *file,const char *iomode=0,int insist=0);
51  virtual Int_t SetTFile(TFile *tfile);
52  virtual TFile *GetTFile(){return fTFile;};
53  virtual void SetName(const char *name){fUKey=name;TDataSet::SetName(name);};
54  virtual void SetUKey(Int_t ukey){fUKey=ukey;};
55  virtual StUKey GetUKey() const {return fUKey;};
56  virtual Int_t GetNEvents() const {return fNEvents;};
57  virtual Int_t GetEvent(Int_t mode);
58  virtual Int_t ReadEvent (const StUKey &ukey);
59  virtual Int_t NextEvent ( StUKey &ukey);
60  virtual Int_t NextEvent ();
61  virtual Int_t WriteEvent(const StUKey &ukey);
62  virtual void Clear(const char *opt=0);
63  virtual void Close(const char *opt=0);
64  virtual Int_t Open();
65  virtual Int_t GetDebug(){return fDebug;};
66  virtual void SetDebug(int dbl=1){fDebug=dbl;};
67 
68 protected:
69  virtual void OpenTFile();
70  void SetParAll(TDataSet *parNew,TDataSet *parOld, TList *savList);
71  void SetParAll(TList *savList);
72  Int_t fNEvents; // Number of written events in file
73  StUKey fUKey;
74  char fIOMode;
75  TString fFile; // File name
76  TString fOption; // Option string
77  TFile *fTFile;
78  Int_t fDebug;
79  ULong_t fHandle;
80 ClassDef(StBranch,1)
81 };
82 
83 
84 class StTree : public StBranch {
85 public:
86  StTree(const char *name="");
87  ~StTree();
88 
89  virtual void SetIOMode (Option_t *iomode="0"); //Set for all branches
90  virtual Int_t ReadEvent (const StUKey &ukey);
91  virtual Int_t NextEvent ( StUKey &ukey);
92  virtual Int_t NextEvent ();
93  Int_t NextKey();
94  Int_t Skip(int nskip);
95  virtual Int_t WriteEvent(const StUKey &ukey);
96  virtual void Close(const char *opt=0);
97  virtual Int_t Open();
98  virtual void Clear(Option_t *opt="");
99  virtual Int_t SetFile(const char *file,const char *iomode=0,int insist=0);
100  virtual void SetBaseName(const char* basename,const char* dirname=0);
101  virtual const char *GetBaseName()
102  {return (fBaseName.IsNull()) ? 0:(const char*)fBaseName;};
103  static StTree *GetTree(TFile *file, const char *treeName);
104  virtual Int_t UpdateFile(const char *file);
105 
106 protected:
107  TString fBaseName; //base name to construct branch file name
108  // as <basename>.<branchname>.root
109 ClassDef(StTree,1)
110 };
111 
112 // Auxiliary class for StIO only.
113 class StIOEvent : public TObject
114 {
115 public:
116  StIOEvent();
117  ~StIOEvent(){};
118 TObject *fObj; // Pointer to full tree
119  virtual void Browse(TBrowser *b);
120  virtual Bool_t IsFolder() const { return kTRUE; }
121 
122 ClassDef(StIOEvent,1)
123 };
124 
125 class StFile : public StFileI
126 {
127 public:
128  StFile(const char** fileList=0);
129  virtual ~StFile();
130 
131  virtual void ls(Option_t *opt="") ;
132  virtual void ls(Option_t *opt="") const{ ((StFile*)this)->ls(opt);}
133  virtual Int_t AddFile(const char *file,const char *opt=0); //opt="remove" or "exclude" remove file from list
134  virtual Int_t AddFile(const char **fileList);
135  virtual Int_t AddWild(const char *file,const char *opt=0);
136  virtual Int_t AddEvent(UInt_t r,UInt_t e=0);
137  virtual Int_t GetNBundles();
138  virtual Int_t GetNFiles();
139  virtual Int_t GetBundleSize(){return 1;};
140  virtual StUKey GetNextEvent();
141  virtual Int_t GetNextEvent(UInt_t *NextEventNumber){return StFileI::GetNextEvent(NextEventNumber);}
142 
143  virtual const char *GetFileName(Int_t idx=-1);
144  virtual const char *GetCompName(Int_t idx=0);
145  virtual const char *GetFormat(Int_t idx=0);
146  virtual Int_t GetNextBundle();
147  virtual void Rewind(){fIter = -1; delete fKeyIter; fKeyIter =0;}
148 
149 protected:
150  void lsFull(Option_t *opt="") ;
151  void SetInfo(TDataSet *ds);
152  const char *GetAttr(TDataSet *ds,const char *att);
153  TDataSet *GetFileDS(int idx);
154  TDataSet *fDS;
155  Int_t fIter;
156  TDataSetIter *fKeyIter;
157  ClassDef(StFile,1)
158 };
159 #endif
TString fFile
1=ReadOnly; 2=WriteOnly; 1+2=Update;0=do nothing
Definition: StTree.h:75
char fIOMode
Current RunEvent number.
Definition: StTree.h:74
Definition: StTree.h:125
Definition: StTree.h:17
ULong_t fHandle
debug level
Definition: StTree.h:79
Int_t fDebug
Opened TFile.
Definition: StTree.h:78
Definition: StFileI.h:13
Definition: StTree.h:84