User Tools

Site Tools


root:example_ttree

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
root:example_ttree [2017/06/12 21:51] iwnroot:example_ttree [2017/06/22 15:25] (current) iwn
Line 1: Line 1:
-Below is an example on the use of ''TTree'' in ''pyROOT''. Run with+Below is an example on the use of ''TTree'' in ''pyROOT''. Run in the command line with
 <code> <code>
-python trees.py+python trees.py 
 +</code> 
 +and check output with 
 +<code> 
 +$ root -l tree.root 
 +root [1] TBrowser a
 </code> </code>
  
- +<code python trees.py>
-<code python trees.py>+
 #! /usr/bin/env python #! /usr/bin/env python
  
Line 11: Line 15:
 start = time.time() start = time.time()
  
-from ROOT import gRandom, TFile, TTree, TH1D, TObject+from ROOT import gRandom, TFile, TTree, TH1D
 from array import array from array import array
 import numpy # alternative to array import numpy # alternative to array
Line 74: Line 78:
  
     # overwrite the tree in the output file and close the file     # overwrite the tree in the output file and close the file
-    f.Write("",TObject.kOverwrite)+    f.Write("",TFile.kOverwrite)
     f.Close()     f.Close()
  
Line 93: Line 97:
         h1.Fill(gRandom.Gaus(2,2))         h1.Fill(gRandom.Gaus(2,2))
  
-    f.Write("",TObject.kOverwrite)+    f.Write("",TFile.kOverwrite)
     f.Close()     f.Close()
  
Line 120: Line 124:
         h1.Fill(gRandom.Gaus(4,3))         h1.Fill(gRandom.Gaus(4,3))
  
-    f.Write("",TObject.kOverwrite)+    f.Write("",TFile.kOverwrite)
     f.Close()     f.Close()
  
Line 150: Line 154:
         t.Fill()         t.Fill()
  
-    f.Write("",TObject.kOverwrite)+    f.Write("",TFile.kOverwrite)
     f.Close()     f.Close()
  
root/example_ttree.1497297072.txt.gz · Last modified: 2017/06/12 21:51 by iwn