ROOT
Version v6.32
master
v6.34
Reference Guide
▼
ROOT
ROOT Reference Documentation
Tutorials
▼
Functional Parts
►
Core ROOT classes
►
std Extension classes
►
Parallelized classes
►
The Geometry Package
►
Graphics
►
Event display with ROOT7
►
GUI
►
Web Widgets
►
Web Display
►
Histogram Library
►
Input/Output Library
►
Math
►
N-D parametric functions
►
VecOps
►
Monte Carlo
►
HTTP server
►
PROOF
►
TMVA
►
RooFit
►
Dataframe
►
ROOT7 classes
►
NTuple-related classes
►
Tree Library
►
TreePlayer Library
▼
Tutorials
►
Histograms tutorials
►
Tree tutorials
►
Dataframe tutorials
►
ROOT 7 tutorials
►
FOAM tutorials
►
Containers tutorials
►
Event display tutorials
►
Event display ROOT7 tutorials
►
Geometry tutorials
►
Fast Fourier Transforms tutorials
►
Fit Tutorials
►
RooFit Tutorials
►
Graphs tutorials
►
Graphics tutorials
►
OpenGL tutorials
►
Tutorials specific to Mac/Cocoa
►
GUI tutorials
►
HistFactory Tutorials
►
HTTP tutorials
►
Image tutorials
►
IO tutorials
►
Math tutorials
►
Matrix tutorials
►
Monte Carlo tutorials
►
Multicore tutorials
►
Net tutorials
►
Physics tutorials
▼
PyRoot tutorials
demo.py
demoshelp.py
DynamicSlice.py
fillrandom.py
fit1.py
formula1.py
geometry.py
gerrors.py
graph.py
gui_ex.py
h1ReadAndDraw.py
hsimple.py
hsum.py
mrt.py
na49geomfile.py
na49view.py
na49visible.py
ntuple1.py
numberEntry.py
parse_CSV_file_with_TTree_ReadStream.py
pyroot001_arrayInterface.py
pyroot002_pythonizationDecorator.py
pyroot003_prettyPrinting.py
pyroot004_NumbaDeclare.py
pyroot005_tfile_context_manager.py
pyroot006_tcontext_context_manager.py
ratioplot.py
shapes.py
staff.py
surfaces.py
tornado.py
zdemo.py
►
Pythia tutorials
►
Quadratic programming package.
►
R tutorials
►
RooStats Tutorials
►
Spectrum tutorials
►
TSPlot tutorials
►
SQL tutorials
►
TMVA tutorials
►
TUnfold tutorials
►
Unuran tutorials
►
VecOps tutorials
►
FITS files interface tutorials
►
XML tutorials
►
Proof tutorials
►
Webgui tutorials
►
Legacy tutorials
demos.C
demoshelp.C
hsimple.C
rootlogoff.C
rootlogon.C
►
R Interface for Statistical Computing
►
Namespaces
►
All Classes
►
Files
Release Notes
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
Namespaces
ntuple1.py File Reference
Tutorials
»
PyRoot tutorials
Detailed Description
Ntuple drawing example.
from
ROOT
import
TCanvas, TPad, TFile, TPaveText
from
ROOT
import
gBenchmark, gStyle, gROOT
c1 =
TCanvas
(
'c1'
,
'The Ntuple canvas'
,200,10,700,780)
gBenchmark.Start
(
'ntuple1'
)
#
# Connect ROOT histogram/ntuple demonstration file
# generated by example hsimple.C.
f1 =
TFile
(
'py-hsimple.root'
)
#
# Inside this canvas, we create 4 pads
pad1 =
TPad
(
'pad1'
,
'This is pad1'
,0.02,0.52,0.48,0.98,21)
pad2 =
TPad
(
'pad2'
,
'This is pad2'
,0.52,0.52,0.98,0.98,21)
pad3 =
TPad
(
'pad3'
,
'This is pad3'
,0.02,0.02,0.48,0.48,21)
pad4 =
TPad
(
'pad4'
,
'This is pad4'
,0.52,0.02,0.98,0.48,1)
pad1.Draw
()
pad2.Draw
()
pad3.Draw
()
pad4.Draw
()
#
# Change default style for the statistics box
gStyle.SetStatW
(0.30)
gStyle.SetStatH
(0.20)
gStyle.SetStatColor
(42)
#
# Display a function of one ntuple column imposing a condition
# on another column.
pad1.cd
()
pad1.SetGrid
()
pad1.SetLogy
()
pad1.GetFrame
().
SetFillColor
(15)
ntuple =
gROOT.FindObject
(
'ntuple'
)
ntuple.SetLineColor
(1)
ntuple.SetFillStyle
(1001)
ntuple.SetFillColor
(45)
ntuple.Draw
(
'3*px+2'
,
'px**2+py**2>1'
)
ntuple.SetFillColor
(38)
ntuple.Draw
(
'2*px+2'
,
'pz>2'
,
'same'
)
ntuple.SetFillColor
(5)
ntuple.Draw
(
'1.3*px+2'
,
'(px^2+py^2>4) && py>0'
,
'same'
)
c1.Update
()
#
# Display the profile of two columns
# The profile histogram produced is saved in the current directory with
# the name hprofs
pad2.cd
()
pad2.SetGrid
()
pad2.GetFrame
().
SetFillColor
(32)
ntuple.Draw
(
'pz:px>>hprofs'
,
''
,
'goffprofs'
)
hprofs =
gROOT.FindObject
(
'hprofs'
)
hprofs.SetMarkerColor
(5)
hprofs.SetMarkerSize
(0.7)
hprofs.SetMarkerStyle
(21)
hprofs.Fit
(
'pol2'
)
#
# Get pointer to fitted function and modify its attributes
fpol2 =
hprofs.GetFunction
(
'pol2'
)
fpol2.SetLineWidth
(4)
fpol2.SetLineColor
(2)
c1.Update
()
#
# Display a scatter plot of two columns with a selection.
# Superimpose the result of another cut with a different marker color
pad3.cd
()
pad3.GetFrame
().
SetFillColor
(38)
pad3.GetFrame
().
SetBorderSize
(8)
ntuple.SetMarkerColor
(1)
ntuple.Draw
(
'py:px'
,
'pz>1'
)
ntuple.SetMarkerColor
(2)
ntuple.Draw
(
'py:px'
,
'pz<1'
,
'same'
)
c1.Update
()
#
# Display a 3-D scatter plot of 3 columns. Superimpose a different selection.
pad4.cd
()
ntuple.Draw
(
'pz:py:px'
,
'(pz<10 && pz>6)+(pz<4 && pz>3)'
)
ntuple.SetMarkerColor
(4)
ntuple.Draw
(
'pz:py:px'
,
'pz<6 && pz>4'
,
'same'
)
ntuple.SetMarkerColor
(5)
ntuple.Draw
(
'pz:py:px'
,
'pz<4 && pz>3'
,
'same'
)
l4 =
TPaveText
(-0.9,0.5,0.9,0.95)
l4.SetFillColor
(42)
l4.SetTextAlign
(12)
l4.AddText
(
'You can interactively rotate this view in 2 ways:'
)
l4.AddText
(
' - With the RotateCube in clicking in this pad'
)
l4.AddText
(
' - Selecting View with x3d in the View menu'
)
l4.Draw
()
#
# done
c1.cd
()
c1.Update
()
gStyle.SetStatColor
(19)
gBenchmark.Show
(
'ntuple1'
)
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
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
TPad
The most important graphics class in the ROOT system.
Definition
TPad.h:28
TPaveText
A Pave (see TPave) with text, lines or/and boxes inside.
Definition
TPaveText.h:21
SetBorderSize
c SetBorderSize(2)
Author
Wim Lavrijsen
Definition in file
ntuple1.py
.
tutorials
pyroot
ntuple1.py
ROOT v6-32 - Reference Guide Generated on Tue Mar 25 2025 14:22:38 (GVA Time) using Doxygen 1.10.0