File indexing completed on 2026-04-09 07:48:47
0001
0002 """
0003 evtplt.py : pyvista 3d plotting photon step points within selections
0004 =========================================================================
0005
0006 ::
0007
0008 run evtplt.py --tag -1
0009
0010
0011 TODO: for G4 only (-ve itag) could use the deluxe buffer dx.npy for double precision step points
0012
0013
0014 """
0015 import numpy as np
0016 from opticks.ana.evt import Evt
0017 import pyvista as pv
0018
0019 if __name__ == '__main__':
0020 from opticks.ana.main import opticks_main
0021 ok = opticks_main(pfx="tds3ip", src="natural")
0022
0023 itag = int(ok.utag)
0024
0025 a = Evt(tag="%d"%itag, src=ok.src, det=ok.det, pfx=ok.pfx, args=ok)
0026 if hasattr(a, 'seqhis_ana'):
0027 expr="a.seqhis_ana.table[0:20]"
0028 print(expr)
0029 print(eval(expr))
0030 pass
0031
0032 if itag < 0:
0033 a.sel = "TO BT BT BT BT SD"
0034
0035
0036 elif itag > 0:
0037 a.sel = "TO BT BT BT SD"
0038
0039
0040 else:
0041 assert 0
0042 pass
0043
0044 post = a.rpost()
0045 pos = post[:,:,:3]
0046
0047
0048 q000 = np.logical_and( np.logical_and( pos[:,-1,0] < 0, pos[:,-1,1] < 0 ), pos[:,-1,2] < 0 )
0049 q001 = np.logical_and( np.logical_and( pos[:,-1,0] < 0, pos[:,-1,1] < 0 ), pos[:,-1,2] > 0 )
0050 q010 = np.logical_and( np.logical_and( pos[:,-1,0] < 0, pos[:,-1,1] > 0 ), pos[:,-1,2] < 0 )
0051 q011 = np.logical_and( np.logical_and( pos[:,-1,0] < 0, pos[:,-1,1] > 0 ), pos[:,-1,2] > 0 )
0052 q100 = np.logical_and( np.logical_and( pos[:,-1,0] > 0, pos[:,-1,1] < 0 ), pos[:,-1,2] < 0 )
0053 q101 = np.logical_and( np.logical_and( pos[:,-1,0] > 0, pos[:,-1,1] < 0 ), pos[:,-1,2] > 0 )
0054 q110 = np.logical_and( np.logical_and( pos[:,-1,0] > 0, pos[:,-1,1] > 0 ), pos[:,-1,2] < 0 )
0055 q111 = np.logical_and( np.logical_and( pos[:,-1,0] > 0, pos[:,-1,1] > 0 ), pos[:,-1,2] > 0 )
0056
0057
0058 qos = pos[q001]
0059
0060 colors = {}
0061 colors[-1] = [1,0,0]
0062 colors[-2] = [0,1,0]
0063 colors[-3] = [0,0,1]
0064 colors[-4] = [0,1,1]
0065 colors[-5] = [1,0,1]
0066 colors[-6] = [1,1,0]
0067
0068 pl = pv.Plotter()
0069
0070
0071 qq = [-1,-2,-3,-4]
0072 if itag < 0:
0073 qq += [-5]
0074 pass
0075
0076 for q in qq:
0077 pl.add_points( qos[:,q,:], color=colors[q] )
0078 pass
0079
0080 pl.show()
0081
0082
0083
0084