Ntuple drawing example.
2 from ROOT
import TCanvas, TPad, TFile, TPaveText
3 from ROOT
import gBenchmark, gStyle, gROOT
5 c1 =
TCanvas(
'c1',
'The Ntuple canvas',200,10,700,780)
7 gBenchmark.Start(
'ntuple1')
12 f1 =
TFile(
'py-hsimple.root')
16 pad1 =
TPad(
'pad1',
'This is pad1',0.02,0.52,0.48,0.98,21)
17 pad2 =
TPad(
'pad2',
'This is pad2',0.52,0.52,0.98,0.98,21)
18 pad3 =
TPad(
'pad3',
'This is pad3',0.02,0.02,0.48,0.48,21)
19 pad4 =
TPad(
'pad4',
'This is pad4',0.52,0.02,0.98,0.48,1)
29 gStyle.SetStatColor(42)
38 ntuple = gROOT.FindObject(
'ntuple')
39 ntuple.SetLineColor(1)
40 ntuple.SetFillStyle(1001)
41 ntuple.SetFillColor(45)
42 ntuple.Draw(
'3*px+2',
'px**2+py**2>1')
43 ntuple.SetFillColor(38)
44 ntuple.Draw(
'2*px+2',
'pz>2',
'same')
45 ntuple.SetFillColor(5)
46 ntuple.Draw(
'1.3*px+2',
'(px^2+py^2>4) && py>0',
'same')
56 ntuple.Draw(
'pz:px>>hprofs',
'',
'goffprofs')
57 hprofs = gROOT.FindObject(
'hprofs')
58 hprofs.SetMarkerColor(5)
59 hprofs.SetMarkerSize(0.7)
60 hprofs.SetMarkerStyle(21)
65 fpol2 = hprofs.GetFunction(
'pol2')
76 ntuple.SetMarkerColor(1)
77 ntuple.Draw(
'py:px',
'pz>1')
78 ntuple.SetMarkerColor(2)
79 ntuple.Draw(
'py:px',
'pz<1',
'same')
85 ntuple.Draw(
'pz:py:px',
'(pz<10 && pz>6)+(pz<4 && pz>3)')
86 ntuple.SetMarkerColor(4)
87 ntuple.Draw(
'pz:py:px',
'pz<6 && pz>4',
'same')
88 ntuple.SetMarkerColor(5)
89 ntuple.Draw(
'pz:py:px',
'pz<4 && pz>3',
'same')
93 l4.AddText(
'You can interactively rotate this view in 2 ways:')
94 l4.AddText(
' - With the RotateCube in clicking in this pad')
95 l4.AddText(
' - Selecting View with x3d in the View menu')
102 gStyle.SetStatColor(19)
103 gBenchmark.Show(
'ntuple1')
- Author
- Wim Lavrijsen
Definition in file ntuple1.py.