00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 import ROOT
00013
00014 ROOT.gSystem.Load("libCLHEPRflx")
00015
00016 _ROOT = ROOT
00017
00018
00019 import xmldetdesc
00020 xmldetdesc.config()
00021
00022
00023 from GaudiKernel import SystemOfUnits as units
00024
00025
00026 from Gaudi.Configuration import *
00027 conf = ApplicationMgr()
00028 from DetHelpers.DetHelpersConf import PmtGeomInfoSvc
00029 pgisvc = PmtGeomInfoSvc("PmtGeomInfoSvc")
00030
00031 pgisvc.StreamItems = [ "/dd/Structure/DayaBay" ]
00032
00033
00034 from GaudiPython.GaudiAlgs import GaudiAlgo
00035 from GaudiPython import *
00036 class InitAlg(GaudiAlgo):
00037 """A dummy algorithm that does nothing but provide access to gaudi
00038 services"""
00039 def __init__(self,name):
00040 GaudiAlgo.__init__(self,name)
00041 print "Making InitAlg",name
00042
00043 def initialize(self):
00044 status = GaudiAlgo.initialize(self)
00045 return status
00046
00047 def execute(self):
00048 return SUCCESS
00049
00050
00051 from GaudiPython import AppMgr
00052 app = AppMgr()
00053
00054 app.EvtSel = "NONE"
00055 app.ExtSvc += [ "PmtGeomInfoSvc" ]
00056 initalg = InitAlg("InitAlg")
00057 app.setAlgorithms( [ initalg ] )
00058
00059
00060 app.run(1)
00061
00062
00063 ROOT = _ROOT
00064 del _ROOT
00065
00066
00067
00068 pmtSvc = initalg.svc("IPmtGeomInfoSvc","PmtGeomInfoSvc")
00069
00070
00071
00072
00073
00074 site = 0x01
00075 ad = 1
00076 ring = 1
00077 col = 1
00078
00079 pmtid = (site<<24) | (ad<<16) | (ring<<8) | col
00080
00081
00082 pmtPath = "/dd/Structure/AdPmtStructure/db-ad/db-ad1-ring8-column1"
00083
00084
00085 pmtGeom_1_1 = pmtSvc.get(pmtid)
00086 pmtGeom_8_1 = pmtSvc.get(pmtPath)
00087
00088
00089 pmtPos_1_1 = pmtGeom_1_1.localPosition()
00090 pmtPos_8_1 = pmtGeom_8_1.localPosition()
00091 print "="*60
00092 print "\n\n"
00093 print "Daya Bay Site, AD1"
00094 print ""
00095 print "In AD Coordinate System:"
00096 print " PMT (Ring 1, Column 1) X Y Z [mm]: ",pmtPos_1_1.x(),pmtPos_1_1.y(),pmtPos_1_1.z()
00097 print " PMT (Ring 8, Column 1) X Y Z [mm]: ",pmtPos_8_1.x(),pmtPos_8_1.y(),pmtPos_8_1.z()
00098
00099
00100 pmtGPos_1_1 = pmtGeom_1_1.globalPosition()
00101 pmtGPos_8_1 = pmtGeom_8_1.globalPosition()
00102 print ""
00103 print "In Global Coordinate System of the entire experiment:"
00104 print " PMT (Ring 1, Column 1) X Y Z [mm]: ",pmtGPos_1_1.x(),pmtGPos_1_1.y(),pmtGPos_1_1.z()
00105 print " PMT (Ring 8, Column 1) X Y Z [mm]: ",pmtGPos_8_1.x(),pmtGPos_8_1.y(),pmtGPos_8_1.z()
00106
00107
00108 adDetector = pmtGeom_1_1.parentDetector()
00109 adName = adDetector.name()
00110
00111 origin = gbl.Gaudi.XYZPoint(0,0,0)
00112
00113 adPos = adDetector.geometry().toGlobal(origin)
00114 print ""
00115 print "Daya Bay Site AD1"
00116 print " Path:", adName
00117 print " Global Coordinates X Y Z [mm]:",adPos.x(),adPos.y(),adPos.z()
00118 print "\n\n"
00119 print "="*60
00120
00121
00122
00123
00124
00125 nRings = 8
00126 nColumns = 24
00127 nPMTs = nRings*nColumns
00128 pmtHist = ROOT.TH3F("pmtHist",
00129 "PMT Positions",
00130 200,-2.5,2.5,
00131 200,-2.5,2.5,
00132 200,-2.5,2.5)
00133
00134 site = 0x01
00135 ad = 1
00136 meter = float(units.meter)
00137 for ring in range(1,nRings+1):
00138 for col in range(1,nColumns+1):
00139 pmtid = (site<<24) | (ad<<16) | (ring<<8) | col
00140 pos = pmtSvc.get(pmtid).localPosition()
00141
00142 point = (ring-1)*nColumns + (col-1)
00143 [x,y,z] = [pos.x()/meter, pos.y()/meter, pos.z()/meter]
00144
00145 pmtHist.Fill(x,y,z)
00146
00147
00148 pmtHist.SetMarkerStyle(8)
00149 pmtHist.SetMarkerSize(1)
00150 pmtHist.SetMarkerColor(4)
00151 pmtHist.GetXaxis().SetTitle("X [m]")
00152 pmtHist.GetYaxis().SetTitle("Y [m]")
00153 pmtHist.GetZaxis().SetTitle("Z [m]")
00154 pmtHist.GetXaxis().SetTitleOffset(1.75)
00155 pmtHist.GetYaxis().SetTitleOffset(1.75)
00156 pmtHist.GetZaxis().SetTitleOffset(1)
00157 pmtHist.Draw()
00158