The Gaudi Framework  v36r13 (995e4364)
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

 __all__
 
 long
 
 gbl
 
 Gaudi
 
 _gaudi
 
 Helper
 
 StringProperty
 
 StringPropertyRef
 
 GaudiHandleProperty
 
 GaudiHandleArrayProperty
 
 DataObject
 
 SUCCESS
 
 FAILURE
 
 nullptr
 
 ROOT
 
 makeNullPointer
 
 setOwnership
 
 _CallbackStreamBufBase
 
 _PyAlgorithm
 

Function Documentation

◆ _copyFactoriesFromList()

def GaudiPython.Bindings._copyFactoriesFromList (   factories)
private

Definition at line 1399 of file Bindings.py.

1399 def _copyFactoriesFromList(factories):
1400  result = []
1401  for i in range(factories.size()):
1402  factory = factories.front()
1403  result.append(factory)
1404  factories.pop_front()
1405  for factory in result:
1406  factories.push_back(factory)
1407  return result
1408 
1409 
1410 # ----CallbackStreamBuf--------------------------------------------------------
1411 # Used for redirecting C++ messages to python

◆ _getFIDandEvents()

def GaudiPython.Bindings._getFIDandEvents (   pfn)
private

Definition at line 1332 of file Bindings.py.

1332 def _getFIDandEvents(pfn):
1333  tfile = gbl.TFile.Open(pfn)
1334  if not tfile:
1335  raise IOError("Cannot open ROOT file {0}".format(pfn))
1336  tree = tfile.Get("##Params")
1337  tree.GetEvent(0)
1338  text = tree.db_string
1339  if "NAME=FID" in text:
1340  fid = text[text.rfind("VALUE=") + 6 : -1]
1341  nevt = tfile.Get("_Event").GetEntries()
1342  tfile.Close()
1343  return fid, nevt
1344 
1345 
1346 # -----------------------------------------------------------------------------
1347 
1348 

◆ deprecation()

def GaudiPython.Bindings.deprecation (   message)

Definition at line 138 of file Bindings.py.

138 def deprecation(message):
139  warnings.warn("GaudiPython: " + message, DeprecationWarning, stacklevel=3)
140 
141 
142 # ----InterfaceCast class -----------------------------------------------------
143 
144 

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

209 def getClass(name, libs=[]):
210  """
211  Function to retrieve a certain C++ class by name and to load dictionary if requested
212 
213  Usage:
214 
215  from gaudimodule import getClass
216  # one knows that class is already loaded
217  AppMgr = getClass( 'ApplicationMgr' )
218  # one knows where to look for class, if not loaded yet
219  MCParticle = getClass( 'MCParticle' , 'EventDict' )
220  # one knows where to look for class, if not loaded yet
221  Vertex = getClass( 'Vertex' , ['EventDict', 'PhysEventDict'] )
222  """
223  # see if class is already loaded
224  if hasattr(gbl, name):
225  return getattr(gbl, name)
226  # try to load dictionaries and look for the required class
227  if type(libs) is not list:
228  libs = [libs]
229  for lib in libs:
230  loaddict(lib)
231  if hasattr(gbl, name):
232  return getattr(gbl, name)
233  # return None ( or raise exception? I do not know... )
234  return None
235 
236 
237 # ----PropertyEntry class------------------------------------------------------
238 
239 

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

1349 def getComponentProperties(name):
1350  """Get all the properties of a component as a Python dictionary.
1351  The component is instantiated using the component library
1352  """
1353  properties = {}
1354  if name == "GaudiCoreSvc":
1355  if Helper.loadDynamicLib(name) != 1:
1356  raise ImportError("Error loading component library " + name)
1357  factorylist = gbl.FactoryTable.instance().getEntries()
1358  factories = _copyFactoriesFromList(factorylist)
1359  _ = AppMgr(outputlevel=7)
1360  else:
1361  _ = AppMgr(outputlevel=7)
1362  if Helper.loadDynamicLib(name) != 1:
1363  raise ImportError("Error loading component library " + name)
1364  factorylist = gbl.FactoryTable.instance().getEntries()
1365  factories = _copyFactoriesFromList(factorylist)
1366  svcloc = gbl.Gaudi.svcLocator()
1367  dummysvc = gbl.Service("DummySvc", svcloc)
1368  for factory in factories:
1369  if InterfaceCast(gbl.IAlgFactory)(factory):
1370  ctype = "Algorithm"
1371  elif InterfaceCast(gbl.ISvcFactory)(factory):
1372  ctype = "Service"
1373  elif InterfaceCast(gbl.IToolFactory)(factory):
1374  ctype = "AlgTool"
1375  elif factory.ident() == "ApplicationMgr":
1376  ctype = "ApplicationMgr"
1377  else:
1378  ctype = "Unknown"
1379  cname = factory.ident().split()[-1]
1380  if ctype in ("Algorithm", "Service", "AlgTool", "ApplicationMgr"):
1381  try:
1382  if ctype == "AlgTool":
1383  obj = factory.instantiate(dummysvc)
1384  else:
1385  obj = factory.instantiate(svcloc)
1386  except RuntimeError as text:
1387  print("Error instantiating", cname, " from ", name)
1388  print(text)
1389  continue
1390  prop = iProperty("dummy", obj)
1391  properties[cname] = [ctype, prop.properties()]
1392  try:
1393  obj.release()
1394  except Exception:
1395  pass
1396  return properties
1397 
1398 

