Logo ROOT  
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
11void 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,.805);
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,.78,.5,.83,"Leaf 0");
70 leaf0->SetFillColor(leafcolor);
71 leaf0->Draw();
72 TPaveLabel* leaf1 = new TPaveLabel(.6,.78,.7,.83,"Leaf 1");
73 leaf1->SetFillColor(leafcolor);
74 leaf1->Draw();
75 TPaveLabel* leaf2 = new TPaveLabel(.8,.78,.9,.83,"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,.805,.39,.805,0.015,"|>");
117 ar1->DrawArrow(.50,.805,.59,.805,0.015,"|>");
118 ar1->DrawArrow(.70,.805,.79,.805,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,.805,.99,.805);
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,.84,"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,.73);
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,.73);
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("f : a 24 bit truncated float");
171 type->AddText("D : a 64 bit floating point");
172 type->AddText("d : a 24 bit truncated double");
173 type->AddText("TXXXX : a class name TXXXX");
174 type->Draw();
175 TPaveLabel* typecode = new TPaveLabel(.7,.71,.9,.75,"fType codes");
176 typecode->SetFillColor(leafcolor);
177 typecode->Draw();
178 ldot->DrawLine(.4,.78,.30,.73);
179 ldot->DrawLine(.5,.78,.62,.73);
180 TPaveText* ntbasket = new TPaveText(0.02,-0.07,0.35,.25);
181 ntbasket->SetFillColor(basketcolor);
182 ntbasket->SetTextSize(0.014);
183 ntbasket->SetTextAlign(12);
184 ntbasket->AddText("fNbytes: Size of compressed Basket");
185 ntbasket->AddText("fObjLen: Size of uncompressed Basket");
186 ntbasket->AddText("fDatime: Date/Time when written to store");
187 ntbasket->AddText("fKeylen: Number of bytes for the key");
188 ntbasket->AddText("fCycle : Cycle number");
189 ntbasket->AddText("fSeekKey: Pointer to Basket on file");
190 ntbasket->AddText("fSeekPdir: Pointer to directory on file");
191 ntbasket->AddText("fClassName: 'TBasket'");
192 ntbasket->AddText("fName: Branch name");
193 ntbasket->AddText("fTitle: TreePave name");
194 ntbasket->AddText(" ");
195 ntbasket->AddLine(0,0,0,0);
196 ntbasket->AddText("fNevBuf: Number of events in Basket");
197 ntbasket->AddText("fLast: pointer to last used byte in Basket");
198 ntbasket->Draw();
199 ldot->DrawLine(.4,.3,0.02,0.25);
200 ldot->DrawLine(.5,.25,0.35,-.07);
201 ldot->DrawLine(.5,.3,0.35,0.25);
202 TPaveText* ntbranch = new TPaveText(0.02,0.40,0.18,0.68);
203 ntbranch->SetFillColor(branchcolor);
204 ntbranch->SetTextSize(0.015);
205 ntbranch->SetTextAlign(12);
206 ntbranch->AddText("fBasketSize");
207 ntbranch->AddText("fEventOffsetLen");
208 ntbranch->AddText("fMaxBaskets");
209 ntbranch->AddText("fEntries");
210 ntbranch->AddText("fAddress of Leaf0");
211 ntbranch->AddText(" ");
212 ntbranch->AddLine(0,0,0,0);
213 ntbranch->AddText("fName: Branchname");
214 ntbranch->AddText("fTitle: leaflist");
215 ntbranch->Draw();
216 ldot->DrawLine(.2,.97,.02,.68);
217 ldot->DrawLine(.35,.97,.18,.68);
218 ldot->DrawLine(.35,.87,.18,.40);
219 TPavesText* basketstore = new TPavesText(.8,-0.088,0.952,-0.0035,7,"tr");
220 basketstore->SetFillColor(28);
221 basketstore->AddText("Baskets");
222 basketstore->AddText("Stores");
223 basketstore->Draw();
224 c1->Update();
225
226 gBenchmark->Show("treePave");
227}
int Int_t
Definition: RtypesCore.h:41
R__EXTERN TBenchmark * gBenchmark
Definition: TBenchmark.h:59
int type
Definition: TGX11.cxx:120
Draw all kinds of Arrows.
Definition: TArrow.h:29
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:134
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition: TAttText.h:41
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:45
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:46
virtual void Start(const char *name)
Starts Benchmark with the specified name.
Definition: TBenchmark.cxx:174
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
Definition: TBenchmark.cxx:157
The Canvas class.
Definition: TCanvas.h:31
A simple line.
Definition: TLine.h:23
virtual TLine * DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
Definition: TLine.cxx:88
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
A Pave (see TPave) with a text centered in the Pave.
Definition: TPaveLabel.h:20
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
Definition: TPaveLabel.cxx:77
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:21
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 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
A PaveText (see TPaveText) with several stacked paves.
Definition: TPavesText.h:18
virtual void Draw(Option_t *option="")
Draw this pavestext with its current attributes.
Definition: TPavesText.cxx:79
Base class for several text objects.
Definition: TText.h:23
virtual TText * DrawText(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates.
Definition: TText.cxx:174
return c1
Definition: legend1.C:41
Definition: tree.py:1