The Gaudi Framework  v36r7 (7f57a304)
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 1403 of file Bindings.py.

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

◆ _getFIDandEvents()

def GaudiPython.Bindings._getFIDandEvents (   pfn)
private

Definition at line 1336 of file Bindings.py.

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

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

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

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

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

◆ loaddict()

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

Definition at line 197 of file Bindings.py.

197 def loaddict(dict):
198  """Load a LCG dictionary using various mechanisms"""
199  if Helper.loadDynamicLib(dict) == 1:
200  return
201  else:
202  try:
203  cppyy.loadDict(dict)
204  except:
205  raise ImportError("Error loading dictionary library")
206 
207 
208 # ---get a class (by loading modules if needed)--------------------------------
209 
210 

◆ 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 1416 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 1433 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:1403
GaudiPython.Bindings.loaddict
def loaddict(dict)
Definition: Bindings.py:197
GaudiPython.Bindings.getComponentProperties
def getComponentProperties(name)
Definition: Bindings.py:1353
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:1336
gaudirun.type
type
Definition: gaudirun.py:160
GaudiPython.Bindings.getClass
def getClass(name, libs=[])
Definition: Bindings.py:211
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:102