| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Functions | Variables

# GaudiPython::TupleUtils Namespace Reference

## Functions
def | _getToolSvc
| Helper private auxillary utility to get Tool Service.
def | _nTuple_
| Retrive N-Tuple ( book on demand )
def | nTuple
| Retrieve (book-on-demand) 'Smart'-N-tuple object.
def | activeTuples
| Return the list of active tools.
def | releaseTuples
| Release the active tool/tuples.
def | _TupleUtils_AtExit_
## Variables
string | __author__ = "Vanya BELYAEV ibelyaev@physics.syr.edu"
| This module contains set of simple and useful utilities to booking and manipulation with N-Tuples (in the spirit of GaudiTuples<TYPE>)
tuple | __all__
| _Tool = cpp.ITupleTool
| _Deco = cpp.GaudiPython.TupleToolDecorator
list | _TOOLS_ = []
| ntuple = nTuple
| getNTuple = nTuple
| getNtuple = nTuple
| getntuple = nTuple
| getTuple = nTuple
| gettuple = nTuple

## Function Documentation

def GaudiPython::TupleUtils::_getToolSvc | ( |  | kwargs ) | `[private]`

Helper private auxillary utility to get Tool Service.

    Helper private auxillary utility to get Tool Service

Definition at line 39 of file TupleUtils.py.

    00040                             :
    00041     """ Helper private auxillary utility to get Tool Service """
    00042     svc = kwargs.get ( 'toolSvc' , None )
    00043     if not svc : svc = kwargs.get ( 'toolsvc' , None )
    00044     if not svc : svc = kwargs.get ( 'service' , None )
    00045     if not svc : svc = kwargs.get ( 'svc'     , None )
    00046     else       : return svc                                ## RETURN
    00047     gaudi = kwargs.get ( 'gaudi' , None )
    00048     if not gaudi : gaudi = AppMgr()
    00049     return gaudi.toolsvc()                                 ## RETURN
    00050
    00051
    # =============================================================================

def GaudiPython::TupleUtils::_nTuple_ | ( |  | s,
|  |  | args
| ) |  | `[private]`

Retrive N-Tuple ( book on demand )

    Retrive N-tuple ( book on demand )

Definition at line 53 of file TupleUtils.py.

    00054                            :
    00055     """ Retrive N-tuple ( book on demand )  """
    00056     print 'ARGS:' , args
    00057     return _Deco.nTuple ( s , *args)
    00058
    00059 # =============================================================================
    00060 _nTuple_. __doc__ += "\n" + _Deco.nTuple . __doc__
    00061 _Tool.nTuple = _nTuple_
    00062 _Tool.ntuple = _nTuple_
    00063
    00064
    # =============================================================================

def GaudiPython::TupleUtils::_TupleUtils_AtExit_ | ( | ) | `[private]`

    AtExit function for GaudiPython.TupleUtils module

Definition at line 177 of file TupleUtils.py.

    00178                            :
    00179     """
    00180     AtExit function for GaudiPython.TupleUtils module
    00181     """
    00182     if activeTuples() :
    00183         print 'WARNING: the list of local TupleTools is not empty!'
    00184         print 'WARNING: please use GaudiPython.TupleUtils.releaseTuples() at the end'

def GaudiPython::TupleUtils::activeTuples | ( | ) |

Return the list of active tools.

    Return the list of active tools

Definition at line 148 of file TupleUtils.py.

    00149                     :
    00150     """
    00151     Return the list of active tools
    00152     """
    00153     return _TOOLS_
    00154
    # =============================================================================

def GaudiPython::TupleUtils::nTuple | ( |  | dirpath,
|  |  | ID,
|  |  | ID2 = `None`,
|  |  | topdir = `None`,
|  |  | LUN = `'FILE1'`
| ) |  |

Retrieve (book-on-demand) 'Smart'-N-tuple object.

    Retrieve 'Smart'-N-tuple object.
    N-tuple is booked on-demand.

    Atetntion !!
    The logical unit LUN must be configured by N-Tuple Service

    Retrieve (book-n-demand) N-Tuple using
    the  directory name and the title:
    >>> t = nTuple ( 'the/path/to/directory' , ## the path to the directory
                     'N-tuple title'         , ## the title for N-Tuple
                      LUN = 'FILE1'          ) ## logical file unit

    Retrieve (book-n-demand) N-Tuple using
    the  directory name, literal ID and the title:
    >>> t = nTuple ( 'the/path/to/directory' , ## the path to the directory
                     'Tuple1'                , ## the literal ID for N-Tuple
                     'N-tuple title'         , ## the title for N-Tuple
                      LUN = 'FILE1'          ) ## logical file unit

    Retrieve (book-n-demand) N-Tuple using
    the  directory name, numerical ID and the title:
    >>> t = nTuple ( 'the/path/to/directory' , ## the path to the directory
                     124                     , ## the numerical ID for N-Tuple
                     'N-tuple title'         , ## the title for N-Tuple
                      LUN = 'FILE1'          ) ## logical file unit

