Writing an Athena algorithm in Python

To define an algorithm directly in Python, derive from the Gaudi Python class PyAlgorithm. A complete usage example is shown below. To actually run this file, you'll need to replace the name of the input data file with some data file that you have. If it's not fast simulation, then you may also need to change the collection name used in the getElectrons call.
# read AOD
include( "AthenaPoolCnvSvc/ReadAthenaPool_jobOptions.py" )
EventSelector = Service( "EventSelector" )
EventSelector.InputCollections = [
# Replace this with some input file that you can read.
  "AODfile.pool.root",
]
include( "ParticleEventAthenaPool/AOD_PoolCnv_jobOptions.py" )
theApp.Dlls += ["TruthParticleAlgs"]
include ("PyAnalysisCore/InitPyAnalysisCore.py")

class Alg (PyAlgorithm):
    def execute (self):
        # This is set up for reading fast simulation data.
        # Replace the collection name below if needed.
        for e in PyParticleTools.getElectrons ('AtlfastElectronCollection'):
            print e.pt(),
        print
        return 1

theApp.initialize()
theApp.addAlgorithm (Alg ('alg'))
theApp.run(100)
theApp.finalize()


sss
Last modified: Wed Jul 27 17:18:08 EDT 2005