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

In This Package:

TupleEx3.py

Go to the documentation of this file.
00001 #!/usr/bin/env python2.4
00002 # =============================================================================
00003 # $Id: TupleEx3.py,v 1.4 2007/10/29 14:29:47 mato Exp $
00004 # =============================================================================
00005 # CVS tag $Name: GAUDI_v20r4-pre $, version $Revision: 1.4 $
00006 # =============================================================================
00007 ## @file
00008 #
00009 # Simple example which illustrate the usage of useful                         
00010 # algorithm  base class for N-Tuple manipulations
00011 #
00012 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
00013 # @date 2007-01-24
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 ## @class TupleEx3
00049 #  Simple algorithm for advanced N-Tuple columns 
00050 #  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00051 #  @date 2007-01-24
00052 class TupleEx3(TupleAlgo) :
00053     """
00054     Simple algorithm for advanced (matrix&array) N-Tuple columns 
00055     """
00056 
00057     ## standard constructor 
00058     def __init__ ( self , name = 'TupleEx3' ) :
00059         """ Constructor """
00060         TupleAlgo.__init__( self , name )
00061 
00062     ## the main execution method 
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         ## N-tuple with farrays
00071         tup = self.nTuple('farrays', 'N-tuple with farrays')
00072         
00073         for i in range(0,20) :
00074 
00075             # std::vector<double>
00076             
00077             # prepare some data array (std::vector<double>)
00078             v1=vct1()
00079             n=long(50+2*flat())
00080             # fill it with some random data 
00081             for j in range(0,n) : v1.push_back( gauss() )
00082             #fill N-tuple 
00083             tup.farray('gauss',v1,'len1',150)
00084 
00085             # prepare some data array (CLHEP::HepVector<double>)
00086             n=long(50+2*flat())
00087             v2=vct2(n)
00088             #fill N-tuple 
00089             tup.farray('breit',v2,'len2',150)
00090 
00091             # commit the row 
00092             tup.write() 
00093 
00094         ## N-tuple with arrays
00095         tup = self.nTuple('arrays', 'N-tuple with arrays')
00096         for i in range(0,20) :
00097 
00098             # std::vector<double>
00099             
00100             # prepare some data array (std::vector<double>)
00101             v1=vct1(30,1.0)
00102             #fill N-tuple 
00103             tup.array('gauss',v1)
00104             
00105             # use CLHEP::HepVector
00106             v2=vct2( 30 )
00107             tup.array('breit',v2)
00108 
00109             # use Gaudi::Vector2
00110             v= Gaudi.Vector2()
00111             tup.array ( 'v2' , v ) ;
00112 
00113             # use Gaudi::Vector3
00114             v= Gaudi.Vector3()
00115             tup.array ( 'v3' , v ) ;
00116 
00117             # use Gaudi::Vector4
00118             v= Gaudi.Vector4()
00119             tup.array ( 'v4' , v ) ;
00120 
00121             # use Gaudi::Vector5
00122             v= Gaudi.Vector5()
00123             tup.array ( 'v5' , v ) ;
00124 
00125             # use Gaudi::Vector6
00126             v= Gaudi.Vector6()
00127             tup.array ( 'v6' , v ) ;
00128 
00129             # use Gaudi::Vector7
00130             v= Gaudi.Vector7()
00131             tup.array ( 'v7' , v ) ;
00132 
00133             # use Gaudi::Vector8
00134             v= Gaudi.Vector8()
00135             tup.array ( 'v8' , v ) ;
00136 
00137             # use Gaudi::Vector9
00138             v= Gaudi.Vector9()
00139             tup.array ( 'v9' , v ) ;
00140 
00141             # commit the row 
00142             tup.write() 
00143 
00144         ## N-tuple with fixed square matrices 
00145         tup = self.nTuple('square', 'N-tuple with square matrices')
00146         for i in range(0,20) :
00147 
00148             # make a matrice 
00149             m=Gaudi.Matrix2x2()
00150             tup.matrix ( "m2" , m )
00151 
00152             # make a matrice 
00153             m=Gaudi.Matrix3x3()
00154             tup.matrix ( "m3" , m )
00155 
00156             # make a matrice 
00157             m=Gaudi.Matrix4x4()
00158             tup.matrix ( "m4" , m )
00159 
00160             # make a matrice 
00161             m=Gaudi.Matrix5x5()
00162             # fill n-tuple 
00163             tup.matrix ( "m5" , m )
00164 
00165             # make a matrice 
00166             m=Gaudi.Matrix6x6()
00167             # fill n-tuple 
00168             tup.matrix ( "m6" , m )
00169 
00170             # make a matrice 
00171             m=Gaudi.Matrix7x7()
00172             tup.matrix ( "m7" , m )
00173 
00174             # make a matrice 
00175             m=Gaudi.Matrix8x8()
00176             # fill n-tuple 
00177             tup.matrix ( "m8" , m )
00178 
00179             # make a matrice 
00180             m=Gaudi.Matrix9x9()
00181             tup.matrix ( "m9" , m )
00182 
00183             # commit the row 
00184             tup.write()
00185 
00186         return SUCCESS                
00187                 
00188 # =============================================================================
00189 ## job configuration 
00190 #
00191 #  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00192 #  @date 2006-11-26
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     # configure proeprties
00217     alg.NTupleLUN = 'MYLUN'
00218     
00219     return SUCCESS
00220 
00221 
00222 # =============================================================================
00223 ## The actual job execution 
00224 #  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00225 #  @date 2007-01-24
00226 if '__main__' == __name__ :
00227     print __doc__
00228     gaudi = GaudiPython.AppMgr()
00229     configure( gaudi )
00230     gaudi.run(10)
00231 
00232 # =============================================================================
00233 # The END 
00234 # =============================================================================
| 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