File indexing completed on 2026-04-10 07:49:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 import os, logging, sys
0023 log = logging.getLogger(__name__)
0024 import numpy as np
0025
0026 from opticks.analytic.treebase import Tree
0027
0028 from opticks.ana.base import opticks_main
0029 from opticks.ana.nbase import Buf
0030 from opticks.ana.pmt.ddbase import Dddb
0031 from opticks.ana.pmt.ddpart import ddpart_manual_mixin
0032 from opticks.ana.pmt.treepart import treepart_manual_mixin
0033
0034
0035 from GPmt import GPmt
0036
0037 if __name__ == '__main__':
0038
0039
0040
0041
0042
0043
0044 args = opticks_main(apmtidx=2)
0045
0046 ddpart_manual_mixin()
0047 treepart_manual_mixin()
0048
0049
0050 apmtpath = args.apmtpath
0051
0052 print "\nAiming to write serialized analytic PMT to below apmtpath\n%s\n" % apmtpath
0053
0054 if args.yes:
0055 print "proceeding without asking"
0056 else:
0057 proceed = raw_input("Enter YES to proceed... (use eg \"--apmtidx 3\" to write to different index whilst testing, skip dialog with --yes) ... ")
0058 if proceed != "YES": sys.exit(1)
0059 pass
0060
0061 xmlpath = args.apmtddpath
0062
0063 log.info("\n\nparsing %s -> %s " % (xmlpath, os.path.expandvars(xmlpath)))
0064
0065 log.info("\n\nDddb.parse xml \n")
0066 g = Dddb.parse(xmlpath)
0067
0068 log.info("\n\ng.logvol \n")
0069 lv = g.logvol_("lvPmtHemi")
0070
0071 log.info("\n\nTree(lv) \n")
0072 tr = Tree(lv)
0073
0074 log.info("\n\nDump Tree \n")
0075 tr.dump()
0076
0077 log.info("\n\nPartition Tree into parts list **ddpart.py:ElemPartitioner.parts** IS THE HUB \n")
0078 parts = tr.parts()
0079
0080 log.info("\n\nDump parts : type(parts):%s \n", type(parts))
0081 for pt in parts:
0082 print pt
0083
0084 assert hasattr(parts, 'gcsg') and len(parts.gcsg) > 0
0085 log.info("\n\nConvert parts to Buf (convert method mixed in from treepart.py applying as_quads to each part) \n")
0086 buf = tr.convert(parts)
0087 assert type(buf) is Buf
0088
0089 log.info("\n\nmake GPmt from Buf \n")
0090 gp = GPmt(apmtpath, buf )
0091
0092 log.info("\n\nsave GPmt\n")
0093 gp.save()
0094
0095
0096