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
00014 TH1F = gbl.TH1F
00015
00016
00017 class ExampleAlg(DybPythonAlg):
00018 "Example Python Algorithm"
00019 def __init__(self,name):
00020 DybPythonAlg.__init__(self,name)
00021 return
00022
00023 def initialize(self):
00024 status = DybPythonAlg.initialize(self)
00025 if status.isFailure(): return status
00026 self.info("initializing")
00027
00028
00029
00030
00031 self.stats.defaultPath = "/file1/examples/"
00032
00033 self.stats["TrigTime"] = TH1F("TrigTime","Trigger Time [s]",
00034 100,0.0,10.0)
00035
00036 self.stats["Tdc"] = TH1F("Tdc","TDC Values",300,0,300)
00037
00038 return SUCCESS
00039
00040 def execute(self):
00041 self.info("executing")
00042
00043 evt = self.evtSvc()
00044 hdr = evt["/Event/Readout/ReadoutHeader"]
00045
00046 ro = hdr.readout()
00047 if ro == None:
00048 self.info("No Readout this cycle")
00049 return SUCCESS
00050 print ro.detector().detName()
00051
00052 self.stats["TrigTime"].Fill( ro.triggerTime().GetSeconds() )
00053
00054 channelIDs = ro.channels()
00055 for channelID in channelIDs:
00056 channel = ro.channel(channelID)
00057 for tdc in channel.tdc():
00058 self.stats["Tdc"].Fill( tdc )
00059 for adcClock in channel.adcClocks():
00060 adc = channel.adcByClock(adcClock)
00061 print adcClock, adc
00062 return SUCCESS
00063
00064 def finalize(self):
00065 self.info("finalizing")
00066 status = DybPythonAlg.finalize(self)
00067 return status
00068
00069 def configure():
00070 from StatisticsSvc.StatisticsSvcConf import StatisticsSvc
00071 statsSvc = StatisticsSvc()
00072 statsSvc.Output ={"file1":"exampleHist.root"}
00073 return
00074
00075 def run(app):
00076 '''
00077 Configure and add an algorithm to job
00078 '''
00079 app.ExtSvc += ["StaticCableSvc", "StatisticsSvc"]
00080 example = ExampleAlg("MyExample")
00081 app.addAlgorithm(example)
00082 pass