-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.py
executable file
·40 lines (29 loc) · 935 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /usr/bin/env python
import ROOT
from PyTreeReader import PyTreeReader
from timeit import default_timer as timer
h = ROOT.TH1F("h","h",1024,-200,200)
fill = h.Fill
f = ROOT.TFile("./hsimple.root")
start = timer()
for event in f.ntuple:
fill(event.px*event.py*event.pz*event.random)
duration = timer() - start
print "PyROOT: %s" %duration
start = timer()
for event in PyTreeReader(f.ntuple,"*"):
fill(event.px()*event.py()*event.pz()*event.random())
duration = timer() - start
print "PyTreeReader no cache: %s" %duration
start = timer()
ptr = PyTreeReader(f.ntuple,"*",cache=True)
duration = timer() - start
print "PyTreeReader build cache: %s" %duration
start = timer()
for event in ptr:
fill(event.px()*event.py()*event.pz()*event.random())
duration = timer() - start
print "PyTreeReader with cache: %s" %duration
h.Draw()
for i in ptr.py_array(): print i
## Are we in need of a method to fill histos from vectors?