Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 1459 of file Bindings.py.

1459 def _copyFactoriesFromList(factories):
1460  result = []
1461  for i in range(factories.size()):
1462  factory = factories.front()
1463  result.append(factory)
1464  factories.pop_front()
1465  for factory in result:
1466  factories.push_back(factory)
1467  return result
1468 
1469 
1470 # ----CallbackStreamBuf--------------------------------------------------------
1471 # 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:1459
def GaudiPython.Bindings._getFIDandEvents (   pfn)
private

Definition at line 1392 of file Bindings.py.

1393  tfile = gbl.TFile.Open(pfn)
1394  if not tfile:
1395  raise 'Cannot open ROOT file ', pfn
1396  tree = tfile.Get('##Params')
1397  tree.GetEvent(0)
1398  text = tree.db_string
1399  if 'NAME=FID' in text:
1400  fid = text[text.rfind('VALUE=') + 6:-1]
1401  nevt = tfile.Get('_Event').GetEntries()
1402  tfile.Close()
1403  return fid, nevt
1404 
1405 
1406 # -----------------------------------------------------------------------------
1407 
1408 
def _getFIDandEvents(pfn)
Definition: Bindings.py:1392
def GaudiPython.Bindings.deprecation (   message)

Definition at line 90 of file Bindings.py.

90 def deprecation(message):
91  warnings.warn('GaudiPython: ' + message, DeprecationWarning, stacklevel=3)
92 
93 
94 # ----InterfaceCast class -----------------------------------------------------
95 
96 
def deprecation(message)
Definition: Bindings.py:90
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 152 of file Bindings.py.

152 def getClass(name, libs=[]):
153  """
154  Function to retrieve a certain C++ class by name and to load dictionary if requested
155 
156  Usage:
157 
158  from gaudimodule import getClass
159  # one knows that class is already loaded
160  AppMgr = getClass( 'ApplicationMgr' )
161  # one knows where to look for class, if not loaded yet
162  MCParticle = getClass( 'MCParticle' , 'EventDict' )
163  # one knows where to look for class, if not loaded yet
164  Vertex = getClass( 'Vertex' , ['EventDict', 'PhysEventDict'] )
165  """
166  # see if class is already loaded
167  if hasattr(gbl, name):
168  return getattr(gbl, name)
169  # try to load dictionaries and look for the required class
170  if type(libs) is not list:
171  libs = [libs]
172  for lib in libs:
173  loaddict(lib)
174  if hasattr(gbl, name):
175  return getattr(gbl, name)
176  # return None ( or raise exception? I do not know... )
177  return None
178 
179 
180 # ----PropertyEntry class------------------------------------------------------
181 
182 
def getClass(name, libs=[])
Definition: Bindings.py:152
def loaddict(dict)
Definition: Bindings.py:138
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 1409 of file Bindings.py.

1410  """ Get all the properties of a component as a Python dictionary.
1411  The component is instantiated using the component library
1412  """
1413  properties = {}
1414  if name == 'GaudiCoreSvc':
1415  if Helper.loadDynamicLib(name) != 1:
1416  raise ImportError, 'Error loading component library ' + name
1417  factorylist = gbl.FactoryTable.instance().getEntries()
1418  factories = _copyFactoriesFromList(factorylist)
1419  g = AppMgr(outputlevel=7)
1420  else:
1421  g = AppMgr(outputlevel=7)
1422  if Helper.loadDynamicLib(name) != 1:
1423  raise ImportError, 'Error loading component library ' + name
1424  factorylist = gbl.FactoryTable.instance().getEntries()
1425  factories = _copyFactoriesFromList(factorylist)
1426  svcloc = gbl.Gaudi.svcLocator()
1427  dummysvc = gbl.Service('DummySvc', svcloc)
1428  for factory in factories:
1429  if InterfaceCast(gbl.IAlgFactory)(factory):
1430  ctype = 'Algorithm'
1431  elif InterfaceCast(gbl.ISvcFactory)(factory):
1432  ctype = 'Service'
1433  elif InterfaceCast(gbl.IToolFactory)(factory):
1434  ctype = 'AlgTool'
1435  elif factory.ident() == 'ApplicationMgr':
1436  ctype = 'ApplicationMgr'
1437  else:
1438  ctype = 'Unknown'
1439  cname = factory.ident().split()[-1]
1440  if ctype in ('Algorithm', 'Service', 'AlgTool', 'ApplicationMgr'):
1441  try:
1442  if ctype == 'AlgTool':
1443  obj = factory.instantiate(dummysvc)
1444  else:
1445  obj = factory.instantiate(svcloc)
1446  except RuntimeError, text:
1447  print 'Error instantiating', cname, ' from ', name
1448  print text
1449  continue
1450  prop = iProperty('dummy', obj)
1451  properties[cname] = [ctype, prop.properties()]
1452  try:
1453  obj.release()
1454  except:
1455  pass
1456  return properties
1457 
1458 
def _copyFactoriesFromList(factories)
Definition: Bindings.py:1459
def getComponentProperties(name)
Definition: Bindings.py:1409
def GaudiPython.Bindings.loaddict (   dict)
Load a LCG dictionary using various mechanisms

Definition at line 138 of file Bindings.py.

138 def loaddict(dict):
139  """ Load a LCG dictionary using various mechanisms"""
140  if Helper.loadDynamicLib(dict) == 1:
141  return
142  else:
143  try:
144  cppyy.loadDict(dict)
145  except:
146  raise ImportError, 'Error loading dictionary library'
147 
148 
149 # ---get a class (by loading modules if needed)--------------------------------
150 
151 
def loaddict(dict)
Definition: Bindings.py:138
def GaudiPython.Bindings.toArray (   typ)

Definition at line 76 of file Bindings.py.

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

Variable Documentation

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

Definition at line 9 of file Bindings.py.

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

Definition at line 1472 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 1489 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 86 of file Bindings.py.

GaudiPython.Bindings.ROOT = cppyy.libPyROOT

Definition at line 85 of file Bindings.py.

GaudiPython.Bindings.setOwnership = cppyy.libPyROOT.SetOwnership

Definition at line 87 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.