The Gaudi Framework  v29r0 (ff2e7097)
GaudiPython.Bindings Namespace Reference

Classes

class  AppMgr
 
class  CallbackStreamBuf
 
class  iAlgorithm
 
class  iAlgTool
 
class  iDataSvc
 
class  iEventSelector
 
class  iHistogramSvc
 
class  iJobOptSvc
 
class  Interface
 
class  InterfaceCast
 
class  iNTupleSvc
 
class  iProperty
 
class  iService
 
class  iToolSvc
 
class  PropertyEntry
 
class  PyAlgorithm
 

Functions

def toArray (typ)
 
def deprecation (message)
 
def loaddict (dict)
 
def getClass (name, libs=[])
 
def _getFIDandEvents (pfn)
 
def getComponentProperties (name)
 
def _copyFactoriesFromList (factories)
 

Variables

list __all__
 
 gbl = cppyy.gbl
 
 Gaudi = gbl.Gaudi
 
 _gaudi = None
 
 Helper = gbl.GaudiPython.Helper
 
 StringProperty = gbl.Gaudi.Property('std::string')
 
 StringPropertyRef = gbl.Gaudi.Property('std::string&')
 
 GaudiHandleProperty = gbl.GaudiHandleProperty
 
 GaudiHandleArrayProperty = gbl.GaudiHandleArrayProperty
 
 DataObject = gbl.DataObject
 
 SUCCESS = gbl.StatusCode(gbl.StatusCode.SUCCESS, True)
 
 FAILURE = gbl.StatusCode(gbl.StatusCode.FAILURE, True)
 
 ROOT = cppyy.libPyROOT
 
 makeNullPointer = cppyy.libPyROOT.MakeNullPointer
 
 setOwnership = cppyy.libPyROOT.SetOwnership
 
 _CallbackStreamBufBase = gbl.GaudiPython.CallbackStreamBuf
 
 _PyAlgorithm = gbl.GaudiPython.PyAlgorithm
 

Function Documentation

def GaudiPython.Bindings._copyFactoriesFromList (   factories)
private

Definition at line 1409 of file Bindings.py.

1409 def _copyFactoriesFromList(factories):
1410  result = []
1411  for i in range(factories.size()):
1412  factory = factories.front()
1413  result.append(factory)
1414  factories.pop_front()
1415  for factory in result:
1416  factories.push_back(factory)
1417  return result
1418 
1419 
1420 # ----CallbackStreamBuf--------------------------------------------------------
1421 # Used for redirecting C++ messages to python
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
def _copyFactoriesFromList(factories)
Definition: Bindings.py:1409
def GaudiPython.Bindings._getFIDandEvents (   pfn)
private

Definition at line 1343 of file Bindings.py.

1344  tfile = gbl.TFile.Open(pfn)
1345  if not tfile:
1346  raise 'Cannot open ROOT file ', pfn
1347  tree = tfile.Get('##Params')
1348  tree.GetEvent(0)
1349  text = tree.db_string
1350  if 'NAME=FID' in text:
1351  fid = text[text.rfind('VALUE=') + 6:-1]
1352  nevt = tfile.Get('_Event').GetEntries()
1353  tfile.Close()
1354  return fid, nevt
1355 
1356 # -----------------------------------------------------------------------------
1357 
1358 
def _getFIDandEvents(pfn)
Definition: Bindings.py:1343
def GaudiPython.Bindings.deprecation (   message)

Definition at line 87 of file Bindings.py.

87 def deprecation(message):
88  warnings.warn('GaudiPython: ' + message, DeprecationWarning, stacklevel=3)
89 
90 # ----InterfaceCast class -----------------------------------------------------
91 
92 
def deprecation(message)
Definition: Bindings.py:87
def GaudiPython.Bindings.getClass (   name,
  libs = [] 
)
Function to retrieve a certain C++ class by name and to load dictionary if requested

Usage:

from gaudimodule import getClass
# one knows that class is already loaded
AppMgr     = getClass( 'ApplicationMgr'           )
# one knows where to look for class, if not loaded yet
MCParticle = getClass( 'MCParticle' , 'EventDict' )
# one knows where to look for class, if not loaded yet
Vertex     = getClass( 'Vertex' , ['EventDict', 'PhysEventDict'] )

Definition at line 143 of file Bindings.py.

143 def getClass(name, libs=[]):
144  """
145  Function to retrieve a certain C++ class by name and to load dictionary if requested
146 
147  Usage:
148 
149  from gaudimodule import getClass
150  # one knows that class is already loaded
151  AppMgr = getClass( 'ApplicationMgr' )
152  # one knows where to look for class, if not loaded yet
153  MCParticle = getClass( 'MCParticle' , 'EventDict' )
154  # one knows where to look for class, if not loaded yet
155  Vertex = getClass( 'Vertex' , ['EventDict', 'PhysEventDict'] )
156  """
157  # see if class is already loaded
158  if hasattr(gbl, name):
159  return getattr(gbl, name)
160  # try to load dictionaries and look for the required class
161  if type(libs) is not list:
162  libs = [libs]
163  for lib in libs:
164  loaddict(lib)
165  if hasattr(gbl, name):
166  return getattr(gbl, name)
167  # return None ( or raise exception? I do not know... )
168  return None
169 
170 # ----PropertyEntry class------------------------------------------------------
171 
172 
def getClass(name, libs=[])
Definition: Bindings.py:143
def loaddict(dict)
Definition: Bindings.py:130
def GaudiPython.Bindings.getComponentProperties (   name)
Get all the properties of a component as a Python dictionary.
    The component is instantiated using the component library

Definition at line 1359 of file Bindings.py.

