Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Create notebooks from pyroot tutorials
  • Loading branch information
pmiquelm committed Aug 23, 2016
commit c8570e766dcac3824956fecd165d7209587c2513
1 change: 1 addition & 0 deletions tutorials/pyroot/DynamicSlice.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## Example of function called when a mouse event occurs in a pad.
## When moving the mouse in the canvas, a second canvas shows the
## projection along X of the bin corresponding to the Y position
Expand Down
8 changes: 4 additions & 4 deletions tutorials/pyroot/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

ROOT.SetSignalPolicy( ROOT.kSignalFast )

### macro files
## macro files
macros = [
'framework.py', 'hsimple.py', 'hsum.py', 'formula1.py',
'fillrandom.py','fit1.py', 'h1draw.py', 'graph.py',
'gerrors.py', 'tornado.py', 'surfaces.py', 'zdemo.py',
'geometry.py', 'na49view.py', 'file.py',
'ntuple1.py', 'rootmarks.py' ]

### note: this function is defined in tutorials/rootlogon.C
## note: this function is defined in tutorials/rootlogon.C
def bexec( dir, macro, bench ):
if ROOT.gROOT.IsBatch():
print 'Processing benchmark: %s\n' % macro
Expand All @@ -41,12 +41,12 @@ def bexec( dir, macro, bench ):
bench.Update()


### --------------------------------------------------------------------------
## --------------------------------------------------------------------------
if __name__ == '__main__':

try:
# convenience, allowing to run this file from a different directory
macrodir = os.path.dirname( os.path.join( os.getcwd(), __file__ ) )
macrodir = os.path.expandvars('$ROOTSYS/tutorials/pyroot/')
except NameError:
macrodir = '' # in case of p2.2

Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/demoshelp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## Display demo help.
##
## \macro_code
Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/fildir.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## This macro displays the ROOT Directory data structure
##
## \macro_image
Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/file.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## This macro displays the physical ROOT file structure
##
## \macro_image
Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/fillrandom.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## FillRandom example
##
## \macro_image
Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/first.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## My first PyROOT interactive session
##
## \macro_image
Expand Down
3 changes: 2 additions & 1 deletion tutorials/pyroot/fit1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## Fit example.
##
## \macro_image
Expand Down Expand Up @@ -50,7 +51,7 @@
fitlabel = TPaveText( 0.6, 0.3, 0.9, 0.80, 'NDC' )
fitlabel.SetTextAlign( 12 )
fitlabel.SetFillColor( 42 )
fitlabel.ReadFile(path.join(path.dirname(__file__),'fit1_py.py'))
fitlabel.ReadFile(path.expandvars('$ROOTSYS/tutorials/pyroot/fit1_py.py'))
fitlabel.Draw()
c1.Update()
gBenchmark.Show( 'fit1' )
57 changes: 57 additions & 0 deletions tutorials/pyroot/fit2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## Fit example.
##
## \macro_image
## \macro_output
## \macro_code
##
## \author Wim Lavrijsen

from os import path
from ROOT import TCanvas, TFile, TPaveText
from ROOT import gROOT, gBenchmark

c1 = TCanvas( 'c1', 'The Fit Canvas', 200, 10, 700, 500 )
c1.SetGridx()
c1.SetGridy()
c1.GetFrame().SetFillColor( 21 )
c1.GetFrame().SetBorderMode(-1 )
c1.GetFrame().SetBorderSize( 5 )

gBenchmark.Start( 'fit1' )
#
# We connect the ROOT file generated in a previous tutorial
#
fill = TFile( 'py-fillrandom.root' )

#
# The function "ls()" lists the directory contents of this file
#
fill.ls()

#
# Get object "sqroot" from the file.
#

sqroot = gROOT.FindObject( 'sqroot' )
sqroot.Print()

#
# Now fit histogram h1f with the function sqroot
#
h1f = gROOT.FindObject( 'h1f' )
h1f.SetFillColor( 45 )
h1f.Fit( 'sqroot' )

