| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# 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.
## 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__
| _gbl = GaudiPython.gbl
| _Tool = _gbl.ITupleTool
| _Deco = _gbl.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 31 of file TupleUtils.py.

    00031                             :
    00032     """ Helper private auxillary utility to get Tool Service """
    00033     svc = kwargs.get ( 'toolSvc' , None )
    00034     if not svc : svc = kwargs.get ( 'toolsvc' , None )
    00035     if not svc : svc = kwargs.get ( 'service' , None )
    00036     if not svc : svc = kwargs.get ( 'svc'     , None )
    00037     else       : return svc                                ## RETURN
    00038     gaudi = kwargs.get ( 'gaudi' , None )
    00039     if not gaudi : gaudi = GaudiPython.AppMgr()
    00040     return gaudi.toolsvc()                                 ## RETURN
    00041
    00042
    00043 # =============================================================================
    ## Retrive N-Tuple ( book on demand )

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

Retrive N-Tuple ( book on demand ).

    Retrive N-tuple ( book on demand )

Definition at line 45 of file TupleUtils.py.

    00045                            :
    00046     """ Retrive N-tuple ( book on demand )  """
    00047     print 'ARGS:' , args
    00048     return _Deco.nTuple ( s , *args)
    00049
    00050 # =============================================================================
    00051 _nTuple_. __doc__ += "\n" + _Deco.nTuple . __doc__
    00052 _Tool.nTuple = _nTuple_
    00053 _Tool.ntuple = _nTuple_
    00054
    00055
    00056
    00057 # =============================================================================
    ## Retrieve (book-on-demand) 'Smart'-N-tuple object.

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

Return the list of active tools.

    Return the list of active tools

Definition at line 143 of file TupleUtils.py.

    00143                     :
    00144     """
    00145     Return the list of active tools
    00146     """
    00147     return _TOOLS_
    00148
    00149 # =============================================================================
    ## Release the active tool/tuples

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 59 of file TupleUtils.py.

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

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 151 of file TupleUtils.py.

    00151                      :
    00152     """
    00153     Release the active tool/tuples
    00154     The method needs to be invoked explicitely at the end of the job
    00155     """
    00156     if not _TOOLS_ : return
    00157     print ' %s/%s: release all pending ITupleTools: %s' % ( __file__     ,
    00158                                                            __name__     ,
    00159                                                            len(_TOOLS_) )
    00160     toolSvc = _getToolSvc()
    00161     while _TOOLS_ and toolSvc.isValid() :
    00162         t = _TOOLS_.pop()
    00163         if t and 0 < t.refCount() : toolSvc._its.releaseTool( t )
    00164
    if "__main__" == __name__ :

## Variable Documentation

tuple GaudiPython::TupleUtils::__all__

Initial value:

    ( 'nTuple' , 'getNTuple' , 'getNtuple'    , 'getntuple'     ,
                'ntuple' , 'gettuple'  , 'activeTuples' , 'releaseTuples' )

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 = _gbl.GaudiPython.TupleToolDecorator

Definition at line 24 of file TupleUtils.py.

GaudiPython::TupleUtils::_gbl = GaudiPython.gbl

Definition at line 22 of file TupleUtils.py.

GaudiPython::TupleUtils::_Tool = _gbl.ITupleTool

Definition at line 23 of file TupleUtils.py.

list GaudiPython::TupleUtils::_TOOLS_ = []

Definition at line 27 of file TupleUtils.py.

GaudiPython::TupleUtils::getntuple = nTuple

Definition at line 137 of file TupleUtils.py.

GaudiPython::TupleUtils::getNtuple = nTuple

Definition at line 136 of file TupleUtils.py.

GaudiPython::TupleUtils::getNTuple = nTuple

Definition at line 135 of file TupleUtils.py.

GaudiPython::TupleUtils::gettuple = nTuple

Definition at line 139 of file TupleUtils.py.

GaudiPython::TupleUtils::getTuple = nTuple

Definition at line 138 of file TupleUtils.py.

GaudiPython::TupleUtils::ntuple = nTuple

Definition at line 134 of file TupleUtils.py.