File indexing completed on 2026-04-10 07:49:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 """
0022
0023
0024
0025 Torchstep are read by optixrap/cu/torchstep.h:tsload
0026
0027
0028 ::
0029
0030 In [2]: run torchdbg.py
0031
0032 In [3]: a
0033 Out[3]:
0034 array([[[ 0. , 0. , 0. , 0. ],
0035 [ 0. , 0. , -200. , 0.1], ## post : ts.x0, ts.t0
0036 [ 0. , 0. , 1. , 1. ], ## dirw : ts.p0, ts.weight
0037 [ 0. , 0. , -1. , 550. ], ## polw : ts.pol, ts.wavelength
0038 [ 0.5, 1. , 0. , 1. ], ## zeaz : ts.zeaz
0039 [ 100. , 25. , 0. , 0. ]]], ## beam : ts.beam.x (radius) ts.beam.y (distance) ts.type eg T_REFLTEST ts.mode
0040 dtype=float32)
0041
0042 In [4]: a.view(np.int32)
0043 Out[4]:
0044 array([[[ 4096, 0, 3, 10000], ## ctrl : GenstepType/ts.ParentId/ts.MaterialIndex/ts.NumPhotons
0045 [ 0, 0, -1018691584, 1036831949],
0046 [ 0, 0, 1065353216, 1065353216],
0047 [ 0, 0, -1082130432, 1141473280],
0048 [ 1056964608, 1065353216, 0, 1065353216],
0049 [ 1120403456, 1103626240, 5, 9]]] ts.mode = 5 , ts.type = 9
0050 , dtype=int32)
0051
0052 ::
0053
0054 In [8]: 0x1 << 2 | 0x1 << 0 ## M_SPOL | M_FLAT_THETA
0055 Out[8]: 5
0056
0057
0058
0059
0060 ::
0061
0062 3 // for both non-CUDA and CUDA compilation
0063 4 typedef enum {
0064 5 T_UNDEF, # 0
0065 6 T_SPHERE,
0066 7 T_POINT,
0067 8 T_DISC,
0068 9 T_DISC_INTERSECT_SPHERE, # 4
0069 10 T_DISC_INTERSECT_SPHERE_DUMB, # 5
0070 11 T_DISCLIN,
0071 12 T_DISCAXIAL,
0072 13 T_INVSPHERE,
0073 14 T_REFLTEST, # 9
0074 15 T_INVCYLINDER,
0075 16 T_RING,
0076 17 T_NUM_TYPE
0077 18 } Torch_t ;
0078
0079 20 typedef enum {
0080 21 M_UNDEF = 0x0 ,
0081 22 M_SPOL = 0x1 << 0,
0082 23 M_PPOL = 0x1 << 1,
0083 24 M_FLAT_THETA = 0x1 << 2,
0084 25 M_FLAT_COSTHETA = 0x1 << 3,
0085 26 M_FIXPOL = 0x1 << 4
0086 27 } Mode_t ;
0087 28
0088
0089
0090
0091
0092
0093
0094 ::
0095
0096 simon:optickscore blyth$ cat OpticksPhoton.h
0097
0098 enum
0099 {
0100 CERENKOV = 0x1 << 0,
0101 SCINTILLATION = 0x1 << 1,
0102 ...
0103 TORCH = 0x1 << 12, ## 4096
0104 G4GUN = 0x1 << 14
0105 };
0106
0107
0108
0109
0110
0111 """
0112 import os, logging, numpy as np
0113 log = logging.getLogger(__name__)
0114
0115 if __name__ == '__main__':
0116 os.environ["TMP"] = os.path.expandvars("/tmp/$USER/opticks")
0117 a = np.load(os.path.expandvars("$TMP/torchdbg.npy"))
0118
0119