The Gaudi Framework  v36r1 (3e2fb5a8)
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

 __author__
 
 __all__
 
 _Tool
 
 _Deco
 
 _TOOLS_
 
 ntuple
 
 getNTuple
 
 getNtuple
 
 getntuple
 
 getTuple
 
 gettuple
 

Function Documentation

◆ _getToolSvc()

def GaudiPython.TupleUtils._getToolSvc ( **  kwargs)
private
Helper private auxillary utility to get Tool Service 

Definition at line 52 of file TupleUtils.py.

52 def _getToolSvc(**kwargs):
53  """ Helper private auxillary utility to get Tool Service """
54  svc = kwargs.get('toolSvc', None)
55  if not svc:
56  svc = kwargs.get('toolsvc', None)
57  if not svc:
58  svc = kwargs.get('service', None)
59  if not svc:
60  svc = kwargs.get('svc', None)
61  else:
62  return svc # RETURN
63  gaudi = kwargs.get('gaudi', None)
64  if not gaudi:
65  gaudi = AppMgr()
66  return gaudi.toolsvc() # RETURN
67 
68 
69 # =============================================================================
70 # Retrive N-Tuple ( book on demand )

◆ _nTuple_()

def GaudiPython.TupleUtils._nTuple_ (   s,
args 
)
private
Retrive N-tuple ( book on demand )  

Definition at line 71 of file TupleUtils.py.

71 def _nTuple_(s, *args):
72  """ Retrive N-tuple ( book on demand ) """
73  return _Deco.nTuple(s, *args)
74 
75 
76 # =============================================================================
77 _nTuple_.__doc__ += "\n" + _Deco.nTuple.__doc__
78 _Tool.nTuple = _nTuple_
79 _Tool.ntuple = _nTuple_
80 
81 
82 # =============================================================================
83 # Retrieve (book-on-demand) 'Smart'-N-tuple object.

◆ _TupleUtils_AtExit_()

def GaudiPython.TupleUtils._TupleUtils_AtExit_ ( )
private
AtExit function for GaudiPython.TupleUtils module

Definition at line 207 of file TupleUtils.py.

207 def _TupleUtils_AtExit_():
208  """
209  AtExit function for GaudiPython.TupleUtils module
210  """
211  if activeTuples():
212  print('WARNING: the list of local TupleTools is not empty!')
213  print(
214  'WARNING: please use GaudiPython.TupleUtils.releaseTuples() at the end'
215  )
216 
217 

◆ activeTuples()

def GaudiPython.TupleUtils.activeTuples ( )
Return the list of active tools

Definition at line 172 of file TupleUtils.py.

172 def activeTuples():
173  """
174  Return the list of active tools
175  """
176  return _TOOLS_
177 
178 
179 # =============================================================================
180 # Release the active tool/tuples
181 
182 

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

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

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

183 def releaseTuples():
184  """
185  Release the active tool/tuples
186  The method needs to be invoked explicitely at the end of the job
187  """
188  if not _TOOLS_:
189  return
190  from GaudiPython.Bindings import _gaudi
191  if not _gaudi:
192  return
193 
194  toolSvc = _getToolSvc()
195  if toolSvc.isValid():
196  while _TOOLS_:
197  t = _TOOLS_.pop()
198  if not t:
199  continue
200  while 1 < t.refCount():
201  toolSvc._its.releaseTool(t)
202 
203 
204 # =============================================================================
205 
206 

Variable Documentation

◆ __all__

GaudiPython.TupleUtils.__all__
private

Definition at line 27 of file TupleUtils.py.

◆ __author__

GaudiPython.TupleUtils.__author__
private

Definition at line 25 of file TupleUtils.py.

◆ _Deco

GaudiPython.TupleUtils._Deco
private

Definition at line 43 of file TupleUtils.py.

◆ _Tool

GaudiPython.TupleUtils._Tool
private

Definition at line 42 of file TupleUtils.py.

◆ _TOOLS_

GaudiPython.TupleUtils._TOOLS_
private

Definition at line 46 of file TupleUtils.py.

◆ getNTuple

GaudiPython.TupleUtils.getNTuple

Definition at line 162 of file TupleUtils.py.

◆ getNtuple

GaudiPython.TupleUtils.getNtuple

Definition at line 163 of file TupleUtils.py.

◆ getntuple

GaudiPython.TupleUtils.getntuple

Definition at line 164 of file TupleUtils.py.

◆ getTuple

GaudiPython.TupleUtils.getTuple

Definition at line 165 of file TupleUtils.py.

◆ gettuple

GaudiPython.TupleUtils.gettuple

Definition at line 166 of file TupleUtils.py.

◆ ntuple

GaudiPython.TupleUtils.ntuple

Definition at line 161 of file TupleUtils.py.

GaudiPython.TupleUtils._TupleUtils_AtExit_
def _TupleUtils_AtExit_()
Definition: TupleUtils.py:207
GaudiPython.TupleUtils._nTuple_
def _nTuple_(s, *args)
Definition: TupleUtils.py:71
GaudiPython.Bindings
Definition: Bindings.py:1
GaudiPython.TupleUtils.activeTuples
def activeTuples()
Definition: TupleUtils.py:172
GaudiPython.TupleUtils._getToolSvc
def _getToolSvc(**kwargs)
Definition: TupleUtils.py:52
GaudiPython.TupleUtils.nTuple
def nTuple(dirpath, ID, ID2=None, topdir=None, LUN='FILE1')
Definition: TupleUtils.py:84
GaudiPython.TupleUtils.releaseTuples
def releaseTuples()
Definition: TupleUtils.py:183
GaudiPython.Bindings.iAlgTool
Definition: Bindings.py:459