00001
00002
00003
00004
00005
00006
00007
00008
00009 from DybPython.DybPythonAlg import DybPythonAlg
00010 from GaudiPython import SUCCESS, FAILURE
00011 from GaudiPython import gbl
00012
00013 ServiceMode = gbl.ServiceMode
00014
00015
00016 class ExampleAlg(DybPythonAlg):
00017 "Example Python Algorithm"
00018 def __init__(self,name):
00019 DybPythonAlg.__init__(self,name)
00020 return
00021
00022 def initialize(self):
00023 status = DybPythonAlg.initialize(self)
00024 if status.isFailure(): return status
00025 self.info("initializing")
00026
00027 self.cableSvc = self.svc('ICableSvc','StaticCableSvc')
00028 self.pmtGeomSvc = self.svc('IPmtGeomInfoSvc','PmtGeomInfoSvc')
00029
00030 return SUCCESS
00031
00032 def execute(self):
00033 self.info("executing")
00034
00035
00036 evt = self.evtSvc()
00037 readoutHdr = evt["/Event/Readout/ReadoutHeader"]
00038 readout = readoutHdr.readout()
00039 if readout == None:
00040 self.info("No Triggered Readout for this event")
00041 return SUCCESS
00042
00043
00044 svcMode = ServiceMode( readoutHdr.context(), 0 )
00045
00046
00047 for channelPair in readout.channelReadout():
00048 channel = channelPair.second
00049
00050
00051 adc = channel.adc()
00052
00053 channelId = channel.channelId()
00054 print "==================================="
00055 print "VME board= ", channelId.board()
00056 print "connector= ", channelId.connector()
00057
00058
00059 pmtId = self.cableSvc.adPmtSensor( channelId, svcMode )
00060 print "pmt ring=", pmtId.ring()
00061 print "pmt column=", pmtId.column()
00062
00063
00064
00065 pmtHardwareId = self.cableSvc.pmtHardwareId( pmtId, svcMode )
00066
00067
00068 pmtGeomInfo = self.pmtGeomSvc.get( pmtId.fullPackedData() )
00069 pmtPosition = pmtGeomInfo.localPosition()
00070
00071 print "pmt x= ", pmtPosition.x()
00072 print "pmt y= ", pmtPosition.y()
00073 print "pmt z= ", pmtPosition.z()
00074 print "=================================="
00075
00076 return SUCCESS
00077
00078 def finalize(self):
00079 self.info("finalizing")
00080 status = DybPythonAlg.finalize(self)
00081 return status
00082
00083
00084
00085
00086 def configure():
00087 from DetHelpers.DetHelpersConf import PmtGeomInfoSvc
00088 pgiSvc = PmtGeomInfoSvc()
00089 pgiSvc.StreamItems = ["/dd/Structure/DayaBay"]
00090 import DataSvc
00091 DataSvc.Configure()
00092 return
00093
00094 def run(app):
00095 '''
00096 Configure and add an algorithm to job
00097 '''
00098 app.ExtSvc += ["StaticCableSvc", "PmtGeomInfoSvc"]
00099 example = ExampleAlg("MyExample")
00100 app.addAlgorithm(example)
00101 pass
00102