File indexing completed on 2026-04-09 07:49:04
0001
0002 """
0003 gx.py : examine geometry from G4CXOpticks::saveGeometry
0004 ==========================================================
0005
0006 """
0007
0008 import numpy as np
0009 from opticks.ana.fold import Fold
0010 from opticks.sysrap.stree import stree
0011 from opticks.CSG.CSGFoundry import CSGFoundry
0012
0013
0014 def desc_sensor(st):
0015 """
0016 desc_sensor
0017 nds : lv : soname
0018 4997 : 106 : HamamatsuR12860_PMT_20inch_inner1_solid_I
0019 4997 : 108 : HamamatsuR12860_PMT_20inch_body_solid_1_4
0020 12615 : 113 : NNVTMCPPMT_PMT_20inch_inner1_solid_head
0021 12615 : 115 : NNVTMCPPMT_PMT_20inch_body_solid_head
0022 25600 : 118 : PMT_3inch_inner1_solid_ell_helper
0023 25600 : 120 : PMT_3inch_body_solid_ell_ell_helper
0024 2400 : 130 : PMT_20inch_veto_inner1_solid
0025 2400 : 132 : PMT_20inch_veto_body_solid_1_2
0026
0027
0028 In [7]: np.unique( st.nds.sensor_id )
0029 Out[7]: array([ -1, 0, 1, 2, 3, ..., 325595, 325596, 325597, 325598, 325599], dtype=int32)
0030
0031 In [8]: np.unique( st.nds.sensor_index )
0032 Out[8]: array([ -1, 0, 1, 2, 3, ..., 45607, 45608, 45609, 45610, 45611], dtype=int32)
0033
0034 In [9]: np.unique( st.nds.sensor_name )
0035 Out[9]: array([-1, 0, 1, 2, 3], dtype=int32)
0036
0037 """
0038 ws = np.where(st.nds.sensor_index > -1 )[0]
0039 se = st.nds.sensor_index[ws]
0040 xse = np.arange(len(se), dtype=np.int32)
0041 assert np.all( xse == se )
0042 ulv, nlv = np.unique(st.nds.lvid[ws], return_counts=True)
0043
0044 hfmt = "%7s : %3s : %50s : %s "
0045 fmt = "%7d : %3d : %50s : %s "
0046 hdr = hfmt % ("nds", "lv", "soname", "0th" )
0047
0048 zths = [st.find_lvid_node(ulv[i],0) for i in range(len(ulv))]
0049
0050 extra = []
0051 for zth in zths:
0052 extra += ["zth:%s" % zth,]
0053 extra += [st.desc_nodes( st.get_children(zth, prepend_arg=True),brief=True),]
0054 pass
0055
0056 head = ["desc_sensor",hdr]
0057 body = [fmt % ( nlv[i], ulv[i], st.soname_[ulv[i]], zths[i] ) for i in range(len(ulv))]
0058 tail = [hfmt % ( nlv.sum(), "", "", "" ),]
0059 return "\n".join(head+body+tail+extra)
0060
0061
0062 if __name__ == '__main__':
0063 cf = CSGFoundry.Load(symbol="cf")
0064 print(cf)
0065
0066 f = Fold.Load(cf.base, "CSGFoundry/SSim/stree", symbol="f")
0067 st = stree(f)
0068
0069 print(repr(st))
0070 print(desc_sensor(st))
0071 pass
0072
0073