The Gaudi Framework  v36r1 (3e2fb5a8)
GaudiPython.Bindings Namespace Reference

Classes

class  AppMgr
 
class  CallbackStreamBuf
 
class  iAlgorithm
 
class  iAlgTool
 
class  iDataSvc
 
class  iEventSelector
 
class  iHistogramSvc
 
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__
 
 long = int
 
 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)
 
 nullptr = cppyy.nullptr
 
 ROOT = cppyy.libPyROOT
 
 makeNullPointer = ROOT.MakeNullPointer
 
 setOwnership = ROOT.SetOwnership
 
 _CallbackStreamBufBase = gbl.GaudiPython.CallbackStreamBuf
 
 _PyAlgorithm = gbl.GaudiPython.PyAlgorithm
 

Function Documentation

◆ _copyFactoriesFromList()

def GaudiPython.Bindings._copyFactoriesFromList (   factories)
private

Definition at line 1358 of file Bindings.py.

1358 def _copyFactoriesFromList(factories):
1359  result = []
1360  for i in range(factories.size()):
1361  factory = factories.front()
1362  result.append(factory)
1363  factories.pop_front()
1364  for factory in result:
1365  factories.push_back(factory)
1366  return result
1367 
1368 
1369 # ----CallbackStreamBuf--------------------------------------------------------
1370 # Used for redirecting C++ messages to python

◆ _getFIDandEvents()

def GaudiPython.Bindings._getFIDandEvents (   pfn)
private

Definition at line 1291 of file Bindings.py.

1291 def _getFIDandEvents(pfn):
1292  tfile = gbl.TFile.Open(pfn)
1293  if not tfile:
1294  raise IOError('Cannot open ROOT file {0}'.format(pfn))
1295  tree = tfile.Get('##Params')
1296  tree.GetEvent(0)
1297  text = tree.db_string
1298  if 'NAME=FID' in text:
1299  fid = text[text.rfind('VALUE=') + 6:-1]
1300  nevt = tfile.Get('_Event').GetEntries()
1301  tfile.Close()
1302  return fid, nevt
1303 
1304 
1305 # -----------------------------------------------------------------------------
1306 
1307 

◆ deprecation()

def GaudiPython.Bindings.deprecation (   message)

Definition at line 117 of file Bindings.py.

117 def deprecation(message):
118  warnings.warn('GaudiPython: ' + message, DeprecationWarning, stacklevel=3)
119 
120 
121 # ----InterfaceCast class -----------------------------------------------------
122 
123 

◆ getClass()

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 182 of file Bindings.py.

182 def getClass(name, libs=[]):
183  """
184  Function to retrieve a certain C++ class by name and to load dictionary if requested
185 
186  Usage:
187 
188  from gaudimodule import getClass
189  # one knows that class is already loaded
190  AppMgr = getClass( 'ApplicationMgr' )
191  # one knows where to look for class, if not loaded yet
192  MCParticle = getClass( 'MCParticle' , 'EventDict' )
193  # one knows where to look for class, if not loaded yet
194  Vertex = getClass( 'Vertex' , ['EventDict', 'PhysEventDict'] )
195  """
196  # see if class is already loaded
197  if hasattr(gbl, name):
198  return getattr(gbl, name)
199  # try to load dictionaries and look for the required class
200  if type(libs) is not list:
201  libs = [libs]
202  for lib in libs:
203  loaddict(lib)
204  if hasattr(gbl, name):
205  return getattr(gbl, name)
206  # return None ( or raise exception? I do not know... )
207  return None
208 
209 
210 # ----PropertyEntry class------------------------------------------------------
211 
212 

◆ getComponentProperties()

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 1308 of file Bindings.py.

1308 def getComponentProperties(name):
1309  """ Get all the properties of a component as a Python dictionary.
1310  The component is instantiated using the component library
1311  """
1312  properties = {}
1313  if name == 'GaudiCoreSvc':
1314  if Helper.loadDynamicLib(name) != 1:
1315  raise ImportError('Error loading component library ' + name)
1316  factorylist = gbl.FactoryTable.instance().getEntries()
1317  factories = _copyFactoriesFromList(factorylist)
1318  g = AppMgr(outputlevel=7)
1319  else:
1320  g = AppMgr(outputlevel=7)
1321  if Helper.loadDynamicLib(name) != 1:
1322  raise ImportError('Error loading component library ' + name)
1323  factorylist = gbl.FactoryTable.instance().getEntries()
1324  factories = _copyFactoriesFromList(factorylist)
1325  svcloc = gbl.Gaudi.svcLocator()
1326  dummysvc = gbl.Service('DummySvc', svcloc)
1327  for factory in factories:
1328  if InterfaceCast(gbl.IAlgFactory)(factory):
1329  ctype = 'Algorithm'
1330  elif InterfaceCast(gbl.ISvcFactory)(factory):
1331  ctype = 'Service'
1332  elif InterfaceCast(gbl.IToolFactory)(factory):
1333  ctype = 'AlgTool'
1334  elif factory.ident() == 'ApplicationMgr':
1335  ctype = 'ApplicationMgr'
1336  else:
1337  ctype = 'Unknown'
1338  cname = factory.ident().split()[-1]
1339  if ctype in ('Algorithm', 'Service', 'AlgTool', 'ApplicationMgr'):
1340  try:
1341  if ctype == 'AlgTool':
1342  obj = factory.instantiate(dummysvc)
1343  else:
1344  obj = factory.instantiate(svcloc)
1345  except RuntimeError as text:
1346  print('Error instantiating', cname, ' from ', name)
1347  print(text)
1348  continue
1349  prop = iProperty('dummy', obj)
1350  properties[cname] = [ctype, prop.properties()]
1351  try:
1352  obj.release()
1353  except:
1354  pass
1355  return properties
1356 
1357 

