The Gaudi Framework  v36r10 (fc05264c)
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)
 
 FAILURE = gbl.StatusCode(gbl.StatusCode.FAILURE)
 
 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 1402 of file Bindings.py.

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

◆ _getFIDandEvents()

def GaudiPython.Bindings._getFIDandEvents (   pfn)
private

Definition at line 1335 of file Bindings.py.

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

◆ deprecation()

def GaudiPython.Bindings.deprecation (   message)

Definition at line 139 of file Bindings.py.

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

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

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

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

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

◆ loaddict()

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

Definition at line 197 of file Bindings.py.

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

◆ toArray()

def GaudiPython.Bindings.toArray (   typ)

Definition at line 120 of file Bindings.py.

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

Variable Documentation

◆ __all__

list GaudiPython.Bindings.__all__
private
Initial value:
1 = [
2  "gbl",
3  "InterfaceCast",
4  "Interface",
5  "PropertyEntry",
6  "AppMgr",
7  "PyAlgorithm",
8  "CallbackStreamBuf",
9  "iAlgorithm",
10  "iDataSvc",
11  "iHistogramSvc",
12  "iNTupleSvc",
13  "iService",
14  "iAlgTool",
15  "Helper",
16  "SUCCESS",
17  "FAILURE",
18  "toArray",
19  "ROOT",
20  "makeNullPointer",
21  "setOwnership",
22  "getClass",
23  "loaddict",
24  "deprecation",
25 ]

Definition at line 20 of file Bindings.py.

◆ _CallbackStreamBufBase

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

Definition at line 1415 of file Bindings.py.

◆ _gaudi

GaudiPython.Bindings._gaudi = None
private

Definition at line 79 of file Bindings.py.

◆ _PyAlgorithm

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

Definition at line 1432 of file Bindings.py.

◆ DataObject

GaudiPython.Bindings.DataObject = gbl.DataObject

Definition at line 88 of file Bindings.py.

◆ FAILURE

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

Definition at line 90 of file Bindings.py.

◆ Gaudi

GaudiPython.Bindings.Gaudi = gbl.Gaudi

Definition at line 77 of file Bindings.py.

◆ GaudiHandleArrayProperty

GaudiPython.Bindings.GaudiHandleArrayProperty = gbl.GaudiHandleArrayProperty

Definition at line 87 of file Bindings.py.

◆ GaudiHandleProperty

GaudiPython.Bindings.GaudiHandleProperty = gbl.GaudiHandleProperty

Definition at line 86 of file Bindings.py.

◆ gbl

GaudiPython.Bindings.gbl = cppyy.gbl

Definition at line 76 of file Bindings.py.

◆ Helper

GaudiPython.Bindings.Helper = gbl.GaudiPython.Helper

Definition at line 83 of file Bindings.py.

◆ long

GaudiPython.Bindings.long = int

Definition at line 61 of file Bindings.py.

◆ makeNullPointer

GaudiPython.Bindings.makeNullPointer = ROOT.MakeNullPointer

Definition at line 135 of file Bindings.py.

◆ nullptr

GaudiPython.Bindings.nullptr = cppyy.nullptr

Definition at line 93 of file Bindings.py.

◆ ROOT

GaudiPython.Bindings.ROOT = cppyy.libPyROOT

Definition at line 132 of file Bindings.py.

◆ setOwnership

GaudiPython.Bindings.setOwnership = ROOT.SetOwnership

Definition at line 136 of file Bindings.py.

◆ StringProperty

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

Definition at line 84 of file Bindings.py.

◆ StringPropertyRef

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

Definition at line 85 of file Bindings.py.

◆ SUCCESS

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

Definition at line 89 of file Bindings.py.

GaudiPython.Bindings._copyFactoriesFromList
def _copyFactoriesFromList(factories)
Definition: Bindings.py:1402
GaudiPython.Bindings.loaddict
def loaddict(dict)
Definition: Bindings.py:197
GaudiPython.Bindings.getComponentProperties
def getComponentProperties(name)
Definition: Bindings.py:1352
GaudiPython.Bindings.toArray
def toArray(typ)
Definition: Bindings.py:120
GaudiPython.Bindings.deprecation
def deprecation(message)
Definition: Bindings.py:139
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:1335
gaudirun.type
type
Definition: gaudirun.py:160
GaudiPython.Bindings.getClass
def getClass(name, libs=[])
Definition: Bindings.py:210
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:102