Loading [MathJax]/jax/output/HTML-CSS/config.js
ROOT
6.10/09
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
+
Namespaces
Namespace List
+
Namespace Members
+
All
<
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
<
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
u
w
x
+
Enumerations
a
e
f
g
m
p
t
w
y
+
Enumerator
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
w
+
All Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
v
w
x
y
+
Enumerations
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
w
y
+
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
+
Properties
f
+
Related Functions
:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
+
Files
File List
+
File Members
+
All
1
2
3
4
5
6
7
8
9
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
+
Enumerations
c
e
f
i
l
m
p
r
u
x
+
Enumerator
a
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
v
w
x
y
z
+
Macros
1
2
3
4
5
6
7
8
9
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Release Notes
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
tutorials
pyroot
fit1.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_pyroot
3
## \notebook
4
## Fit example.
5
##
6
## \macro_image
7
## \macro_output
8
## \macro_code
9
##
10
## \author Wim Lavrijsen
11
12
from
os
import
path
13
from
ROOT
import
TCanvas, TFile, TPaveText
14
from
ROOT
import
gROOT, gBenchmark
15
16
c1 =
TCanvas
(
'c1'
,
'The Fit Canvas'
, 200, 10, 700, 500 )
17
c1.SetGridx()
18
c1.SetGridy()
19
c1.GetFrame().
SetFillColor
( 21 )
20
c1.GetFrame().SetBorderMode(-1 )
21
c1.GetFrame().
SetBorderSize
( 5 )
22
23
gBenchmark.Start(
'fit1'
)
24
#
25
# We connect the ROOT file generated in a previous tutorial
26
#
27
fill =
TFile
(
'py-fillrandom.root'
)
28
29
#
30
# The function "ls()" lists the directory contents of this file
31
#
32
fill.ls()
33
34
#
35
# Get object "sqroot" from the file.
36
#
37
38
sqroot = gROOT.FindObject(
'sqroot'
)
39
sqroot.Print()
40
41
#
42
# Now fit histogram h1f with the function sqroot
43
#
44
h1f = gROOT.FindObject(
'h1f'
)
45
h1f.SetFillColor( 45 )
46
h1f.Fit(
'sqroot'
)
47
48
# We now annotate the picture by creating a PaveText object
49
# and displaying the list of commands in this macro
50
#
51
fitlabel =
TPaveText
( 0.6, 0.3, 0.9, 0.80,
'NDC'
)
52
fitlabel.SetTextAlign( 12 )
53
fitlabel.SetFillColor( 42 )
54
fitlabel.ReadFile(path.join(str(gROOT.GetTutorialDir()),
'pyroot'
,
'fit1_py.py'
))
55
fitlabel.Draw()
56
c1.Update()
57
gBenchmark.Show(
'fit1'
)
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition:
TFile.h:46
SetBorderSize
c SetBorderSize(2)
SetFillColor
h1 SetFillColor(kGreen)
TCanvas
The Canvas class.
Definition:
TCanvas.h:31
TPaveText
A Pave (see TPave) with text, lines or/and boxes inside.
Definition:
TPaveText.h:21