File indexing completed on 2026-04-09 07:48:48
0001
0002 """
0003 gpltcf.py
0004 ===========
0005
0006 This plots solids parsed from two GDML files providing
0007 a visualization of geometry changes.
0008
0009 See also:
0010
0011 gpmt.py
0012 plotting solids from a single GDML file
0013
0014
0015 ::
0016
0017 cp -r /tmp/fig/PolyconeNeck ~/simoncblyth.bitbucket.io/env/presentation/ana/
0018 l ~/simoncblyth.bitbucket.io/env/presentation/ana/PolyconeNeck/
0019
0020
0021 ::
0022
0023 jcv HamamatsuR12860PMTManager
0024 jcv Hamamatsu_R12860_PMTSolid
0025
0026
0027 """
0028 import matplotlib.pyplot as plt, numpy as np, logging
0029 log = logging.getLogger(__name__)
0030
0031 from opticks.analytic.gdml import GDML
0032 from opticks.ana.gargs import GArgs
0033 from opticks.ana.gplt import GPlot
0034
0035 from j.PMTEfficiencyCheck_ import PMTEfficiencyCheck_
0036
0037 if __name__ == '__main__':
0038
0039 plt.ion()
0040
0041 pec = PMTEfficiencyCheck_()
0042
0043
0044 args = GArgs.parse(__doc__)
0045
0046 combiZoom = False
0047
0048
0049
0050 ilv = 2
0051
0052 if ilv == 1:
0053 ipec = 1
0054 elif ilv == 2:
0055 ipec = 0
0056 else:
0057 ipec = None
0058 pass
0059
0060
0061 closeup = False
0062
0063 lvx = args.lvname(ilv)
0064 if lvx.startswith("Hamamatsu") and closeup:
0065 def zoomlimits(ax):
0066 ax.set_xlim( 80,180)
0067 ax.set_ylim(-230,-130)
0068 pass
0069 elif lvx.startswith("NNVT") and closeup:
0070 def zoomlimits(ax):
0071 ax.set_xlim( 40,140)
0072 ax.set_ylim(-250,-150)
0073 pass
0074 else:
0075 def zoomlimits(ax):
0076 pass
0077 pass
0078 pass
0079
0080 args.figdir = "/tmp/fig/PolyconeNeck"
0081
0082 figpfx = "gpltcf"
0083 figpfx += "_%s" % lvx
0084 if combiZoom: figpfx += "_combiZoom"
0085
0086 args.figpfx = figpfx
0087 args.shorten_title_ = lambda s:s.replace("PMT_20inch_","")
0088
0089
0090 g0 = GDML.parse(args.gdmlpath(0))
0091 g0.smry()
0092 g1 = GDML.parse(args.gdmlpath(1))
0093 g1.smry()
0094
0095 lv0 = g0.find_one_volume(lvx)
0096 log.info( "lv0 %r " % lvx )
0097
0098 lv1 = g1.find_one_volume(lvx)
0099 log.info( "lv1 %r " % lvx )
0100
0101 lvs0 = g0.get_traversed_volumes( lv0, maxdepth=args.maxdepth )
0102 lvs1 = g1.get_traversed_volumes( lv1, maxdepth=args.maxdepth )
0103
0104 fig, axs = GPlot.SubPlotsFig(plt, [lvs0,lvs1], args, combiZoom=combiZoom, zoomlimits=zoomlimits)
0105
0106 if not pec is None:
0107 pec.rz_plot(axs, ipec)
0108 pass
0109
0110 fig.show()
0111
0112 cfpath = args.figpath("_SubPlotsFig")
0113 log.info("save to cfpath : %s " % cfpath)
0114 fig.savefig(cfpath)
0115
0116
0117 if combiZoom == False:
0118 ax = axs[0,0] if len(axs.shape) == 2 else axs[0]
0119 zoomlimits(ax)
0120
0121 fig.show()
0122
0123 cfzpath = args.figpath("_SubPlotsFig_Zoom")
0124 log.info("save to cfzpath : %s " % cfzpath)
0125 fig.savefig(cfzpath)
0126
0127
0128
0129