]>
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" | |
06c19f2e | 9 | #include "TTree.h" |
b857113b | 10 | #include "TDirectory.h" |
11 | #include "TFile.h" | |
cd246117 | 12 | class TObjArray; |
13 | class TTree; | |
14 | class TDataType; | |
15 | ||
16 | class TTreeDataElement: public TNamed { | |
17 | friend class TTreeStream; | |
18 | public: | |
19 | TTreeDataElement(Char_t type); | |
20 | TTreeDataElement(TDataType* type); | |
21 | TTreeDataElement(TClass* cl); | |
22 | void SetPointer(void* pointer) {fPointer=pointer;} | |
23 | Char_t GetType() const {return fType;} | |
24 | protected: | |
90e48c0c | 25 | |
26 | TTreeDataElement(const TTreeDataElement & tde); | |
27 | TTreeDataElement & operator=(const TTreeDataElement & tde); | |
28 | ||
cd246117 | 29 | Char_t fType; // type of data element |
30 | TDataType *fDType; //data type pointer | |
31 | TClass *fClass; //data type pointer | |
32 | void * fPointer; // pointer to element | |
fdf65bb5 | 33 | ClassDef(TTreeDataElement,2) |
cd246117 | 34 | }; |
35 | ||
36 | class TTreeStream: public TNamed { | |
37 | friend class TTreeSRedirector; | |
38 | public: | |
b857113b | 39 | TTreeStream(const char *treename, TTree* externalTree=NULL); |
cd246117 | 40 | ~TTreeStream(); |
41 | void Close(); | |
42 | static void Test(); | |
43 | Int_t CheckIn(Char_t type, void *pointer); | |
44 | //Int_t CheckIn(const char *type, void *pointer); | |
45 | Int_t CheckIn(TObject *o); | |
46 | void BuildTree(); | |
47 | void Fill(); | |
06c19f2e | 48 | Double_t GetSize(){ return fTree->GetZipBytes();} |
cd246117 | 49 | TTreeStream& Endl(); |
50 | // | |
51 | TTreeStream &operator<<(Bool_t &b){CheckIn('B',&b);return *this;} | |
52 | TTreeStream &operator<<(Char_t &c){CheckIn('B',&c);return *this;} | |
53 | TTreeStream &operator<<(UChar_t &c){CheckIn('b',&c);return *this;} | |
54 | TTreeStream &operator<<(Short_t &h){CheckIn('S',&h);return *this;} | |
55 | TTreeStream &operator<<(UShort_t &h){CheckIn('s',&h);return *this;} | |
56 | TTreeStream &operator<<(Int_t &i){CheckIn('I',&i);return *this;} | |
57 | TTreeStream &operator<<(UInt_t &i){CheckIn('i',&i);return *this;} | |
58 | TTreeStream &operator<<(Long_t &l){CheckIn('L',&l);return *this;} | |
59 | TTreeStream &operator<<(ULong_t &l){CheckIn('l',&l);return *this;} | |
60 | TTreeStream &operator<<(Long64_t &l){CheckIn('L',&l);return *this;} | |
61 | TTreeStream &operator<<(ULong64_t &l){CheckIn('l',&l);return *this;} | |
62 | TTreeStream &operator<<(Float_t &f){CheckIn('F',&f);return *this;} | |
63 | TTreeStream &operator<<(Double_t &d){CheckIn('D',&d);return *this;} | |
64 | TTreeStream &operator<<(TObject*o){CheckIn(o);return *this;} | |
4f57cad7 | 65 | TTreeStream &operator<<(const Char_t *name); |
b9d891a4 | 66 | TTree * GetTree() const { return fTree;} |
cd246117 | 67 | protected: |
68 | // | |
90e48c0c | 69 | |
70 | TTreeStream(const TTreeStream & ts); | |
71 | TTreeStream & operator=(const TTreeStream & ts); | |
72 | ||
cd246117 | 73 | TObjArray *fElements; //array of elements |
74 | TObjArray *fBranches; //pointers to branches | |
75 | TTree *fTree; //data storage | |
76 | Int_t fCurrentIndex; //index of current element | |
77 | Int_t fId; //identifier of layout | |
cd246117 | 78 | TString fNextName; //name for next entry |
79 | Int_t fNextNameCounter; //next name counter | |
80 | Int_t fStatus; //status of the layout | |
81 | ClassDef(TTreeStream,1) | |
82 | }; | |
83 | ||
84 | ||
85 | ||
86 | class TTreeSRedirector: public TObject { | |
87 | public: | |
b857113b | 88 | TTreeSRedirector(const char *fname="", const char * option="new"); |
9996a03b | 89 | virtual ~TTreeSRedirector(); |
cd246117 | 90 | void Close(); |
91 | static void Test(); | |
b857113b | 92 | static void Test2(); |
7050703f | 93 | static void UnitTestSparse(Double_t scale); |
94 | static void UnitTest(); | |
df1e0cdc | 95 | void StoreObject(TObject* object); |
b857113b | 96 | TFile * GetFile() {return fDirectory->GetFile();} |
97 | TDirectory * GetDirectory() {return fDirectory;} | |
cd246117 | 98 | virtual TTreeStream &operator<<(Int_t id); |
99 | virtual TTreeStream &operator<<(const char *name); | |
b857113b | 100 | void SetDirectory(TDirectory *sfile); |
101 | void SetFile(TFile *sfile) {SetDirectory(sfile);} | |
102 | void SetExternalTree(const char* name, TTree* externalTree); | |
103 | ||
104 | private: | |
90e48c0c | 105 | |
106 | TTreeSRedirector(const TTreeSRedirector & tsr); | |
107 | TTreeSRedirector & operator=(const TTreeSRedirector & tsr); | |
108 | ||
b857113b | 109 | TDirectory* fDirectory; //file |
110 | Bool_t fDirectoryOwner; //do we own the directory? | |
cd246117 | 111 | TObjArray *fDataLayouts; //array of data layouts |
b857113b | 112 | ClassDef(TTreeSRedirector,2) |
cd246117 | 113 | }; |
114 | ||
115 | ||
116 | ||
117 | ||
118 | #endif |