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 #-*- coding: utf-8 -*-
0003 #
0004 # Copyright (c) 2019 Opticks Team. All Rights Reserved.
0005 #
0006 # This file is part of Opticks
0007 # (see https://bitbucket.org/simoncblyth/opticks).
0008 #
0009 # Licensed under the Apache License, Version 2.0 (the "License"); 
0010 # you may not use this file except in compliance with the License.  
0011 # You may obtain a copy of the License at
0012 #
0013 #   http://www.apache.org/licenses/LICENSE-2.0
0014 #
0015 # Unless required by applicable law or agreed to in writing, software 
0016 # distributed under the License is distributed on an "AS IS" BASIS, 
0017 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0018 # See the License for the specific language governing permissions and 
0019 # limitations under the License.
0020 #
0021 
0022 import os, logging
0023 
0024 log = logging.getLogger(__name__)
0025 
0026 from opticks.ana.base import opticks_main
0027 from opticks.analytic.treebase import Tree
0028 from opticks.analytic.gdml import GDML
0029 
0030 def gdml2idmap(tree, pv_sd_name, pv_sd_pmtid):
0031     name_cache = set()
0032     for k,v in tree.byindex.iteritems():
0033         #print k, v.pv.name
0034         name = v.pv.name.split('0x')[0]
0035 
0036         is_sd = name in pv_sd_name 
0037         pmtid = 0
0038 
0039         if is_sd:
0040             pmtid = pv_sd_pmtid[name]
0041             pv_sd_pmtid[name] += 1
0042 
0043         print "%d %d %d"%(v.index, pmtid, is_sd)
0044 
0045         name_cache.add(name)
0046     log.info(name_cache)
0047     log.info(pv_sd_pmtid)
0048     # set(['pAcylic', 'PMT_3inch_log_phys', 'PMT_3inch_cntr_phys', 'PMT_3inch_body_phys', 'lUpperChimney_phys', 'pCentralDetector', 'pExpHall', 'pPoolLining', 'pLowerChimneySteel', 'pUpperChimneyTyvek', 'pMask', 'lSurftube_phys', 'lFasteners_phys', 'lMaskVirtual_phys', 'top', 'PMT_3inch_inner2_phys', 'pvacSurftube', 'PMT_20inch_inner2_phys', 'pOuterWaterPool', 'pInnerWater', 'PMT_3inch_inner1_phys', 'pBtmRock', 'PMT_20inch_body_phys', 'lLowerChimney_phys', 'pTarget', 'lSteel_phys', 'PMT_20inch_log_phys', 'pUpperChimneySteel', 'pLowerChimneyAcrylic', 'pUpperChimneyLS', 'pLowerChimneyTyvek', 'PMT_20inch_inner1_phys', 'pLowerChimneyBlocker', 'pLowerChimneyLS', 'pTopRock'])
0049 
0050 
0051 if __name__ == "__main__":
0052     args = opticks_main()
0053     log.info(args)
0054     gdmlpath = os.environ['OPTICKS_GDMLPATH']
0055     log.info(gdmlpath)
0056     log.info("start GDML parse")
0057     gdml = GDML.parse(gdmlpath)
0058 
0059     log.info("start treeify")
0060     tree = Tree(gdml.world)  
0061     # print tree
0062     # print dir(tree)
0063     # print tree.root
0064 
0065 
0066     # FOR JUNO ONLY
0067     pv_sd_name = None
0068     pv_sd_pmtid = None
0069 
0070     if args.j1707:
0071         pv_sd_name = ['PMT_20inch_inner1_phys', 'PMT_3inch_inner1_phys']
0072         pv_sd_pmtid = {'PMT_20inch_inner1_phys': 0, 'PMT_3inch_inner1_phys': 300000}
0073 
0074     gdml2idmap(tree, pv_sd_name, pv_sd_pmtid)