Logo ROOT   master
Reference Guide
file.py
Go to the documentation of this file.
1 ## \file
2 ## \ingroup tutorial_pyroot_legacy
3 ## \notebook
4 ## This macro displays the physical ROOT file structure
5 ##
6 ## \macro_image
7 ## \macro_code
8 ##
9 ## \author Wim Lavrijsen
10 
11 from ROOT import TCanvas, TPaveLabel, TPave, TLine, TArrow, TText, TPaveText
12 from ROOT import gROOT
13 
14 c1 = TCanvas( 'c1', 'ROOT File description', 200, 10, 700, 550 )
15 
16 c1.Range( 0, -0.25, 21, 14 )
17 title = TPaveLabel( 5, 12, 15, 13.7, c1.GetTitle() )
18 title.SetFillColor( 16 )
19 title.Draw()
20 
21 # horizonthal file layout
22 file = TPave( 1, 8.5, 20, 11 )
23 file.SetFillColor( 11 )
24 file.Draw()
25 fileh = TPave( 1, 8.5, 2.5, 11 )
26 fileh.SetFillColor( 44 )
27 fileh.Draw()
28 lrh = TPave( 2.5, 8.5, 3.3, 11, 1 )
29 lrh.SetFillColor( 33 )
30 lrh.Draw()
31 lrh.DrawPave( 6.9, 8.5, 7.7, 11, 1 )
32 lrh.DrawPave( 10.5, 8.5, 11.3, 11, 1 )
33 lrh.DrawPave( 14.5, 8.5, 15.3, 11, 1 )
34 ldot = TLine( 1, 8.5, 0.5, 6.5 )
35 ldot.SetLineStyle( 2 )
36 ldot.Draw()
37 ldot.DrawLine( 2.5, 8.5, 9.4, 6.5 )
38 ldot.DrawLine( 10.5, 8.5, 10, 6.5 )
39 ldot.DrawLine( 11.3, 8.5, 19.5, 6.5 )
40 line = TLine( 2.6, 11, 2.6, 11.5 )
41 line.Draw()
42 line.DrawLine( 2.6, 11.5, 7, 11.5 )
43 arrow = TArrow( 7, 11.5, 7, 11.1, 0.01, '|>' )
44 arrow.SetFillStyle( 1001 )
45 arrow.Draw()
46 line.DrawLine( 7, 8.5, 7, 8.0 )
47 line.DrawLine( 7, 8.0, 10.6, 8 )
48 arrow.DrawArrow( 10.6,8, 10.6, 8.4, 0.01, '|>' )
49 line.DrawLine( 10.6, 11, 10.6, 11.5 )
50 line.DrawLine( 10.6, 11.5, 14.6, 11.5 )
51 arrow.DrawArrow( 14.6, 11.5, 14.6, 11.1, 0.01, '|>' )
52 line.DrawLine( 14.6, 8.5, 14.6, 8.0 )
53 line.DrawLine( 14.6, 8.0, 16, 8 )
54 ldot.DrawLine( 16, 8, 19, 8 )
55 vert = TText( 1.5, 9.75, 'File' )
56 vert.SetTextAlign( 21 )
57 vert.SetTextAngle( 90 )
58 vert.SetTextSize( 0.025 )
59 vert.Draw()
60 vert.DrawText( 2.0, 9.75, 'Header' )
61 vert.DrawText( 2.9, 9.75, 'Logical Record' )
62 vert.DrawText( 3.2, 9.75, 'Header' )
63 vert.DrawText( 7.3, 9.75, 'Logical Record' )
64 vert.DrawText( 7.6, 9.75, 'Header' )
65 vert.DrawText( 10.9, 9.75, 'Logical Record' )
66 vert.DrawText( 11.2, 9.75, 'Header' )
67 vert.DrawText( 14.9, 9.75, 'Logical Record' )
68 vert.DrawText( 15.2, 9.75, 'Header' )
69 hori = TText( 4.75, 10, 'Object' )
70 hori.SetTextAlign( 22 )
71 hori.SetTextSize( 0.035 )
72 hori.Draw()
73 hori.DrawText( 4.75, 9.5, 'Data' )
74 hori.DrawText( 9.2, 10, 'Deleted' )
75 hori.DrawText( 9.2, 9.5, 'Object' )
76 line.DrawLine( 6.9, 8.5, 10.5, 11 )
77 line.DrawLine( 6.9, 11, 10.5, 8.5 )
78 tbig = TText( 17, 9.75, '............' )
79 tbig.SetTextAlign( 22 )
80 tbig.SetTextSize( 0.03 )
81 tbig.Draw()
82 tbig.DrawText( 2.6, 7, 'fBEGIN' )
83 tbig.DrawText( 20., 7, 'fEND' )
84 arrow.DrawArrow( 2.6, 7, 2.6, 8.4, 0.01, '|>' )
85 arrow.DrawArrow( 20, 7, 20, 8.4, 0.01, '|>' )
86 
87 #file header
88 header = TPaveText( 0.5, .2, 9.4, 6.5 )
89 header.SetFillColor( 44 )
90 header.Draw()
91 fh = header.AddText( 'File Header' )
92 fh.SetTextAlign( 22 )
93 fh.SetTextSize( 0.04 )
94 header.SetTextSize( 0.027 )
95 header.SetTextAlign( 12 )
96 header.AddText( ' ' )
97 header.AddLine( 0, 0, 0, 0 )
98 header.AddText( '"root": Root File Identifier' )
99 header.AddText( 'fVersion: File version identifier' )
100 header.AddText( 'fBEGIN: Pointer to first data record' )
101 header.AddText( 'fEND: Pointer to first free word at EOF' )
102 header.AddText( 'fSeekFree: Pointer to FREE data record' )
103 header.AddText( 'fNbytesFree: Number of bytes in FREE' )
104 header.AddText( 'fNfree: Number of free data records' )
105 header.AddText( 'fNbytesName: Number of bytes in name/title' )
106 header.AddText( 'fUnits: Number of bytes for pointers' )
107 header.AddText( 'fCompress: Compression level' )
108 
109 #logical record header
110 lrecord = TPaveText( 10, 0.2, 19.5, 6.5 )
111 lrecord.SetFillColor( 33 )
112 lrecord.Draw()
113 tlrh = lrecord.AddText( 'Logical Record Header (TKEY)' )
114 tlrh.SetTextAlign( 22 )
115 tlrh.SetTextSize( 0.04 )
116 lrecord.SetTextSize( 0.027 )
117 lrecord.SetTextAlign( 12 )
118 lrecord.AddText( ' ' )
119 lrecord.AddLine( 0, 0, 0, 0 )
120 lrecord.AddText( 'fNbytes: Length of compressed object' )
121 lrecord.AddText( 'fVersion: Key version identifier' )
122 lrecord.AddText( 'fObjLen: Length of uncompressed object' )
123 lrecord.AddText( 'fDatime: Date/Time when written to store' )
124 lrecord.AddText( 'fKeylen: Number of bytes for the key' )
125 lrecord.AddText( 'fCycle : Cycle number' )
126 lrecord.AddText( 'fSeekKey: Pointer to object on file' )
127 lrecord.AddText( 'fSeekPdir: Pointer to directory on file' )
128 lrecord.AddText( 'fClassName: class name of the object' )
129 lrecord.AddText( 'fName: name of the object' )
130 lrecord.AddText( 'fTitle: title of the object' )
131 
132 c1.Update()
A TBox with a bordersize and a shadow option.
Definition: TPave.h:19
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:27
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:21
Draw all kinds of Arrows.
Definition: TArrow.h:29