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