Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
10void 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,.805);
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,.78,.5,.83,"Leaf 0");
69 leaf0->SetFillColor(leafcolor);
70 leaf0->Draw();
71 TPaveLabel* leaf1 = new TPaveLabel(.6,.78,.7,.83,"Leaf 1");
72 leaf1->SetFillColor(leafcolor);
73 leaf1->Draw();
74 TPaveLabel* leaf2 = new TPaveLabel(.8,.78,.9,.83,"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;
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,.805,.39,.805,0.015,"|>");
116 ar1.DrawArrow(.50,.805,.59,.805,0.015,"|>");
117 ar1.DrawArrow(.70,.805,.79,.805,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(kDotted);
125 ldot->Draw();
126 ldot->DrawLine(.9,.805,.99,.805);
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,.84,"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,.73);
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,.73);
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("f : a 24 bit truncated float");
170 type->AddText("D : a 64 bit floating point");
171 type->AddText("d : a 24 bit truncated double");
172 type->AddText("TXXXX : a class name TXXXX");
173 type->Draw();
174 TPaveLabel* typecode = new TPaveLabel(.7,.71,.9,.75,"fType codes");
175 typecode->SetFillColor(leafcolor);
176 typecode->Draw();
177 ldot->DrawLine(.4,.78,.30,.73);
178 ldot->DrawLine(.5,.78,.62,.73);
179 TPaveText* ntbasket = new TPaveText(0.02,-0.07,0.35,.25);
180 ntbasket->SetFillColor(basketcolor);
181 ntbasket->SetTextSize(0.014);
182 ntbasket->SetTextAlign(12);
183 ntbasket->AddText("fNbytes: Size of compressed Basket");
184 ntbasket->AddText("fObjLen: Size of uncompressed Basket");
185 ntbasket->AddText("fDatime: Date/Time when written to store");
186 ntbasket->AddText("fKeylen: Number of bytes for the key");
187 ntbasket->AddText("fCycle : Cycle number");
188 ntbasket->AddText("fSeekKey: Pointer to Basket on file");
189 ntbasket->AddText("fSeekPdir: Pointer to directory on file");
190 ntbasket->AddText("fClassName: 'TBasket'");
191 ntbasket->AddText("fName: Branch name");
192 ntbasket->AddText("fTitle: TreePave name");
193 ntbasket->AddText(" ");
194 ntbasket->AddLine(0,0,0,0);
195 ntbasket->AddText("fNevBuf: Number of events in Basket");
196 ntbasket->AddText("fLast: pointer to last used byte in Basket");
197 ntbasket->Draw();
198 ldot->DrawLine(.4,.3,0.02,0.25);
199 ldot->DrawLine(.5,.25,0.35,-.07);
200 ldot->DrawLine(.5,.3,0.35,0.25);
201 TPaveText* ntbranch = new TPaveText(0.02,0.40,0.18,0.68);
202 ntbranch->SetFillColor(branchcolor);
203 ntbranch->SetTextSize(0.015);
204 ntbranch->SetTextAlign(12);
205 ntbranch->AddText("fBasketSize");
206 ntbranch->AddText("fEventOffsetLen");
207 ntbranch->AddText("fMaxBaskets");
208 ntbranch->AddText("fEntries");
209 ntbranch->AddText("fAddress of Leaf0");
210 ntbranch->AddText(" ");
211 ntbranch->AddLine(0,0,0,0);
212 ntbranch->AddText("fName: Branchname");
213 ntbranch->AddText("fTitle: leaflist");
214 ntbranch->Draw();
215 ldot->DrawLine(.2,.97,.02,.68);
216 ldot->DrawLine(.35,.97,.18,.68);
217 ldot->DrawLine(.35,.87,.18,.40);
218 TPavesText* basketstore = new TPavesText(.8,-0.088,0.952,-0.0035,7,"tr");
219 basketstore->SetFillColor(28);
220 basketstore->AddText("Baskets");
221 basketstore->AddText("Stores");
222 basketstore->Draw();
223 c1->Update();
224
225 gBenchmark->Show("treePave");
226}
int Int_t
Definition RtypesCore.h:45
@ kDotted
Definition TAttLine.h:52
R__EXTERN TBenchmark * gBenchmark
Definition TBenchmark.h:59
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Draw all kinds of Arrows.
Definition TArrow.h:29
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:38
virtual void Start(const char *name)
Starts Benchmark with the specified name.
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
The Canvas class.
Definition TCanvas.h:23
Use the TLine constructor to create a simple line.
Definition TLine.h:22
A Pave (see TPave) with a text centered in the Pave.
Definition TPaveLabel.h:20
void Draw(Option_t *option="") override
Draw this pavelabel with its current attributes.
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.
void Draw(Option_t *option="") override
Draw this pavetext with its current attributes.
A PaveText (see TPaveText) with several stacked paves.
Definition TPavesText.h:18
Base class for several text objects.
Definition TText.h:22
return c1
Definition legend1.C:41