Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:49:17

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 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     #apmtpathtmpl_default = "$TMP/GPmt/%(apmtidx)s/GPmt.npy"
0040     #apmtpathtmpl_default = "$IDPATH/GPmt/%(apmtidx)s/GPmt.npy"
0041     #apmtpathtmpl_default = "$OPTICKS_INSTALL_PREFIX/opticksdata/export/DayaBay/GPmt/%(apmtidx)s/GPmt.npy" 
0042     #args = opticks_main(apmtpathtmpl=apmtpathtmpl_default, apmtidx=2)
0043 
0044     args = opticks_main(apmtidx=2)
0045 
0046     ddpart_manual_mixin()  # add partitioner methods to Tubs, Sphere, Elem and Primitive
0047     treepart_manual_mixin() # add partitioner methods to Node and Tree
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()   # to apmtpath and sidecars
0094 
0095 
0096