Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #!/usr/bin/env python
0002 #
0003 # Copyright (c) 2019 Opticks Team. All Rights Reserved.
0004 #
0005 # This file is part of Opticks
0006 # (see https://bitbucket.org/simoncblyth/opticks).
0007 #
0008 # Licensed under the Apache License, Version 2.0 (the "License"); 
0009 # you may not use this file except in compliance with the License.  
0010 # You may obtain a copy of the License at
0011 #
0012 #   http://www.apache.org/licenses/LICENSE-2.0
0013 #
0014 # Unless required by applicable law or agreed to in writing, software 
0015 # distributed under the License is distributed on an "AS IS" BASIS, 
0016 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0017 # See the License for the specific language governing permissions and 
0018 # limitations under the License.
0019 #
0020 
0021 """
0022 tgltf.py : Shakedown analytic geometry
0023 ==========================================================
0024 
0025 Loads test events from Opticks
0026 
0027 Create the events by running tgltf-transitional
0028 
0029 Huh, top of cyl-z should not be there::
0030 
0031     In [8]: lpos[lpos[:,2] > 1500 ][:100]
0032     Out[8]: 
0033     A()sliced
0034     A([[ -367.125 ,   236.7812,  1535.    ,     1.    ],
0035            [  337.    , -1032.    ,  1535.    ,     1.    ],
0036            [  568.8125, -1328.9688,  1535.    ,     1.    ],
0037            [ 1212.875 ,  -858.375 ,  1535.    ,     1.    ],
0038            [  137.0625,  -371.6875,  1535.    ,     1.    ],
0039            [  849.6875,   997.6562,  1545.9814,     1.    ],
0040            [ -936.5625,   868.7812,  1547.71  ,     1.    ],
0041            [  196.3125,   411.9688,  1535.    ,     1.    ],
0042            [  -55.625 ,  -304.75  ,  1535.    ,     1.    ],
0043            [ -144.5   ,  -538.3125,  1535.    ,     1.    ],
0044            [ 1299.0625,  -612.9375,  1535.    ,     1.    ],
0045            [ -407.5   ,    13.3438,  1535.    ,     1.    ],
0046            [  865.375 ,   370.4062,  1535.    ,     1.    ],
0047            [  416.75  ,   478.5938,  1535.    ,     1.    ],
0048            [  431.75  ,   800.6875,  1535.    ,     1.    ],
0049            [   -8.5625,  1549.9375,  1526.9644,     1.    ],
0050            [  948.25  ,  -512.3438,  1535.    ,     1.    ],
0051            [  229.    ,   -32.5625,  1535.    ,     1.    ],
0052            [-1007.125 ,  -461.25  ,  1535.    ,     1.    ],
0053            [  -74.6875,  -607.125 ,  1535.    ,     1.    ],
0054            [  503.625 ,  -807.9062,  1535.    ,     1.    ],
0055            [  160.125 , -1057.0625,  1535.    ,     1.    ],
0056            [ -798.3125,    67.3125,  1535.    ,     1.    ],
0057            [-1278.25  ,   865.4062,  1535.    ,     1.    ],
0058            [ -509.625 ,   477.1562,  1535.    ,     1.    ],
0059            [ -141.875 ,  1289.5   ,  1535.    ,     1.    ],
0060 
0061 
0062 
0063 
0064 """
0065 import os, sys, logging, argparse, numpy as np
0066 import numpy.linalg as la
0067 
0068 log = logging.getLogger(__name__)
0069 
0070 from opticks.ana.base import opticks_main
0071 from opticks.ana.nbase import vnorm
0072 from opticks.ana.evt  import Evt
0073 
0074 from opticks.analytic.sc  import gdml2gltf_main
0075 
0076 
0077 if __name__ == '__main__':
0078     np.set_printoptions(precision=4, linewidth=200)
0079 
0080     os.environ['OPTICKS_QUERY']="range:3159:3160" 
0081 
0082     args = opticks_main(doc=__doc__, tag="1", src="torch", det="gltf" )
0083 
0084     sc = gdml2gltf_main(args)
0085     tx = sc.get_transform(3159)
0086     print tx
0087 
0088     itx = la.inv(tx)
0089     print itx
0090 
0091 
0092     log.info("tag %s src %s det %s  " % (args.utag,args.src,args.det))
0093 
0094 
0095     seqs=[]
0096 
0097     try:
0098         a = Evt(tag="%s" % args.utag, src=args.src, det=args.det, seqs=seqs, args=args)
0099     except IOError as err:
0100         log.fatal(err)
0101         #sys.exit(args.mrc)  this causes a sysrap-t test fail from lack of a tmp file
0102         sys.exit(0)
0103 
0104 
0105     log.info( " a : %s " % a.brief)
0106 
0107     print a.seqhis_ana.table
0108 
0109     a.sel = "TO SA"
0110     ox = a.ox
0111 
0112 
0113     print ox.shape   # masked array with those photons
0114 
0115     pos = ox[:,0,:4]
0116     pos[:,3] = 1.
0117 
0118     lpos = np.dot( pos, itx )
0119 
0120 
0121 
0122 
0123