All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 deprecation
 
def loaddict
 
def getClass
 
def _getFIDandEvents
 
def getComponentProperties
 
def _copyFactoriesFromList
 

Variables

list __all__
 
 gbl = cppyy.gbl
 
 Gaudi = gbl.Gaudi
 
 _gaudi = None
 
 Helper = gbl.GaudiPython.Helper
 
tuple StringProperty = gbl.SimpleProperty('string','BoundedVerifier<string>')
 
tuple StringPropertyRef = gbl.SimplePropertyRef('string','NullVerifier<string>')
 
 GaudiHandleProperty = gbl.GaudiHandleProperty
 
 GaudiHandleArrayProperty = gbl.GaudiHandleArrayProperty
 
 DataObject = gbl.DataObject
 
tuple SUCCESS = gbl.StatusCode( gbl.StatusCode.SUCCESS, True )
 
tuple FAILURE = gbl.StatusCode( gbl.StatusCode.FAILURE, True )
 
tuple toArray = lambdatyp:getattr(Helper,"toArray")
 
 ROOT = cppyy.libPyROOT
 
 makeNullPointer = cppyy.libPyROOT.MakeNullPointer
 
 makeClass = cppyy.libPyROOT.MakeRootClass
 
 setOwnership = cppyy.libPyROOT.SetOwnership
 
 _CallbackStreamBufBase = gbl.GaudiPython.CallbackStreamBuf
 
 _PyAlgorithm = gbl.GaudiPython.PyAlgorithm
 

Function Documentation

def GaudiPython.Bindings._copyFactoriesFromList (   factories)
private

Definition at line 1063 of file Bindings.py.

1064 def _copyFactoriesFromList(factories) :
1065  result = []
1066  for i in range(factories.size()) :
1067  factory = factories.front()
1068  result.append(factory)
1069  factories.pop_front()
1070  for factory in result :
1071  factories.push_back(factory)
1072  return result
1073 
1074 #----CallbackStreamBuf----------------------------------------------------------------
# Used for redirecting C++ messages to python
NamedRange_< CONTAINER > range(const CONTAINER &cnt, const std::string &name)
simple function to create the named range form arbitrary container
Definition: NamedRange.h:133
def GaudiPython.Bindings._getFIDandEvents (   pfn)
private

Definition at line 1008 of file Bindings.py.

1009 def _getFIDandEvents( pfn ):
1010  tfile = gbl.TFile.Open(pfn)
1011  if not tfile : raise 'Cannot open ROOT file ', pfn
1012  tree = tfile.Get('##Params')
1013  tree.GetEvent(0)
1014  text = tree.db_string
1015  if 'NAME=FID' in text :
1016  fid = text[text.rfind('VALUE=')+6:-1]
1017  nevt = tfile.Get('_Event').GetEntries()
1018  tfile.Close()
1019  return fid, nevt
1020 
#--------------------------------------------------------------------------------------
def GaudiPython.Bindings.deprecation (   message)

Definition at line 74 of file Bindings.py.

74 
75 def deprecation(message):
76  warnings.warn('GaudiPython: '+ message, DeprecationWarning, stacklevel=3)
77 
#----InterfaceCast class ----------------------------------------------------------------
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 118 of file Bindings.py.

119 def getClass( name , libs = [] ) :
120  """
121  Function to retrieve a certain C++ class by name and to load dictionary if requested
122 
123  Usage:
124 
125  from gaudimodule import getClass
126  # one knows that class is already loaded
127  AppMgr = getClass( 'ApplicationMgr' )
128  # one knows where to look for class, if not loaded yet
129  MCParticle = getClass( 'MCParticle' , 'EventDict' )
130  # one knows where to look for class, if not loaded yet
131  Vertex = getClass( 'Vertex' , ['EventDict', 'PhysEventDict'] )
132  """
133  # see if class is already loaded
134  if hasattr( gbl , name ) : return getattr( gbl , name )
135  # try to load dictionaries and look for the required class
136  if type(libs) is not list : libs = [libs]
137  for lib in libs :
138  loaddict( lib )
139  if hasattr( gbl , name ) : return getattr( gbl , name )
140  # return None ( or raise exception? I do not know... )
141  return None
142 
#----PropertyEntry class---------------------------------------------------------------------
string type
Definition: gaudirun.py:126
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 1021 of file Bindings.py.