◆ loaddict()

def GaudiPython.Bindings.loaddict (   dict)
Load an LCG dictionary

Definition at line 196 of file Bindings.py.

196 def loaddict(dict):
197  """Load an LCG dictionary"""
198  loadlib_return_code = Helper.loadDynamicLib(dict)
199  if loadlib_return_code == 1:
200  return
201  raise RuntimeError(
202  f"Failed to load dictionary library {dict} (return code {loadlib_return_code})"
203  )
204 
205 
206 # ---get a class (by loading modules if needed)--------------------------------
207 
208 

◆ toArray()

def GaudiPython.Bindings.toArray (   typ)

Definition at line 119 of file Bindings.py.

119  def toArray(typ):
120  return getattr(Helper, "toArray")
121 
122 else:

Variable Documentation

◆ __all__

GaudiPython.Bindings.__all__
private

Definition at line 20 of file Bindings.py.

◆ _CallbackStreamBufBase

GaudiPython.Bindings._CallbackStreamBufBase
private

Definition at line 1412 of file Bindings.py.

◆ _gaudi

GaudiPython.Bindings._gaudi
private

Definition at line 78 of file Bindings.py.

◆ _PyAlgorithm

GaudiPython.Bindings._PyAlgorithm
private

Definition at line 1429 of file Bindings.py.

◆ DataObject

GaudiPython.Bindings.DataObject

Definition at line 87 of file Bindings.py.

◆ FAILURE

GaudiPython.Bindings.FAILURE

Definition at line 89 of file Bindings.py.

◆ Gaudi

GaudiPython.Bindings.Gaudi

Definition at line 76 of file Bindings.py.

◆ GaudiHandleArrayProperty

GaudiPython.Bindings.GaudiHandleArrayProperty

Definition at line 86 of file Bindings.py.

◆ GaudiHandleProperty

GaudiPython.Bindings.GaudiHandleProperty

Definition at line 85 of file Bindings.py.

◆ gbl

GaudiPython.Bindings.gbl

Definition at line 75 of file Bindings.py.

◆ Helper

GaudiPython.Bindings.Helper

Definition at line 82 of file Bindings.py.

◆ long

GaudiPython.Bindings.long

Definition at line 60 of file Bindings.py.

◆ makeNullPointer

GaudiPython.Bindings.makeNullPointer

Definition at line 134 of file Bindings.py.

◆ nullptr

GaudiPython.Bindings.nullptr

Definition at line 92 of file Bindings.py.

◆ ROOT

GaudiPython.Bindings.ROOT

Definition at line 131 of file Bindings.py.

◆ setOwnership

GaudiPython.Bindings.setOwnership

Definition at line 135 of file Bindings.py.

◆ StringProperty

GaudiPython.Bindings.StringProperty

Definition at line 83 of file Bindings.py.

◆ StringPropertyRef

GaudiPython.Bindings.StringPropertyRef

Definition at line 84 of file Bindings.py.

◆ SUCCESS

GaudiPython.Bindings.SUCCESS

Definition at line 88 of file Bindings.py.

GaudiPython.Bindings._copyFactoriesFromList
def _copyFactoriesFromList(factories)
Definition: Bindings.py:1399
GaudiPython.Bindings.loaddict
def loaddict(dict)
Definition: Bindings.py:196
GaudiPython.Bindings.getComponentProperties
def getComponentProperties(name)
Definition: Bindings.py:1349
GaudiPython.Bindings.toArray
def toArray(typ)
Definition: Bindings.py:119
GaudiPython.Bindings.deprecation
def deprecation(message)
Definition: Bindings.py:138
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:1332
gaudirun.type
type
Definition: gaudirun.py:162
GaudiPython.Bindings.getClass
def getClass(name, libs=[])
Definition: Bindings.py:209
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:102