# We now annotate the picture by creating a PaveText object
# and displaying the list of commands in this macro
#
fitlabel = TPaveText( 0.6, 0.3, 0.9, 0.80, 'NDC' )
fitlabel.SetTextAlign( 12 )
fitlabel.SetFillColor( 42 )
fitlabel.ReadFile(path.expandvars('$ROOTSYS/tutorials/pyroot/fit1_py.py'))
fitlabel.Draw()
c1.Update()
gBenchmark.Show( 'fit1' )
1 change: 1 addition & 0 deletions tutorials/pyroot/formula1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook -js
## TF1 example.
##
## \macro_image
Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/framework.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## The ROOT Framework
##
## \macro_image
Expand Down
3 changes: 2 additions & 1 deletion tutorials/pyroot/geometry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook -nodraw
## Geometry
##
## \macro_code
Expand All @@ -11,7 +12,7 @@

try:
# convenience, allowing to run this file from a different directory
macrodir = os.path.dirname( os.path.join( os.getcwd(), __file__ ) )
macrodir = os.path.expandvars("$ROOTSYS/tutorials/pyroot/")
except NameError:
macrodir = '' # in case of p2.2

Expand Down
4 changes: 1 addition & 3 deletions tutorials/pyroot/gerrors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook -js
## A Simple Graph with error bars
##
## \macro_image
Expand All @@ -11,11 +12,8 @@
from ROOT import gROOT
from array import array



c1 = TCanvas( 'c1', 'A Simple Graph with error bars', 200, 10, 700, 500 )

c1.SetFillColor( 42 )
c1.SetGrid()
c1.GetFrame().SetFillColor( 21 )
c1.GetFrame().SetBorderSize( 12 )
Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## A Simple Graph Example
##
## \macro_image
Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/h1draw.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook -js
## A Simple histogram drawing example
##
## \macro_image
Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/hsimple.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook -js
## This program creates :
## - a one dimensional histogram
## - a two dimensional histogram
Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/hsum.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook -js
## Simple example illustrating how to use the C++ interpreter
##
## \macro_image
Expand Down
7 changes: 4 additions & 3 deletions tutorials/pyroot/mrt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook -nodraw
## Build ROOT Ntuple from other source.
## This program reads the `aptuple.txt' file row by row, then creates
## the Ntuple by adding row by row.
Expand All @@ -9,15 +10,15 @@
##
## \author Wim Lavrijsen

import sys, string
import sys, string, os
from ROOT import TFile, TNtuple


ifn = 'aptuple.txt'
ifn = os.path.expandvars("${ROOTSYS}/tutorials/pyroot/aptuple.txt")
ofn = 'aptuple.root'

print 'opening file', ifn, '...'
infile = open( 'aptuple.txt', 'r' )
infile = open( ifn, 'r' )
lines = infile.readlines()
title = lines[0]
labels = string.split( lines[1] )
Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/multifit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## Example showing how to fit in a sub-range of an histogram
## An histogram is created and filled with the bin contents and errors
## defined in the table below.
Expand Down
1 change: 1 addition & 0 deletions tutorials/pyroot/ntuple1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## \file
## \ingroup tutorial_pyroot
## \notebook
## Ntuple drawing example.
##
## \macro_code
Expand Down
4 changes: 2 additions & 2 deletions tutorials/pyroot/parse_CSV_file_with_TTree_ReadStream.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
## This example is shipped with a data
## file that looks like:
##
## ```cpp
## ~~~{.cpp}
## Date/Time Synchro Capacity Temp.Cold Head Temp. Electrode HV Supply Voltage Electrode 1 Electrode 2 Electrode 3 Electrode 4
## # Example data to read out. Some data have oddities that might need to
## # dealt with, including the 'NaN' in Electrode 4 and the empty string in Date/Time (last row)
Expand All @@ -23,7 +23,7 @@
## 08112010.160628 7 5.702000E-10 8.786000 24.237400 -0.009141 0 0 0 0
## 08112010.160633 7 5.710000E-10 9.016200 24.237200 -0.008818 0 0 0 0
## 7 5.710000E-10 8.903400 24.237200 -0.008818 0 0 0 0
## ```
## ~~~
##
## These data require some massaging, including:
##
Expand Down
Loading