| The Gaudi Framework v32r1 (f65d50dc)

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_ = []
def | ntuple = nTuple
def | getNTuple = nTuple
def | getNtuple = nTuple
def | getntuple = nTuple
def | getTuple = nTuple
def | gettuple = nTuple

## Function Documentation

## ◆ _getToolSvc()

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

## ◆ _nTuple_()

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

## ◆ _TupleUtils_AtExit_()

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:161
GaudiPython.TupleUtils._TupleUtils_AtExit_
def _TupleUtils_AtExit_()
Definition: TupleUtils.py:196

## ◆ activeTuples()

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

    Return the list of active tools

Definition at line 161 of file TupleUtils.py.

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

## ◆ nTuple()

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', name, interface=_Tool)
130
131 # check the properties and redefine them if needed
132 t1 = GaudiPython.iAlgTool(tool.name(), tool)
133 if t1.NTupleLUN != LUN:
134 t1.NTupleLUN = LUN
135 if t1.NTupleDir != dirpath:
136 t1.NTupleDir = dirpath
137 if topdir and (t1.NTupleTopDir != topdir):
138 t1.NTupleTopDir = topdir
139
140 _TOOLS_.append(tool)
141 if not ID2:
142 return tool.nTuple(ID) # RETURN
143
144 return tool.nTuple(ID, ID2) # RETURN
145
146
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:479

## ◆ releaseTuples()

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

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

## Variable Documentation

## ◆ __all__

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.

## ◆ __author__

string GaudiPython.TupleUtils.__author__ = "Vanya BELYAEV ibelyaev@physics.syr.edu"
| private

Definition at line 14 of file TupleUtils.py.

## ◆ _Deco

GaudiPython.TupleUtils._Deco = cpp.GaudiPython.TupleToolDecorator
| private

Definition at line 32 of file TupleUtils.py.

## ◆ _Tool

GaudiPython.TupleUtils._Tool = cpp.ITupleTool
| private

Definition at line 31 of file TupleUtils.py.

## ◆ _TOOLS_

list GaudiPython.TupleUtils._TOOLS_ = []
| private

Definition at line 35 of file TupleUtils.py.

## ◆ getNTuple

def GaudiPython.TupleUtils.getNTuple = nTuple

Definition at line 151 of file TupleUtils.py.

## ◆ getNtuple

def GaudiPython.TupleUtils.getNtuple = nTuple

Definition at line 152 of file TupleUtils.py.

## ◆ getntuple

def GaudiPython.TupleUtils.getntuple = nTuple

Definition at line 153 of file TupleUtils.py.

## ◆ getTuple

def GaudiPython.TupleUtils.getTuple = nTuple

Definition at line 154 of file TupleUtils.py.

## ◆ gettuple

def GaudiPython.TupleUtils.gettuple = nTuple

Definition at line 155 of file TupleUtils.py.

## ◆ ntuple

def GaudiPython.TupleUtils.ntuple = nTuple

Definition at line 150 of file TupleUtils.py.