◆ loaddict()

def GaudiPython.Bindings.loaddict (   dict)
Load a LCG dictionary using various mechanisms

Definition at line 168 of file Bindings.py.

168 def loaddict(dict):
169  """ Load a LCG dictionary using various mechanisms"""
170  if Helper.loadDynamicLib(dict) == 1:
171  return
172  else:
173  try:
174  cppyy.loadDict(dict)
175  except:
176  raise ImportError('Error loading dictionary library')
177 
178 
179 # ---get a class (by loading modules if needed)--------------------------------
180 
181 

◆ toArray()

def GaudiPython.Bindings.toArray (   typ)

Definition at line 99 of file Bindings.py.

99  def toArray(typ):
100  return getattr(Helper, "toArray")
101 else:

Variable Documentation

◆ __all__

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 20 of file Bindings.py.

◆ _CallbackStreamBufBase

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

Definition at line 1371 of file Bindings.py.

◆ _gaudi

GaudiPython.Bindings._gaudi = None
private

Definition at line 60 of file Bindings.py.

◆ _PyAlgorithm

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

Definition at line 1388 of file Bindings.py.

◆ DataObject

GaudiPython.Bindings.DataObject = gbl.DataObject

Definition at line 69 of file Bindings.py.

◆ FAILURE

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

Definition at line 71 of file Bindings.py.

◆ Gaudi

GaudiPython.Bindings.Gaudi = gbl.Gaudi

Definition at line 58 of file Bindings.py.

◆ GaudiHandleArrayProperty

GaudiPython.Bindings.GaudiHandleArrayProperty = gbl.GaudiHandleArrayProperty

Definition at line 68 of file Bindings.py.

◆ GaudiHandleProperty

GaudiPython.Bindings.GaudiHandleProperty = gbl.GaudiHandleProperty

Definition at line 67 of file Bindings.py.

◆ gbl

GaudiPython.Bindings.gbl = cppyy.gbl

Definition at line 57 of file Bindings.py.

◆ Helper

GaudiPython.Bindings.Helper = gbl.GaudiPython.Helper

Definition at line 64 of file Bindings.py.

◆ long

GaudiPython.Bindings.long = int

Definition at line 43 of file Bindings.py.

◆ makeNullPointer

GaudiPython.Bindings.makeNullPointer = ROOT.MakeNullPointer

Definition at line 113 of file Bindings.py.

◆ nullptr

GaudiPython.Bindings.nullptr = cppyy.nullptr

Definition at line 74 of file Bindings.py.

◆ ROOT

GaudiPython.Bindings.ROOT = cppyy.libPyROOT

Definition at line 110 of file Bindings.py.

◆ setOwnership

GaudiPython.Bindings.setOwnership = ROOT.SetOwnership

Definition at line 114 of file Bindings.py.

◆ StringProperty

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

Definition at line 65 of file Bindings.py.

◆ StringPropertyRef

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

Definition at line 66 of file Bindings.py.

◆ SUCCESS

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

Definition at line 70 of file Bindings.py.

GaudiPython.Bindings._copyFactoriesFromList
def _copyFactoriesFromList(factories)
Definition: Bindings.py:1358
GaudiPython.Bindings.loaddict
def loaddict(dict)
Definition: Bindings.py:168
GaudiPython.Bindings.getComponentProperties
def getComponentProperties(name)
Definition: Bindings.py:1308
GaudiPython.Bindings.toArray
def toArray(typ)
Definition: Bindings.py:99
GaudiPython.Bindings.deprecation
def deprecation(message)
Definition: Bindings.py:117
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
GaudiPython.Bindings._getFIDandEvents
def _getFIDandEvents(pfn)
Definition: Bindings.py:1291
gaudirun.type
type
Definition: gaudirun.py:154
GaudiPython.Bindings.getClass
def getClass(name, libs=[])
Definition: Bindings.py:182
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:97