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 from array import array
00013
00014
00015 TH1F = gbl.TH1F
00016 TFile = gbl.TFile
00017 TGraph = gbl.TGraph
00018
00019
00020 class ReadoutDumperAlg(DybPythonAlg):
00021 "Example Python Algorithm"
00022 def __init__(self,name):
00023 DybPythonAlg.__init__(self,name)
00024 self.plot={}
00025 return
00026
00027 def initialize(self):
00028 status = DybPythonAlg.initialize(self)
00029 if status.isFailure(): return status
00030 self.info("initializing")
00031
00032 self.eventNumber = 0
00033
00034
00035
00036
00037
00038
00039
00040
00041 return SUCCESS
00042
00043 def execute(self):
00044 self.info("executing")
00045
00046 self.eventNumber+=1
00047
00048 evt = self.evtSvc()
00049 hdr = evt["/Event/Readout/ReadoutHeader"]
00050
00051 if (hdr.__class__ != gbl.DayaBay.ReadoutHeader ):
00052 self.warning("Readout Header not found for this event")
00053 return SUCCESS
00054
00055 readout = hdr.readout()
00056
00057 self.debug(str(readout.channelReadout()))
00058 det = readout.detector()
00059
00060
00061
00062
00063
00064
00065
00066 dt = 1
00067
00068 for channel,fadcRo in readout.fadcReadout():
00069 self.debug("FADC channel: " + str(channel.connector()) )
00070 tmp="["
00071 for adc in fadcRo: tmp=tmp+str(adc)+","
00072 self.verbose(tmp[:-1]+"]")
00073
00074 path="/file1/event_%d/%s/"%(self.eventNumber, det.detName())
00075
00076
00077 clock = [tick*dt for tick in range(fadcRo.size())]
00078 print fadcRo
00079 graph = TGraph(fadcRo.size(), array('f',clock), array('f',fadcRo))
00080 graph.SetMarkerStyle(8)
00081 graph.SetMarkerColor(600)
00082 graph.SetTitle("FADC")
00083 graph.GetXaxis().SetTitle("Time (ns)")
00084 graph.GetYaxis().SetTitle("FADC Value")
00085 self.verbose("array size" + str(len(clock)))
00086
00087 self.stats[path+"connector_%d/fadc"%channel.connector()] = graph
00088
00089 return SUCCESS
00090
00091 def finalize(self):
00092 self.info("finalizing")
00093
00094 status = DybPythonAlg.finalize(self)
00095 return status
00096
00097
00098 def configure():
00099
00100
00101
00102 return
00103