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