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

In This Package:

TupleEx2.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # =============================================================================
00003 # $Id: TupleEx2.py,v 1.8 2008/09/30 13:07:04 marcocle Exp $
00004 # =============================================================================
00005 # CVS tag $Name: GAUDI_v20r4-pre $, version $Revision: 1.8 $
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 2006-11-26
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 Math        = GaudiPython.gbl.ROOT.Math
00031 SUCCESS     = GaudiPython.SUCCESS 
00032 
00033 from   GaudiPython.GaudiAlgs   import TupleAlgo
00034 
00035 # =============================================================================
00036 ## @class TupleEx2
00037 #  Simple algorithm for advanced N-Tuple columns 
00038 #
00039 #  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00040 #  @date 2006-11-26
00041 class TupleEx2(TupleAlgo) :
00042     """
00043     Simple algorithm for advanced N-Tuple columns 
00044     """
00045 
00046     ## standard constructor 
00047     def __init__ ( self , name = 'TupleEx2' ) :
00048         """ Constructor """
00049         TupleAlgo.__init__( self , name )
00050 
00051     ## the main execution method 
00052     def execute( self ) :
00053         """ The major method 'execute', it is invoked for each event """
00054 
00055         gauss = Rndm.Numbers ( self.randSvc() , Rndm.Gauss ( 0.0 , 1.0 ) )
00056         flat  = Rndm.Numbers ( self.randSvc() , Rndm.Flat  ( -10 , 10  ) )
00057         breit = Rndm.Numbers ( self.randSvc() , Rndm.BreitWigner  ( 0.0 , 1.0  ) )
00058      
00059         ## N-tuple with 4D-vectors 
00060         tup = self.nTuple('Vectors-4D', 'N-tuple with 4D-vectors')       
00061         for i in range(0,100) :
00062 
00063             lv1 = Math.PxPyPzEVector()
00064 
00065             lv1.SetPx ( gauss () )
00066             lv1.SetPy ( gauss () )
00067             lv1.SetPz ( gauss () )
00068             lv1.SetE  ( gauss () )
00069 
00070             lv2 = Math.PtEtaPhiEVector()
00071             x = flat()
00072             y = flat()
00073             z = flat()
00074             e = flat()
00075             lv2.SetPxPyPzE(x, y, z, e)
00076             
00077             tup.column( 'lv1' , lv1 ) 
00078             tup.column( 'lv2' , lv2 ) 
00079 
00080             tup.write()
00081 
00082         ## N-tuple with 3D-vectors 
00083         tup = self.nTuple('Vectors-3D', 'N-tuple with 3D-vectors')       
00084         for i in range(0,100) :
00085 
00086             v1 = Math.XYZVector()
00087             v1.SetX ( gauss () ) 
00088             v1.SetY ( gauss () ) 
00089             v1.SetZ ( gauss () )
00090             
00091             v2 = Math.Polar3DVector()
00092             x = flat() 
00093             y = flat() 
00094             z = flat() 
00095             v2.SetXYZ(x, y, z)
00096 
00097             v3 = Math.RhoEtaPhiVector()
00098             x = breit() 
00099             y = breit() 
00100             z = breit()
00101             v3.SetXYZ(x, y, z)
00102 
00103             v4 = Math.RhoZPhiVector()
00104             x = gauss() 
00105             y = flat() 
00106             z = breit()
00107             v4.SetXYZ(x, y, z)
00108 
00109             tup.column ( "v1" , v1 ) 
00110             tup.column ( "v2" , v2 ) 
00111             tup.column ( "v3" , v3 ) 
00112             tup.column ( "v4" , v4 ) 
00113 
00114             tup.write() 
00115 
00116         ## N-tuple with 3D-points 
00117         tup = self.nTuple('Points-3D', 'N-tuple with 3D-points')       
00118         for i in range(0,100) :
00119 
00120             p1 = Math.XYZPoint()
00121             p1.SetX ( gauss () ) 
00122             p1.SetY ( gauss () ) 
00123             p1.SetZ ( gauss () )
00124             
00125             p2 = Math.Polar3DPoint()
00126             x = flat() 
00127             y = flat() 
00128             z = flat() 
00129             p2.SetXYZ(x, y, z)
00130 
00131             p3 = Math.RhoEtaPhiPoint()
00132             x = breit() 
00133             y = breit() 
00134             z = breit()
00135             p3.SetXYZ(x, y, z)
00136 
00137             p4 = Math.RhoZPhiPoint()
00138             x = gauss() 
00139             y = flat() 
00140             z = breit()
00141             p4.SetXYZ(x, y, z)
00142 
00143             tup.column ( "p1" , p1 ) 
00144             tup.column ( "p2" , p2 ) 
00145             tup.column ( "p3" , p3 ) 
00146             tup.column ( "p4" , p4 ) 
00147 
00148             tup.write()
00149 
00150         return SUCCESS                
00151                 
00152 # =============================================================================
00153 ## job configuration 
00154 #
00155 #  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00156 #  @date 2006-11-26
00157 def configure( gaudi = None  ) :
00158     """
00159     Configuration of the job
00160     """
00161     
00162     if not gaudi : gaudi = GaudiPython.AppMgr()
00163     
00164     gaudi.JobOptionsType       = 'NONE'
00165     gaudi.EvtSel               = 'NONE'
00166     gaudi.HistogramPersistency = 'ROOT'
00167 
00168     gaudi.ExtSvc += ["NTupleSvc" ]
00169 
00170     ntSvc = gaudi.service('NTupleSvc')
00171     ntSvc.Output = [ "MYLUN DATAFILE='TupleEx2.root' OPT='NEW' TYP='ROOT'" ] 
00172 
00173     gaudi.config()
00174     
00175     gaudi.DLLs = [ 'GaudiAlg', 'RootHistCnv', ]
00176 
00177     alg = TupleEx2()
00178     gaudi.setAlgorithms( [alg] )
00179 
00180     # configure the properties
00181     alg.NTupleLUN = 'MYLUN'
00182     
00183     return SUCCESS
00184 
00185 
00186 # =============================================================================
00187 ## The actual job execution 
00188 #
00189 #  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00190 #  @date 2006-11-26
00191 if '__main__' == __name__ :
00192     print __doc__
00193     gaudi = GaudiPython.AppMgr()
00194     configure( gaudi )
00195     gaudi.run(20)
00196     
00197 # =============================================================================
00198 # The END 
00199 # =============================================================================
| 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