The Gaudi Framework  v36r1 (3e2fb5a8)
Bindings.py
Go to the documentation of this file.
1 
13 """ GaudiPython.Bindings module.
14  This module provides the basic bindings of the main Gaudi
15  components to Python. It is itself based on the ROOT cppyy
16  Python extension module.
17 """
18 from __future__ import absolute_import, print_function
19 
20 __all__ = [
21  'gbl', 'InterfaceCast', 'Interface', 'PropertyEntry', 'AppMgr',
22  'PyAlgorithm', 'CallbackStreamBuf', 'iAlgorithm', 'iDataSvc',
23  'iHistogramSvc', 'iNTupleSvc', 'iService', 'iAlgTool', 'Helper', 'SUCCESS',
24  'FAILURE', 'toArray', 'ROOT', 'makeNullPointer', 'setOwnership',
25  'getClass', 'loaddict', 'deprecation'
26 ]
27 
28 from GaudiKernel import ROOT6WorkAroundEnabled
29 
30 import os
31 import sys
32 import string
33 import warnings
34 import re
35 
36 # Workaround for ROOT-10769
37 with warnings.catch_warnings():
38  warnings.simplefilter("ignore")
39  import cppyy
40 
41 if sys.version_info >= (3, ):
42  # Python 2 compatibility
43  long = int
44 
45 if ROOT6WorkAroundEnabled('ROOT-5478'):
46  # Trigger the loading of GaudiKernelDict
47  cppyy.gbl.DataObject
48  # Trigger the loading of GaudiPythonDict
49  cppyy.gbl.Chrono
50 
51 from . import Pythonizations
52 # Import Configurable from AthenaCommon or GaudiKernel if the first is not
53 # available.
54 from GaudiKernel.Proxy.Configurable import Configurable, getNeededConfigurables
55 
56 # namespaces
57 gbl = cppyy.gbl
58 Gaudi = gbl.Gaudi
59 
60 _gaudi = None
61 
62 # ---- Useful shortcuts for classes -------------------------------------------
63 gbl.gInterpreter.Declare('#include "Gaudi/Property.h"')
64 Helper = gbl.GaudiPython.Helper
65 StringProperty = gbl.Gaudi.Property('std::string')
66 StringPropertyRef = gbl.Gaudi.Property('std::string&')
67 GaudiHandleProperty = gbl.GaudiHandleProperty
68 GaudiHandleArrayProperty = gbl.GaudiHandleArrayProperty
69 DataObject = gbl.DataObject
70 SUCCESS = gbl.StatusCode(gbl.StatusCode.SUCCESS, True)
71 FAILURE = gbl.StatusCode(gbl.StatusCode.FAILURE, True)
72 # Workaround for ROOT-10770
73 if hasattr(cppyy, 'nullptr'):
74  nullptr = cppyy.nullptr
75 elif hasattr(gbl, 'nullptr'):
76  nullptr = gbl.nullptr
77 else:
78  nullptr = None
79 # Helper to create a StringProperty
80 cppyy.gbl.gInterpreter.Declare('''
81 #include <stdexcept>
82 namespace GaudiPython { namespace Helpers {
83  void setProperty(ISvcLocator* svcLoc, std::string key, std::string value) {
84  if ( !svcLoc ) throw std::runtime_error( "invalid ISvcLocator pointer" );
85  svcLoc->getOptsSvc().set(key, value);
86  }
87 }}
88 ''')
89 
90 # toIntArray, toShortArray, etc.
91 for l in [l for l in dir(Helper) if re.match("^to.*Array$", l)]:
92  exec("%s = Helper.%s" % (l, l))
93  __all__.append(l)
94 
95 # FIXME: (MCl) Hack to handle ROOT 5.18 and ROOT >= 5.20
96 if hasattr(Helper, "toArray"):
97  # This is not backward compatible, but allows to use the same signature
98  # with all the versions of ROOT.
99  def toArray(typ):
100  return getattr(Helper, "toArray")
101 else:
102  # forward to the actual implementation of GaudiPython::Helper::toArray<T>
103  def toArray(typ):
104  return getattr(Helper, "toArray<%s>" % typ)
105 
106 
107 # ----Convenient accessors to PyROOT functionality ----------------------------
108 # See https://sft.its.cern.ch/jira/browse/ROOT-10771
109 if hasattr(cppyy, 'libPyROOT'):
110  ROOT = cppyy.libPyROOT
111 else:
112  import ROOT
113 makeNullPointer = ROOT.MakeNullPointer
114 setOwnership = ROOT.SetOwnership
115 
116 
117 def deprecation(message):
118  warnings.warn('GaudiPython: ' + message, DeprecationWarning, stacklevel=3)
119 
120 
121 # ----InterfaceCast class -----------------------------------------------------
122 
123 
124 class InterfaceCast(object):
125  """ Helper class to obtain the adequate interface from a component
126  by using the Gaudi queryInterface() mechanism """
127 
128  def __init__(self, t):
129  if type(t) is str:
130  t = getattr(gbl, t)
131  self.type = t
132 
133  def __call__(self, obj):
134  if obj:
135  ip = makeNullPointer(self.type)
136  try:
137  if obj.queryInterface(self.type.interfaceID(), ip).isSuccess():
138  return ip
139  else:
140  print("ERROR: queryInterface failed for", obj,
141  "interface:", self.type)
142  except Exception as e:
143  print("ERROR: exception", e,
144  "caught when retrieving interface", self.type,
145  "for object", obj)
146  import traceback
147  traceback.print_stack()
148  return cppyy.nullptr
149 
150  cast = __call__
151 
152 
153 # ---Interface class (for backward compatibility)------------------------------
154 
155 
157  def __init__(self, t):
158  deprecation('Use InterfaceCast class instead')
159  InterfaceCast.__init__(self, t)
160 
161  def cast(self, obj):
162  return self(obj)
163 
164 
165 # ----load dictionary function using Gaudi function----------------------------
166 
167 
168 def loaddict(dict):
169  """ Load a LCG dictionary using various mechanisms"""
170  if Helper.loadDynamicLib(dict) == 1:
171  return
172  else:
173  try:
174  cppyy.loadDict(dict)
175  except:
176  raise ImportError('Error loading dictionary library')
177 
178 
179 # ---get a class (by loading modules if needed)--------------------------------
180 
181 
182 def getClass(name, libs=[]):
183  """
184  Function to retrieve a certain C++ class by name and to load dictionary if requested
185 
186  Usage:
187 
188  from gaudimodule import getClass
189  # one knows that class is already loaded
190  AppMgr = getClass( 'ApplicationMgr' )
191  # one knows where to look for class, if not loaded yet
192  MCParticle = getClass( 'MCParticle' , 'EventDict' )
193  # one knows where to look for class, if not loaded yet
194  Vertex = getClass( 'Vertex' , ['EventDict', 'PhysEventDict'] )
195  """
196  # see if class is already loaded
197  if hasattr(gbl, name):
198  return getattr(gbl, name)
199  # try to load dictionaries and look for the required class
200  if type(libs) is not list:
201  libs = [libs]
202  for lib in libs:
203  loaddict(lib)
204  if hasattr(gbl, name):
205  return getattr(gbl, name)
206  # return None ( or raise exception? I do not know... )
207  return None
208 
209 
210 # ----PropertyEntry class------------------------------------------------------
211 
212 
213 class PropertyEntry(object):
214  """ holds the value and the documentation string of a property """
215 
216  def __init__(self, prop):
217  self._type = type(prop).__name__
218  self.__doc__ = " --- Property type is " + self.ptype()
219 
220  if issubclass(type(prop), GaudiHandleProperty):
221  self._value = prop.value() # do nothing for ATLAS' handles
222  elif issubclass(type(prop), GaudiHandleArrayProperty):
223  self._value = prop.value() # do nothing for ATLAS' handles
224  else:
225  # for all other types try to extract the native python type
226  try:
227  self._value = eval(prop.toString(), {}, {})
228  except:
229  if hasattr(prop, 'value'):
230  self._value = prop.value()
231  else:
232  self._value = prop.toString()
233 
234  self.__doc__ += " --- Default value = " + str(self._value) + " --- "
235  if prop.documentation() != 'none':
236  self.__doc__ = prop.documentation() + '\\n' + self.__doc__
237  # keep the original property
238  self._property = prop # property itself
239 
240  def value(self):
241  return self._value
242 
243  def ptype(self):
244  return self._type
245 
246  def property(self):
247  "Return the underlying property itself "
248  return self._property
249 
250  def documentation(self):
251  return self.__doc__
252 
253  def hasDoc(self):
254  return len(self.__doc__) > 0 and self.__doc__ != 'none'
255 
256 
257 # ----iProperty class----------------------------------------------------------
258 
259 
260 class iProperty(object):
261  """ Python equivalent to the C++ Property interface """
262 
263  def __init__(self, name, ip=cppyy.nullptr):
264  self.__dict__['_ip'] = InterfaceCast(gbl.IProperty)(ip)
265  self.__dict__['_svcloc'] = gbl.Gaudi.svcLocator()
266  self.__dict__['_name'] = name
267 
268  def getInterface(self):
269  if not self._ip:
270  self.retrieveInterface()
271  return self._ip
272 
273  def retrieveInterface(self):
274  pass
275 
276  def __call_interface_method__(self, ifname, method, *args):
277  if not getattr(self, ifname):
278  self.retrieveInterface()
279  return getattr(getattr(self, ifname), method)(*args)
280 
281  def __setattr__(self, name, value):
282  """
283  The method which is used for setting the property from the given value.
284  - In the case of the valid instance it sets the property through IProperty interface
285  - In the case of placeholder the property is added to JobOptionsCatalogue
286  """
287  if hasattr(value, 'toStringProperty'):
288  # user defined behaviour
289  value = str(value.toStringProperty())
290  elif hasattr(value, 'toString'):
291  value = str(value.toString())
292  elif type(value) == long:
293  value = '%d' % value # prevent pending 'L'
294  else:
295  value = str(value)
296 
297  ip = self.getInterface()
298  if ip:
299  if not gbl.Gaudi.Utils.hasProperty(ip, name):
300  raise AttributeError('property %s does not exist' % name)
301  ip.setPropertyRepr(name, value)
302  else:
303  gbl.GaudiPython.Helpers.setProperty(self._svcloc, '.'.join(
304  [self._name, name]), value)
305 
306  def __getattr__(self, name):
307  """
308  The method which returns the value for the given property
309  - In the case of the valid instance it returns the valid property value through IProperty interface
310  - In the case of placeholder the property value is retrieved from JobOptionsCatalogue
311  """
312  ip = self.getInterface()
313  if ip:
314  if not gbl.Gaudi.Utils.hasProperty(ip, name):
315  raise AttributeError('property %s does not exist' % name)
316  prop = ip.getProperty(name)
317  if StringProperty == type(prop):
318  return prop.value()
319  elif StringPropertyRef == type(prop):
320  return prop.value()
321  try:
322  return eval(prop.toString(), {}, {})
323  except:
324  return prop.value()
325  else:
326  opts = self._svcloc.getOptsSvc()
327  if opts.has("{}.{}".format(self._name, name)):
328  # from JobOptionsSvc we always have only strings
329  return eval(opts.get("{}.{}".format(self._name, name)), {}, {})
330  raise AttributeError('property %s does not exist' % name)
331 
332  def properties(self):
333  dct = {}
334  props = None
335  ip = self.getInterface()
336  if ip:
337  props = ip.getProperties()
338  propsFrom = self._name # "interface"
339  else:
340  raise NotImplementedError("rely on IJobOptionsSvc")
341  props = self._optsvc.getProperties(self._name)
342  propsFrom = "jobOptionsSvc"
343  if props:
344  for p in props:
345  try:
346  dct[p.name()] = PropertyEntry(p)
347  except (ValueError, TypeError) as e:
348  raise ValueError("gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s" % \
349  (e.__class__.__name__, e.args,
350  propsFrom, p.name(), p.value()))
351  return dct
352 
353  def name(self):
354  return self._name
355 
356 
357 # ----iService class-----------------------------------------------------------
358 
359 
361  """ Python equivalent to IProperty interface """
362 
363  def __init__(self, name, isvc=cppyy.nullptr):
364  iProperty.__init__(self, name, isvc)
365  self.__dict__['_isvc'] = InterfaceCast(gbl.IService)(isvc)
366 
367  def retrieveInterface(self):
368  isvc = Helper.service(self._svcloc, self._name)
369  if isvc:
370  iService.__init__(self, self._name, isvc)
371 
372  def initialize(self):
373  return self.__call_interface_method__("_isvc", "initialize")
374 
375  def start(self):
376  return self.__call_interface_method__("_isvc", "start")
377 
378  def stop(self):
379  return self.__call_interface_method__("_isvc", "stop")
380 
381  def finalize(self):
382  return self.__call_interface_method__("_isvc", "finalize")
383 
384  def reinitialize(self):
385  return self.__call_interface_method__("_isvc", "reinitialize")
386 
387  def restart(self):
388  return self.__call_interface_method__("_isvc", "restart")
389 
390  def isValid(self):
391  if self._isvc:
392  return True
393  else:
394  return False
395 
396 
397 # ----iAlgorithm class---------------------------------------------------------
398 
399 
401  """ Python equivalent to IAlgorithm interface """
402 
403  def __init__(self, name, ialg=cppyy.nullptr):
404  iProperty.__init__(self, name, ialg)
405  self.__dict__['_ialg'] = InterfaceCast(gbl.IAlgorithm)(ialg)
406 
407  def retrieveInterface(self):
408  ialg = Helper.algorithm(
409  InterfaceCast(gbl.IAlgManager)(self._svcloc), self._name)
410  if ialg:
411  iAlgorithm.__init__(self, self._name, ialg)
412 
413  def initialize(self):
414  return self.__call_interface_method__("_ialg", "initialize")
415 
416  def start(self):
417  return self.__call_interface_method__("_ialg", "start")
418 
419  def execute(self):
420  return self.__call_interface_method__("_ialg", "execute")
421 
422  def stop(self):
423  return self.__call_interface_method__("_ialg", "stop")
424 
425  def finalize(self):
426  return self.__call_interface_method__("_ialg", "finalize")
427 
428  def reinitialize(self):
429  return self.__call_interface_method__("_ialg", "reinitialize")
430 
431  def restart(self):
432  return self.__call_interface_method__("_ialg", "restart")
433 
434  def sysInitialize(self):
435  return self.__call_interface_method__("_ialg", "sysInitialize")
436 
437  def sysStart(self):
438  return self.__call_interface_method__("_ialg", "sysStart")
439 
440  def sysExecute(self):
441  return self.__call_interface_method__("_ialg", "sysExecute")
442 
443  def sysStop(self):
444  return self.__call_interface_method__("_ialg", "sysStop")
445 
446  def sysFinalize(self):
447  return self.__call_interface_method__("_ialg", "sysFinalize")
448 
449  def sysReinitialize(self):
450  return self.__call_interface_method__("_ialg", "sysReinitialize")
451 
452  def sysRestart(self):
453  return self.__call_interface_method__("_ialg", "sysRestart")
454 
455 
456 # ----iAlgTool class-----------------------------------------------------------
457 
458 
460  """ Python equivalent to IAlgTool interface (not completed yet) """
461 
462  def __init__(self, name, itool=cppyy.nullptr):
463  iProperty.__init__(self, name, itool)
464  self.__dict__['_itool'] = itool
465  svc = Helper.service(self._svcloc, 'ToolSvc', True)
466  self.__dict__['_toolsvc'] = iToolSvc('ToolSvc', svc)
467 
468  def retrieveInterface(self):
469  itool = self._toolsvc._retrieve(self._name)
470  if itool:
471  iAlgTool.__init__(self, self._name, itool)
472 
473  def start(self):
474  return self.__call_interface_method__("_itool", "start")
475 
476  def stop(self):
477  return self.__call_interface_method__("_itool", "stop")
478 
479  def type(self):
480  return self.__call_interface_method__("_itool", "type")
481 
482  def name(self):
483  if self._itool:
484  return self._itool.name()
485  else:
486  return self._name
487 
488 
489 # ----iDataSvc class-----------------------------------------------------------
490 
491 
493  def __init__(self, name, idp):
494  iService.__init__(self, name, idp)
495  self.__dict__['_idp'] = InterfaceCast(gbl.IDataProviderSvc)(idp)
496  self.__dict__['_idm'] = InterfaceCast(gbl.IDataManagerSvc)(idp)
497 
498  def registerObject(self, path, obj):
499  if not self._idp:
500  raise AttributeError(
501  'C++ service %s does not exist' % self.__dict__['_name'])
502  return Helper.registerObject(self._idp, path, obj)
503 
504  def unregisterObject(self, path):
505  if not self._idp:
506  raise AttributeError(
507  'C++ service %s does not exist' % self.__dict__['_name'])
508  return Helper.unregisterObject(self._idp, path)
509 
510  def retrieveObject(self, path):
511  if not self._idp:
512  return cppyy.nullptr
513  return Helper.dataobject(self._idp, path)
514 
515  # get object from TES
516 
517  def findObject(self, path):
518  """
519 
520  Get the existing object in TransientStore for the given location
521 
522  - loading of object from persistency is NOT triggered
523  - 'data-on-demand' action is NOT triggered
524 
525  >>> svc = ... ## get the service
526  >>> path = ... ## get the path in Transient Store
527  >>> data = svc.findObject ( path ) ## use the method
528 
529  """
530  if not self._idp:
531  raise IndexError(
532  'C++ service %s does not exist' % self.__dict__['_name'])
533  return Helper.findobject(self._idp, path)
534 
535  # get or retrieve object, possible switch-off 'on-demand' actions
536  def getObject(self, path, *args):
537  """
538  Get object from Transient Store for the given location
539 
540  arguments :
541  - path : Location of object in Transient Store
542  - retrieve (bool) True : retrieve versus find
543  - disable on-demand (bool) False : temporary disable 'on-demand' actions
544 
545  >>> svc = ... ## get the service
546  >>> path = ... ## get the path
547 
548  >>> data = svc.getObject ( path , False ) ## find object in Transient Store
549 
550  ## find object in Transient Store
551  # load form tape or use 'on-demand' action for missing objects :
552  >>> data = svc.getObject ( path , True )
553 
554  ## find object in Transient Store
555  # load from tape or for missing objects, disable 'on-demand'-actions
556  >>> data = svc.getObject ( path , True , True )
557 
558  """
559  if not self._idp:
560  raise IndexError(
561  'C++ service %s does not exist' % self.__dict__['_name'])
562  return Helper.getobject(self._idp, path, *args)
563 
564  def __getitem__(self, path):
565  if not self._idp:
566  raise IndexError(
567  'C++ service %s does not exist' % self.__dict__['_name'])
568  return Helper.dataobject(self._idp, path)
569 
570  def __setitem__(self, path, obj):
571  if not self._idp:
572  raise IndexError(
573  'C++ service %s does not exist' % self.__dict__['_name'])
574  return self.registerObject(path, obj)
575 
576  def __delitem__(self, path):
577  if not self._idp:
578  raise IndexError(
579  'C++ service %s does not exist' % self.__dict__['_name'])
580  return self.unregisterObject(path)
581 
582  def leaves(self, node=cppyy.nullptr):
583  if node == cppyy.nullptr:
584  node = self.retrieveObject('')
585  ll = gbl.std.vector('IRegistry*')()
586  if type(node) is str:
587  obj = self.retrieveObject(node)
588  else:
589  obj = node
590  if self._idm.objectLeaves(node, ll).isSuccess():
591  return ll
592 
593  def dump(self, node=cppyy.nullptr):
594  if node == cppyy.nullptr:
595  root = self.retrieveObject('')
596  if root:
597  node = root.registry()
598  else:
599  return
600  print(node.identifier())
601  if node.object():
602  for l in self.leaves(node):
603  self.dump(l)
604 
605  def getList(self, node=cppyy.nullptr, lst=[], rootFID=None):
606  if node == cppyy.nullptr:
607  root = self.retrieveObject('')
608  if root:
609  node = root.registry()
610  rootFID = node.address().par()
611  lst = []
612  else:
613  return
614  Helper.dataobject(self._idp, node.identifier())
615  if node.object():
616  lst.append(node.identifier())
617  for l in self.leaves(node):
618  if l.address() and l.address().par() == rootFID:
619  self.getList(l, lst, rootFID)
620  else:
621  continue
622  return lst
623 
624  def getHistoNames(self, node=cppyy.nullptr, lst=[]):
625  if node == cppyy.nullptr:
626  root = self.retrieveObject('')
627  if root:
628  node = root.registry()
629  # rootFID = node.address().par()
630  lst = []
631  else:
632  return
633  Helper.dataobject(self._idp, node.identifier())
634  if node.object():
635  lst.append(node.identifier())
636  for l in self.leaves(node):
637  if l.name(): # and l.address().par() == rootFID :
638  self.getHistoNames(l, lst)
639  else:
640  continue
641  return lst
642 
643  def setRoot(self, name, obj):
644  if not self._idm:
645  raise IndexError(
646  'C++ service %s does not exist' % self.__dict__['_name'])
647  return self._idm.setRoot(name, obj)
648 
649  def clearStore(self):
650  if not self._idm:
651  raise IndexError(
652  'C++ service %s does not exist' % self.__dict__['_name'])
653  return self._idm.clearStore()
654 
655 
656 # ----iHistogramSvc class------------------------------------------------------
658  def __init__(self, name, ihs):
659  self.__dict__['_ihs'] = InterfaceCast(gbl.IHistogramSvc)(ihs)
660  iDataSvc.__init__(self, name, ihs)
661 
662  def retrieve1D(self, path):
663  return Helper.histo1D(self._ihs, path)
664 
665  def retrieve2D(self, path):
666  return Helper.histo2D(self._ihs, path)
667 
668  def retrieve3D(self, path):
669  return Helper.histo3D(self._ihs, path)
670 
671  def retrieveProfile1D(self, path):
672  return Helper.profile1D(self._ihs, path)
673 
674  def retrieveProfile2D(self, path):
675  return Helper.profile2D(self._ihs, path)
676 
677  def retrieve(self, path):
678  """
679  Retrieve AIDA histogram or AIDA profile histogram by path in Histogram Transient Store
680  >>> svc = ...
681  >>> histo = svc.retrieve ( 'path/to/my/histogram' )
682  """
683  h = self.retrieve1D(path)
684  if not h:
685  h = self.retrieve2D(path)
686  if not h:
687  h = self.retrieve3D(path)
688  if not h:
689  h = self.retrieveProfile1D(path)
690  if not h:
691  h = self.retrieveProfile2D(path)
692  return h
693 
694  def book(self, *args):
695  """
696  Book the histograms(1D,2D&3D) , see IHistogramSvc::book
697  >>> svc = ...
698  >>> histo = svc.book( .... )
699  """
700  return self._ihs.book(*args)
701 
702  def bookProf(self, *args):
703  """
704  Book the profile(1D&2D) histograms, see IHistogramSvc::bookProf
705  >>> svc = ...
706  >>> histo = svc.bookProf( .... )
707  """
708  return self._ihs.bookProf(*args)
709 
710  def __getitem__(self, path):
711  """
712  Retrieve the object from Histogram Transient Store (by path)
713  The reference to AIDA histogram is returned (if possible)
714  >>> svc = ...
715  >>> histo = svc['path/to/my/histogram']
716  """
717  h = self.retrieve(path)
718  if h:
719  return h
720  return iDataSvc.__getitem__(self, path)
721 
722  def getAsAIDA(self, path):
723  """
724  Retrieve the histogram from Histogram Transient Store (by path)
725  The reference to AIDA histogram is returned (if possible)
726  >>> svc = ...
727  >>> histo = svc.getAsAIDA ( 'path/to/my/histogram' )
728  """
729  return self.__getitem__(path)
730 
731  def getAsROOT(self, path):
732  """
733  Retrieve the histogram from Histogram Transient Store (by path)
734  The Underlying native ROOT object is returned (if possible)
735  >>> svc = ...
736  >>> histo = svc.getAsROOT ( 'path/to/my/histogram' )
737  """
738  fun = gbl.Gaudi.Utils.Aida2ROOT.aida2root
739  return fun(self.getAsAIDA(path))
740 
741 
742 # ----iNTupleSvc class---------------------------------------------------------
743 
744 
746  RowWiseTuple = 42
747  ColumnWiseTuple = 43
748 
749  def __init__(self, name, ints):
750  self.__dict__['_ints'] = InterfaceCast(gbl.INTupleSvc)(ints)
751  iDataSvc.__init__(self, name, ints)
752 
753  def book(self, *args):
754  return self._ints.book(*args)
755 
756  def defineOutput(self, files, typ="Gaudi::RootCnvSvc"):
757  """ Defines the mapping between logical names and the output file
758  Usage:
759  defineOutput({'LUN1':'MyFile1.root', 'LUN2':'Myfile2.root'}, svc='Gaudi::RootCnvSvc')
760  """
761  from . import Persistency as prs
762  helper = prs.get(typ)
763  helper.configure(AppMgr())
764  self.Output = [
765  helper.formatOutput(files[lun], lun=lun) for lun in files
766  ]
767  if AppMgr().HistogramPersistency == 'NONE':
768  AppMgr().HistogramPersistency = "ROOT"
769 
770  def __getitem__(self, path):
771  return iDataSvc.__getitem__(self, path)
772 
773 
774 # ----iToolSvc class-----------------------------------------------------------
776  def __init__(self, name, its):
777  self.__dict__['_its'] = InterfaceCast(gbl.IToolSvc)(its)
778  iService.__init__(self, name, its)
779 
780  def _retrieve(self, name, quiet=True):
781  sol = _gaudi.OutputLevel
782  if quiet:
783  self.OutputLevel = 6
784  if name.rfind('.') == -1:
785  itool = Helper.tool(self._its, '', name, nullptr, False)
786  elif name[0:8] == 'ToolSvc.':
787  itool = Helper.tool(self._its, '', name[8:], nullptr, False)
788  elif name.count('.') > 1:
789  ptool = self._retrieve(name[:name.rfind('.')])
790  itool = Helper.tool(self._its, '', name[name.rfind('.') + 1:],
791  ptool, False)
792  elif _gaudi:
793  prop = _gaudi.property(name[:name.rfind('.')])
794  itool = Helper.tool(self._its, '', name[name.rfind('.') + 1:],
795  prop._ip, False)
796  if quiet:
797  self.OutputLevel = sol
798  return itool
799 
800  def retrieve(self, name):
801  return iAlgTool(name, self._retrieve(name, quiet=False))
802 
803  def create(self, typ, name=None, parent=nullptr, interface=None):
804  if not name:
805  name = typ
806  itool = Helper.tool(self._its, typ, name, parent, True)
807  if interface:
808  return InterfaceCast(interface)(itool)
809  else:
810  return iAlgTool(name, itool)
811 
812  def release(self, itool):
813  if type(itool) is iAlgTool:
814  self._its.releaseTool(itool._itool)
815 
816 
817 # ----iEventSelector class-----------------------------------------------------
818 
819 
821  def __init__(self):
822  iService.__init__(
823  self, 'EventSelector',
824  Helper.service(gbl.Gaudi.svcLocator(), 'EventSelector'))
825  self.__dict__['g'] = AppMgr()
826 
827  def open(self, stream, typ='Gaudi::RootCnvSvc', **kwargs):
828  from . import Persistency as prs
829  helper = prs.get(typ)
830  helper.configure(self.g)
831  self.Input = helper.formatInput(stream, **kwargs)
832  self.reinitialize()
833 
834  def rewind(self):
835  # It is not possible to reinitialize EventSelector only
836  self.g.service('EventLoopMgr').reinitialize()
837 
838 
839 # ----AppMgr class-------------------------------------------------------------
840 
841 
843  def __new__(cls, *args, **kwargs):
844  global _gaudi
845  if not _gaudi:
846  newobj = object.__new__(cls)
847  cls.__init__(newobj, *args, **kwargs)
848  _gaudi = newobj
849  return _gaudi
850 
851  def __reset__(self):
852  global _gaudi
853  # Stop, Finalize and Terminate the current AppMgr
854  self.exit()
855  # release interfaces
856  self._evtpro.release()
857  self._svcloc.release()
858  self._appmgr.release()
859  # Reset the C++ globals
860  gbl.Gaudi.setInstance(makeNullPointer('ISvcLocator'))
861  gbl.Gaudi.setInstance(makeNullPointer('IAppMgrUI'))
862  # Reset the Python global
863  _gaudi = None
864 
865  def __init__(self,
866  outputlevel=-1,
867  joboptions=None,
868  selfoptions={},
869  dllname=None,
870  factname=None):
871  global _gaudi
872  if _gaudi:
873  return
874  # Make sure the python stdout buffer is flushed before c++ runs
875  sys.stdout.flush()
876  # Protection against multiple calls to exit() if the finalization fails
877  self.__dict__['_exit_called'] = False
878  # keep the Gaudi namespace around (so it is still available during atexit shutdown)...
879  self.__dict__['_gaudi_ns'] = Gaudi
880  try:
881  from GaudiKernel.Proxy.Configurable import expandvars
882  except ImportError:
883  # pass-through implementation if expandvars is not defined (AthenaCommon)
884  def expandvars(data):
885  return data
886 
887  if dllname and factname:
888  self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr(
889  dllname, factname)
890  elif dllname:
891  self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr(dllname)
892  else:
893  self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr()
894  self.__dict__['_svcloc'] = gbl.Gaudi.svcLocator()
895  self.__dict__['_algmgr'] = InterfaceCast(gbl.IAlgManager)(self._appmgr)
896  self.__dict__['_evtpro'] = InterfaceCast(gbl.IEventProcessor)(
897  self._appmgr)
898  self.__dict__['_svcmgr'] = InterfaceCast(gbl.ISvcManager)(self._appmgr)
899  self.__dict__['pyalgorithms'] = []
900  iService.__init__(self, 'ApplicationMgr', self._appmgr)
901  # ------python specific initialization-------------------------------------
902  if self.FSMState(
903  ) < Gaudi.StateMachine.CONFIGURED: # Not yet configured
904  self.JobOptionsType = 'NONE'
905  if joboptions:
906  from GaudiKernel.ProcessJobOptions import importOptions
907  importOptions(joboptions)
908  # Ensure that the ConfigurableUser instances have been applied
909  import GaudiKernel.Proxy.Configurable
910  if hasattr(GaudiKernel.Proxy.Configurable,
911  "applyConfigurableUsers"):
912  GaudiKernel.Proxy.Configurable.applyConfigurableUsers()
913  # This is the default and could be overridden with "selfopts"
914  self.OutputLevel = 3
915  try:
916  appMgr = Configurable.allConfigurables['ApplicationMgr']
917  selfprops = expandvars(appMgr.getValuedProperties())
918  except KeyError:
919  selfprops = {}
920  for p, v in selfprops.items():
921  setattr(self, p, v)
922  for p, v in selfoptions.items():
923  setattr(self, p, v)
924  # Override job options
925  if outputlevel != -1:
926  self.OutputLevel = outputlevel
927  self.configure()
928  # ---MessageSvc------------------------------------------------------------
929  ms = self.service('MessageSvc')
930  if 'MessageSvc' in Configurable.allConfigurables:
931  msprops = Configurable.allConfigurables['MessageSvc']
932  ms = self.service('MessageSvc')
933  if hasattr(msprops, "getValuedProperties"):
934  msprops = expandvars(msprops.getValuedProperties())
935  for p, v in msprops.items():
936  setattr(ms, p, v)
937  if outputlevel != -1:
938  ms.OutputLevel = outputlevel
939  # ------Configurables initialization (part2)-------------------------------
940  for n in getNeededConfigurables():
941  c = Configurable.allConfigurables[n]
942  if n in ['ApplicationMgr', 'MessageSvc']:
943  continue # These are already done---
944  for p, v in c.getValuedProperties().items():
945  v = expandvars(v)
946  # Note: AthenaCommon.Configurable does not have Configurable.PropertyReference
947  if hasattr(Configurable, "PropertyReference") and type(
948  v) == Configurable.PropertyReference:
949  # this is done in "getFullName", but the exception is ignored,
950  # so we do it again to get it
951  v = v.__resolve__()
952  if type(v) == str:
953  v = repr(v) # need double quotes
954  if type(v) == long:
955  v = '%d' % v # prevent pending 'L'
956  gbl.GaudiPython.Helpers.setProperty(self._svcloc,
957  '.'.join([n, p]), str(v))
958  if hasattr(Configurable, "_configurationLocked"):
959  Configurable._configurationLocked = True
960 
961  # Ensure that the exit method is called when exiting from Python
962  import atexit
963  atexit.register(self.exit)
964 
965  # ---Hack to avoid bad interactions with the ROOT exit handler
966  # let's install a private version of atexit.register that detects when
967  # the ROOT exit handler is installed and adds our own after it to ensure
968  # it is called before.
969  orig_register = atexit.register
970 
971  def register(func, *targs, **kargs):
972  orig_register(func, *targs, **kargs)
973  if hasattr(func, "__module__") and func.__module__ == "ROOT":
974  orig_register(self.exit)
975  # we do not need to remove out handler from the list because
976  # it can be safely called more than once
977 
978  register.__doc__ = (orig_register.__doc__ +
979  "\nNote: version hacked by GaudiPython to work " +
980  "around a problem with the ROOT exit handler")
981  atexit.register = register
982 
983  @property
984  def opts(self):
985  if "_svcloc" in self.__dict__:
986  return self._svcloc.getOptsSvc()
987  return None
988 
989  def state(self):
990  return self._isvc.FSMState()
991 
992  def FSMState(self):
993  return self._isvc.FSMState()
994 
995  def targetFSMState(self):
996  return self._isvc.targetFSMState()
997 
998  def service(self, name, interface=None):
999  svc = Helper.service(self._svcloc, name)
1000  if interface:
1001  return InterfaceCast(interface)(svc)
1002  else:
1003  return iService(name, svc)
1004 
1005  def declSvcType(self, svcname, svctype):
1006  self._svcmgr.declareSvcType(svcname, svctype)
1007 
1008  def createSvc(self, name):
1009  return Helper.service(self._svcloc, name, True)
1010 
1011  def services(self):
1012  l = self._svcloc.getServices()
1013  return [s.name() for s in l]
1014 
1015  def algorithm(self, name, createIf=False):
1016  alg = Helper.algorithm(self._algmgr, name, createIf)
1017  if not alg:
1018  return iAlgorithm(name, alg)
1019  else:
1020  return iAlgorithm(alg.name(), alg)
1021 
1022  def algorithms(self):
1023  l = self._algmgr.getAlgorithms()
1024  return [a.name() for a in l]
1025 
1026  def tool(self, name):
1027  return iAlgTool(name)
1028 
1029  def property(self, name):
1030  if name in self.algorithms():
1031  return self.algorithm(name)
1032  elif name in self.services():
1033  return self.service(name)
1034  else:
1035  return iProperty(name)
1036 
1037  def datasvc(self, name):
1038  if self.state() == Gaudi.StateMachine.CONFIGURED:
1039  self.initialize()
1040  svc = Helper.service(self._svcloc, name)
1041  return iDataSvc(name, svc)
1042 
1043  def evtsvc(self):
1044  return self.datasvc('EventDataSvc')
1045 
1046  def detsvc(self):
1047  return self.datasvc('DetectorDataSvc')
1048 
1049  def filerecordsvc(self):
1050  return self.datasvc('FileRecordDataSvc')
1051 
1052  def evtsel(self):
1053  if self.state() == Gaudi.StateMachine.CONFIGURED:
1054  self.initialize()
1055  if not hasattr(self, '_evtsel'):
1056  self.__dict__['_evtsel'] = iEventSelector()
1057  return self._evtsel
1058 
1059  def histsvc(self, name='HistogramDataSvc'):
1060  svc = Helper.service(self._svcloc, name)
1061  return iHistogramSvc(name, svc)
1062 
1063  def ntuplesvc(self, name='NTupleSvc'):
1064  if name not in self.ExtSvc:
1065  self.ExtSvc += [name]
1066 # if self.HistogramPersistency == 'NONE' : self.HistogramPersistency = 'ROOT'
1067  svc = Helper.service(self._svcloc, name, True)
1068  return iNTupleSvc(name, svc)
1069 
1070  def partsvc(self):
1071  if self.FSMState() == Gaudi.StateMachine.CONFIGURED:
1072  self.initialize()
1073  svc = Helper.service(self._svcloc, 'ParticlePropertySvc')
1074  return InterfaceCast(gbl.IParticlePropertySvc)(svc)
1075 
1076  def toolsvc(self, name='ToolSvc'):
1077  svc = Helper.service(self._svcloc, name, True)
1078  return iToolSvc(name, svc)
1079 
1080  def readOptions(self, file):
1081  return self.opts.readOptions(file)
1082 
1083  def addAlgorithm(self, alg):
1084  """ Add an Algorithm to the list of Top algorithms. It can be either a instance of
1085  an Algorithm class or it name """
1086  if type(alg) is str:
1087  self.topAlg += [alg]
1088  else:
1089  self.pyalgorithms.append(alg)
1090  setOwnership(alg, 0)
1091  if self.targetFSMState() >= Gaudi.StateMachine.INITIALIZED:
1092  alg.sysInitialize()
1093  if self.targetFSMState() == Gaudi.StateMachine.RUNNING:
1094  alg.sysStart()
1095  self.topAlg += [alg.name()]
1096 
1097  def setAlgorithms(self, algs):
1098  """ Set the list of Top Algorithms.
1099  It can be an individual of a list of algorithms names or instances """
1100  if type(algs) is not list:
1101  algs = [algs]
1102  names = []
1103  for alg in algs:
1104  if type(alg) is str:
1105  names.append(alg)
1106  else:
1107  self.pyalgorithms.append(alg)
1108  if self.targetFSMState() >= Gaudi.StateMachine.INITIALIZED:
1109  alg.sysInitialize()
1110  if self.targetFSMState() == Gaudi.StateMachine.RUNNING:
1111  alg.sysStart()
1112  names.append(alg.name())
1113  self.topAlg = names
1114 
1115  def removeAlgorithm(self, alg):
1116  """ Remove an Algorithm to the list of Top algorithms. It can be either a instance of
1117  an Algorithm class or it name """
1118  tmp = self.topAlg
1119  if type(alg) is str:
1120  tmp.remove(alg)
1121  else:
1122  tmp.remove(alg.name())
1123  self.pyalgorithms.remove(alg)
1124  setOwnership(alg, 1)
1125  self.topAlg = tmp
1126 
1128  """
1129  Print the sequence of Algorithms.
1130  """
1131 
1132  def printAlgo(algName, appMgr, prefix=' '):
1133  print(prefix + algName)
1134  alg = appMgr.algorithm(algName.split("/")[-1])
1135  prop = alg.properties()
1136  if "Members" in prop:
1137  subs = prop["Members"].value()
1138  for i in subs:
1139  printAlgo(i.strip('"'), appMgr, prefix + " ")
1140 
1141  mp = self.properties()
1142  prefix = 'ApplicationMgr SUCCESS '
1143  print(
1144  prefix +
1145  "****************************** Algorithm Sequence ****************************"
1146  )
1147  for i in mp["TopAlg"].value():
1148  printAlgo(i, self, prefix)
1149  print(
1150  prefix +
1151  "******************************************************************************"
1152  )
1153 
1154  def config(self, **args):
1155  """
1156  Simple utility to perform the configuration of Gaudi application.
1157  It reads the set of input job-options files, and set few
1158  additional parameters 'options' through the usage of temporary *.opts file
1159  Usage:
1160  gaudi.config( files = [ '$GAUSSOPTS/Gauss.opts' ,
1161  '$DECFILESROOT/options/10022_010.0GeV.opts' ] ,
1162  options = [ 'EventSelector.PrintFreq = 5 ' ] )
1163  """
1164  files = args.get('files', [])
1165  for file in files:
1166  sc = self.readOptions(file)
1167  if sc.isFailure():
1168  raise RuntimeError(' Unable to read file "' + file + '" ')
1169  options = args.get('options', None)
1170  if options:
1171  import tempfile
1172  tmpfilename = tempfile.mktemp()
1173  tmpfile = open(tmpfilename, 'w')
1174  tmpfile.write('#pragma print on \n')
1175  tmpfile.write('/// File "' + tmpfilename +
1176  '" generated by GaudiPython \n\n')
1177  for opt in options:
1178  if type(options) is dict:
1179  tmpfile.write(' \t ' + opt + ' = ' + options[opt] +
1180  ' ; // added by GaudiPython \n')
1181  else:
1182  tmpfile.write(' \t ' + opt +
1183  ' ; // added by GaudiPython \n')
1184  tmpfile.write('/// End of file "' + tmpfilename +
1185  '" generated by GaudiPython \n\n')
1186  tmpfile.close()
1187  sc = self.readOptions(tmpfilename)
1188  if sc.isFailure():
1189  raise RuntimeError(' Unable to read file "' + tmpfilename +
1190  '" ')
1191  os.remove(tmpfilename)
1192 
1193  return SUCCESS
1194 
1195  def configure(self):
1196  return self._appmgr.configure()
1197 
1198  def start(self):
1199  return self._appmgr.start()
1200 
1201  def terminate(self):
1202  return self._appmgr.terminate()
1203 
1204  def run(self, n):
1205  if self.FSMState() == Gaudi.StateMachine.CONFIGURED:
1206  sc = self.initialize()
1207  if sc.isFailure() or self.ReturnCode != 0:
1208  return sc
1209  if self.FSMState() == Gaudi.StateMachine.INITIALIZED:
1210  sc = self.start()
1211  if sc.isFailure() or self.ReturnCode != 0:
1212  return sc
1213  return self._evtpro.executeRun(n)
1214 
1215  def executeEvent(self):
1216  return self._evtpro.executeEvent()
1217 
1218  def execute(self):
1219  return self._evtpro.executeEvent()
1220 
1221  def runSelectedEvents(self, pfn, events):
1222  if self.FSMState() == Gaudi.StateMachine.CONFIGURED:
1223  sc = self.initialize()
1224  if sc.isFailure():
1225  return sc
1226  if self.FSMState() == Gaudi.StateMachine.INITIALIZED:
1227  sc = self.start()
1228  if sc.isFailure():
1229  return sc
1230  # --- Access a number of services ----
1231  if not hasattr(self, '_perssvc'):
1232  self.__dict__['_perssvc'] = self.service('EventPersistencySvc',
1233  'IAddressCreator')
1234  if not hasattr(self, '_filecat'):
1235  self.__dict__['_filecat'] = self.service('FileCatalog',
1236  'Gaudi::IFileCatalog')
1237  if not hasattr(self, '_evtmgr'):
1238  self.__dict__['_evtmgr'] = self.service('EventDataSvc',
1239  'IDataManagerSvc')
1240  # --- Get FID from PFN and number of events in file
1241  if pfn.find('PFN:') == 0:
1242  pfn = pfn[4:]
1243  fid, maxevt = _getFIDandEvents(pfn)
1244  # --- Add FID into catalog if needed ---
1245  if not self._filecat.existsFID(fid):
1246  self._filecat.registerPFN(fid, pfn, '')
1247  # --- Loop over events
1248  if type(events) is not list:
1249  events = (events, )
1250  for evt in events:
1251  # --- Create POOL Address from Generic Address
1252  gadd = gbl.GenericAddress(0x02, 1, fid, '/Event', 0, evt)
1253  oadd = makeNullPointer('IOpaqueAddress')
1254  self._perssvc.createAddress(gadd.svcType(), gadd.clID(),
1255  gadd.par(), gadd.ipar(), oadd)
1256  # --- Clear TES, set root and run all algorithms
1257  self._evtmgr.clearStore()
1258  self._evtmgr.setRoot('/Event', oadd)
1259  self._evtpro.executeEvent()
1260 
1261  def exit(self):
1262  # Protection against multiple calls to exit() if the finalization fails
1263  if not self._exit_called:
1264  self.__dict__['_exit_called'] = True
1265  Gaudi = self._gaudi_ns
1266  if self.FSMState() == Gaudi.StateMachine.RUNNING:
1267  self._appmgr.stop().ignore()
1268  if self.FSMState() == Gaudi.StateMachine.INITIALIZED:
1269  self._appmgr.finalize().ignore()
1270  if self.FSMState() == Gaudi.StateMachine.CONFIGURED:
1271  self._appmgr.terminate()
1272  return SUCCESS
1273 
1274  # Custom destructor to ensure that the application is correctly finalized when exiting from python.
1275 
1276  def __del__(self):
1277  self.exit()
1278 
1279  evtSvc = evtsvc
1280  histSvc = histsvc
1281  ntupleSvc = ntuplesvc
1282  evtSel = evtsel
1283  detSvc = detsvc
1284  toolSvc = toolsvc
1285  partSvc = partsvc
1286 
1287 
1288 # -----------------------------------------------------------------------------
1289 
1290 
1292  tfile = gbl.TFile.Open(pfn)
1293  if not tfile:
1294  raise IOError('Cannot open ROOT file {0}'.format(pfn))
1295  tree = tfile.Get('##Params')
1296  tree.GetEvent(0)
1297  text = tree.db_string
1298  if 'NAME=FID' in text:
1299  fid = text[text.rfind('VALUE=') + 6:-1]
1300  nevt = tfile.Get('_Event').GetEntries()
1301  tfile.Close()
1302  return fid, nevt
1303 
1304 
1305 # -----------------------------------------------------------------------------
1306 
1307 
1309  """ Get all the properties of a component as a Python dictionary.
1310  The component is instantiated using the component library
1311  """
1312  properties = {}
1313  if name == 'GaudiCoreSvc':
1314  if Helper.loadDynamicLib(name) != 1:
1315  raise ImportError('Error loading component library ' + name)
1316  factorylist = gbl.FactoryTable.instance().getEntries()
1317  factories = _copyFactoriesFromList(factorylist)
1318  g = AppMgr(outputlevel=7)
1319  else:
1320  g = AppMgr(outputlevel=7)
1321  if Helper.loadDynamicLib(name) != 1:
1322  raise ImportError('Error loading component library ' + name)
1323  factorylist = gbl.FactoryTable.instance().getEntries()
1324  factories = _copyFactoriesFromList(factorylist)
1325  svcloc = gbl.Gaudi.svcLocator()
1326  dummysvc = gbl.Service('DummySvc', svcloc)
1327  for factory in factories:
1328  if InterfaceCast(gbl.IAlgFactory)(factory):
1329  ctype = 'Algorithm'
1330  elif InterfaceCast(gbl.ISvcFactory)(factory):
1331  ctype = 'Service'
1332  elif InterfaceCast(gbl.IToolFactory)(factory):
1333  ctype = 'AlgTool'
1334  elif factory.ident() == 'ApplicationMgr':
1335  ctype = 'ApplicationMgr'
1336  else:
1337  ctype = 'Unknown'
1338  cname = factory.ident().split()[-1]
1339  if ctype in ('Algorithm', 'Service', 'AlgTool', 'ApplicationMgr'):
1340  try:
1341  if ctype == 'AlgTool':
1342  obj = factory.instantiate(dummysvc)
1343  else:
1344  obj = factory.instantiate(svcloc)
1345  except RuntimeError as text:
1346  print('Error instantiating', cname, ' from ', name)
1347  print(text)
1348  continue
1349  prop = iProperty('dummy', obj)
1350  properties[cname] = [ctype, prop.properties()]
1351  try:
1352  obj.release()
1353  except:
1354  pass
1355  return properties
1356 
1357 
1358 def _copyFactoriesFromList(factories):
1359  result = []
1360  for i in range(factories.size()):
1361  factory = factories.front()
1362  result.append(factory)
1363  factories.pop_front()
1364  for factory in result:
1365  factories.push_back(factory)
1366  return result
1367 
1368 
1369 # ----CallbackStreamBuf--------------------------------------------------------
1370 # Used for redirecting C++ messages to python
1371 _CallbackStreamBufBase = gbl.GaudiPython.CallbackStreamBuf
1372 
1373 
1375  def __init__(self, callback):
1376  _CallbackStreamBufBase.__init__(self, self)
1377  self.callback = callback
1378 
1379  def _sync(self, string=None):
1380  if not string:
1381  return 0
1382  self.callback(string)
1383  return 0
1384 
1385 
1386 # ----PyAlgorithm--------------------------------------------------------------
1387 # Used to implement Algorithms in Python
1388 _PyAlgorithm = gbl.GaudiPython.PyAlgorithm
1389 
1390 
1392  def __init__(self, name=None):
1393  if not name:
1394  name = self.__class__.__name__
1395  _PyAlgorithm.__init__(self, self, name)
1396  self._svcloc = gbl.Gaudi.svcLocator()
1397  self._algmgr = InterfaceCast(gbl.IAlgManager)(self._svcloc)
1398  sc = self._algmgr.addAlgorithm(self)
1399  if sc.isFailure():
1400  raise RuntimeError('Unable to add Algorithm')
1401 
1402  def __del__(self):
1403  sc = self._algmgr.removeAlgorithm(self)
1404  if sc.isFailure():
1405  pass
1406 
1407  def initialize(self):
1408  return 1
1409 
1410  def start(self):
1411  return 1
1412 
1413  def execute(self):
1414  return 1
1415 
1416  def stop(self):
1417  return 1
1418 
1419  def finalize(self):
1420  return 1
1421 
1422 
1423 # ----Enable tab completion----------------------------------------------------
1424 try:
1425  import rlcompleter
1426  import readline
1427  readline.parse_and_bind("tab: complete")
1428 except:
1429  pass
GaudiPython.Bindings.AppMgr.start
def start(self)
Definition: Bindings.py:1198
GaudiPython.Bindings.makeNullPointer
makeNullPointer
Definition: Bindings.py:113
GaudiPython.Bindings.iEventSelector.open
def open(self, stream, typ='Gaudi::RootCnvSvc', **kwargs)
Definition: Bindings.py:827
GaudiPython.Bindings.iService.reinitialize
def reinitialize(self)
Definition: Bindings.py:384
GaudiPython.Bindings.iProperty.__setattr__
def __setattr__(self, name, value)
Definition: Bindings.py:281
GaudiPython.Bindings.iAlgorithm.sysExecute
def sysExecute(self)
Definition: Bindings.py:440
GaudiPython.Bindings.AppMgr.toolsvc
def toolsvc(self, name='ToolSvc')
Definition: Bindings.py:1076
GaudiPython.Bindings.AppMgr.removeAlgorithm
def removeAlgorithm(self, alg)
Definition: Bindings.py:1115
GaudiPython.Bindings.iAlgTool.start
def start(self)
Definition: Bindings.py:473
GaudiPython.Bindings.iDataSvc
Definition: Bindings.py:492
GaudiPython.Bindings.iAlgorithm.__init__
def __init__(self, name, ialg=cppyy.nullptr)
Definition: Bindings.py:403
GaudiPython.Bindings.iToolSvc.create
def create(self, typ, name=None, parent=nullptr, interface=None)
Definition: Bindings.py:803
GaudiPython.Bindings.InterfaceCast.__init__
def __init__(self, t)
Definition: Bindings.py:128
GaudiPython.Bindings.AppMgr.__reset__
def __reset__(self)
Definition: Bindings.py:851
GaudiPython.Bindings.PyAlgorithm.__init__
def __init__(self, name=None)
Definition: Bindings.py:1392
GaudiPython.Bindings.iNTupleSvc.book
def book(self, *args)
Definition: Bindings.py:753
GaudiPython.Bindings.AppMgr.readOptions
def readOptions(self, file)
Definition: Bindings.py:1080
GaudiPython.Bindings.iProperty.retrieveInterface
def retrieveInterface(self)
Definition: Bindings.py:273
GaudiPython.Bindings.iHistogramSvc.getAsAIDA
def getAsAIDA(self, path)
Definition: Bindings.py:722
GaudiPython.Bindings.iEventSelector.rewind
def rewind(self)
Definition: Bindings.py:834
GaudiPython.Bindings.iHistogramSvc.retrieve1D
def retrieve1D(self, path)
Definition: Bindings.py:662
GaudiPython.Bindings.iHistogramSvc.retrieve
def retrieve(self, path)
Definition: Bindings.py:677
GaudiPython.Bindings.iToolSvc.retrieve
def retrieve(self, name)
Definition: Bindings.py:800
GaudiPython.Bindings.AppMgr.tool
def tool(self, name)
Definition: Bindings.py:1026
GaudiPython.Bindings.iDataSvc.__init__
def __init__(self, name, idp)
Definition: Bindings.py:493
GaudiPython.Bindings.iAlgTool.stop
def stop(self)
Definition: Bindings.py:476
GaudiPython.Bindings.AppMgr.__new__
def __new__(cls, *args, **kwargs)
Definition: Bindings.py:843
GaudiPython.Bindings._copyFactoriesFromList
def _copyFactoriesFromList(factories)
Definition: Bindings.py:1358
GaudiPython.Bindings.iAlgorithm.sysStop
def sysStop(self)
Definition: Bindings.py:443
GaudiPython.Bindings.PyAlgorithm.execute
def execute(self)
Definition: Bindings.py:1413
GaudiPython.Bindings.AppMgr.addAlgorithm
def addAlgorithm(self, alg)
Definition: Bindings.py:1083
GaudiPython.Bindings.AppMgr.runSelectedEvents
def runSelectedEvents(self, pfn, events)
Definition: Bindings.py:1221
GaudiPython.Bindings.AppMgr.datasvc
def datasvc(self, name)
Definition: Bindings.py:1037
GaudiPython.Bindings.PropertyEntry.property
def property(self)
Definition: Bindings.py:246
GaudiPython.Bindings.iToolSvc._retrieve
def _retrieve(self, name, quiet=True)
Definition: Bindings.py:780
GaudiPython.Bindings.AppMgr.service
def service(self, name, interface=None)
Definition: Bindings.py:998
GaudiPython.Bindings.iDataSvc.registerObject
def registerObject(self, path, obj)
Definition: Bindings.py:498
GaudiPython.Bindings.iAlgTool.retrieveInterface
def retrieveInterface(self)
Definition: Bindings.py:468
GaudiKernel.ROOT6WorkAroundEnabled
def ROOT6WorkAroundEnabled(id=None)
Definition: __init__.py:14
GaudiPython.Bindings.iHistogramSvc.__getitem__
def __getitem__(self, path)
Definition: Bindings.py:710
GaudiPython.Bindings.iToolSvc.OutputLevel
OutputLevel
Definition: Bindings.py:783
GaudiPython.Bindings.loaddict
def loaddict(dict)
Definition: Bindings.py:168
GaudiPython.Bindings.iDataSvc.retrieveObject
def retrieveObject(self, path)
Definition: Bindings.py:510
GaudiPython.Bindings.AppMgr
Definition: Bindings.py:842
GaudiPython.Bindings.iAlgorithm
Definition: Bindings.py:400
conf.release
string release
Definition: conf.py:28
GaudiPython.Bindings.getComponentProperties
def getComponentProperties(name)
Definition: Bindings.py:1308
GaudiPython.Bindings.iHistogramSvc.bookProf
def bookProf(self, *args)
Definition: Bindings.py:702
GaudiPython.Bindings.AppMgr.opts
def opts(self)
Definition: Bindings.py:984
GaudiPython.Bindings.iDataSvc.leaves
def leaves(self, node=cppyy.nullptr)
Definition: Bindings.py:582
GaudiPython.Bindings.iDataSvc.__setitem__
def __setitem__(self, path, obj)
Definition: Bindings.py:570
GaudiPython.Bindings.iDataSvc.clearStore
def clearStore(self)
Definition: Bindings.py:649
GaudiPython.Bindings.setOwnership
setOwnership
Definition: Bindings.py:114
GaudiPython.Bindings.iAlgorithm.restart
def restart(self)
Definition: Bindings.py:431
GaudiPython.Bindings.iService.__init__
def __init__(self, name, isvc=cppyy.nullptr)
Definition: Bindings.py:363
GaudiPython.Bindings.iService.stop
def stop(self)
Definition: Bindings.py:378
GaudiPython.Bindings.iEventSelector.Input
Input
Definition: Bindings.py:831
GaudiPython.Bindings.iProperty
Definition: Bindings.py:260
GaudiPython.Bindings.iDataSvc.setRoot
def setRoot(self, name, obj)
Definition: Bindings.py:643
GaudiPython.Bindings.iToolSvc.release
def release(self, itool)
Definition: Bindings.py:812
GaudiPython.Bindings.iAlgorithm.retrieveInterface
def retrieveInterface(self)
Definition: Bindings.py:407
GaudiPython.Bindings.iHistogramSvc.retrieveProfile1D
def retrieveProfile1D(self, path)
Definition: Bindings.py:671
GaudiPython.Bindings.iService.retrieveInterface
def retrieveInterface(self)
Definition: Bindings.py:367
GaudiPython.Bindings.iNTupleSvc.Output
Output
Definition: Bindings.py:764
GaudiPython.Bindings.AppMgr.property
def property(self, name)
Definition: Bindings.py:1029
GaudiPython.Bindings.PyAlgorithm.finalize
def finalize(self)
Definition: Bindings.py:1419
GaudiKernel.Proxy.getNeededConfigurables
getNeededConfigurables
Definition: Proxy.py:31
GaudiPython.Bindings.toArray
def toArray(typ)
Definition: Bindings.py:99
GaudiPython.Bindings.PyAlgorithm
Definition: Bindings.py:1391
compareOutputFiles.par
string par
Definition: compareOutputFiles.py:477
GaudiPython.Bindings.iEventSelector.__init__
def __init__(self)
Definition: Bindings.py:821
GaudiPython.Bindings.AppMgr.ntuplesvc
def ntuplesvc(self, name='NTupleSvc')
Definition: Bindings.py:1063
GaudiPython.Bindings.iAlgTool.type
def type(self)
Definition: Bindings.py:479
GaudiPython.Bindings.PyAlgorithm.__del__
def __del__(self)
Definition: Bindings.py:1402
GaudiPython.Bindings.iDataSvc.getHistoNames
def getHistoNames(self, node=cppyy.nullptr, lst=[])
Definition: Bindings.py:624
GaudiPython.Bindings.AppMgr.printAlgsSequences
def printAlgsSequences(self)
Definition: Bindings.py:1127
GaudiPython.Bindings.iHistogramSvc.getAsROOT
def getAsROOT(self, path)
Definition: Bindings.py:731
GaudiPython.Bindings.InterfaceCast.__call__
def __call__(self, obj)
Definition: Bindings.py:133
GaudiPython.Bindings.CallbackStreamBuf
Definition: Bindings.py:1374
GaudiPython.Bindings.deprecation
def deprecation(message)
Definition: Bindings.py:117
GaudiPython.Bindings.iAlgorithm.execute
def execute(self)
Definition: Bindings.py:419
GaudiPython.Bindings.iProperty.__call_interface_method__
def __call_interface_method__(self, ifname, method, *args)
Definition: Bindings.py:276
GaudiPython.Bindings.InterfaceCast.cast
def cast
Definition: Bindings.py:150
GaudiPython.Pythonizations.self
self
Definition: Pythonizations.py:566
GaudiPython.Bindings.iHistogramSvc.retrieve2D
def retrieve2D(self, path)
Definition: Bindings.py:665
GaudiPython.Bindings.iAlgorithm.stop
def stop(self)
Definition: Bindings.py:422
GaudiPython.Bindings.AppMgr.topAlg
topAlg
Definition: Bindings.py:1113
GaudiKernel.ProcessJobOptions
Definition: ProcessJobOptions.py:1
GaudiPython.Bindings.iHistogramSvc.__init__
def __init__(self, name, ihs)
Definition: Bindings.py:658
GaudiPython.Bindings.PyAlgorithm.stop
def stop(self)
Definition: Bindings.py:1416
GaudiPython.Bindings.PyAlgorithm.initialize
def initialize(self)
Definition: Bindings.py:1407
GaudiPython.Bindings.iService.start
def start(self)
Definition: Bindings.py:375
GaudiPython.Bindings.iDataSvc.unregisterObject
def unregisterObject(self, path)
Definition: Bindings.py:504
GaudiPython.Bindings.iAlgorithm.reinitialize
def reinitialize(self)
Definition: Bindings.py:428
GaudiPython.Bindings.AppMgr.executeEvent
def executeEvent(self)
Definition: Bindings.py:1215
GaudiPython.Bindings.CallbackStreamBuf._sync
def _sync(self, string=None)
Definition: Bindings.py:1379
GaudiPython.Bindings.iService.isValid
def isValid(self)
Definition: Bindings.py:390
GaudiPython.Bindings.iDataSvc.dump
def dump(self, node=cppyy.nullptr)
Definition: Bindings.py:593
GaudiPython.Bindings.CallbackStreamBuf.__init__
def __init__(self, callback)
Definition: Bindings.py:1375
GaudiPython.Bindings.AppMgr.createSvc
def createSvc(self, name)
Definition: Bindings.py:1008
GaudiPython.Bindings.InterfaceCast.type
type
Definition: Bindings.py:131
GaudiPython.Bindings.iNTupleSvc.__getitem__
def __getitem__(self, path)
Definition: Bindings.py:770
GaudiPython.Bindings.iHistogramSvc.book
def book(self, *args)
Definition: Bindings.py:694
GaudiPython.Bindings.iNTupleSvc.__init__
def __init__(self, name, ints)
Definition: Bindings.py:749
GaudiPython.Bindings.iAlgTool.__init__
def __init__(self, name, itool=cppyy.nullptr)
Definition: Bindings.py:462
GaudiPython.Bindings.iAlgorithm.sysReinitialize
def sysReinitialize(self)
Definition: Bindings.py:449
GaudiPython.Bindings.iDataSvc.getObject
def getObject(self, path, *args)
Definition: Bindings.py:536
GaudiPython.Bindings.AppMgr.execute
def execute(self)
Definition: Bindings.py:1218
GaudiPython.Bindings.AppMgr.__init__
def __init__(self, outputlevel=-1, joboptions=None, selfoptions={}, dllname=None, factname=None)
Definition: Bindings.py:865
GaudiPython.Bindings.iHistogramSvc.retrieveProfile2D
def retrieveProfile2D(self, path)
Definition: Bindings.py:674
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
GaudiPython.Bindings.AppMgr.run
def run(self, n)
Definition: Bindings.py:1204
GaudiKernel.ProcessJobOptions.importOptions
def importOptions(optsfile)
Definition: ProcessJobOptions.py:491
GaudiPython.Bindings.AppMgr.setAlgorithms
def setAlgorithms(self, algs)
Definition: Bindings.py:1097
GaudiPython.Bindings.AppMgr.algorithm
def algorithm(self, name, createIf=False)
Definition: Bindings.py:1015
GaudiPython.Bindings.PropertyEntry.ptype
def ptype(self)
Definition: Bindings.py:243
GaudiPython.Bindings.PropertyEntry
Definition: Bindings.py:213
GaudiPython.Bindings.iService
Definition: Bindings.py:360
GaudiPython.Bindings.PropertyEntry.documentation
def documentation(self)
Definition: Bindings.py:250
GaudiPython.Bindings.iDataSvc.getList
def getList(self, node=cppyy.nullptr, lst=[], rootFID=None)
Definition: Bindings.py:605
GaudiPython.Bindings.PropertyEntry.value
def value(self)
Definition: Bindings.py:240
GaudiPython.Bindings.AppMgr.state
def state(self)
Definition: Bindings.py:989
GaudiPython.Bindings.AppMgr.config
def config(self, **args)
Definition: Bindings.py:1154
GaudiPython.Bindings.iHistogramSvc
Definition: Bindings.py:657
GaudiPython.Bindings._getFIDandEvents
def _getFIDandEvents(pfn)
Definition: Bindings.py:1291
GaudiPython.Bindings._CallbackStreamBufBase
_CallbackStreamBufBase
Definition: Bindings.py:1371
GaudiPython.Bindings.iProperty.getInterface
def getInterface(self)
Definition: Bindings.py:268
gaudirun.type
type
Definition: gaudirun.py:154
GaudiPython.Bindings.iService.restart
def restart(self)
Definition: Bindings.py:387
GaudiPython.Bindings.iNTupleSvc
Definition: Bindings.py:745
GaudiPython.Bindings.AppMgr.exit
def exit(self)
Definition: Bindings.py:1261
GaudiPython.Bindings.AppMgr.detsvc
def detsvc(self)
Definition: Bindings.py:1046
GaudiPython.Bindings.iDataSvc.__getitem__
def __getitem__(self, path)
Definition: Bindings.py:564
GaudiPython.Bindings.PropertyEntry.__doc__
__doc__
Definition: Bindings.py:218
GaudiPython.Bindings.AppMgr.FSMState
def FSMState(self)
Definition: Bindings.py:992
GaudiPython.Bindings.iDataSvc.findObject
def findObject(self, path)
Definition: Bindings.py:517
GaudiPython.Bindings.Interface
Definition: Bindings.py:156
GaudiPython.Bindings.AppMgr.terminate
def terminate(self)
Definition: Bindings.py:1201
GaudiPython.Bindings.AppMgr.targetFSMState
def targetFSMState(self)
Definition: Bindings.py:995
GaudiPython.Bindings.InterfaceCast
Definition: Bindings.py:124
GaudiPython.Bindings.iProperty.__getattr__
def __getattr__(self, name)
Definition: Bindings.py:306
GaudiPython.Bindings.getClass
def getClass(name, libs=[])
Definition: Bindings.py:182
GaudiPython.Bindings.CallbackStreamBuf.callback
callback
Definition: Bindings.py:1377
GaudiPython.Bindings.AppMgr.OutputLevel
OutputLevel
Definition: Bindings.py:909
GaudiPython.Bindings.PyAlgorithm._algmgr
_algmgr
Definition: Bindings.py:1397
GaudiPython.Bindings.iAlgorithm.start
def start(self)
Definition: Bindings.py:416
GaudiPython.Bindings.iService.initialize
def initialize(self)
Definition: Bindings.py:372
GaudiPython.Bindings.AppMgr.histsvc
def histsvc(self, name='HistogramDataSvc')
Definition: Bindings.py:1059
GaudiPython.Bindings.AppMgr.algorithms
def algorithms(self)
Definition: Bindings.py:1022
GaudiPython.Bindings.PropertyEntry._type
_type
Definition: Bindings.py:217
GaudiPython.Bindings.AppMgr.declSvcType
def declSvcType(self, svcname, svctype)
Definition: Bindings.py:1005
GaudiPython.Bindings.PropertyEntry.__init__
def __init__(self, prop)
Definition: Bindings.py:216
GaudiPython.Bindings.iEventSelector
Definition: Bindings.py:820
GaudiPython.Bindings.iProperty.properties
def properties(self)
Definition: Bindings.py:332
GaudiPython.Bindings.AppMgr.evtsel
def evtsel(self)
Definition: Bindings.py:1052
GaudiPython.Bindings.AppMgr.services
def services(self)
Definition: Bindings.py:1011
GaudiPython.Bindings.iAlgTool.name
def name(self)
Definition: Bindings.py:482
GaudiPython.Bindings.PyAlgorithm._svcloc
_svcloc
Definition: Bindings.py:1396
GaudiPython.Bindings.PropertyEntry._property
_property
Definition: Bindings.py:238
GaudiPython.Bindings.AppMgr.__del__
def __del__(self)
Definition: Bindings.py:1276
GaudiPython.Bindings.iAlgorithm.sysRestart
def sysRestart(self)
Definition: Bindings.py:452
GaudiPython.Bindings.iHistogramSvc.retrieve3D
def retrieve3D(self, path)
Definition: Bindings.py:668
GaudiPython.Bindings.iProperty.__init__
def __init__(self, name, ip=cppyy.nullptr)
Definition: Bindings.py:263
GaudiPython.Bindings.iAlgorithm.sysInitialize
def sysInitialize(self)
Definition: Bindings.py:434
GaudiPython.Bindings.iAlgorithm.finalize
def finalize(self)
Definition: Bindings.py:425
GaudiPython.Bindings.iAlgorithm.initialize
def initialize(self)
Definition: Bindings.py:413
GaudiPython.Bindings.PropertyEntry._value
_value
Definition: Bindings.py:221
GaudiPython.Bindings.AppMgr.configure
def configure(self)
Definition: Bindings.py:1195
GaudiPython.Bindings.iAlgorithm.sysStart
def sysStart(self)
Definition: Bindings.py:437
GaudiPython.Bindings.iAlgorithm.sysFinalize
def sysFinalize(self)
Definition: Bindings.py:446
GaudiPython.Bindings.Interface.__init__
def __init__(self, t)
Definition: Bindings.py:157
GaudiPython.Bindings.iDataSvc.__delitem__
def __delitem__(self, path)
Definition: Bindings.py:576
GaudiPython.Bindings.PyAlgorithm.start
def start(self)
Definition: Bindings.py:1410
GaudiPython.Bindings.PropertyEntry.hasDoc
def hasDoc(self)
Definition: Bindings.py:253
GaudiPython.Bindings.iToolSvc.__init__
def __init__(self, name, its)
Definition: Bindings.py:776
GaudiPython.Bindings._PyAlgorithm
_PyAlgorithm
Definition: Bindings.py:1388
GaudiPython.Bindings.iNTupleSvc.defineOutput
def defineOutput(self, files, typ="Gaudi::RootCnvSvc")
Definition: Bindings.py:756
GaudiKernel.Configurable.expandvars
def expandvars(data)
Definition: Configurable.py:47
GaudiPython.Bindings.AppMgr.partsvc
def partsvc(self)
Definition: Bindings.py:1070
GaudiPython.Bindings.AppMgr.evtsvc
def evtsvc(self)
Definition: Bindings.py:1043
GaudiPython.Bindings.AppMgr.filerecordsvc
def filerecordsvc(self)
Definition: Bindings.py:1049
GaudiPython.Bindings.iService.finalize
def finalize(self)
Definition: Bindings.py:381
GaudiPython.Bindings.iToolSvc
Definition: Bindings.py:775
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:97
GaudiPython.Bindings.AppMgr.JobOptionsType
JobOptionsType
Definition: Bindings.py:899
GaudiPython.Bindings.iProperty.name
def name(self)
Definition: Bindings.py:353
GaudiPython.Bindings.iAlgTool
Definition: Bindings.py:459
GaudiPython.Pythonizations.items
items
Definition: Pythonizations.py:526