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 *******************************************************************************
00012 """
00013
00014 __author__ = 'Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr'
00015
00016
00017 import GaudiPython
00018
00019 from GaudiPython.GaudiAlgs import HistoAlgo
00020
00021 SUCCESS = GaudiPython.SUCCESS
00022
00023
00024
00025
00026 class HistoEx(HistoAlgo) :
00027 """ Simple algorithm which implicitely book&fill three histograms """
00028 def __init__ ( self , name ) :
00029 """ Constructor """
00030 HistoAlgo.__init__( self , name )
00031
00032 def execute( self ) :
00033 """ The major method 'execute', it is invoked for each event """
00034 for i in range(0,10) :
00035 self.plot1D( i
00036 , ' 1D histo '
00037 , 0 , 20 , 20 )
00038 for j in range(0,10) :
00039 self.plot2D( i , j
00040 ,' 2D histo '
00041 , 0 , 20
00042 , 0 , 20
00043 , 20 , 20 )
00044 for k in range(0,10) :
00045 self.plot3D( i , j , k
00046 , ' 3D histo '
00047 , 0 , 20
00048 , 0 , 20
00049 , 0 , 20
00050 , 20 , 20 , 20 )
00051
00052 return SUCCESS
00053
00054
00055
00056
00057
00058 def configure( gaudi = None ) :
00059 """ Configuration of the job """
00060
00061 if not gaudi : gaudi = GaudiPython.AppMgr()
00062
00063 gaudi.JobOptionsType = 'NONE'
00064 gaudi.EvtSel = 'NONE'
00065 gaudi.HistogramPersistency = 'ROOT'
00066
00067 gaudi.config()
00068
00069 gaudi.DLLs = [ 'GaudiAlg', 'RootHistCnv', ]
00070
00071 alg = HistoEx('HistoEx')
00072 gaudi.setAlgorithms( [alg] )
00073 alg.HistoPrint = True
00074
00075 hsvc = gaudi.service('HistogramPersistencySvc')
00076 hsvc.OutputFile = "histo1.root"
00077
00078 return SUCCESS
00079
00080
00081
00082
00083
00084 if '__main__' == __name__ :
00085 print __doc__ , __author__
00086 gaudi = GaudiPython.AppMgr()
00087 configure( gaudi )
00088 gaudi.run(20)
00089
00090