Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:47

0001 #!/usr/bin/env python
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"  # 0x7ccccd 
0034         #        -6 -5 -4 -3 -2 -1
0035         #         Y  M  C  B  G  R
0036     elif itag > 0:
0037         a.sel = "TO BT BT BT SD"    #  0x7cccd 
0038         #        -5 -4 -3 -2 -1
0039         #         M  C  B  G  R
0040     else:
0041         assert 0 
0042     pass
0043 
0044     post = a.rpost()     # (247, 6, 4) 
0045     pos = post[:,:,:3]   # (247, 6, 3)
0046 
0047     #xyz  # octants 
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     #qos = pos[q000]   # pick an octant 
0058     qos = pos[q001]   # pick an octant 
0059 
0060     colors = {}
0061     colors[-1] = [1,0,0]   # R
0062     colors[-2] = [0,1,0]   # G
0063     colors[-3] = [0,0,1]   # B
0064     colors[-4] = [0,1,1]   # C
0065     colors[-5] = [1,0,1]   # M
0066     colors[-6] = [1,1,0]   # Y
0067 
0068     pl = pv.Plotter()
0069 
0070     #     R   G  B  C 
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