| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

Functions | Variables
GaudiPython.TupleUtils Namespace Reference

## Functions
def | _getToolSvc (kwargs)
def | _nTuple_ (s, args)
def | nTuple (dirpath, ID, ID2=None, topdir=None, LUN='FILE1')
def | activeTuples ()
def | releaseTuples ()
def | _TupleUtils_AtExit_ ()

## Variables
string | __author__ = "Vanya BELYAEV ibelyaev@physics.syr.edu"
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

Definition at line 41 of file TupleUtils.py.

41 def _getToolSvc(**kwargs):
42 """ Helper private auxillary utility to get Tool Service """
43 svc = kwargs.get('toolSvc', None)
44 if not svc:
45 svc = kwargs.get('toolsvc', None)
46 if not svc:
47 svc = kwargs.get('service', None)
48 if not svc:
49 svc = kwargs.get('svc', None)
50 else:
51 return svc # RETURN
52 gaudi = kwargs.get('gaudi', None)
53 if not gaudi:
54 gaudi = AppMgr()
55 return gaudi.toolsvc() # RETURN
56
57
58 # =============================================================================
59 # Retrive N-Tuple ( book on demand )
GaudiPython.TupleUtils._getToolSvc
def _getToolSvc(kwargs)
Definition: TupleUtils.py:41
GaudiPython.Bindings.AppMgr
Definition: Bindings.py:883

def GaudiPython.TupleUtils._nTuple_ | ( |  | s,
|  |  | args
| ) |  |
| private

    Retrive N-tuple ( book on demand )

Definition at line 60 of file TupleUtils.py.

60 def _nTuple_(s, *args):
61 """ Retrive N-tuple ( book on demand ) """
62 return _Deco.nTuple(s, *args)
63
64
65 # =============================================================================
66 _nTuple_. __doc__ += "\n" + _Deco.nTuple . __doc__
67 _Tool.nTuple = _nTuple_
68 _Tool.ntuple = _nTuple_
69
70
71 # =============================================================================
72 # Retrieve (book-on-demand) 'Smart'-N-tuple object.
GaudiPython.TupleUtils._nTuple_
def _nTuple_(s, args)
Definition: TupleUtils.py:60

def GaudiPython.TupleUtils._TupleUtils_AtExit_ | ( |  | ) |
| private

    AtExit function for GaudiPython.TupleUtils module

Definition at line 196 of file TupleUtils.py.

196 def _TupleUtils_AtExit_():
197 """
198 AtExit function for GaudiPython.TupleUtils module
199 """
200 if activeTuples():
201 print 'WARNING: the list of local TupleTools is not empty!'
202 print 'WARNING: please use GaudiPython.TupleUtils.releaseTuples() at the end'
203
204
GaudiPython.TupleUtils.activeTuples
def activeTuples()
Definition: TupleUtils.py:163
GaudiPython.TupleUtils._TupleUtils_AtExit_
def _TupleUtils_AtExit_()
Definition: TupleUtils.py:196

def GaudiPython.TupleUtils.activeTuples | ( |  | ) |

    Return the list of active tools

Definition at line 163 of file TupleUtils.py.

163 def activeTuples():
164 """
165 Return the list of active tools
166 """
167 return _TOOLS_
168
169 # =============================================================================
170 # Release the active tool/tuples
171
172
GaudiPython.TupleUtils.activeTuples
def activeTuples()
Definition: TupleUtils.py:163

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

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

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

def GaudiPython.TupleUtils.releaseTuples | ( |  | ) |

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

Definition at line 173 of file TupleUtils.py.

173 def releaseTuples():
174 """
175 Release the active tool/tuples
176 The method needs to be invoked explicitely at the end of the job
177 """
178 if not _TOOLS_:
179 return
180 from GaudiPython.Bindings import _gaudi
181 if not _gaudi:
182 return
183
184 toolSvc = _getToolSvc()
185 if toolSvc.isValid():
186 while _TOOLS_:
187 t = _TOOLS_.pop()
188 if not t:
189 continue
190 while 1 < t.refCount():
191 toolSvc._its.releaseTool(t)
192
193 # =============================================================================
194
195
GaudiPython.TupleUtils.releaseTuples
def releaseTuples()
Definition: TupleUtils.py:173
GaudiPython.Bindings
Definition: Bindings.py:1
GaudiPython.TupleUtils._getToolSvc
def _getToolSvc(kwargs)
Definition: TupleUtils.py:41

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

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

GaudiPython.TupleUtils.getNtuple = nTuple

Definition at line 154 of file TupleUtils.py.

GaudiPython.TupleUtils.getntuple = nTuple

Definition at line 155 of file TupleUtils.py.

GaudiPython.TupleUtils.getTuple = nTuple

Definition at line 156 of file TupleUtils.py.

GaudiPython.TupleUtils.gettuple = nTuple

Definition at line 157 of file TupleUtils.py.

GaudiPython.TupleUtils.ntuple = nTuple

Definition at line 152 of file TupleUtils.py.