-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
33 lines (26 loc) · 751 Bytes
/
example.py
File metadata and controls
33 lines (26 loc) · 751 Bytes
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
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
import ROOT
from array import array
rechits=[]
recfile=ROOT.TFile('savehits_output_1.root','READ')
myTree = recfile.Get("hits_tree")
n=0
for entry in myTree:
n=n+1
if n==3:
break
for i in range(len(entry.hit_global_x)):
rechits.append([entry.hit_global_x[i],entry.hit_global_y[i],entry.hit_global_z[i]])
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
rechits_t=list(map(list, zip(*rechits)))
xs = array( 'd' , rechits_t[0])
ys = array( 'd' , rechits_t[1])
zs = array( 'd' , rechits_t[2])
ax.scatter(zs, xs, ys, c='b',alpha=0.2, marker='.',s=1)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
plt.show()