ROOT
Version v6.32
master
v6.34
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
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'
)
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
SetFillColor
Option_t Option_t SetFillColor
Definition
TGWin32VirtualXProxy.cxx:50
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TFile
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition
TFile.h:53
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-32 - Reference Guide Generated on Wed Mar 26 2025 04:43:21 (GVA Time) using Doxygen 1.10.0