2 from ROOT
import TCanvas, TPad, TFile, TPaveText
3 from ROOT
import gBenchmark, gStyle, gROOT
7 c1 = TCanvas(
'c1',
'The Ntuple canvas',200,10,700,780)
9 gBenchmark.Start(
'ntuple1')
14 f1 = TFile(
'hsimple.root')
18 pad1 = TPad(
'pad1',
'This is pad1',0.02,0.52,0.48,0.98,21)
19 pad2 = TPad(
'pad2',
'This is pad2',0.52,0.52,0.98,0.98,21)
20 pad3 = TPad(
'pad3',
'This is pad3',0.02,0.02,0.48,0.48,21)
21 pad4 = TPad(
'pad4',
'This is pad4',0.52,0.02,0.98,0.48,1)
31 gStyle.SetStatColor(42)
40 ntuple = gROOT.FindObject(
'ntuple')
41 ntuple.SetLineColor(1)
42 ntuple.SetFillStyle(1001)
43 ntuple.SetFillColor(45)
44 ntuple.Draw(
'3*px+2',
'px**2+py**2>1')
45 ntuple.SetFillColor(38)
46 ntuple.Draw(
'2*px+2',
'pz>2',
'same')
47 ntuple.SetFillColor(5)
48 ntuple.Draw(
'1.3*px+2',
'(px^2+py^2>4) && py>0',
'same')
58 ntuple.Draw(
'pz:px>>hprofs',
'',
'goffprofs')
59 hprofs = gROOT.FindObject(
'hprofs')
60 hprofs.SetMarkerColor(5)
61 hprofs.SetMarkerSize(0.7)
62 hprofs.SetMarkerStyle(21)
67 fpol2 = hprofs.GetFunction(
'pol2')
78 ntuple.SetMarkerColor(1)
79 ntuple.Draw(
'py:px',
'pz>1')
80 ntuple.SetMarkerColor(2)
81 ntuple.Draw(
'py:px',
'pz<1',
'same')
87 ntuple.Draw(
'pz:py:px',
'(pz<10 && pz>6)+(pz<4 && pz>3)')
88 ntuple.SetMarkerColor(4)
89 ntuple.Draw(
'pz:py:px',
'pz<6 && pz>4',
'same')
90 ntuple.SetMarkerColor(5)
91 ntuple.Draw(
'pz:py:px',
'pz<4 && pz>3',
'same')
92 l4 = TPaveText(-0.9,0.5,0.9,0.95)
95 l4.AddText(
'You can interactively rotate this view in 2 ways:')
96 l4.AddText(
' - With the RotateCube in clicking in this pad')
97 l4.AddText(
' - Selecting View with x3d in the View menu')
104 gStyle.SetStatColor(19)
105 gBenchmark.Show(
'ntuple1')