ROOT
v6-28
Reference Guide
Loading...
Searching...
No Matches
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
import
ROOT
13
from
os
import
path
14
from
ROOT
import
TCanvas, TFile, TPaveText
15
from
ROOT
import
gROOT, gBenchmark
16
17
c1 =
TCanvas
(
'c1'
,
'The Fit Canvas'
, 200, 10, 700, 500 )
18
c1.SetGridx()
19
c1.SetGridy()
20
c1.GetFrame().
SetFillColor
( 21 )
21
c1.GetFrame().SetBorderMode(-1 )
22
c1.GetFrame().
SetBorderSize
( 5 )
23
24
gBenchmark.Start(
'fit1'
)
25
#
26
# We connect the ROOT file generated in a previous tutorial
27
#
28
File =
"py-fillrandom.root"
29
if
(ROOT.gSystem.AccessPathName(File)) :
30
ROOT.Info(
"fit1.py"
, File+
" does not exist"
)
31
exit()
32
33
fill =
TFile
(File)
34
35
#
36
# The function "ls()" lists the directory contents of this file
37
#
38
fill.ls()
39
40
#
41
# Get object "sqroot" from the file.
42
#
43
44
sqroot = gROOT.FindObject(
'sqroot'
)
45
sqroot.Print()
46
47
#
48
# Now fit histogram h1f with the function sqroot
49
#
50
h1f = gROOT.FindObject(
'h1f'
)
51
h1f.SetFillColor( 45 )
52
h1f.Fit(
'sqroot'
)
53
54
# We now annotate the picture by creating a PaveText object
55
# and displaying the list of commands in this macro
56
#
57
fitlabel =
TPaveText
( 0.6, 0.3, 0.9, 0.80,
'NDC'
)
58
fitlabel.SetTextAlign( 12 )
59
fitlabel.SetFillColor( 42 )
60
fitlabel.ReadFile(path.join(str(gROOT.GetTutorialDir()),
'pyroot'
,
'fit1_py.py'
))
61
fitlabel.Draw()
62
c1.Update()
63
gBenchmark.Show(
'fit1'
)
SetFillColor
Option_t Option_t SetFillColor
Definition
TGWin32VirtualXProxy.cxx:50
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition
TFile.h:51
TPaveText
A Pave (see TPave) with text, lines or/and boxes inside.
Definition
TPaveText.h:21
SetBorderSize
c SetBorderSize(2)
tutorials
pyroot
fit1.py
ROOT v6-28 - Reference Guide Generated on Thu Oct 24 2024 01:50:04 (GVA Time) using Doxygen 1.9.8