Gaudi Framework, version v25r2

Home   Generated: Wed Jun 4 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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.

39 
40 def _getToolSvc( **kwargs ) :
41  """ Helper private auxillary utility to get Tool Service """
42  svc = kwargs.get ( 'toolSvc' , None )
43  if not svc : svc = kwargs.get ( 'toolsvc' , None )
44  if not svc : svc = kwargs.get ( 'service' , None )
45  if not svc : svc = kwargs.get ( 'svc' , None )
46  else : return svc ## RETURN
47  gaudi = kwargs.get ( 'gaudi' , None )
48  if not gaudi : gaudi = AppMgr()
49  return gaudi.toolsvc() ## RETURN
50 
51 
# =============================================================================
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.

53 
54 def _nTuple_ ( s , *args ) :
55  """ Retrive N-tuple ( book on demand ) """
56  print 'ARGS:' , args
57  return _Deco.nTuple ( s , *args)
58 
59 # =============================================================================
60 _nTuple_. __doc__ += "\n" + _Deco.nTuple . __doc__
61 _Tool.nTuple = _nTuple_
62 _Tool.ntuple = _nTuple_
63 
64 
# =============================================================================
def GaudiPython.TupleUtils._TupleUtils_AtExit_ ( )
private
AtExit function for GaudiPython.TupleUtils module

Definition at line 177 of file TupleUtils.py.

178 def _TupleUtils_AtExit_ () :
179  """
180  AtExit function for GaudiPython.TupleUtils module
181  """
182  if activeTuples() :
183  print 'WARNING: the list of local TupleTools is not empty!'
184  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.

149 def activeTuples () :
150  """
151  Return the list of active tools
152  """
153  return _TOOLS_
154 
# =============================================================================
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.

66 
67 def nTuple ( dirpath , ID , ID2 = None , topdir = None , LUN = 'FILE1' ) :
68  """
69  Retrieve 'Smart'-N-tuple object.
70  N-tuple is booked on-demand.
71 
72  Atetntion !!
73  The logical unit LUN must be configured by N-Tuple Service
74 
75  Retrieve (book-n-demand) N-Tuple using
76  the directory name and the title:
77  >>> t = nTuple ( 'the/path/to/directory' , ## the path to the directory
78  'N-tuple title' , ## the title for N-Tuple
79  LUN = 'FILE1' ) ## logical file unit
80 
81  Retrieve (book-n-demand) N-Tuple using
82  the directory name, literal ID and the title:
83  >>> t = nTuple ( 'the/path/to/directory' , ## the path to the directory
84  'Tuple1' , ## the literal ID for N-Tuple
85  'N-tuple title' , ## the title for N-Tuple
86  LUN = 'FILE1' ) ## logical file unit
87 
88  Retrieve (book-n-demand) N-Tuple using
89  the directory name, numerical ID and the title:
90  >>> t = nTuple ( 'the/path/to/directory' , ## the path to the directory
91  124 , ## the numerical ID for N-Tuple
92  'N-tuple title' , ## the title for N-Tuple
93  LUN = 'FILE1' ) ## logical file unit
94 
95 
96  """
97  toolSvc = _getToolSvc ()
98 
99  # construct the name of the intermediate TupleTool
100  name = 'Tuple'+LUN+"/"
101  if topdir : name += topdir
102  name += dirpath
103  name += "_%s"%ID
104  if ID2 : name += "_%s"%ID2
105  name=name.replace ( '.' , '_' )
106  name=name.replace ( '/' , '_' )
107  name=name.replace ( '\\' , '_' )
108  name=name.replace ( ' ' , '_' )
109 
110  ## define tool properties
111  t0 = GaudiPython.iAlgTool( 'ToolSvc.'+name )
112  t0.OutputLevel = 1
113  t0.NTupleLUN = LUN
114  t0.NTupleDir = dirpath
115  t0.PropertiesPrint = False
116  t0.OutputLevel = 4
117  if topdir : t0.NTupleTopDir = topdir
118 
119  ## get the tool from Tool service
120  tool = toolSvc.create ( 'TupleTool' ,
121  name ,
122  interface = _Tool )
123 
124  ## check the properties and redefine them if needed
125  t1 = GaudiPython.iAlgTool ( tool.name() , tool )
126  if t1.NTupleLUN != LUN : t1.NTupleLUN = LUN
127  if t1.NTupleDir != dirpath : t1.NTupleDir = dirpath
128  if topdir and ( t1.NTupleTopDir != topdir ) :
129  t1.NTupleTopDir = topdir
130 
131  _TOOLS_.append ( tool )
132  if not ID2 : return tool.nTuple ( ID ) ## RETURN
133 
134  return tool.nTuple ( ID , ID2 ) ## RETURN
135 
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.

157 def releaseTuples () :
158  """
159  Release the active tool/tuples
160  The method needs to be invoked explicitely at the end of the job
161  """
162  if not _TOOLS_ : return
163  print ' %s/%s: release all pending ITupleTools: %s' % ( __file__ ,
164  __name__ ,
165  len(_TOOLS_) )
166  from GaudiPython.Bindings import _gaudi
167  if not _gaudi : return
168 
169  toolSvc = _getToolSvc()
170  if toolSvc.isValid() :
171  while _TOOLS_ :
172  t = _TOOLS_.pop()
173  if not t : continue
174  while 1 < t.refCount() :
175  toolSvc._its.releaseTool( t )
176 
# =============================================================================

Variable Documentation

tuple GaudiPython.TupleUtils.__all__
Initial value:
1 (
2  'nTuple' , ## function to book/retrieve N-tuple
3  'getNTuple' , ## ditto
4  'getNtuple' , ## ditto
5  'getntuple' , ## ditto
6  'gettuple' , ## ditto
7  'activeTuples' , ## get the list of all active n-tuples
8  'releaseTuples' ## release all actibe N-tuples
9  )

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 ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u

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

GaudiPython.TupleUtils.gettuple nTuple

Definition at line 144 of file TupleUtils.py.

GaudiPython.TupleUtils.ntuple nTuple

Definition at line 139 of file TupleUtils.py.


Generated at Wed Jun 4 2014 14:49:06 for Gaudi Framework, version v25r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004