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 ibelyaev@physics.syr.edu'
00025
00026
00027 import GaudiPython, math
00028
00029 Rndm = GaudiPython.gbl.Rndm
00030 Math = GaudiPython.gbl.ROOT.Math
00031 SUCCESS = GaudiPython.SUCCESS
00032 Gaudi = GaudiPython.gbl.Gaudi
00033
00034 GaudiPython.loaddict('STLRflx')
00035 GaudiPython.loaddict('STLAddRflx')
00036 GaudiPython.loaddict('MathRflx')
00037 GaudiPython.loaddict('MathAddRflx')
00038
00039 vct1 = GaudiPython.gbl.vector('double')
00040
00041 GaudiPython.loaddict('CLHEPRflx')
00042 vct2 = GaudiPython.gbl.CLHEP.HepVector
00043
00044 from GaudiPython.GaudiAlgs import TupleAlgo
00045
00046
00047
00048
00049
00050
00051
00052 class TupleEx3(TupleAlgo) :
00053 """
00054 Simple algorithm for advanced (matrix&array) N-Tuple columns
00055 """
00056
00057
00058 def __init__ ( self , name = 'TupleEx3' ) :
00059 """ Constructor """
00060 TupleAlgo.__init__( self , name )
00061
00062
00063 def execute( self ) :
00064 """ The major method 'execute', it is invoked for each event """
00065
00066 gauss = Rndm.Numbers ( self.randSvc() , Rndm.Gauss ( 0.0 , 1.0 ) )
00067 flat = Rndm.Numbers ( self.randSvc() , Rndm.Flat ( -10 , 10 ) )
00068 breit = Rndm.Numbers ( self.randSvc() , Rndm.BreitWigner ( 0.0 , 1.0 ) )
00069
00070
00071 tup = self.nTuple('farrays', 'N-tuple with farrays')
00072
00073 for i in range(0,20) :
00074
00075
00076
00077
00078 v1=vct1()
00079 n=long(50+2*flat())
00080
00081 for j in range(0,n) : v1.push_back( gauss() )
00082
00083 tup.farray('gauss',v1,'len1',150)
00084
00085
00086 n=long(50+2*flat())
00087 v2=vct2(n)
00088
00089 tup.farray('breit',v2,'len2',150)
00090
00091
00092 tup.write()
00093
00094
00095 tup = self.nTuple('arrays', 'N-tuple with arrays')
00096 for i in range(0,20) :
00097
00098
00099
00100
00101 v1=vct1(30,1.0)
00102
00103 tup.array('gauss',v1)
00104
00105
00106 v2=vct2( 30 )
00107 tup.array('breit',v2)
00108
00109
00110 v= Gaudi.Vector2()
00111 tup.array ( 'v2' , v ) ;
00112
00113
00114 v= Gaudi.Vector3()
00115 tup.array ( 'v3' , v ) ;
00116
00117
00118 v= Gaudi.Vector4()
00119 tup.array ( 'v4' , v ) ;
00120
00121
00122 v= Gaudi.Vector5()
00123 tup.array ( 'v5' , v ) ;
00124
00125
00126 v= Gaudi.Vector6()
00127 tup.array ( 'v6' , v ) ;
00128
00129
00130 v= Gaudi.Vector7()
00131 tup.array ( 'v7' , v ) ;
00132
00133
00134 v= Gaudi.Vector8()
00135 tup.array ( 'v8' , v ) ;
00136
00137
00138 v= Gaudi.Vector9()
00139 tup.array ( 'v9' , v ) ;
00140
00141
00142 tup.write()
00143
00144
00145 tup = self.nTuple('square', 'N-tuple with square matrices')
00146 for i in range(0,20) :
00147
00148
00149 m=Gaudi.Matrix2x2()
00150 tup.matrix ( "m2" , m )
00151
00152
00153 m=Gaudi.Matrix3x3()
00154 tup.matrix ( "m3" , m )
00155
00156
00157 m=Gaudi.Matrix4x4()
00158 tup.matrix ( "m4" , m )
00159
00160
00161 m=Gaudi.Matrix5x5()
00162
00163 tup.matrix ( "m5" , m )
00164
00165
00166 m=Gaudi.Matrix6x6()
00167
00168 tup.matrix ( "m6" , m )
00169
00170
00171 m=Gaudi.Matrix7x7()
00172 tup.matrix ( "m7" , m )
00173
00174
00175 m=Gaudi.Matrix8x8()
00176
00177 tup.matrix ( "m8" , m )
00178
00179
00180 m=Gaudi.Matrix9x9()
00181 tup.matrix ( "m9" , m )
00182
00183
00184 tup.write()
00185
00186 return SUCCESS
00187
00188
00189
00190
00191
00192
00193 def configure( gaudi = None ) :
00194 """
00195 Configuration of the job
00196 """
00197
00198 if not gaudi : gaudi = GaudiPython.AppMgr()
00199
00200 gaudi.JobOptionsType = 'NONE'
00201 gaudi.EvtSel = 'NONE'
00202 gaudi.HistogramPersistency = 'ROOT'
00203
00204 gaudi.ExtSvc += ["NTupleSvc" , 'ChronoStatSvc']
00205
00206 ntSvc = gaudi.service('NTupleSvc')
00207 ntSvc.Output = [ "MYLUN DATAFILE='TupleEx3.root' OPT='NEW' TYP='ROOT'" ]
00208
00209 gaudi.config()
00210
00211 gaudi.DLLs = [ 'GaudiAlg', 'RootHistCnv', ]
00212
00213 alg = TupleEx3()
00214 gaudi.setAlgorithms( [alg] )
00215
00216
00217 alg.NTupleLUN = 'MYLUN'
00218
00219 return SUCCESS
00220
00221
00222
00223
00224
00225
00226 if '__main__' == __name__ :
00227 print __doc__
00228 gaudi = GaudiPython.AppMgr()
00229 configure( gaudi )
00230 gaudi.run(10)
00231
00232
00233
00234