File indexing completed on 2026-04-10 07:49:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 """
0022 g4gun.py: loads G4Gun event
0023 ===============================
0024
0025 To create the event use::
0026
0027 ggv-
0028 ggv-g4gun
0029
0030
0031 """
0032 import os, sys, logging, numpy as np
0033 log = logging.getLogger(__name__)
0034
0035
0036 from opticks.ana.base import opticks_main
0037 from opticks.ana.evt import Evt
0038
0039 import matplotlib.pyplot as plt
0040
0041
0042 mnavmx_ = lambda _:(np.min(_),np.average(_),np.max(_))
0043
0044
0045 def red_gensteps_everywhere_issue(gs):
0046 """
0047 """
0048 post = gs[:,1]
0049 print post.shape
0050 print post
0051
0052 npho = gs[:,0,3].view(np.int32)
0053
0054 npho_0 = np.count_nonzero(npho == 0)
0055 npho_1 = np.count_nonzero(npho == 1)
0056 npho_2 = np.count_nonzero(npho > 1)
0057
0058
0059 cx = np.array(map(mnavmx_, map(np.array, post.T )))
0060 ce = cx[:3,1]
0061 print cx
0062
0063 x = post[:,0] - ce[0]
0064 y = post[:,1] - ce[1]
0065 z = post[:,2] - ce[2]
0066 t = post[:,3]
0067
0068
0069 s = npho > 0
0070
0071 fig = plt.figure()
0072
0073 ax = fig.add_subplot(221)
0074 ax.hist(x[s], bins=100)
0075 ax.set_yscale('log')
0076
0077 ax = fig.add_subplot(222)
0078 ax.hist(y[s], bins=100)
0079 ax.set_yscale('log')
0080
0081 ax = fig.add_subplot(223)
0082 ax.hist(z[s], bins=100)
0083 ax.set_yscale('log')
0084
0085 ax = fig.add_subplot(224)
0086 ax.hist(t[s], bins=100)
0087 ax.set_yscale('log')
0088 fig.show()
0089
0090
0091
0092 if __name__ == '__main__':
0093
0094 ok = opticks_main(src="G4Gun", det="G4Gun", tag="-1")
0095
0096 try:
0097 evt = Evt(tag=ok.tag, src=ok.src, det=ok.det, args=ok)
0098 except IOError as err:
0099 log.fatal(err)
0100 sys.exit(ok.mrc)
0101 pass
0102
0103 print evt
0104
0105 red_gensteps_everywhere_issue(evt.gs)
0106
0107
0108
0109
0110
0111