00001
00002
00003
00004 from GaudiPython.GaudiAlgs import GaudiAlgo
00005 from GaudiPython import SUCCESS, FAILURE
00006 from GaudiPython import gbl
00007 from DybPython.Util import irange
00008
00009
00010 TH1F = gbl.TH1F
00011
00012
00013 class ExampleAlg(GaudiAlgo):
00014 "Example Python Algorithm"
00015 def __init__(self,name):
00016 GaudiAlgo.__init__(self,name)
00017 return
00018
00019 def initialize(self):
00020 status = GaudiAlgo.initialize(self)
00021 print "Init ExampleAlg",self.name()
00022 if status.isFailure(): return status
00023 return SUCCESS
00024
00025 def execute(self):
00026 print "Executing ExampleAlg",self.name()
00027 evt = self.evtSvc()
00028 hdr = evt["/Event/Sim/SimHeader"]
00029 shh = hdr.hits()
00030 for detector in shh.hitDetectors():
00031 print "Detector: ",detector
00032 hitCollection = shh.hitsByDetector(detector)
00033 print "Hits: ",hitCollection
00034 if hitCollection == None:
00035 print "No Hit Collection for detector ",detector
00036 hits = hitCollection.collection()
00037 for hit in hits:
00038 print " PMT",hit.sensDetId(),"hit at time",hit.hitTime()
00039 return SUCCESS
00040
00041 def finalize(self):
00042 print "Finalizing ExampleAlg",self.name()
00043 status = GaudiAlgo.finalize(self)
00044 return status
00045
00046 def configure():
00047 return
00048
00049 def run(app):
00050 '''
00051 Configure and add an algorithm to job
00052 '''
00053 example = ExampleAlg("MyExample")
00054 app.addAlgorithm(example)
00055 pass