| The Gaudi Framework v32r1 (f65d50dc)

Classes | Functions | Variables
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

## ◆ _copyFactoriesFromList()

def GaudiPython.Bindings._copyFactoriesFromList | ( |  | factories | ) |
| private

Definition at line 1460 of file Bindings.py.

1460 def _copyFactoriesFromList(factories):
1461 result = []
1462 for i in range(factories.size()):
1463 factory = factories.front()
1464 result.append(factory)
1465 factories.pop_front()
1466 for factory in result:
1467 factories.push_back(factory)
1468 return result
1469
1470
1471 # ----CallbackStreamBuf--------------------------------------------------------
1472 # Used for redirecting C++ messages to python
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:71
GaudiPython.Bindings._copyFactoriesFromList
def _copyFactoriesFromList(factories)
Definition: Bindings.py:1460

## ◆ _getFIDandEvents()

def GaudiPython.Bindings._getFIDandEvents | ( |  | pfn | ) |
| private

Definition at line 1393 of file Bindings.py.

1393 def _getFIDandEvents(pfn):
1394 tfile = gbl.TFile.Open(pfn)
1395 if not tfile:
1396 raise IOError('Cannot open ROOT file {0}'.format(pfn))
1397 tree = tfile.Get('##Params')
1398 tree.GetEvent(0)
1399 text = tree.db_string
1400 if 'NAME=FID' in text:
1401 fid = text[text.rfind('VALUE=') + 6:-1]
1402 nevt = tfile.Get('_Event').GetEntries()
1403 tfile.Close()
1404 return fid, nevt
1405
1406
1407 # -----------------------------------------------------------------------------
1408
1409
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
GaudiPython.Bindings._getFIDandEvents
def _getFIDandEvents(pfn)
Definition: Bindings.py:1393

## ◆ deprecation()

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
GaudiPython.Bindings.deprecation
def deprecation(message)
Definition: Bindings.py:90

## ◆ 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 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
GaudiPython.Bindings.getClass
def getClass(name, libs=[])
Definition: Bindings.py:152
gaudirun.type
type
Definition: gaudirun.py:142
GaudiPython.Bindings.loaddict
def loaddict(dict)
Definition: Bindings.py:138

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

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

## ◆ loaddict()

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
GaudiPython.Bindings.loaddict
def loaddict(dict)
Definition: Bindings.py:138

## ◆ toArray()

def GaudiPython.Bindings.toArray | ( |  | typ | ) |

Definition at line 76 of file Bindings.py.

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

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

## ◆ _CallbackStreamBufBase

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

Definition at line 1473 of file Bindings.py.

## ◆ _gaudi

GaudiPython.Bindings._gaudi = None
| private

Definition at line 46 of file Bindings.py.

## ◆ _PyAlgorithm

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

Definition at line 1490 of file Bindings.py.

## ◆ DataObject

GaudiPython.Bindings.DataObject = gbl.DataObject

Definition at line 55 of file Bindings.py.

## ◆ FAILURE

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

Definition at line 57 of file Bindings.py.

## ◆ Gaudi

GaudiPython.Bindings.Gaudi = gbl.Gaudi

Definition at line 44 of file Bindings.py.

## ◆ GaudiHandleArrayProperty

GaudiPython.Bindings.GaudiHandleArrayProperty = gbl.GaudiHandleArrayProperty

Definition at line 54 of file Bindings.py.

## ◆ GaudiHandleProperty

GaudiPython.Bindings.GaudiHandleProperty = gbl.GaudiHandleProperty

Definition at line 53 of file Bindings.py.

## ◆ gbl

GaudiPython.Bindings.gbl = cppyy.gbl

Definition at line 43 of file Bindings.py.

## ◆ Helper

GaudiPython.Bindings.Helper = gbl.GaudiPython.Helper

Definition at line 50 of file Bindings.py.

## ◆ makeNullPointer

GaudiPython.Bindings.makeNullPointer = cppyy.libPyROOT.MakeNullPointer

Definition at line 86 of file Bindings.py.

## ◆ ROOT

GaudiPython.Bindings.ROOT = cppyy.libPyROOT

Definition at line 85 of file Bindings.py.

## ◆ setOwnership

GaudiPython.Bindings.setOwnership = cppyy.libPyROOT.SetOwnership

Definition at line 87 of file Bindings.py.

## ◆ StringProperty

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

Definition at line 51 of file Bindings.py.

## ◆ StringPropertyRef

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

Definition at line 52 of file Bindings.py.

## ◆ SUCCESS

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

Definition at line 56 of file Bindings.py.