Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:04

0001 #!/usr/bin/env python
0002 """
0003 sev.py
0004 ========
0005 
0006 ::
0007 
0008     In [11]: iid[hit_ii]
0009     Out[11]: 
0010     array([[29082,     2,  4938,  4938],
0011            [31842,     2,  8753,  8753],
0012            [32525,     2,  9656,  9656],
0013            [32355,     2,  9485,  9485],
0014            [35884,     2, 14395, 14395],
0015            ...,
0016            [40408,     3,  7566,  7566],
0017            [34641,     2, 12663, 12663],
0018            [29988,     2,  6174,  6174],
0019            [29182,     2,  5082,  5082],
0020            [37875,     2, 17165, 17165]], dtype=int32)
0021 
0022     In [18]: np.unique( iid[hit_ii,1], return_counts=True )
0023     Out[18]: (array([1, 2, 3], dtype=int32), array([ 138, 2587, 1068]))
0024 
0025 
0026 
0027 """
0028 
0029 import numpy as np
0030 from opticks.CSG.CSGFoundry import CSGFoundry
0031 from opticks.ana.fold import Fold
0032 from opticks.sysrap.stree import stree
0033 from opticks.ana.eprint import eprint, epr
0034 
0035 if __name__ == '__main__':
0036 
0037 
0038     cf = CSGFoundry.Load(symbol="cf") 
0039     print(repr(cf))
0040 
0041     stf = Fold.Load(cf.base, "CSGFoundry/SSim/stree", symbol="stf")
0042     st = stree(stf)
0043     print(repr(st))
0044 
0045     ev = Fold.Load("$FOLD",symbol="ev")
0046     print(repr(ev))
0047 
0048     hit_ii = ev.hit.view(np.int32)[:,1,3]  # sphoton.iindex
0049     print("hit_ii : %s " % str(hit_ii))
0050 
0051     iid = stf.inst_f4[:,:,3].view(np.int32)
0052     iid2 = cf.inst[:,:,3].view(np.int32)
0053     assert np.all( iid == iid2 ) 
0054 
0055     inst_diff = np.abs(stf.inst_f4[:,:,:3] - cf.inst[:,:,:3]).max() 
0056     print(" inst_diff : %s " % inst_diff )
0057 
0058      
0059 
0060