1022 def getComponentProperties( name ):
1023  """ Get all the properties of a component as a Python dictionary.
1024  The component is instantiated using the component library
1025  """
1026  properties = {}
1027  if name == 'GaudiCoreSvc' :
1028  if Helper.loadDynamicLib(name) != 1 :
1029  raise ImportError, 'Error loading component library '+ name
1030  factorylist = gbl.FactoryTable.instance().getEntries()
1031  factories = _copyFactoriesFromList(factorylist)
1032  g = AppMgr(outputlevel=7)
1033  else :
1034  g = AppMgr(outputlevel=7)
1035  if Helper.loadDynamicLib(name) != 1 :
1036  raise ImportError, 'Error loading component library '+ name
1037  factorylist = gbl.FactoryTable.instance().getEntries()
1038  factories = _copyFactoriesFromList(factorylist)
1039  svcloc = gbl.Gaudi.svcLocator()
1040  dummysvc = gbl.Service('DummySvc',svcloc)
1041  for factory in factories :
1042  if InterfaceCast(gbl.IAlgFactory)(factory) : ctype = 'Algorithm'
1043  elif InterfaceCast(gbl.ISvcFactory)(factory) : ctype = 'Service'
1044  elif InterfaceCast(gbl.IToolFactory)(factory) : ctype = 'AlgTool'
1045  elif factory.ident() == 'ApplicationMgr' : ctype = 'ApplicationMgr'
1046  else : ctype = 'Unknown'
1047  cname = factory.ident().split()[-1]
1048  if ctype in ('Algorithm','Service', 'AlgTool', 'ApplicationMgr') :
1049  try :
1050  if ctype == 'AlgTool' :
1051  obj = factory.instantiate(dummysvc)
1052  else :
1053  obj = factory.instantiate(svcloc)
1054  except RuntimeError, text :
1055  print 'Error instantiating', cname, ' from ', name
1056  print text
1057  continue
1058  prop = iProperty('dummy', obj)
1059  properties[cname] = [ctype, prop.properties()]
1060  try: obj.release()
1061  except: pass
1062  return properties
def GaudiPython.Bindings.loaddict (   dict)
Load a LCG dictionary using various mechanisms

Definition at line 108 of file Bindings.py.

109 def loaddict(dict) :
110  """ Load a LCG dictionary using various mechanisms"""
111  if Helper.loadDynamicLib(dict) == 1 : return
112  else :
113  try:
114  cppyy.loadDict(dict)
115  except:
116  raise ImportError, 'Error loading dictionary library'
117 
#---get a class (by loading modules if needed)--------------------------------------------

Variable Documentation

list GaudiPython.Bindings.__all__
Initial value:
1 = [ 'gbl','InterfaceCast', 'Interface', 'PropertyEntry',
2  'AppMgr', 'PyAlgorithm', 'CallbackStreamBuf',
3  'iAlgorithm', 'iDataSvc', 'iHistogramSvc','iNTupleSvc','iService', 'iAlgTool', 'Helper',
4  'SUCCESS', 'FAILURE', 'toArray',
5  'ROOT', 'makeNullPointer', 'makeClass', 'setOwnership',
6  'getClass', 'loaddict', 'deprecation' ]

Definition at line 10 of file Bindings.py.

GaudiPython.Bindings._CallbackStreamBufBase = gbl.GaudiPython.CallbackStreamBuf

Definition at line 1075 of file Bindings.py.

GaudiPython.Bindings._gaudi = None

Definition at line 42 of file Bindings.py.

GaudiPython.Bindings._PyAlgorithm = gbl.GaudiPython.PyAlgorithm

Definition at line 1087 of file Bindings.py.

GaudiPython.Bindings.DataObject = gbl.DataObject

Definition at line 50 of file Bindings.py.

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

Definition at line 52 of file Bindings.py.

GaudiPython.Bindings.Gaudi = gbl.Gaudi

Definition at line 40 of file Bindings.py.

GaudiPython.Bindings.GaudiHandleArrayProperty = gbl.GaudiHandleArrayProperty

Definition at line 49 of file Bindings.py.

GaudiPython.Bindings.GaudiHandleProperty = gbl.GaudiHandleProperty

Definition at line 48 of file Bindings.py.

GaudiPython.Bindings.gbl = cppyy.gbl

Definition at line 39 of file Bindings.py.

GaudiPython.Bindings.Helper = gbl.GaudiPython.Helper

Definition at line 45 of file Bindings.py.

GaudiPython.Bindings.makeClass = cppyy.libPyROOT.MakeRootClass

Definition at line 71 of file Bindings.py.

GaudiPython.Bindings.makeNullPointer = cppyy.libPyROOT.MakeNullPointer

Definition at line 70 of file Bindings.py.

GaudiPython.Bindings.ROOT = cppyy.libPyROOT

Definition at line 69 of file Bindings.py.

GaudiPython.Bindings.setOwnership = cppyy.libPyROOT.SetOwnership

Definition at line 72 of file Bindings.py.

tuple GaudiPython.Bindings.StringProperty = gbl.SimpleProperty('string','BoundedVerifier<string>')

Definition at line 46 of file Bindings.py.

tuple GaudiPython.Bindings.StringPropertyRef = gbl.SimplePropertyRef('string','NullVerifier<string>')

Definition at line 47 of file Bindings.py.

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

Definition at line 51 of file Bindings.py.

tuple GaudiPython.Bindings.toArray = lambdatyp:getattr(Helper,"toArray")

Definition at line 63 of file Bindings.py.