]>
Commit | Line | Data |
---|---|---|
cd246117 | 1 | #ifndef TTREESTREAM_H |
2 | #define TTREESTREAM_H | |
3 | /////////////////////////////////////////////////////////////////////////////// | |
4 | // // | |
5 | // TTreeSRedirector // | |
6 | ||
7 | #include "TObject.h" | |
8 | #include "TString.h" | |
9 | class TFile; | |
10 | class TObjArray; | |
11 | class TTree; | |
12 | class TDataType; | |
13 | ||
14 | class TTreeDataElement: public TNamed { | |
15 | friend class TTreeStream; | |
16 | public: | |
17 | TTreeDataElement(Char_t type); | |
18 | TTreeDataElement(TDataType* type); | |
19 | TTreeDataElement(TClass* cl); | |
20 | void SetPointer(void* pointer) {fPointer=pointer;} | |
21 | Char_t GetType() const {return fType;} | |
22 | protected: | |
23 | TString fName; // name of the data element | |
24 | Char_t fType; // type of data element | |
25 | TDataType *fDType; //data type pointer | |
26 | TClass *fClass; //data type pointer | |
27 | void * fPointer; // pointer to element | |
28 | ClassDef(TTreeDataElement,1) | |
29 | }; | |
30 | ||
31 | class TTreeStream: public TNamed { | |
32 | friend class TTreeSRedirector; | |
33 | public: | |
34 | TTreeStream(const char *treename); | |
35 | ~TTreeStream(); | |
36 | void Close(); | |
37 | static void Test(); | |
38 | Int_t CheckIn(Char_t type, void *pointer); | |
39 | //Int_t CheckIn(const char *type, void *pointer); | |
40 | Int_t CheckIn(TObject *o); | |
41 | void BuildTree(); | |
42 | void Fill(); | |
43 | TTreeStream& Endl(); | |
44 | // | |
45 | TTreeStream &operator<<(Bool_t &b){CheckIn('B',&b);return *this;} | |
46 | TTreeStream &operator<<(Char_t &c){CheckIn('B',&c);return *this;} | |
47 | TTreeStream &operator<<(UChar_t &c){CheckIn('b',&c);return *this;} | |
48 | TTreeStream &operator<<(Short_t &h){CheckIn('S',&h);return *this;} | |
49 | TTreeStream &operator<<(UShort_t &h){CheckIn('s',&h);return *this;} | |
50 | TTreeStream &operator<<(Int_t &i){CheckIn('I',&i);return *this;} | |
51 | TTreeStream &operator<<(UInt_t &i){CheckIn('i',&i);return *this;} | |
52 | TTreeStream &operator<<(Long_t &l){CheckIn('L',&l);return *this;} | |
53 | TTreeStream &operator<<(ULong_t &l){CheckIn('l',&l);return *this;} | |
54 | TTreeStream &operator<<(Long64_t &l){CheckIn('L',&l);return *this;} | |
55 | TTreeStream &operator<<(ULong64_t &l){CheckIn('l',&l);return *this;} | |
56 | TTreeStream &operator<<(Float_t &f){CheckIn('F',&f);return *this;} | |
57 | TTreeStream &operator<<(Double_t &d){CheckIn('D',&d);return *this;} | |
58 | TTreeStream &operator<<(TObject*o){CheckIn(o);return *this;} | |
59 | TTreeStream &operator<<(Char_t *name); | |
60 | protected: | |
61 | // | |
62 | TObjArray *fElements; //array of elements | |
63 | TObjArray *fBranches; //pointers to branches | |
64 | TTree *fTree; //data storage | |
65 | Int_t fCurrentIndex; //index of current element | |
66 | Int_t fId; //identifier of layout | |
cd246117 | 67 | TString fNextName; //name for next entry |
68 | Int_t fNextNameCounter; //next name counter | |
69 | Int_t fStatus; //status of the layout | |
70 | ClassDef(TTreeStream,1) | |
71 | }; | |
72 | ||
73 | ||
74 | ||
75 | class TTreeSRedirector: public TObject { | |
76 | public: | |
77 | TTreeSRedirector(const char *fname); | |
78 | ~TTreeSRedirector(); | |
79 | void Close(); | |
80 | static void Test(); | |
81 | virtual TTreeStream &operator<<(Int_t id); | |
82 | virtual TTreeStream &operator<<(const char *name); | |
83 | private: | |
84 | TFile* fFile; //file | |
85 | TObjArray *fDataLayouts; //array of data layouts | |
86 | ClassDef(TTreeSRedirector,1) | |
87 | }; | |
88 | ||
89 | ||
90 | ||
91 | ||
92 | #endif |