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

In This Package:

HistoEx1.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # =============================================================================
00003 # $Id: HistoEx1.py,v 1.6 2007/10/29 14:29:47 mato Exp $
00004 # =============================================================================
00005 """
00006 *******************************************************************************
00007 *                                                                             *
00008 * Simple example which illustrate the usage of useful algorithm  base class   *
00009 * HistoAlgo (python version of C++ GaudiHistoAlg) for "easy" histogramming.   *
00010 * It is an extension of HistoEx module, it provides similar algorithm, but    *
00011 * with explicit histogram manipulation trhrough explicit book and fill        *
00012 *                                                                             *
00013 *******************************************************************************
00014 """
00015 # =============================================================================
00016 __author__ = 'Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr'
00017 # =============================================================================
00018 
00019 import GaudiPython
00020 
00021 from   GaudiPython.GaudiAlgs   import HistoAlgo
00022 
00023 SUCCESS = GaudiPython.SUCCESS 
00024 
00025 # =============================================================================
00026 # Simple algorithm which book&fill 3 histograms
00027 # =============================================================================
00028 class HistoEx1 (HistoAlgo) :
00029     """ Simple algorithm which explicitely book&fill three histograms """
00030     def __init__ ( self , name ) :
00031         """ Constructor """
00032         HistoAlgo.__init__( self , name )
00033 
00034     def initialize ( self ) :
00035         """ Initialization, initialize the base class and book histograms """ 
00036         status = HistoAlgo.initialize( self )
00037         if status.isFailure() : return status
00038         
00039         self.h1 = self.book1D ( ' 1D histo '
00040                                 , 0 , 20 , 20 )
00041         self.h2 = self.book2D ( ' 2D histo '
00042                                 , 0 , 20 , 20 
00043                                 , 0 , 20 , 20 )
00044         self.h3 = self.book3D ( ' 3D histo '
00045                                 , 0 , 20 , 20 
00046                                 , 0 , 20 , 20 
00047                                 , 0 , 20 , 20 )
00048 
00049         return SUCCESS
00050     
00051     def execute( self ) :
00052         """ The major method 'execute', it is invoked for each event """
00053 
00054         for i in range(0,10) :
00055             self.h1.fill( i , 0.166 )
00056             for j in range(0,10) :
00057                 self.h2.fill( i   , j )
00058                 for k in range(0,10) : 
00059                     self.h3.fill( i , j , k )
00060                     
00061         
00062         return SUCCESS
00063     
00064 
00065 # =============================================================================
00066 # job configuration 
00067 # =============================================================================
00068 def configure( gaudi = None  ) :
00069     """ Configuration of the job """
00070     
00071     import HistoEx
00072 
00073     if not gaudi : gaudi = GaudiPython.AppMgr()
00074 
00075     HistoEx.configure( gaudi ) 
00076 
00077     alg = HistoEx1('HistoEx1')
00078     gaudi.addAlgorithm( alg )
00079     
00080     alg.HistoPrint = True
00081     
00082     return SUCCESS
00083 
00084 
00085 # =============================================================================
00086 # The actual job excution 
00087 # =============================================================================
00088 if '__main__' == __name__ :
00089     print __doc__ , __author__
00090     gaudi = GaudiPython.AppMgr()
00091     configure( gaudi )
00092     gaudi.run(20)
00093     
00094 # =============================================================================
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:59:39 2011 for GaudiExamples by doxygen 1.4.7