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