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