All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GaudiPython.TupleUtils Namespace Reference

Functions

def _getToolSvc (kwargs)
 Helper private auxillary utility to get Tool Service. More...
 
def _nTuple_ (s, args)
 Retrive N-Tuple ( book on demand ) More...
 
def nTuple (dirpath, ID, ID2=None, topdir=None, LUN='FILE1')
 Retrieve (book-on-demand) 'Smart'-N-tuple object. More...
 
def activeTuples ()
 Return the list of active tools. More...
 
def releaseTuples ()
 Release the active tool/tuples. More...
 
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>) More...
 
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 def _getToolSvc( **kwargs ) :
40  """ Helper private auxillary utility to get Tool Service """
41  svc = kwargs.get ( 'toolSvc' , None )
42  if not svc : svc = kwargs.get ( 'toolsvc' , None )
43  if not svc : svc = kwargs.get ( 'service' , None )
44  if not svc : svc = kwargs.get ( 'svc' , None )
45  else : return svc ## RETURN
46  gaudi = kwargs.get ( 'gaudi' , None )
47  if not gaudi : gaudi = AppMgr()
48  return gaudi.toolsvc() ## RETURN
49 
50 
51 # =============================================================================
def _getToolSvc(kwargs)
Helper private auxillary utility to get Tool Service.
Definition: TupleUtils.py:39
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 def _nTuple_ ( s , *args ) :
54  """ Retrive N-tuple ( book on demand ) """
55  return _Deco.nTuple ( s , *args)
56 
57 # =============================================================================
58 _nTuple_. __doc__ += "\n" + _Deco.nTuple . __doc__
59 _Tool.nTuple = _nTuple_
60 _Tool.ntuple = _nTuple_
61 
62 
63 # =============================================================================
def _nTuple_(s, args)
Retrive N-Tuple ( book on demand )
Definition: TupleUtils.py:53
def GaudiPython.TupleUtils._TupleUtils_AtExit_ ( )
private
AtExit function for GaudiPython.TupleUtils module

Definition at line 173 of file TupleUtils.py.

174  """
175  AtExit function for GaudiPython.TupleUtils module
176  """
177  if activeTuples() :
178  print 'WARNING: the list of local TupleTools is not empty!'
179  print 'WARNING: please use GaudiPython.TupleUtils.releaseTuples() at the end'
180 
def activeTuples()
Return the list of active tools.
Definition: TupleUtils.py:147
def GaudiPython.TupleUtils.activeTuples ( )

Return the list of active tools.

Return the list of active tools

Definition at line 147 of file TupleUtils.py.

147 def activeTuples () :
148  """
149  Return the list of active tools
150  """
151  return _TOOLS_
152 
153 # =============================================================================
def activeTuples()
Return the list of active tools.
Definition: TupleUtils.py:147
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 65 of file TupleUtils.py.

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

156  """
157  Release the active tool/tuples
158  The method needs to be invoked explicitely at the end of the job
159  """
160  if not _TOOLS_ : return
161  from GaudiPython.Bindings import _gaudi
162  if not _gaudi : return
163 
164  toolSvc = _getToolSvc()
165  if toolSvc.isValid() :
166  while _TOOLS_ :
167  t = _TOOLS_.pop()
168  if not t : continue
169  while 1 < t.refCount() :
170  toolSvc._its.releaseTool( t )
171 
172 # =============================================================================
def releaseTuples()
Release the active tool/tuples.
Definition: TupleUtils.py:155
def _getToolSvc(kwargs)
Helper private auxillary utility to get Tool Service.
Definition: TupleUtils.py:39

Variable Documentation

tuple GaudiPython.TupleUtils.__all__
private
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"
private

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
private

Definition at line 32 of file TupleUtils.py.

GaudiPython.TupleUtils._Tool = cpp.ITupleTool
private

Definition at line 31 of file TupleUtils.py.

list GaudiPython.TupleUtils._TOOLS_ = []
private

Definition at line 35 of file TupleUtils.py.

GaudiPython.TupleUtils.getNTuple = nTuple

Definition at line 139 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.getTuple = nTuple

Definition at line 142 of file TupleUtils.py.

GaudiPython.TupleUtils.gettuple = nTuple

Definition at line 143 of file TupleUtils.py.

GaudiPython.TupleUtils.ntuple = nTuple

Definition at line 138 of file TupleUtils.py.