AliRoot Core  ee782a0 (ee782a0)
TTreeStream.h
Go to the documentation of this file.
1 #ifndef TTREESTREAM_H
2 #define TTREESTREAM_H
3 // //
5 // TTreeSRedirector //
6 
7 #include "TObject.h"
8 #include "TString.h"
9 #include "TTree.h"
10 #include "TDirectory.h"
11 #include "TFile.h"
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:
25 
28 
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
33  ClassDef(TTreeDataElement,2)
34 };
35 
36 class TTreeStream: public TNamed {
37  friend class TTreeSRedirector;
38 public:
39  TTreeStream(const char *treename, TTree* externalTree=NULL);
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();
48  Double_t GetSize(){ return fTree->GetZipBytes();}
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;}
65  TTreeStream &operator<<(const Char_t *name);
66  TTree * GetTree() const { return fTree;}
67  protected:
68  //
69 
70  TTreeStream(const TTreeStream & ts);
71  TTreeStream & operator=(const TTreeStream & ts);
72 
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
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 class TTreeSRedirector: public TObject {
86 public:
87  TTreeSRedirector(const char *fname="", const char * option="update");
88  virtual ~TTreeSRedirector();
89  void Close();
90  static void Test();
91  static void Test2();
92  static void UnitTestSparse(Double_t scale, Int_t testEntries);
93  static void UnitTest(Int_t testEntries=5000);
94  void StoreObject(TObject* object);
95  TFile * GetFile() {return fDirectory->GetFile();}
96  TDirectory * GetDirectory() {return fDirectory;}
97  virtual TTreeStream &operator<<(Int_t id);
98  virtual TTreeStream &operator<<(const char *name);
99  void SetDirectory(TDirectory *sfile);
100  void SetFile(TFile *sfile) {SetDirectory(sfile);}
101  void SetExternalTree(const char* name, TTree* externalTree);
102  static void SetDisabled(Bool_t b=kTRUE) {fgDisabled=b;}
103  static Bool_t IsDisabled() {return fgDisabled;}
104  static void FixLeafNameBug(TTree* tree);
105 private:
106 
107  TTreeSRedirector(const TTreeSRedirector & tsr);
109 
110  TDirectory* fDirectory; //file
111  Bool_t fDirectoryOwner; //do we own the directory?
112  TObjArray *fDataLayouts; //array of data layouts
113  static Bool_t fgDisabled; //disable - do not open any files
114  ClassDef(TTreeSRedirector,2)
115 };
116 
117 
118 
119 
120 #endif
TBrowser b
Definition: RunAnaESD.C:12
TTreeStream & operator<<(ULong_t &l)
Definition: TTreeStream.h:59
TTreeStream & operator<<(UInt_t &i)
Definition: TTreeStream.h:57
Char_t GetType() const
Definition: TTreeStream.h:23
TTreeStream & operator<<(Long64_t &l)
Definition: TTreeStream.h:60
TTree * fTree
Definition: MakeTreeStat.C:55
Double_t GetSize()
Definition: TTreeStream.h:48
#define TObjArray
TTreeStream & operator<<(Short_t &h)
Definition: TTreeStream.h:54
TString fNextName
Definition: TTreeStream.h:78
TFile * GetFile()
Definition: TTreeStream.h:95
TTreeStream & operator<<(Char_t &c)
Definition: TTreeStream.h:52
TTreeStream & operator<<(Int_t &i)
Definition: TTreeStream.h:56
TTreeStream & operator<<(Float_t &f)
Definition: TTreeStream.h:62
TDirectory * GetDirectory()
Definition: TTreeStream.h:96
TObjArray * fBranches
Definition: TTreeStream.h:74
TClass * fClass
Definition: TTreeStream.h:31
TTreeStream & operator<<(Bool_t &b)
Definition: TTreeStream.h:51
void SetPointer(void *pointer)
Definition: TTreeStream.h:22
Float_t scale[5]
Int_t fNextNameCounter
Definition: TTreeStream.h:79
TObjArray * fElements
Definition: TTreeStream.h:73
static void SetDisabled(Bool_t b=kTRUE)
Definition: TTreeStream.h:102
Bool_t fDirectoryOwner
Definition: TTreeStream.h:111
TTree * tree
Int_t fCurrentIndex
Definition: TTreeStream.h:76
TDataType * fDType
Definition: TTreeStream.h:30
static void Test()
TTreeStream & operator<<(UChar_t &c)
Definition: TTreeStream.h:53
TObjArray * fDataLayouts
Definition: TTreeStream.h:112
TDirectory * fDirectory
Definition: TTreeStream.h:110
TTreeDataElement(Char_t type)
TTreeStream & operator<<(Double_t &d)
Definition: TTreeStream.h:63
TTreeStream & operator<<(ULong64_t &l)
Definition: TTreeStream.h:61
TTreeStream & operator<<(Long_t &l)
Definition: TTreeStream.h:58
void StoreObject(const char *cdbPath, TObject *object, AliCDBMetaData *metaData)
TF1 * f
Definition: interpolTest.C:21
TTree * fTree
Definition: TTreeStream.h:75
ostream & operator<<(ostream &stream, const AliMpIntPair &op)
static Bool_t fgDisabled
Definition: TTreeStream.h:113
TTree * GetTree() const
Definition: TTreeStream.h:66
static Bool_t IsDisabled()
Definition: TTreeStream.h:103
TTreeStream & operator<<(UShort_t &h)
Definition: TTreeStream.h:55
void SetFile(TFile *sfile)
Definition: TTreeStream.h:100
Int_t fStatus
Definition: TTreeStream.h:80
friend class TTreeStream
Definition: TTreeStream.h:17
char * fname
TTreeDataElement & operator=(const TTreeDataElement &tde)
TTreeStream & operator<<(TObject *o)
Definition: TTreeStream.h:64