00001
00002
00003 import PyCintex
00004 gbl = PyCintex.makeNamespace("")
00005
00006 import xmldetdesc
00007 xmldetdesc.config()
00008
00009 from Gaudi.Configuration import *
00010 conf = ApplicationMgr()
00011
00012 from DetHelpers.DetHelpersConf import PmtGeomInfoSvc
00013 pgisvc = PmtGeomInfoSvc("PmtGeomInfoSvc")
00014
00015 pgisvc.StreamItems = [ "/dd/Structure/DayaBay" ]
00016 print pgisvc
00017 conf.ExtSvc += [ pgisvc ]
00018 print "Done with configure"
00019
00020 from GaudiPython.GaudiAlgs import GaudiAlgo
00021 from GaudiPython import *
00022 class MyAlg(GaudiAlgo):
00023 def __init__(self,name):
00024 GaudiAlgo.__init__(self,name)
00025 print "Making MyAlg",name
00026
00027 def initialize(self):
00028 status = GaudiAlgo.initialize(self)
00029 print "Init MyAlg",self.name
00030 if status.isFailure(): return status
00031 app = AppMgr()
00032 app.DLLs += [ "DetHelpersLib", 'DetHelpers', 'DetHelpersDict' ]
00033 self.pgis = self.svc('IPmtGeomInfoSvc','PmtGeomInfoSvc')
00034 print self.pgis
00035 return self.spin()
00036
00037 def spin(self):
00038
00039 import time
00040 start = time.time()
00041 count = 0
00042 for site,nads in [(0x01,2),(0x02,2),(0x04,4)]:
00043 print "Site:",site,
00044 for iad in range(0,nads):
00045 iad += 1
00046 print "[",iad,"]",
00047 for icol in range(0,24):
00048 icol +=1
00049 for iring in range(0,8):
00050 iring += 1
00051 pmtid = (site<<24)|(iad<<16)|(iring<<8)|icol
00052
00053 pgi = self.pgis.get(pmtid)
00054 if not pgi:
00055 print "PmtGeomInfoSvc returned None"
00056 return FAILURE
00057 if pmtid != pgi.pmtid():
00058 print "Ask for PMT ID %d, got %d"%(pmtid,pgi.pmtid())
00059 return FAILURE
00060 count += 1
00061 continue
00062 continue
00063 continue
00064 print "\n",
00065 continue
00066 stop = time.time()
00067 print "Found %d PMTs in %f seconds"%(count,stop-start)
00068
00069
00070 return SUCCESS
00071
00072 def execute(self):
00073 for r in range(0,10): self.spin()
00074
00075 pass
00076
00077
00078
00079 from GaudiPython import AppMgr
00080 app = AppMgr()
00081 app.EvtSel = "NONE"
00082 app.ExtSvc += [ "PmtGeomInfoSvc" ]
00083
00084
00085 myalg = MyAlg("MyAlg")
00086 print 'myalg="%s"'%str(myalg)
00087 app.setAlgorithms( [ myalg ] )
00088 print ' running'
00089 app.run(1)
00090