ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
fit1.py
Go to the documentation of this file.
1 #
2 # To see the output of this macro, click begin_html <a href="gif/fit1.gif">here</a>. end_html
3 #
4 from os import path
5 from ROOT import TCanvas, TFile, TPaveText
6 from ROOT import gROOT, gBenchmark
7 
8 c1 = TCanvas( 'c1', 'The Fit Canvas', 200, 10, 700, 500 )
9 c1.SetGridx()
10 c1.SetGridy()
11 c1.GetFrame().SetFillColor( 21 )
12 c1.GetFrame().SetBorderMode(-1 )
13 c1.GetFrame().SetBorderSize( 5 )
14 
15 gBenchmark.Start( 'fit1' )
16 #
17 # We connect the ROOT file generated in a previous tutorial
18 # (see begin_html <a href="fillrandom.C.html">Filling histograms with random numbers from a function</a>) end_html
19 #
20 fill = TFile( 'py-fillrandom.root' )
21 
22 #
23 # The function "ls()" lists the directory contents of this file
24 #
25 fill.ls()
26 
27 #
28 # Get object "sqroot" from the file.
29 #
30 
31 sqroot = gROOT.FindObject( 'sqroot' )
32 sqroot.Print()
33 
34 #
35 # Now fit histogram h1f with the function sqroot
36 #
37 h1f = gROOT.FindObject( 'h1f' )
38 h1f.SetFillColor( 45 )
39 h1f.Fit( 'sqroot' )
40 
41 # We now annotate the picture by creating a PaveText object
42 # and displaying the list of commands in this macro
43 #
44 fitlabel = TPaveText( 0.6, 0.3, 0.9, 0.80, 'NDC' )
45 fitlabel.SetTextAlign( 12 )
46 fitlabel.SetFillColor( 42 )
47 fitlabel.ReadFile(path.join(path.dirname(__file__),'fit1_py.py'))
48 fitlabel.Draw()
49 c1.Update()
50 gBenchmark.Show( 'fit1' )
c SetBorderSize(2)
h1 SetFillColor(kGreen)