00001
00002
00003
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 * *
00011 * This example illustrates the usage of 1D and 2D profile histograms *
00012 * *
00013 *******************************************************************************
00014 """
00015
00016 __author__ = 'Vanya BELYAEV ibelyaev@physics.syr.edu'
00017
00018
00019 import GaudiPython
00020
00021 from GaudiPython.GaudiAlgs import HistoAlgo
00022
00023 Rndm = GaudiPython.gbl.Rndm
00024 SUCCESS = GaudiPython.SUCCESS
00025
00026
00027
00028
00029 class HistoEx2 (HistoAlgo) :
00030 """ Simple algorithm which explicitely book&fill profile histograms """
00031 def __init__ ( self , name = 'HistoEx2' ) :
00032 """ Constructor """
00033 HistoAlgo.__init__( self , name )
00034
00035 def execute( self ) :
00036 """ The major method 'execute', it is invoked for each event """
00037
00038 gauss = Rndm.Numbers ( self.randSvc() ,
00039 Rndm.Gauss ( 0 , 1 ) )
00040
00041 for i in range(0,10000) :
00042 x = gauss ()
00043 y = gauss ()
00044 self.plot2D ( x , y , ' x vs y ' , -2 , 2 , -4 , 4 )
00045 self.plot2D ( x , y+3*x , ' x vs y+3x ' , -2 , 2 , -4 , 4 )
00046 self.plot2D ( x , y-3*x , ' x vs y-3x ' , -2 , 2 , -4 , 4 )
00047 self.profile1D ( x , y , ' x vs y (profile)' , -2 , 2 )
00048 self.profile1D ( x , y+3*x , ' x vs y+3x (profile)' , -2 , 2 )
00049 self.profile1D ( x , y-3*x , ' x vs y-3y (profile)' , -2 , 2 )
00050 return SUCCESS
00051
00052
00053
00054
00055
00056 def configure( gaudi = None ) :
00057 """ Configuration of the job """
00058
00059 import HistoEx1
00060
00061 if not gaudi : gaudi = GaudiPython.AppMgr()
00062
00063 HistoEx1.configure( gaudi )
00064
00065 alg = HistoEx2('HistoEx2')
00066 gaudi.addAlgorithm( alg )
00067
00068 alg.HistoPrint = True
00069
00070 return SUCCESS
00071
00072
00073
00074
00075
00076 if '__main__' == __name__ :
00077 print __doc__ , __author__
00078 gaudi = GaudiPython.AppMgr()
00079 configure( gaudi )
00080 gaudi.run(20)
00081
00082
00083
00084
00085
00086