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/22 15:24] 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> </code>
-and check result with+and check output with
 <code> <code>
-root -l tree.root+root -l tree.root 
 +root [1] TBrowser a
 </code> </code>
  
Line 14: 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 77: 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 96: 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 123: 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 153: Line 154:
         t.Fill()         t.Fill()
  
-    f.Write("",TObject.kOverwrite)+    f.Write("",TFile.kOverwrite)
     f.Close()     f.Close()
  
root/example_ttree.txt · Last modified: 2017/06/22 15:25 by iwn