Back to home page

EIC code displayed by LXR

 
 

    


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

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 
0023 ::
0024 
0025     simon:pmt blyth$ ./polyconfig.py 
0026                  DEFAULT : {'verbosity': '0', 'resolution': '40', 'poly': 'IM'} 
0027                CONTAINER : {'containerscale': '4', 'container': '1', 'verbosity': '0', 'resolution': '40', 'poly': 'IM'} 
0028                lvPmtHemi : {'verbosity': '0', 'resolution': '40', 'poly': 'IM'} 
0029          lvPmtHemiVacuum : {'verbosity': '0', 'resolution': '40', 'poly': 'IM'} 
0030         lvPmtHemiCathode : {'threshold': '1', 'verbosity': '0', 'nominal': '7', 'coarse': '6', 'poly': 'DCS'} 
0031          lvPmtHemiBottom : {'threshold': '1', 'verbosity': '0', 'nominal': '7', 'coarse': '6', 'poly': 'DCS'} 
0032          lvPmtHemiDynode : {'verbosity': '3', 'resolution': '40', 'poly': 'IM'} 
0033 
0034 
0035 """
0036 
0037 DEFAULT = "DEFAULT"
0038 CONTAINER = "CONTAINER"
0039 PYREX = "lvPmtHemi"    
0040 VACUUM = "lvPmtHemiVacuum"   
0041 CATHODE = "lvPmtHemiCathode"
0042 BOTTOM = "lvPmtHemiBottom"
0043 DYNODE = "lvPmtHemiDynode"
0044 
0045 ALL = [DEFAULT, CONTAINER, PYREX, VACUUM, CATHODE, BOTTOM, DYNODE ]
0046 
0047 
0048 class PolyConfig(object):
0049     """
0050     Common location for volume specific polygonization settings
0051     to avoid duplication between the GDML and detdesc branches.
0052     """
0053 
0054     def __init__(self, lvn):
0055         self.lvn = lvn 
0056 
0057     def _get(self, d):
0058         return d.get(self.lvn, d[DEFAULT])  
0059 
0060 
0061     # general settings
0062 
0063     _verbosity = {
0064           DYNODE:"0",
0065           DEFAULT:"0"
0066     }
0067 
0068     _poly = {
0069      #    CATHODE:"DCS",
0070      #    BOTTOM:"DCS",
0071          CONTAINER:"IM",
0072          DEFAULT:"IM"
0073     }
0074 
0075     verbosity = property(lambda self:self._get(self._verbosity))
0076     poly = property(lambda self:self._get(self._poly))
0077 
0078 
0079     # im settings
0080 
0081     _seeds = {
0082         CATHODE: "0,0,127.9,0,0,1",
0083          BOTTOM:"0,0,0,0,0,-1", 
0084          DEFAULT:None
0085      }
0086 
0087     _resolution = {
0088        #   BOTTOM:"150",
0089          DEFAULT:"20",
0090     }
0091 
0092     seeds = property(lambda self:self._get(self._seeds))
0093     resolution = property(lambda self:self._get(self._resolution))
0094 
0095 
0096     # dcs settings
0097 
0098     _nominal = {
0099          DEFAULT:"7",
0100     }
0101     _coarse = {
0102          DEFAULT:"6",
0103     }
0104     _threshold = {
0105          DEFAULT:"1",
0106     }
0107 
0108     nominal = property(lambda self:self._get(self._nominal))
0109     coarse = property(lambda self:self._get(self._coarse))
0110     threshold = property(lambda self:self._get(self._threshold))
0111 
0112 
0113     # mc settings
0114 
0115     _nx = {
0116          DEFAULT:"30"
0117     } 
0118 
0119     nx = property(lambda self:self._get(self._nx))
0120 
0121     # container settings
0122     #
0123     #      container="1" meta causes the NCSG deserialization 
0124     #      to adjust box size and position to contain contents (ie prior trees)
0125     #
0126 
0127     _container = dict(poly="IM",resolution="40", container="1", containerscale="4")
0128 
0129     def _get_meta(self):
0130         d = dict(verbosity=self.verbosity, poly=self.poly)
0131         if self.lvn == CONTAINER:
0132             d.update(self._container) 
0133         else:
0134             if d['poly'] == "IM":
0135                 d.update(resolution=self.resolution) 
0136                 seeds = self.seeds
0137                 if seeds is not None:d.update(seeds=seeds)
0138             elif d['poly'] == "DCS":
0139                 d.update(nominal=self.nominal, coarse=self.coarse, threshold=self.threshold) 
0140             elif d['poly'] == "MC":
0141                 d.update(nx=self.nx)
0142             else:
0143                 assert 0, d 
0144             pass
0145         pass
0146         return d
0147     meta = property(_get_meta)
0148 
0149     def __repr__(self):
0150         return "%20s : %s " % (self.lvn, self.meta )
0151 
0152 
0153 
0154 if __name__ == '__main__':
0155 
0156     for lvn in ALL:
0157         pc = PolyConfig(lvn)
0158         print(pc)
0159 
0160 
0161 
0162 
0163