Logo ROOT   6.14/05
Reference Guide
tree.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_tree
3 /// \notebook
4 /// Display the Tree data structures
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author Rene Brun
10 
11 void tree() {
12  TCanvas* c1 = new TCanvas("c1","Tree Data Structure",200,10,750,940);
13  c1->Range(0,-0.1,1,1.15);
14 
15  gBenchmark->Start("tree");
16 
17  Int_t branchcolor = 26;
18  Int_t leafcolor = 30;
19  Int_t basketcolor = 42;
20  Int_t offsetcolor = 43;
21  TPaveLabel* title = new TPaveLabel(.3,1.05,.8,1.13,c1->GetTitle());
22  title->SetFillColor(16);
23  title->Draw();
24  TPaveText* treePave = new TPaveText(.01,.75,.15,1.00);
25  treePave->SetFillColor(18);
26  treePave->SetTextAlign(12);
27  TText *tnt = treePave->AddText("Tree");
28  tnt->SetTextAlign(22);
29  tnt->SetTextSize(0.030);
30  treePave->AddText("fScanField");
31  treePave->AddText("fMaxEventLoop");
32  treePave->AddText("fMaxVirtualSize");
33  treePave->AddText("fEntries");
34  treePave->AddText("fDimension");
35  treePave->AddText("fSelectedRows");
36  treePave->Draw();
37  TPavesText* farm = new TPavesText(.01,1.02,.15,1.1,9,"tr");
38  TText *tfarm = farm->AddText("CHAIN");
39  tfarm->SetTextSize(0.024);
40  farm->AddText("Collection");
41  farm->AddText("of Trees");
42  farm->Draw();
43  TLine* llink = new TLine(.15,.92,.80,.92);
44  llink->SetLineWidth(2);
45  llink->SetLineColor(1);
46  llink->Draw();
47  llink->DrawLine(.21,.87,.21,.275);
48  llink->DrawLine(.23,.87,.23,.375);
49  llink->DrawLine(.25,.87,.25,.775);
50  llink->DrawLine(.41,.25,.41,-.025);
51  llink->DrawLine(.43,.25,.43,.075);
52  llink->DrawLine(.45,.25,.45,.175);
53  TPaveLabel* branch0 = new TPaveLabel(.20,.87,.35,.97,"Branch 0");
54  branch0->SetTextSize(0.35);
55  branch0->SetFillColor(branchcolor);
56  branch0->Draw();
57  TPaveLabel* branch1 = new TPaveLabel(.40,.87,.55,.97,"Branch 1");
58  branch1->SetTextSize(0.35);
59  branch1->SetFillColor(branchcolor);
60  branch1->Draw();
61  TPaveLabel* branch2 = new TPaveLabel(.60,.87,.75,.97,"Branch 2");
62  branch2->SetTextSize(0.35);
63  branch2->SetFillColor(branchcolor);
64  branch2->Draw();
65  TPaveLabel* branch3 = new TPaveLabel(.80,.87,.95,.97,"Branch 3");
66  branch3->SetTextSize(0.35);
67  branch3->SetFillColor(branchcolor);
68  branch3->Draw();
69  TPaveLabel* leaf0 = new TPaveLabel(.4,.75,.5,.8,"Leaf 0");
70  leaf0->SetFillColor(leafcolor);
71  leaf0->Draw();
72  TPaveLabel* leaf1 = new TPaveLabel(.6,.75,.7,.8,"Leaf 1");
73  leaf1->SetFillColor(leafcolor);
74  leaf1->Draw();
75  TPaveLabel* leaf2 = new TPaveLabel(.8,.75,.9,.8,"Leaf 2");
76  leaf2->SetFillColor(leafcolor);
77  leaf2->Draw();
78  TPaveText* firstevent = new TPaveText(.4,.35,.9,.4);
79  firstevent->AddText("First event of each basket");
80  firstevent->AddText("Array of fMaxBaskets Integers");
81  firstevent->SetFillColor(basketcolor);
82  firstevent->Draw();
83  TPaveLabel* basket0 = new TPaveLabel(.4,.25,.5,.3,"Basket 0");
84  basket0->SetFillColor(basketcolor);
85  basket0->Draw();
86  TPaveLabel* basket1 = new TPaveLabel(.6,.25,.7,.3,"Basket 1");
87  basket1->SetFillColor(basketcolor);
88  basket1->Draw();
89  TPaveLabel* basket2 = new TPaveLabel(.8,.25,.9,.3,"Basket 2");
90  basket2->SetFillColor(basketcolor);
91  basket2->Draw();
92 
93  TPaveText* offset = new TPaveText(.55,.15,.9,.2);
94  offset->AddText("Offset of events in fBuffer");
95  offset->AddText("Array of fEventOffsetLen Integers");
96  offset->AddText("(if variable length structure)");
97  offset->SetFillColor(offsetcolor);
98  offset->Draw();
99  TPaveText* buffer = new TPaveText(.55,.05,.9,.1);
100  buffer->AddText("Basket buffer");
101  buffer->AddText("Array of fBasketSize chars");
102  buffer->SetFillColor(offsetcolor);
103  buffer->Draw();
104  TPaveText* zipbuffer = new TPaveText(.55,-.05,.75,.0);
105  zipbuffer->AddText("Basket compressed buffer");
106  zipbuffer->AddText("(if compression)");
107  zipbuffer->SetFillColor(offsetcolor);
108  zipbuffer->Draw();
109  TArrow* ar1 = new TArrow();
110  ar1->SetLineWidth(2);
111  ar1->SetLineColor(1);
112  ar1->SetFillStyle(1001);
113  ar1->SetFillColor(1);
114  ar1->DrawArrow(.21,.275,.39,.275,0.015,"|>");
115  ar1->DrawArrow(.23,.375,.39,.375,0.015,"|>");
116  ar1->DrawArrow(.25,.775,.39,.775,0.015,"|>");
117  ar1->DrawArrow(.50,.775,.59,.775,0.015,"|>");
118  ar1->DrawArrow(.70,.775,.79,.775,0.015,"|>");
119  ar1->DrawArrow(.50,.275,.59,.275,0.015,"|>");
120  ar1->DrawArrow(.70,.275,.79,.275,0.015,"|>");
121  ar1->DrawArrow(.45,.175,.54,.175,0.015,"|>");
122  ar1->DrawArrow(.43,.075,.54,.075,0.015,"|>");
123  ar1->DrawArrow(.41,-.025,.54,-.025,0.015,"|>");
124  TLine* ldot = new TLine(.95,.92,.99,.92);
125  ldot->SetLineStyle(3);
126  ldot->Draw();
127  ldot->DrawLine(.9,.775,.99,.775);
128  ldot->DrawLine(.9,.275,.99,.275);
129  ldot->DrawLine(.55,.05,.55,0);
130  ldot->DrawLine(.9,.05,.75,0);
131  TText* pname = new TText(.46,.21,"fEventOffset");
132  pname->SetTextFont(72);
133  pname->SetTextSize(0.018);
134  pname->Draw();
135  pname->DrawText(.44,.11,"fBuffer");
136  pname->DrawText(.42,.01,"fZipBuffer");
137  pname->DrawText(.26,.81,"fLeaves = TObjArray of TLeaf");
138  pname->DrawText(.24,.40,"fBasketEvent");
139  pname->DrawText(.22,.31,"fBaskets = TObjArray of TBasket");
140  pname->DrawText(.20,1.0,"fBranches = TObjArray of TBranch");
141  TPaveText* ntleaf = new TPaveText(0.30,.42,.62,.7);
142  ntleaf->SetTextSize(0.014);
143  ntleaf->SetFillColor(leafcolor);
144  ntleaf->SetTextAlign(12);
145  ntleaf->AddText("fLen: number of fixed elements");
146  ntleaf->AddText("fLenType: number of bytes of data type");
147  ntleaf->AddText("fOffset: relative to Leaf0-fAddress");
148  ntleaf->AddText("fNbytesIO: number of bytes used for I/O");
149  ntleaf->AddText("fIsPointer: True if pointer");
150  ntleaf->AddText("fIsRange: True if leaf has a range");
151  ntleaf->AddText("fIsUnsigned: True if unsigned");
152  ntleaf->AddText("*fLeafCount: points to Leaf counter");
153  ntleaf->AddText(" ");
154  ntleaf->AddLine(0,0,0,0);
155  ntleaf->AddText("fName = Leaf name");
156  ntleaf->AddText("fTitle = Leaf type (see Type codes)");
157  ntleaf->Draw();
158  TPaveText* type = new TPaveText(.65,.42,.95,.7);
159  type->SetTextAlign(12);
160  type->SetFillColor(leafcolor);
161  type->AddText(" ");
162  type->AddText("C : a character string");
163  type->AddText("B : an 8 bit signed integer");
164  type->AddText("b : an 8 bit unsigned integer");
165  type->AddText("S : a 16 bit signed short integer");
166  type->AddText("s : a 16 bit unsigned short integer");
167  type->AddText("I : a 32 bit signed integer");
168  type->AddText("i : a 32 bit unsigned integer");
169  type->AddText("F : a 32 bit floating point");
170  type->AddText("D : a 64 bit floating point");
171  type->AddText("TXXXX : a class name TXXXX");
172  type->Draw();
173  TPaveLabel* typecode = new TPaveLabel(.7,.68,.9,.72,"fType codes");
174  typecode->SetFillColor(leafcolor);
175  typecode->Draw();
176  ldot->DrawLine(.4,.75,.30,.7);
177  ldot->DrawLine(.5,.75,.62,.7);
178  TPaveText* ntbasket = new TPaveText(0.02,-0.07,0.35,.25);
179  ntbasket->SetFillColor(basketcolor);
180  ntbasket->SetTextSize(0.014);
181  ntbasket->SetTextAlign(12);
182  ntbasket->AddText("fNbytes: Size of compressed Basket");
183  ntbasket->AddText("fObjLen: Size of uncompressed Basket");
184  ntbasket->AddText("fDatime: Date/Time when written to store");
185  ntbasket->AddText("fKeylen: Number of bytes for the key");
186  ntbasket->AddText("fCycle : Cycle number");
187  ntbasket->AddText("fSeekKey: Pointer to Basket on file");
188  ntbasket->AddText("fSeekPdir: Pointer to directory on file");
189  ntbasket->AddText("fClassName: 'TBasket'");
190  ntbasket->AddText("fName: Branch name");
191  ntbasket->AddText("fTitle: TreePave name");
192  ntbasket->AddText(" ");
193  ntbasket->AddLine(0,0,0,0);
194  ntbasket->AddText("fNevBuf: Number of events in Basket");
195  ntbasket->AddText("fLast: pointer to last used byte in Basket");
196  ntbasket->Draw();
197  ldot->DrawLine(.4,.3,0.02,0.25);
198  ldot->DrawLine(.5,.25,0.35,-.07);
199  ldot->DrawLine(.5,.3,0.35,0.25);
200  TPaveText* ntbranch = new TPaveText(0.02,0.40,0.18,0.68);
201  ntbranch->SetFillColor(branchcolor);
202  ntbranch->SetTextSize(0.015);
203  ntbranch->SetTextAlign(12);
204  ntbranch->AddText("fBasketSize");
205  ntbranch->AddText("fEventOffsetLen");
206  ntbranch->AddText("fMaxBaskets");
207  ntbranch->AddText("fEntries");
208  ntbranch->AddText("fAddress of Leaf0");
209  ntbranch->AddText(" ");
210  ntbranch->AddLine(0,0,0,0);
211  ntbranch->AddText("fName: Branchname");
212  ntbranch->AddText("fTitle: leaflist");
213  ntbranch->Draw();
214  ldot->DrawLine(.2,.97,.02,.68);
215  ldot->DrawLine(.35,.97,.18,.68);
216  ldot->DrawLine(.35,.87,.18,.40);
217  TPavesText* basketstore = new TPavesText(.8,-0.088,0.952,-0.0035,7,"tr");
218  basketstore->SetFillColor(28);
219  basketstore->AddText("Baskets");
220  basketstore->AddText("Stores");
221  basketstore->Draw();
222  c1->Update();
223 
224  gBenchmark->Show("treePave");
225 }
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:233
virtual TLine * AddLine(Double_t x1=0, Double_t y1=0, Double_t x2=0, Double_t y2=0)
Add a new graphics line to this pavetext.
Definition: TPaveText.cxx:169
return c1
Definition: legend1.C:41
virtual void DrawArrow(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Float_t arrowsize=0, Option_t *option="")
Draw this arrow with new coordinates.
Definition: TArrow.cxx:138
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
Definition: TPaveText.cxx:182
virtual TLine * DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition: TLine.cxx:93
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
Definition: TBenchmark.cxx:157
int Int_t
Definition: RtypesCore.h:41
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
virtual void Draw(Option_t *option="")
Draw this pavestext with its current attributes.
Definition: TPavesText.cxx:79
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:45
virtual void Start(const char *name)
Starts Benchmark with the specified name.
Definition: TBenchmark.cxx:174
const char * GetTitle() const
Returns title of object.
Definition: TPad.h:256
Base class for several text objects.
Definition: TText.h:23
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition: TAttText.h:41
A Pave (see TPave) with a text centered in the Pave.
Definition: TPaveLabel.h:20
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Set world coordinate system for the pad.
Definition: TPad.cxx:5121
R__EXTERN TBenchmark * gBenchmark
Definition: TBenchmark.h:59
A simple line.
Definition: TLine.h:23
The Canvas class.
Definition: TCanvas.h:31
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:21
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
Definition: TPaveLabel.cxx:77
int type
Definition: TGX11.cxx:120
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
virtual TText * DrawText(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates.
Definition: TText.cxx:176
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:46
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2248
Draw all kinds of Arrows.
Definition: TArrow.h:29
A PaveText (see TPaveText) with several stacked paves.
Definition: TPavesText.h:18