00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 """
00016 *******************************************************************************
00017 * *
00018 * Simple example which illustrate the usage of useful *
00019 * algorithm base class for N-Tuple manipulations *
00020 * *
00021 *******************************************************************************
00022 """
00023
00024 __author__ = 'Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr'
00025
00026
00027 import GaudiPython, math
00028
00029 Rndm = GaudiPython.gbl.Rndm
00030 SUCCESS = GaudiPython.SUCCESS
00031
00032 from GaudiPython.GaudiAlgs import TupleAlgo
00033
00034
00035
00036
00037
00038
00039 class TupleEx(TupleAlgo) :
00040 """
00041 Simple algorithm which implicitely book&fill N-Tuples
00042 """
00043
00044 def __init__ ( self , name = 'TupleEx' ) :
00045 """ Constructor """
00046 TupleAlgo.__init__( self , name )
00047
00048
00049 def execute( self ) :
00050 """
00051 The major method 'execute', it is invoked for each event
00052 """
00053
00054 gauss = Rndm.Numbers( self.randSvc() , Rndm.Gauss( 0.0 , 1.0 ) )
00055
00056 tup = self.nTuple('My trivial N-tuple')
00057 for i in range(0,100) :
00058 tup.column( 'a' , math.sin(i) )
00059 tup.column( 'b' , math.cos(i) )
00060 tup.column( 'c' , math.tan(i) )
00061 tup.column( 'g' , gauss() )
00062 tup.write()
00063
00064 return SUCCESS
00065
00066
00067
00068
00069
00070
00071 def configure( gaudi = None ) :
00072 """ Configuration of the job """
00073
00074 if not gaudi : gaudi = GaudiPython.AppMgr()
00075
00076 gaudi.JobOptionsType = 'NONE'
00077 gaudi.EvtSel = 'NONE'
00078 gaudi.HistogramPersistency = 'ROOT'
00079
00080 gaudi.ExtSvc += ["NTupleSvc" ]
00081
00082 ntSvc = gaudi.service('NTupleSvc')
00083 ntSvc.Output = [ "MYLUN DATAFILE='TupleEx.root' OPT='NEW' TYP='ROOT'" ]
00084
00085 gaudi.config()
00086
00087 gaudi.DLLs = [ 'GaudiAlg', 'RootHistCnv', ]
00088
00089 alg = TupleEx()
00090 gaudi.setAlgorithms( [alg] )
00091
00092
00093 alg.NTupleLUN = 'MYLUN'
00094
00095 return SUCCESS
00096
00097
00098
00099
00100
00101
00102 if '__main__' == __name__ :
00103 print __doc__
00104 gaudi = GaudiPython.AppMgr()
00105 configure( gaudi )
00106 gaudi.run(20)
00107
00108
00109
00110