Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:43

0001 #
0002 # This example demonstrates how to implement a JEventProccessor in Python.
0003 #
0004 # This can be run like so:
0005 #
0006 #   jana -Pplugins=janapy -PJANA_PYTHON_FILE=MyProcessor.py
0007 #
0008 #
0009 import jana
0010 import inspect
0011 
0012 # JEventProcessor class defined in janapy module
0013 class MyProcessor( jana.JEventProcessor ):
0014     #--------------------------------------
0015     # Constructor
0016     def __init__(self):
0017         super().__init__(self)
0018         super().Prefetch('Hit')
0019 
0020     #--------------------------------------
0021     # Init
0022     def Init( self ):
0023         print('Python Init called')
0024 
0025     #--------------------------------------
0026     # Process
0027     def Process( self ):
0028         hits = super().Get('Hit') # hits is standard python dictionary with string types for keys and values
0029         for hit in hits:
0030             print('E=' + hit['E'] + '  t= ' + hit['t'] )
0031 
0032     #--------------------------------------
0033     # Finish
0034     def Finish( self ):
0035         print('Python Finish called')
0036 
0037 #-----------------------------------------------------------
0038 
0039 jana.SetParameterValue( 'NEVENTS', '10')
0040 
0041 proc = MyProcessor()
0042 jana.AddProcessor( proc )
0043 
0044 jana.AddPlugin('JTestRoot')
0045 jana.Run()
0046 
0047 print('PYTHON DONE.')
0048