7 from ROOT
import TCanvas, TH1F, TSlider
8 from ROOT
import gROOT, gBenchmark, gRandom
13 c1 = TCanvas(
'c1',
'The HSUM example', 200, 10, 600, 400 )
16 gBenchmark.Start(
'hsum' )
19 total = TH1F(
'total',
'This is the total distribution', 100, -4, 4 )
20 main = TH1F(
'main',
'Main contributor', 100, -4, 4 )
21 s1 = TH1F(
's1',
'This is the first signal', 100, -4, 4 )
22 s2 = TH1F(
's2',
'This is the second signal', 100, -4, 4 )
26 total.SetMarkerStyle( 21 )
27 total.SetMarkerSize( 0.7 )
28 main.SetFillColor( 16 )
34 gauss, landau = gRandom.Gaus, gRandom.Landau
37 histos = [
'total',
'main',
's1',
's2' ]
39 exec
'%sFill = %s.Fill' % (name,name)
43 for i
in xrange( 10000 ):
45 xmain = gauss( -1, 1.5 )
46 xs1 = gauss( -0.5, 0.5 )
47 xs2 = landau( 1, 0.15 )
58 if i
and (i%kUPDATE) == 0 :
65 slider = TSlider(
'slider',
'test', 4.2, 0, 4.6, total.GetMaximum(), 38 )
66 slider.SetFillColor( 46 )
69 slider.SetRange( 0, float(i) / 10000. )
76 exec
'del %sFill' % name
80 slider.SetRange( 0, 1 )
81 total.Draw(
'sameaxis' )
85 gBenchmark.Show(
'hsum' )