4 """ GaudiPython.Bindings module. 5 This module provides the basic bindings of the main Gaudi 6 components to Python. It is itself based on the ROOT cppyy 7 Python extension module. 10 __all__ = [
'gbl',
'InterfaceCast',
'Interface',
'PropertyEntry',
11 'AppMgr',
'PyAlgorithm',
'CallbackStreamBuf',
12 'iAlgorithm',
'iDataSvc',
'iHistogramSvc',
'iNTupleSvc',
'iService',
'iAlgTool',
'Helper',
13 'SUCCESS',
'FAILURE',
'toArray',
14 'ROOT',
'makeNullPointer',
'setOwnership',
15 'getClass',
'loaddict',
'deprecation']
17 from GaudiKernel
import ROOT6WorkAroundEnabled
28 print "# WARNING: using PyCintex as cppyy implementation" 29 import PyCintex
as cppyy
49 gbl.gInterpreter.Declare(
'#include "GaudiKernel/Property.h"')
50 Helper = gbl.GaudiPython.Helper
51 StringProperty = gbl.Gaudi.Property(
'std::string')
52 StringPropertyRef = gbl.Gaudi.Property(
'std::string&')
53 GaudiHandleProperty = gbl.GaudiHandleProperty
54 GaudiHandleArrayProperty = gbl.GaudiHandleArrayProperty
55 DataObject = gbl.DataObject
56 SUCCESS = gbl.StatusCode(gbl.StatusCode.SUCCESS,
True)
57 FAILURE = gbl.StatusCode(gbl.StatusCode.FAILURE,
True)
59 cppyy.gbl.gInterpreter.Declare(
''' 60 namespace GaudiPython { namespace Helpers { 61 Gaudi::Property<std::string> mkStringProperty(const std::string &name, 62 const std::string &value) { 63 return Gaudi::Property<std::string>{name, value}; 68 for l
in [l
for l
in dir(Helper)
if re.match(
"^to.*Array$", l)]:
69 exec
"%s = Helper.%s" % (l, l)
73 if hasattr(Helper,
"toArray"):
76 def toArray(typ):
return getattr(Helper,
"toArray")
79 def toArray(typ):
return getattr(Helper,
"toArray<%s>" % typ)
82 ROOT = cppyy.libPyROOT
83 makeNullPointer = cppyy.libPyROOT.MakeNullPointer
84 setOwnership = cppyy.libPyROOT.SetOwnership
88 warnings.warn(
'GaudiPython: ' + message, DeprecationWarning, stacklevel=3)
94 """ Helper class to obtain the adequate interface from a component 95 by using the Gaudi queryInterface() mechanism """ 106 if obj.queryInterface(self.type.interfaceID(), ip).isSuccess():
109 print "ERROR: queryInterface failed for", obj,
"interface:", self.
type 111 print "ERROR: exception", e,
"caught when retrieving interface", self.
type,
"for object", obj
113 traceback.print_stack()
122 InterfaceCast.__init__(self, t)
131 """ Load a LCG dictionary using various mechanisms""" 132 if Helper.loadDynamicLib(dict) == 1:
138 raise ImportError,
'Error loading dictionary library' 145 Function to retrieve a certain C++ class by name and to load dictionary if requested 149 from gaudimodule import getClass 150 # one knows that class is already loaded 151 AppMgr = getClass( 'ApplicationMgr' ) 152 # one knows where to look for class, if not loaded yet 153 MCParticle = getClass( 'MCParticle' , 'EventDict' ) 154 # one knows where to look for class, if not loaded yet 155 Vertex = getClass( 'Vertex' , ['EventDict', 'PhysEventDict'] ) 158 if hasattr(gbl, name):
159 return getattr(gbl, name)
161 if type(libs)
is not list:
165 if hasattr(gbl, name):
166 return getattr(gbl, name)
174 """ holds the value and the documentation string of a property """ 180 if issubclass(
type(prop), GaudiHandleProperty):
182 elif issubclass(
type(prop), GaudiHandleArrayProperty):
183 self.
_value = prop.value()
187 self.
_value = eval(prop.toString(), {}, {})
189 if hasattr(prop,
'value'):
190 self.
_value = prop.value()
192 self.
_value = prop.toString()
194 self.
__doc__ +=
" --- Default value = " + str(self.
_value) +
" --- " 195 if prop.documentation() !=
'none':
207 "Return the underlying property itself " 220 """ Python equivalent to the C++ Property interface """ 226 self.__dict__[
'_ip'] =
None 227 self.__dict__[
'_svcloc'] = gbl.Gaudi.svcLocator()
228 optsvc = Helper.service(self._svcloc,
'JobOptionsSvc')
231 gbl.IJobOptionsSvc)(optsvc)
233 self.__dict__[
'_optsvc'] =
None 234 self.__dict__[
'_name'] = name
245 if not getattr(self, ifname):
246 self.retrieveInterface()
247 return getattr(getattr(self, ifname), method)(*args)
251 The method which is used for setting the property from the given value. 252 - In the case of the valid instance it sets the property through IProperty interface 253 - In the case of placeholder the property is added to JobOptionsCatalogue 255 if hasattr(value,
'toStringProperty'):
257 value =
'%s' % value.toStringProperty()
260 if not gbl.Gaudi.Utils.hasProperty(ip, name):
261 raise AttributeError,
'property %s does not exist' % name
262 prop = ip.getProperty(name)
265 canSetValue = (hasattr(prop,
'value')
and 266 'const&[' not in prop.value.func_doc
and 269 canSetValue = (hasattr(prop,
'value')
and 273 if not prop.setValue(value):
274 raise AttributeError,
'property %s could not be set from %s' % (
277 if tuple ==
type(value):
279 elif hasattr(value,
'toString'):
280 value = value.toString()
281 elif not long ==
type(value):
286 sc = cppyy.gbl.GaudiPython.Helper.setPropertyFromString(
289 sc = prop.fromString(value)
291 raise AttributeError,
'property %s could not be set from %s' % (
294 if type(value) == str:
295 value =
'"%s"' % value
296 elif type(value) == tuple:
298 elif hasattr(value,
'toString'):
299 value = value.toString()
300 elif type(value) == long:
302 sp = gbl.GaudiPython.Helpers.mkStringProperty(name, str(value))
303 self._optsvc.addPropertyToCatalogue(self._name, sp).ignore()
307 The method which returns the value for the given property 308 - In the case of the valid instance it returns the valid property value through IProperty interface 309 - In the case of placeholder the property value is retrieved from JobOptionsCatalogue 313 if not gbl.Gaudi.Utils.hasProperty(ip, name):
314 raise AttributeError,
'property %s does not exist' % name
315 prop = ip.getProperty(name)
316 if StringProperty ==
type(prop):
318 elif StringPropertyRef ==
type(prop):
321 return eval(prop.toString(), {}, {})
325 props = self._optsvc.getProperties(self._name)
327 if not p.name() == name:
331 return eval(p.value(), {}, {})
334 raise AttributeError,
'property %s does not exist' % name
341 props = ip.getProperties()
342 propsFrom = self._name
344 props = self._optsvc.getProperties(self._name)
345 propsFrom =
"jobOptionsSvc" 350 except (ValueError, TypeError), e:
351 raise ValueError,
"gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s" % \
352 (e.__class__.__name__, e.args,
353 propsFrom, p.name(), p.value())
363 """ Python equivalent to IProperty interface """ 366 iProperty.__init__(self, name, isvc)
370 self.__dict__[
'_isvc'] =
None 373 isvc = Helper.service(self._svcloc, self._name)
375 iService.__init__(self, self._name, isvc)
378 "_isvc",
"initialize")
388 "_isvc",
"reinitialize")
403 """ Python equivalent to IAlgorithm interface """ 406 iProperty.__init__(self, name, ialg)
410 self.__dict__[
'_ialg'] =
None 414 gbl.IAlgManager)(self._svcloc), self._name)
416 iAlgorithm.__init__(self, self._name, ialg)
419 "_ialg",
"initialize")
432 "_ialg",
"reinitialize")
438 "_ialg",
"sysInitialize")
444 "_ialg",
"sysExecute")
450 "_ialg",
"sysFinalize")
453 "_ialg",
"sysReinitialize")
456 "_ialg",
"sysRestart")
462 """ Python equivalent to IAlgTool interface (not completed yet) """ 465 iProperty.__init__(self, name, itool)
467 self.__dict__[
'_itool'] = itool
469 self.__dict__[
'_itool'] =
None 470 svc = Helper.service(self._svcloc,
'ToolSvc',
True)
471 self.__dict__[
'_toolsvc'] =
iToolSvc(
'ToolSvc', svc)
474 itool = self._toolsvc._retrieve(self._name)
476 iAlgTool.__init__(self, self._name, itool)
486 return self._itool.name()
495 iService.__init__(self, name, idp)
496 self.__dict__[
'_idp'] =
InterfaceCast(gbl.IDataProviderSvc)(idp)
497 self.__dict__[
'_idm'] =
InterfaceCast(gbl.IDataManagerSvc)(idp)
501 raise AttributeError(
502 'C++ service %s does not exist' % self.__dict__[
'_name'])
503 return Helper.registerObject(self._idp, path, obj)
507 raise AttributeError(
508 'C++ service %s does not exist' % self.__dict__[
'_name'])
509 return Helper.unregisterObject(self._idp, path)
514 return Helper.dataobject(self._idp, path)
520 Get the existing object in TransientStore for the given location 522 - loading of object from persistency is NOT triggered 523 - 'data-on-demand' action is NOT triggered 525 >>> svc = ... ## get the service 526 >>> path = ... ## get the path in Transient Store 527 >>> data = svc.findObject ( path ) ## use the method 531 raise IndexError(
'C++ service %s does not exist' %
532 self.__dict__[
'_name'])
533 return Helper.findobject(self._idp, path)
538 Get object from Transient Store for the given location 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 545 >>> svc = ... ## get the service 546 >>> path = ... ## get the path 548 >>> data = svc.getObject ( path , False ) ## find object in Transient Store 550 ## find object in Transient Store 551 # load form tape or use 'on-demand' action for missing objects : 552 >>> data = svc.getObject ( path , True ) 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 ) 560 raise IndexError(
'C++ service %s does not exist' %
561 self.__dict__[
'_name'])
562 return Helper.getobject(self._idp, path, *args)
566 raise IndexError(
'C++ service %s does not exist' %
567 self.__dict__[
'_name'])
568 return Helper.dataobject(self._idp, path)
572 raise IndexError(
'C++ service %s does not exist' %
573 self.__dict__[
'_name'])
578 raise IndexError(
'C++ service %s does not exist' %
579 self.__dict__[
'_name'])
585 ll = gbl.std.vector(
'IRegistry*')()
586 if type(node)
is str:
590 if self._idm.objectLeaves(node, ll).isSuccess():
597 node = root.registry()
600 print node.identifier()
602 for l
in self.
leaves(node):
605 def getList(self, node=None, lst=[], rootFID=None):
609 node = root.registry()
610 rootFID = node.address().
par()
614 Helper.dataobject(self._idp, node.identifier())
616 lst.append(node.identifier())
617 for l
in self.
leaves(node):
618 if l.address()
and l.address().
par() == rootFID:
628 node = root.registry()
633 Helper.dataobject(self._idp, node.identifier())
635 lst.append(node.identifier())
636 for l
in self.
leaves(node):
645 raise IndexError(
'C++ service %s does not exist' %
646 self.__dict__[
'_name'])
647 return self._idm.setRoot(name, obj)
651 raise IndexError(
'C++ service %s does not exist' %
652 self.__dict__[
'_name'])
653 return self._idm.clearStore()
659 self.__dict__[
'_ihs'] =
InterfaceCast(gbl.IHistogramSvc)(ihs)
660 iDataSvc.__init__(self, name, ihs)
663 return Helper.histo1D(self._ihs, path)
666 return Helper.histo2D(self._ihs, path)
669 return Helper.histo3D(self._ihs, path)
672 return Helper.profile1D(self._ihs, path)
675 return Helper.profile2D(self._ihs, path)
679 Retrieve AIDA histogram or AIDA profile histogram by path in Histogram Transient Store 681 >>> histo = svc.retrieve ( 'path/to/my/histogram' ) 696 Book the histograms(1D,2D&3D) , see IHistogramSvc::book 698 >>> histo = svc.book( .... ) 700 return apply(self._ihs.book, args)
704 Book the profile(1D&2D) histograms, see IHistogramSvc::bookProf 706 >>> histo = svc.bookProf( .... ) 708 return apply(self._ihs.bookProf, args)
712 Retrieve the object from Histogram Transient Store (by path) 713 The reference to AIDA histogram is returned (if possible) 715 >>> histo = svc['path/to/my/histogram'] 720 return iDataSvc.__getitem__(self, path)
724 Retrieve the histogram from Histogram Transient Store (by path) 725 The reference to AIDA histogram is returned (if possible) 727 >>> histo = svc.getAsAIDA ( 'path/to/my/histogram' ) 733 Retrieve the histogram from Histogram Transient Store (by path) 734 The Underlying native ROOT object is returned (if possible) 736 >>> histo = svc.getAsROOT ( 'path/to/my/histogram' ) 738 fun = gbl.Gaudi.Utils.Aida2ROOT.aida2root
750 iDataSvc.__init__(self, name, ints)
753 return apply(self._ints.book, args)
756 """ Defines the mapping between logical names and the output file 758 defineOutput({'LUN1':'MyFile1.root', 'LUN2':'Myfile2.root'}, svc='Gaudi::RootCnvSvc') 760 import Persistency
as prs
761 helper = prs.get(typ)
762 helper.configure(
AppMgr())
764 files[lun], lun=lun)
for lun
in files]
765 if AppMgr().HistogramPersistency ==
'NONE':
766 AppMgr().HistogramPersistency =
"ROOT" 769 return iDataSvc.__getitem__(self, path)
776 iService.__init__(self, name, its)
779 sol = _gaudi.OutputLevel
782 if name.rfind(
'.') == -1:
783 itool = Helper.tool(self._its,
'', name,
None,
False)
784 elif name[0:8] ==
'ToolSvc.':
785 itool = Helper.tool(self._its,
'', name[8:],
None,
False)
786 elif name.count(
'.') > 1:
787 ptool = self.
_retrieve(name[:name.rfind(
'.')])
789 self._its,
'', name[name.rfind(
'.') + 1:], ptool,
False)
791 prop = _gaudi.property(name[:name.rfind(
'.')])
793 self._its,
'', name[name.rfind(
'.') + 1:], prop._ip,
False)
801 def create(self, typ, name=None, parent=None, interface=None):
804 itool = Helper.tool(self._its, typ, name, parent,
True)
811 if type(itool)
is iAlgTool:
812 self._its.releaseTool(itool._itool)
819 Python-image of C++ class IJobOptionsSvc 825 self.__dict__[
'_optsvc'] =
InterfaceCast(gbl.IJobOptionsSvc)(svc)
826 return iService.__init__(self, name, svc)
830 Extract *ALL* properties of the given component 832 >>> jos = gaudi.optSvc() 833 >>> props = jos.getProperties( 'Name' ) 835 props = self._optsvc.getProperties(component)
840 prop = p.name().upper()
842 value = eval(p.value(), {}, {})
851 Get a certain property of the certain component 854 >>> extServices = jos.getProperty( 'ApplicationMgr', 'ExtSvc' ) 858 return all.get(name.upper(),
None)
865 iService.__init__(self,
'EventSelector', Helper.service(
866 gbl.Gaudi.svcLocator(),
'EventSelector'))
867 self.__dict__[
'g'] =
AppMgr()
869 def open(self, stream, typ='Gaudi::RootCnvSvc
', **kwargs): 870 import Persistency
as prs
871 helper = prs.get(typ)
872 helper.configure(self.g)
873 self.
Input = helper.formatInput(stream, **kwargs)
887 newobj = object.__new__(cls)
888 cls.
__init__(newobj, *args, **kwargs)
897 self._evtpro.release()
898 self._svcloc.release()
899 self._appmgr.release()
906 def __init__(self, outputlevel=-1, joboptions=None, selfoptions={},
907 dllname=
None, factname=
None):
912 self.__dict__[
'_exit_called'] =
False 914 self.__dict__[
'_gaudi_ns'] = Gaudi
920 if dllname
and factname:
921 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr(
924 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr(dllname)
926 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr()
927 self.__dict__[
'_svcloc'] = gbl.Gaudi.svcLocator()
928 self.__dict__[
'_algmgr'] =
InterfaceCast(gbl.IAlgManager)(self._appmgr)
930 gbl.IEventProcessor)(self._appmgr)
931 self.__dict__[
'_svcmgr'] =
InterfaceCast(gbl.ISvcManager)(self._appmgr)
932 self.__dict__[
'pyalgorithms'] = []
933 iService.__init__(self,
'ApplicationMgr', self._appmgr)
935 if self.
FSMState() < Gaudi.StateMachine.CONFIGURED:
943 GaudiKernel.Proxy.Configurable.applyConfigurableUsers()
946 selfprops = Configurable.allConfigurables.get(
'ApplicationMgr', {})
948 selfprops =
expandvars(selfprops.getValuedProperties())
949 for p, v
in selfprops.items():
951 for p, v
in selfoptions.items():
954 if outputlevel != -1:
958 ms = self.
service(
'MessageSvc')
959 if 'MessageSvc' in Configurable.allConfigurables:
960 msprops = Configurable.allConfigurables[
'MessageSvc']
961 ms = self.
service(
'MessageSvc')
962 if hasattr(msprops,
"getValuedProperties"):
963 msprops =
expandvars(msprops.getValuedProperties())
964 for p, v
in msprops.items():
966 if outputlevel != -1:
967 ms.OutputLevel = outputlevel
969 self.__dict__[
'_optsvc'] =
InterfaceCast(gbl.IJobOptionsSvc)(
970 Helper.service(self._svcloc,
'JobOptionsSvc'))
972 mkStringProperty = gbl.GaudiPython.Helpers.mkStringProperty
974 c = Configurable.allConfigurables[n]
975 if n
in [
'ApplicationMgr',
'MessageSvc']:
977 for p, v
in c.getValuedProperties().items():
980 if hasattr(Configurable,
"PropertyReference")
and type(v) == Configurable.PropertyReference:
986 elif type(v) == long:
988 self._optsvc.addPropertyToCatalogue(
989 n, mkStringProperty(p, str(v)))
990 if hasattr(Configurable,
"_configurationLocked"):
991 Configurable._configurationLocked =
True 995 atexit.register(self.
exit)
999 root_handler_installed =
False 1000 for h
in atexit._exithandlers:
1002 if hasattr(func,
"__module__")
and func.__module__ ==
"ROOT":
1003 root_handler_installed =
True 1009 if not root_handler_installed:
1010 orig_register = atexit.register
1012 def register(func, *targs, **kargs):
1013 orig_register(func, *targs, **kargs)
1014 if hasattr(func,
"__module__")
and func.__module__ ==
"ROOT":
1015 orig_register(self.
exit)
1018 register.__doc__ = (orig_register.__doc__ +
1019 "\nNote: version hacked by GaudiPython to work " +
1020 "around a problem with the ROOT exit handler")
1021 atexit.register = register
1023 def state(self):
return self._isvc.FSMState()
1030 svc = Helper.service(self._svcloc, name)
1037 self._svcmgr.declareSvcType(svcname, svctype)
1040 return Helper.service(self._svcloc, name,
True)
1043 l = self._svcloc.getServices()
1044 return [s.name()
for s
in l]
1047 alg = Helper.algorithm(self._algmgr, name, createIf)
1054 l = self._algmgr.getAlgorithms()
1055 return [a.name()
for a
in l]
1069 if self.
state() == Gaudi.StateMachine.CONFIGURED:
1071 svc = Helper.service(self._svcloc, name)
1075 return self.
datasvc(
'EventDataSvc')
1078 return self.
datasvc(
'DetectorDataSvc')
1081 return self.
datasvc(
'FileRecordDataSvc')
1084 if self.
state() == Gaudi.StateMachine.CONFIGURED:
1086 if not hasattr(self,
'_evtsel'):
1091 svc = Helper.service(self._svcloc, name)
1095 if name
not in self.ExtSvc:
1096 self.ExtSvc += [name]
1098 svc = Helper.service(self._svcloc, name,
True)
1102 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1104 svc = Helper.service(self._svcloc,
'ParticlePropertySvc')
1108 svc = Helper.service(self._svcloc, name,
True)
1112 svc = Helper.service(self._svcloc, name,
True)
1116 return self._optsvc.readOptions(file)
1119 """ Add an Algorithm to the list of Top algorithms. It can be either a instance of 1120 an Algorithm class or it name """ 1121 if type(alg)
is str:
1124 self.pyalgorithms.append(alg)
1130 self.
topAlg += [alg.name()]
1133 """ Set the list of Top Algorithms. 1134 It can be an individual of a list of algorithms names or instances """ 1135 if type(algs)
is not list:
1139 if type(alg)
is str:
1142 self.pyalgorithms.append(alg)
1147 names.append(alg.name())
1151 """ Remove an Algorithm to the list of Top algorithms. It can be either a instance of 1152 an Algorithm class or it name """ 1154 if type(alg)
is str:
1157 tmp.remove(alg.name())
1158 self.pyalgorithms.remove(alg)
1164 Print the sequence of Algorithms. 1166 def printAlgo(algName, appMgr, prefix=' '):
1167 print prefix + algName
1168 alg = appMgr.algorithm(algName.split(
"/")[-1])
1169 prop = alg.properties()
1170 if prop.has_key(
"Members"):
1171 subs = prop[
"Members"].value()
1173 printAlgo(i.strip(
'"'), appMgr, prefix +
" ")
1175 prefix =
'ApplicationMgr SUCCESS ' 1176 print prefix +
"****************************** Algorithm Sequence ****************************" 1177 for i
in mp[
"TopAlg"].value():
1178 printAlgo(i, self, prefix)
1179 print prefix +
"******************************************************************************" 1183 Simple utility to perform the configuration of Gaudi application. 1184 It reads the set of input job-options files, and set few 1185 additional parameters 'options' through the usage of temporary *.opts file 1187 gaudi.config( files = [ '$GAUSSOPTS/Gauss.opts' , 1188 '$DECFILESROOT/options/10022_010.0GeV.opts' ] , 1189 options = [ 'EventSelector.PrintFreq = 5 ' ] ) 1191 files = args.get(
'files', [])
1195 raise RuntimeError,
' Unable to read file "' + file +
'" ' 1196 options = args.get(
'options',
None)
1199 tmpfilename = tempfile.mktemp()
1200 tmpfile = open(tmpfilename,
'w')
1201 tmpfile.write(
'#pragma print on \n')
1202 tmpfile.write(
'/// File "' + tmpfilename +
1203 '" generated by GaudiPython \n\n')
1205 if type(options)
is dict:
1206 tmpfile.write(
' \t ' + opt +
' = ' +
1207 options[opt] +
' ; // added by GaudiPython \n')
1210 ' \t ' + opt +
' ; // added by GaudiPython \n')
1211 tmpfile.write(
'/// End of file "' + tmpfilename +
1212 '" generated by GaudiPython \n\n')
1216 raise RuntimeError,
' Unable to read file "' + tmpfilename +
'" ' 1217 os.remove(tmpfilename)
1220 if self.
FSMState() != Gaudi.StateMachine.OFFLINE:
1226 _dlls = jos.getProperty(self.
name(),
'DLLs')
1229 libs = [l
for l
in _dlls
if not l
in self.DLLs]
1234 _svcs = jos.getProperty(self.
name(),
'ExtSvc')
1237 svcs = [s
for s
in _svcs
if not s
in self.ExtSvc]
1242 props = jos.getProperties(self.
name())
1245 if 'DLLS' == key
or 'EXTSVC' == key:
1251 return self._appmgr.configure()
1254 return self._appmgr.start()
1257 return self._appmgr.terminate()
1260 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1262 if sc.isFailure()
or self.ReturnCode != 0:
1264 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1266 if sc.isFailure()
or self.ReturnCode != 0:
1268 return self._evtpro.executeRun(n)
1271 return self._evtpro.executeEvent()
1274 return self._evtpro.executeEvent()
1277 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1281 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1286 if not hasattr(self,
'_perssvc'):
1287 self.__dict__[
'_perssvc'] = self.
service(
1288 'EventPersistencySvc',
'IAddressCreator')
1289 if not hasattr(self,
'_filecat'):
1290 self.__dict__[
'_filecat'] = self.
service(
1291 'FileCatalog',
'Gaudi::IFileCatalog')
1292 if not hasattr(self,
'_evtmgr'):
1293 self.__dict__[
'_evtmgr'] = self.
service(
1294 'EventDataSvc',
'IDataManagerSvc')
1296 if pfn.find(
'PFN:') == 0:
1300 if not self._filecat.existsFID(fid):
1301 self._filecat.registerPFN(fid, pfn,
'')
1303 if type(events)
is not list:
1307 gadd = gbl.GenericAddress(0x02, 1, fid,
'/Event', 0, evt)
1309 self._perssvc.createAddress(
1310 gadd.svcType(), gadd.clID(), gadd.par(), gadd.ipar(), oadd)
1312 self._evtmgr.clearStore()
1313 self._evtmgr.setRoot(
'/Event', oadd)
1314 self._evtpro.executeEvent()
1318 if not self._exit_called:
1319 self.__dict__[
'_exit_called'] =
True 1320 Gaudi = self._gaudi_ns
1321 if self.
FSMState() == Gaudi.StateMachine.RUNNING:
1322 self._appmgr.stop().ignore()
1323 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1324 self._appmgr.finalize().ignore()
1325 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1326 self._appmgr.terminate()
1334 ntupleSvc = ntuplesvc
1344 tfile = gbl.TFile.Open(pfn)
1346 raise 'Cannot open ROOT file ', pfn
1347 tree = tfile.Get(
'##Params')
1349 text = tree.db_string
1350 if 'NAME=FID' in text:
1351 fid = text[text.rfind(
'VALUE=') + 6:-1]
1352 nevt = tfile.Get(
'_Event').GetEntries()
1360 """ Get all the properties of a component as a Python dictionary. 1361 The component is instantiated using the component library 1364 if name ==
'GaudiCoreSvc':
1365 if Helper.loadDynamicLib(name) != 1:
1366 raise ImportError,
'Error loading component library ' + name
1367 factorylist = gbl.FactoryTable.instance().getEntries()
1369 g =
AppMgr(outputlevel=7)
1371 g =
AppMgr(outputlevel=7)
1372 if Helper.loadDynamicLib(name) != 1:
1373 raise ImportError,
'Error loading component library ' + name
1374 factorylist = gbl.FactoryTable.instance().getEntries()
1376 svcloc = gbl.Gaudi.svcLocator()
1377 dummysvc = gbl.Service(
'DummySvc', svcloc)
1378 for factory
in factories:
1385 elif factory.ident() ==
'ApplicationMgr':
1386 ctype =
'ApplicationMgr' 1389 cname = factory.ident().split()[-1]
1390 if ctype
in (
'Algorithm',
'Service',
'AlgTool',
'ApplicationMgr'):
1392 if ctype ==
'AlgTool':
1393 obj = factory.instantiate(dummysvc)
1395 obj = factory.instantiate(svcloc)
1396 except RuntimeError, text:
1397 print 'Error instantiating', cname,
' from ', name
1401 properties[cname] = [ctype, prop.properties()]
1411 for i
in range(factories.size()):
1412 factory = factories.front()
1413 result.append(factory)
1414 factories.pop_front()
1415 for factory
in result:
1416 factories.push_back(factory)
1422 _CallbackStreamBufBase = gbl.GaudiPython.CallbackStreamBuf
1427 _CallbackStreamBufBase.__init__(self, self)
1439 _PyAlgorithm = gbl.GaudiPython.PyAlgorithm
1445 name = self.__class__.__name__
1446 _PyAlgorithm.__init__(self, self, name)
1449 sc = self._algmgr.addAlgorithm(self)
1451 raise RuntimeError,
'Unable to add Algorithm' 1454 sc = self._algmgr.removeAlgorithm(self)
1477 readline.parse_and_bind(
"tab: complete")
def declSvcType(self, svcname, svctype)
def getHistoNames(self, node=None, lst=[])
def setAlgorithms(self, algs)
def printAlgsSequences(self)
def createSvc(self, name)
def histsvc(self, name='HistogramDataSvc')
def __init__(self, name, ints)
def __init__(self, name, isvc=None)
def retrieveInterface(self)
def runSelectedEvents(self, pfn, events)
def __getitem__(self, path)
def findObject(self, path)
def unregisterObject(self, path)
def getClass(name, libs=[])
def retrieveProfile1D(self, path)
def getAsAIDA(self, path)
def getProperties(self, component)
decltype(auto) constexpr apply(F &&f, Tuple &&t) noexcept(noexcept( detail::apply_impl(std::forward< F >(f), std::forward< Tuple >(t), std::make_index_sequence< std::tuple_size< std::remove_reference_t< Tuple >>::value >{})))
def _getFIDandEvents(pfn)
def __init__(self, name, ialg=None)
def open(self, stream, typ='Gaudi::RootCnvSvc', kwargs)
def toolsvc(self, name='ToolSvc')
def __getitem__(self, path)
def __init__(self, name, ip=None)
def ROOT6WorkAroundEnabled(id=None)
def service(self, name, interface=None)
def getObject(self, path, args)
def __init__(self, callback)
def retrieveInterface(self)
def algorithm(self, name, createIf=False)
def retrieve1D(self, path)
def retrieve3D(self, path)
def __init__(self, name, svc)
def __new__(cls, args, kwargs)
def sysReinitialize(self)
def _sync(self, string=None)
def removeAlgorithm(self, alg)
def __init__(self, name, idp)
def importOptions(optsfile)
def __delitem__(self, path)
def defineOutput(self, files, typ="Gaudi::RootCnvSvc")
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
def addAlgorithm(self, alg)
def retrieveProfile2D(self, path)
def retrieve2D(self, path)
def getProperty(self, component, name)
def __setitem__(self, path, obj)
def retrieveInterface(self)
def __init__(self, outputlevel=-1, joboptions=None, selfoptions={}, dllname=None, factname=None)
def __init__(self, name, ihs)
def ntuplesvc(self, name='NTupleSvc')
def getAsROOT(self, path)
def dump(self, node=None)
double fun(const std::vector< double > &x)
def __call_interface_method__(self, ifname, method, args)
def retrieveObject(self, path)
def __getitem__(self, path)
def _copyFactoriesFromList(factories)
def setRoot(self, name, obj)
def __init__(self, name=None)
def registerObject(self, path, obj)
def optSvc(self, name='JobOptionsSvc')
def getComponentProperties(name)
def leaves(self, node=None)
def __getattr__(self, name)
def getList(self, node=None, lst=[], rootFID=None)
def readOptions(self, file)
def __setattr__(self, name, value)