/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 #!/usr/bin/env python 00002 ''' 00003 Dump local-volume coordinate axis 00004 00005 Note to others: this uses a non-standard way to boot up Gaudi 00006 ''' 00007 00008 from DybPython import gaudiutil 00009 from GaudiKernel import SystemOfUnits as units 00010 from GaudiPython import gbl 00011 00012 # site in [db, la, far] 00013 # det in [Pool, AD] 00014 # vol in [iws,ows,ade1,sst2,oil4, (etc)] 00015 site_de_pat = '/dd/Structure/DayaBay/%(site)s-rock' 00016 det_de_pat = '/dd/Structure/%(det)s/%(site)s-%(vol)s' 00017 00018 00019 def volumes(): 00020 ''' 00021 Iterate over possible volumes. 00022 00023 for v in volumes(): ... 00024 ''' 00025 for site in ['db', 'la', 'far']: 00026 det = 'Pool' 00027 for vol in ['iws','ows']: 00028 yield locals() 00029 continue # vol 00030 00031 numads = 2 00032 if site is 'far': numads = 4 00033 det = 'AD' 00034 for adnum in range(numads): 00035 adnum += 1 00036 for vol in ['%s%d'%(x,adnum) for x in ['ade','sst','oil','lso','gds']]: 00037 yield locals() 00038 continue # vol 00039 continue # adnum 00040 00041 continue # site 00042 raise StopIteration 00043 00044 def vec2str(vec, unit_conv = 1): 00045 'Return string representation of given thing with .x()/.y()/.z()' 00046 return '[%.3f, %.3f, %.3f]' % (vec.x()/unit_conv, vec.y()/unit_conv, vec.z()/unit_conv) 00047 00048 def v2v(vec,de1,de2): 00049 'Transform vec from de1 to global and global to de2' 00050 gvec = de1.geometry().toGlobal(vec) 00051 return de2.geometry().toLocal(gvec) 00052 00053 def d2d(vec1,vec2,de1,de2): 00054 'Return the vector from vec1 to vec2 local to de1 expressed in de2 coordinates' 00055 lv1 = v2v(vec1,de1,de2) 00056 lv2 = v2v(vec2,de1,de2) 00057 lv1.SetXYZ(lv2.x()-lv1.x(),lv2.y()-lv1.y(),lv2.z()-lv1.z()) 00058 return lv1 00059 00060 #css = gaudiutil.coordSvc() 00061 zero = gbl.ROOT.Math.XYZPoint(0,0,0) 00062 xaxis = gbl.ROOT.Math.XYZPoint(1,0,0) 00063 yaxis = gbl.ROOT.Math.XYZPoint(0,1,0) 00064 zaxis = gbl.ROOT.Math.XYZPoint(0,0,1) 00065 00066 if __name__ == '__main__': 00067 import os 00068 00069 last_site = None 00070 for d in volumes(): 00071 site_name = site_de_pat%d 00072 det_name = det_de_pat%d 00073 site_de = gaudiutil.deify(site_name) 00074 det_de = gaudiutil.deify(det_name) 00075 00076 site_short_name = os.path.split(site_name)[-1] 00077 det_short_name = os.path.split(det_name)[-1] 00078 00079 if site_name != last_site: 00080 last_site = site_name 00081 print '%s origin in globals %s' % (site_name, vec2str(site_de.geometry().toGlobal(zero))) 00082 pass 00083 00084 lorig = v2v(zero,det_de,site_de) 00085 lxaxis = d2d(zero,xaxis,det_de,site_de) 00086 lyaxis = d2d(zero,yaxis,det_de,site_de) 00087 lzaxis = d2d(zero,zaxis,det_de,site_de) 00088 00089 print '\t%s @ %s (meter) X=%s, Y=%s, Z=%s' % (det_short_name, 00090 vec2str(lorig, units.meter), 00091 vec2str(lxaxis), vec2str(lyaxis), vec2str(lzaxis)) 00092