Geant4 Cross Reference |
1 #!/usr/bin/env python 1 #!/usr/bin/env python 2 # Python program explaining 2 # Python program explaining 3 # load() function 3 # load() function 4 4 5 import numpy as geek 5 import numpy as geek 6 import matplotlib.pyplot as plt 6 import matplotlib.pyplot as plt 7 7 8 b = geek.load('hits.npy') 8 b = geek.load('hits.npy') 9 9 10 print("size of b is:",b.size) 10 print("size of b is:",b.size) 11 print("shape of b is:",b.shape) 11 print("shape of b is:",b.shape) 12 print("ndim of b is:",b.ndim) 12 print("ndim of b is:",b.ndim) 13 print(b) 13 print(b) 14 print(b[0,0,0]) 14 print(b[0,0,0]) 15 print(b[0,3,0]) 15 print(b[0,3,0]) 16 print("b is printed from hits.npy") 16 print("b is printed from hits.npy") 17 x = b[:,0,0] 17 x = b[:,0,0] 18 y = b[:,0,1] 18 y = b[:,0,1] 19 z = b[:,0,2] 19 z = b[:,0,2] 20 lamb = b[:,2,3] 20 lamb = b[:,2,3] 21 print(x.shape) 21 print(x.shape) 22 print(y.shape) 22 print(y.shape) 23 print(lamb.shape) 23 print(lamb.shape) 24 24 25 #axs = plt.subplots(2, 2, figsize=(5, 5)) 25 #axs = plt.subplots(2, 2, figsize=(5, 5)) 26 plt.subplot(131) 26 plt.subplot(131) 27 plt.ylabel('#Photons') 27 plt.ylabel('#Photons') 28 plt.xlabel('x-position/mm') 28 plt.xlabel('x-position/mm') 29 plt.hist(x,50,(-200,200.)) 29 plt.hist(x,50,(-200,200.)) 30 plt.subplot(132) 30 plt.subplot(132) 31 plt.xlabel('x-position/mm') 31 plt.xlabel('x-position/mm') 32 plt.ylabel('y-position/mm') 32 plt.ylabel('y-position/mm') 33 plt.scatter(x, y) 33 plt.scatter(x, y) 34 plt.subplot(133) 34 plt.subplot(133) 35 plt.xlabel('lambda/nm') 35 plt.xlabel('lambda/nm') 36 plt.ylabel('#Photons') 36 plt.ylabel('#Photons') 37 plt.hist(lamb,50,(50,800.)) 37 plt.hist(lamb,50,(50,800.)) 38 #plt.hist(z) 38 #plt.hist(z) 39 plt.show() 39 plt.show()