1360  """ Get all the properties of a component as a Python dictionary.
1361  The component is instantiated using the component library
1362  """
1363  properties = {}
1364  if name == 'GaudiCoreSvc':
1365  if Helper.loadDynamicLib(name) != 1:
1366  raise ImportError, 'Error loading component library ' + name
1367  factorylist = gbl.FactoryTable.instance().getEntries()
1368  factories = _copyFactoriesFromList(factorylist)
1369  g = AppMgr(outputlevel=7)
1370  else:
1371  g = AppMgr(outputlevel=7)
1372  if Helper.loadDynamicLib(name) != 1:
1373  raise ImportError, 'Error loading component library ' + name
1374  factorylist = gbl.FactoryTable.instance().getEntries()
1375  factories = _copyFactoriesFromList(factorylist)
1376  svcloc = gbl.Gaudi.svcLocator()
1377  dummysvc = gbl.Service('DummySvc', svcloc)
1378  for factory in factories:
1379  if InterfaceCast(gbl.IAlgFactory)(factory):
1380  ctype = 'Algorithm'
1381  elif InterfaceCast(gbl.ISvcFactory)(factory):
1382  ctype = 'Service'
1383  elif InterfaceCast(gbl.IToolFactory)(factory):
1384  ctype = 'AlgTool'
1385  elif factory.ident() == 'ApplicationMgr':
1386  ctype = 'ApplicationMgr'
1387  else:
1388  ctype = 'Unknown'
1389  cname = factory.ident().split()[-1]
1390  if ctype in ('Algorithm', 'Service', 'AlgTool', 'ApplicationMgr'):
1391  try:
1392  if ctype == 'AlgTool':
1393  obj = factory.instantiate(dummysvc)
1394  else:
1395  obj = factory.instantiate(svcloc)
1396  except RuntimeError, text:
1397  print 'Error instantiating', cname, ' from ', name
1398  print text
1399  continue
1400  prop = iProperty('dummy', obj)
1401  properties[cname] = [ctype, prop.properties()]
1402  try:
1403  obj.release()
1404  except:
1405  pass
1406  return properties
1407 
1408 
def _copyFactoriesFromList(factories)
Definition: Bindings.py:1409
def getComponentProperties(name)
Definition: Bindings.py:1359
def GaudiPython.Bindings.loaddict (   dict)
Load a LCG dictionary using various mechanisms

Definition at line 130 of file Bindings.py.

130 def loaddict(dict):
131  """ Load a LCG dictionary using various mechanisms"""
132  if Helper.loadDynamicLib(dict) == 1:
133  return
134  else:
135  try:
136  cppyy.loadDict(dict)
137  except:
138  raise ImportError, 'Error loading dictionary library'
139 
140 # ---get a class (by loading modules if needed)--------------------------------
141 
142 
def loaddict(dict)
Definition: Bindings.py:130
def GaudiPython.Bindings.toArray (   typ)

Definition at line 76 of file Bindings.py.

76  def toArray(typ): return getattr(Helper, "toArray")
77 else:
def toArray(typ)
Definition: Bindings.py:76

Variable Documentation

list GaudiPython.Bindings.__all__
private
Initial value:
1 = ['gbl', 'InterfaceCast', 'Interface', 'PropertyEntry',
2  'AppMgr', 'PyAlgorithm', 'CallbackStreamBuf',
3  'iAlgorithm', 'iDataSvc', 'iHistogramSvc', 'iNTupleSvc', 'iService', 'iAlgTool', 'Helper',
4  'SUCCESS', 'FAILURE', 'toArray',
5  'ROOT', 'makeNullPointer', 'setOwnership',
6  'getClass', 'loaddict', 'deprecation']

Definition at line 10 of file Bindings.py.

GaudiPython.Bindings._CallbackStreamBufBase = gbl.GaudiPython.CallbackStreamBuf
private

Definition at line 1422 of file Bindings.py.

GaudiPython.Bindings._gaudi = None
private

Definition at line 46 of file Bindings.py.

GaudiPython.Bindings._PyAlgorithm = gbl.GaudiPython.PyAlgorithm
private

Definition at line 1439 of file Bindings.py.

GaudiPython.Bindings.DataObject = gbl.DataObject

Definition at line 55 of file Bindings.py.

GaudiPython.Bindings.FAILURE = gbl.StatusCode(gbl.StatusCode.FAILURE, True)

Definition at line 57 of file Bindings.py.

GaudiPython.Bindings.Gaudi = gbl.Gaudi

Definition at line 44 of file Bindings.py.

GaudiPython.Bindings.GaudiHandleArrayProperty = gbl.GaudiHandleArrayProperty

Definition at line 54 of file Bindings.py.

GaudiPython.Bindings.GaudiHandleProperty = gbl.GaudiHandleProperty

Definition at line 53 of file Bindings.py.

GaudiPython.Bindings.gbl = cppyy.gbl

Definition at line 43 of file Bindings.py.

GaudiPython.Bindings.Helper = gbl.GaudiPython.Helper

Definition at line 50 of file Bindings.py.

GaudiPython.Bindings.makeNullPointer = cppyy.libPyROOT.MakeNullPointer

Definition at line 83 of file Bindings.py.

GaudiPython.Bindings.ROOT = cppyy.libPyROOT

Definition at line 82 of file Bindings.py.

GaudiPython.Bindings.setOwnership = cppyy.libPyROOT.SetOwnership

Definition at line 84 of file Bindings.py.

GaudiPython.Bindings.StringProperty = gbl.Gaudi.Property('std::string')

Definition at line 51 of file Bindings.py.

GaudiPython.Bindings.StringPropertyRef = gbl.Gaudi.Property('std::string&')

Definition at line 52 of file Bindings.py.

GaudiPython.Bindings.SUCCESS = gbl.StatusCode(gbl.StatusCode.SUCCESS, True)

Definition at line 56 of file Bindings.py.