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

In This Package:

EvtColWrite.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # =============================================================================
00003 # $Id: EvtColWrite.py,v 1.11 2007/10/29 14:29:47 mato Exp $
00004 # =============================================================================
00005 # CVS tag $Name: GAUDI_v20r4-pre $, version $Revision: 1.11 $
00006 # =============================================================================
00007 """
00008 *******************************************************************************
00009 *                                                                             *
00010 * Simple example which illustrate the usage of useful                         *
00011 * algorithm  base class for writing of EventTag Collections                   *
00012 *                                                                             *
00013 *******************************************************************************
00014 """
00015 # =============================================================================
00016 __author__ = 'Vanya BELYAEV ibelyaev@physics.syr.edu'
00017 # =============================================================================
00018 
00019 import GaudiPython, math 
00020 
00021 Rndm    = GaudiPython.gbl.Rndm
00022 Numbers = Rndm.Numbers 
00023 SUCCESS = GaudiPython.SUCCESS 
00024 
00025 from   GaudiPython.GaudiAlgs   import TupleAlgo
00026 
00027 # =============================================================================
00028 # Simple algorithm which book&fill 3 histograms
00029 # =============================================================================
00030 class EvtColEx(TupleAlgo) :
00031     """ Simple algorithm which implicitely book&Fill Event Tag collection"""
00032     def __init__ ( self , name = 'EvtColEx' ) :
00033         """ Constructor """
00034         TupleAlgo.__init__( self , name )
00035         self.s_nEvt = 0
00036         self.s_nRun = 0
00037         
00038         
00039     def execute( self ) :
00040         """ The major method 'execute', it is invoked for each event """
00041         
00042         self.s_nEvt += 1
00043         if 1 == self.s_nEvt % 50 : self.s_nRun += 1
00044         
00045         rSvc    = self.randSvc()
00046         
00047         gauss   = Numbers ( rSvc , Rndm.Gauss        (   0.0 ,   1.0  ) )
00048         flat    = Numbers ( rSvc , Rndm.Flat         ( -10   ,  10    ) )
00049         expo    = Numbers ( rSvc , Rndm.Exponential  (   1.0          ) )
00050         breit   = Numbers ( rSvc , Rndm.BreitWigner  (   0.0 ,   1.0  ) )
00051         poisson = Numbers ( rSvc , Rndm.Poisson      (   2.0          ) )
00052         binom   = Numbers ( rSvc , Rndm.Binomial     (   8   ,   0.25 ) )
00053         
00054         address = self.get('/Event')
00055         address = address.registry().address()
00056 
00057         # get the event tag collection itself 
00058         tup = self.evtCol( 'COL1' , 'My trivial N-tuple' )
00059         
00060         tup.column ( 'Address' , address     )
00061 
00062         tup.column ( 'evtNum'  , self.s_nEvt )
00063         tup.column ( 'runNum'  , self.s_nRun )
00064         
00065         tup.column ( 'gauss'   ,       gauss   ()   )
00066         tup.column ( 'flat'    ,       flat    ()   )
00067         tup.column ( 'expo'    ,       expo    ()   )
00068         tup.column ( 'poisson' , int ( poisson () ) )
00069         tup.column ( 'binom'   , int ( binom   () ) )
00070         tup.column ( 'flag'    ,   0 > gauss   ()   )
00071         
00072         return SUCCESS
00073 
00074 
00075 def _evtcolsvc_(self, name='EvtTupleSvc') :
00076     svc = GaudiPython.Helper.service( self._svcloc, name, False )
00077     return GaudiPython.iNTupleSvc(name, svc)
00078 
00079 GaudiPython.AppMgr.evtcolsvc = _evtcolsvc_ 
00080 
00081 # =============================================================================
00082 # job configuration 
00083 # =============================================================================
00084 def configure( gaudi = None  ) :
00085     """ Configuration of the job """
00086     
00087     if not gaudi : gaudi = GaudiPython.AppMgr()
00088     
00089     gaudi.HistogramPersistency = "ROOT"
00090     gaudi.DLLs   += [ 'GaudiAlg'  , 'RootHistCnv'     ]
00091     gaudi.ExtSvc += [ 'RndmGenSvc'    ,
00092                       'NTupleSvc'      ,
00093                       'TagCollectionSvc/EvtTupleSvc' ]
00094     
00095     alg = EvtColEx('Fill')
00096     gaudi.setAlgorithms( [alg] )
00097 
00098     alg.EvtColLUN       = 'EVTTAGS'
00099     alg.EvtColsProduce  = True
00100     alg.EvtColsPrint    = True
00101     alg.NTupleProduce   = False
00102     alg.HistoProduce    = False
00103     
00104     gaudi.OutStream = [ 'EvtCollectionStream/TagsWriter']
00105     tagsWriter = gaudi.algorithm('TagsWriter')
00106     tagsWriter.ItemList    = [ '/NTUPLES/EVTTAGS/Fill/COL1']
00107     tagsWriter.EvtDataSvc  =   "EvtTupleSvc" ;
00108    
00109     evtColSvc = gaudi.evtcolsvc()
00110     evtColSvc.defineOutput( {'EVTTAGS' : 'PFN:EvtTags1.root'} , typ='POOL_ROOT' )  
00111     evtColSvc.OutputLevel = 2
00112     
00113     evtSel = gaudi.evtSel()
00114     evtSel.PrintFreq = 1000
00115     evtSel.open( ['EvtColsEx.dst'] )
00116     
00117     return SUCCESS
00118 
00119 
00120 # =============================================================================
00121 # The actual job excution 
00122 # =============================================================================
00123 if '__main__' == __name__ :
00124     print __doc__
00125     gaudi = GaudiPython.AppMgr( joboptions = 'GaudiPoolDbRoot.opts' )
00126     configure( gaudi )
00127     gaudi.run(10000)
00128     
00129 # =============================================================================
00130 # The END 
00131 # =============================================================================
| 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