| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# 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.

    00039                             :
    00040     """ Helper private auxillary utility to get Tool Service """
    00041     svc = kwargs.get ( 'toolSvc' , None )
    00042     if not svc : svc = kwargs.get ( 'toolsvc' , None )
    00043     if not svc : svc = kwargs.get ( 'service' , None )
    00044     if not svc : svc = kwargs.get ( 'svc'     , None )
    00045     else       : return svc                                ## RETURN
    00046     gaudi = kwargs.get ( 'gaudi' , None )
    00047     if not gaudi : gaudi = AppMgr()
    00048     return gaudi.toolsvc()                                 ## RETURN
    00049
    00050
    00051 # =============================================================================
    ## 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 53 of file TupleUtils.py.

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

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

    AtExit function for GaudiPython.TupleUtils module

Definition at line 177 of file TupleUtils.py.

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

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

Return the list of active tools.

    Return the list of active tools

Definition at line 148 of file TupleUtils.py.

    00148                     :
    00149     """
    00150     Return the list of active tools
    00151     """
    00152     return _TOOLS_
    00153
    00154 # =============================================================================
    ## 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 66 of file TupleUtils.py.

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

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.

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

## Variable Documentation

tuple GaudiPython::TupleUtils::__all__

Initial value:

    (
        'nTuple'        ,  ## function to book/retrieve N-tuple
        'getNTuple'     ,  ## ditto
        'getNtuple'     ,  ## ditto
        'getntuple'     ,  ## ditto
        'gettuple'      ,  ## ditto
        'activeTuples'  ,  ## get the list of all active n-tuples
        'releaseTuples'    ## release all actibe N-tuples
        )

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

GaudiPython::TupleUtils::getNtuple = nTuple

Definition at line 141 of file TupleUtils.py.

GaudiPython::TupleUtils::getNTuple = nTuple

Definition at line 140 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.