Definition at line 66 of file TupleUtils.py.

    00067                                                                          :
    00068     """
    00069     Retrieve 'Smart'-N-tuple object.
    00070     N-tuple is booked on-demand.
    00071
    00072     Atetntion !!
    00073     The logical unit LUN must be configured by N-Tuple Service
    00074
    00075     Retrieve (book-n-demand) N-Tuple using
    00076     the  directory name and the title:
    00077     >>> t = nTuple ( 'the/path/to/directory' , ## the path to the directory
    00078                      'N-tuple title'         , ## the title for N-Tuple
    00079                       LUN = 'FILE1'          ) ## logical file unit
    00080
    00081     Retrieve (book-n-demand) N-Tuple using
    00082     the  directory name, literal ID and the title:
    00083     >>> t = nTuple ( 'the/path/to/directory' , ## the path to the directory
    00084                      'Tuple1'                , ## the literal ID for N-Tuple
    00085                      'N-tuple title'         , ## the title for N-Tuple
    00086                       LUN = 'FILE1'          ) ## logical file unit
    00087
    00088     Retrieve (book-n-demand) N-Tuple using
    00089     the  directory name, numerical ID and the title:
    00090     >>> t = nTuple ( 'the/path/to/directory' , ## the path to the directory
    00091                      124                     , ## the numerical ID for N-Tuple
    00092                      'N-tuple title'         , ## the title for N-Tuple
    00093                       LUN = 'FILE1'          ) ## logical file unit
    00094
    00095
    00096     """
    00097     toolSvc = _getToolSvc ()
    00098
    00099     # construct the name of the intermediate TupleTool
    00100     name = 'Tuple'+LUN+"/"
    00101     if topdir : name += topdir
    00102     name += dirpath
    00103     name += "_%s"%ID
    00104     if  ID2 : name += "_%s"%ID2
    00105     name=name.replace ( '.'  , '_' )
    00106     name=name.replace ( '/'  , '_' )
    00107     name=name.replace ( '\\' , '_' )
    00108     name=name.replace ( ' '  , '_' )
    00109
    00110     ## define tool properties
    00111     t0 = GaudiPython.iAlgTool( 'ToolSvc.'+name )
    00112     t0.OutputLevel      = 1
    00113     t0.NTupleLUN        = LUN
    00114     t0.NTupleDir        = dirpath
    00115     t0.PropertiesPrint  = False
    00116     t0.OutputLevel      = 4
    00117     if topdir : t0.NTupleTopDir = topdir
    00118
    00119     ## get the tool from Tool service
    00120     tool = toolSvc.create ( 'TupleTool'       ,
    00121                             name              ,
    00122                             interface = _Tool )
    00123
    00124     ## check the properties and redefine them if needed
    00125     t1 = GaudiPython.iAlgTool ( tool.name() , tool )
    00126     if t1.NTupleLUN != LUN     : t1.NTupleLUN = LUN
    00127     if t1.NTupleDir != dirpath : t1.NTupleDir = dirpath
    00128     if topdir and ( t1.NTupleTopDir != topdir ) :
    00129         t1.NTupleTopDir = topdir
    00130
    00131     _TOOLS_.append ( tool )
    00132     if not ID2 : return tool.nTuple ( ID )               ## RETURN
    00133
    00134     return tool.nTuple ( ID , ID2 )                      ## RETURN
    00135

def GaudiPython::TupleUtils::releaseTuples | ( | ) |

Release the active tool/tuples.

    Release the active tool/tuples
    The method needs to be invoked explicitely at the end of the job

Definition at line 156 of file TupleUtils.py.

    00157                      :
    00158     """
    00159     Release the active tool/tuples
    00160     The method needs to be invoked explicitely at the end of the job
    00161     """
    00162     if not _TOOLS_ : return
    00163     print ' %s/%s: release all pending ITupleTools: %s' % ( __file__     ,
    00164                                                            __name__     ,
    00165                                                            len(_TOOLS_) )
    00166     from GaudiPython.Bindings import _gaudi
    00167     if not _gaudi : return
    00168
    00169     toolSvc = _getToolSvc()
    00170     if toolSvc.isValid() :
    00171         while _TOOLS_ :
    00172             t = _TOOLS_.pop()
    00173             if not t : continue
    00174             while 1 < t.refCount() :
    00175                 toolSvc._its.releaseTool( t )
    00176
    # =============================================================================

## Variable Documentation

tuple GaudiPython::TupleUtils::__all__

Initial value:

    00001 (
    00002     'nTuple'        ,  ## function to book/retrieve N-tuple
    00003     'getNTuple'     ,  ## ditto
    00004     'getNtuple'     ,  ## ditto
    00005     'getntuple'     ,  ## ditto
    00006     'gettuple'      ,  ## ditto
    00007     'activeTuples'  ,  ## get the list of all active n-tuples
    00008     'releaseTuples'    ## release all actibe N-tuples
    00009     )

Definition at line 16 of file TupleUtils.py.

string GaudiPython::TupleUtils::__author__ = "Vanya BELYAEV ibelyaev@physics.syr.edu"

This module contains set of simple and useful utilities to booking and manipulation with N-Tuples (in the spirit of GaudiTuples<TYPE>)

Author:
  Vanya BELYAEV ibelyaev@physics.syr.edu

Date:
  2007-08-04 =============================================================================

Definition at line 14 of file TupleUtils.py.

GaudiPython::TupleUtils::_Deco = cpp.GaudiPython.TupleToolDecorator

Definition at line 32 of file TupleUtils.py.

GaudiPython::TupleUtils::_Tool = cpp.ITupleTool

Definition at line 31 of file TupleUtils.py.

list GaudiPython::TupleUtils::_TOOLS_ = []

Definition at line 35 of file TupleUtils.py.

GaudiPython::TupleUtils::getNTuple = nTuple

Definition at line 140 of file TupleUtils.py.

GaudiPython::TupleUtils::getNtuple = nTuple

Definition at line 141 of file TupleUtils.py.

GaudiPython::TupleUtils::getntuple = nTuple

Definition at line 142 of file TupleUtils.py.

GaudiPython::TupleUtils::gettuple = nTuple

Definition at line 144 of file TupleUtils.py.

GaudiPython::TupleUtils::getTuple = nTuple

Definition at line 143 of file TupleUtils.py.

GaudiPython::TupleUtils::ntuple = nTuple

Definition at line 139 of file TupleUtils.py.

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines