| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Example_GenEvent.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # Load GaudiPython
00004 from GaudiPython.GaudiAlgs import GaudiAlgo
00005 from GaudiPython import SUCCESS, FAILURE
00006 from GaudiPython import gbl
00007 from GaudiPython import loaddict
00008 from DybPython.Util import irange
00009 
00010 # Load HepMC classes
00011 loaddict('libHepMCRflx')
00012 
00013 # Make shortcuts to ROOT classes
00014 TH1F = gbl.TH1F
00015 
00016 # Make your algorithm
00017 class ExampleAlg(GaudiAlgo):
00018     "Example Python Algorithm"
00019     def __init__(self,name):
00020         GaudiAlgo.__init__(self,name)
00021         return
00022 
00023     def initialize(self):
00024         status = GaudiAlgo.initialize(self)
00025         print "Init ExampleAlg",self.name()
00026         if status.isFailure(): return status
00027         return SUCCESS
00028 
00029     def execute(self):
00030         print "Executing ExampleAlg",self.name()
00031         evt = self.evtSvc()
00032         hdr = evt["/Event/Gen/GenHeader"]
00033         event = hdr.event()
00034         for vertex in irange(event.vertices_begin(),
00035                              event.vertices_end()):
00036             pos = vertex.position()
00037             print "vertex position = ", pos.x(), pos.y(), pos.z() 
00038             for particle in irange(vertex.particles_out_const_begin(),
00039                                    vertex.particles_out_const_end()):
00040                 mom = particle.momentum()
00041                 print "4 momentum = ", mom.px(), mom.py(), mom.pz(), mom.e()
00042         return SUCCESS
00043         
00044     def finalize(self):        
00045         print "Finalizing ExampleAlg",self.name()
00046         status = GaudiAlgo.finalize(self)
00047         return status
00048 
00049 def configure():
00050     return
00051 
00052 def run(app):
00053     '''
00054     Configure and add an algorithm to job
00055     '''
00056     example = ExampleAlg("MyExample")
00057     app.addAlgorithm(example)
00058     pass
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:05:58 2011 for DivingIn by doxygen 1.4.7