3 """ GaudiPython.Bindings module. 4 This module provides the basic bindings of the main Gaudi 5 components to Python. It is itself based on the ROOT cppyy 6 Python extension module. 10 'gbl',
'InterfaceCast',
'Interface',
'PropertyEntry',
'AppMgr',
11 'PyAlgorithm',
'CallbackStreamBuf',
'iAlgorithm',
'iDataSvc',
12 'iHistogramSvc',
'iNTupleSvc',
'iService',
'iAlgTool',
'Helper',
'SUCCESS',
13 'FAILURE',
'toArray',
'ROOT',
'makeNullPointer',
'setOwnership',
14 'getClass',
'loaddict',
'deprecation' 17 from GaudiKernel
import ROOT6WorkAroundEnabled
28 print "# WARNING: using PyCintex as cppyy implementation" 29 import PyCintex
as cppyy
40 from GaudiKernel.Proxy.Configurable
import Configurable, getNeededConfigurables
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"):
77 return getattr(Helper,
"toArray")
81 return getattr(Helper,
"toArray<%s>" % typ)
85 ROOT = cppyy.libPyROOT
86 makeNullPointer = cppyy.libPyROOT.MakeNullPointer
87 setOwnership = cppyy.libPyROOT.SetOwnership
91 warnings.warn(
'GaudiPython: ' + message, DeprecationWarning, stacklevel=3)
98 """ Helper class to obtain the adequate interface from a component 99 by using the Gaudi queryInterface() mechanism """ 110 if obj.queryInterface(self.type.interfaceID(), ip).isSuccess():
113 print "ERROR: queryInterface failed for", obj,
"interface:", self.
type 114 except Exception
as e:
115 print "ERROR: exception", e,
"caught when retrieving interface", self.
type,
"for object", obj
117 traceback.print_stack()
129 InterfaceCast.__init__(self, t)
139 """ Load a LCG dictionary using various mechanisms""" 140 if Helper.loadDynamicLib(dict) == 1:
146 raise ImportError(
'Error loading dictionary library')
154 Function to retrieve a certain C++ class by name and to load dictionary if requested 158 from gaudimodule import getClass 159 # one knows that class is already loaded 160 AppMgr = getClass( 'ApplicationMgr' ) 161 # one knows where to look for class, if not loaded yet 162 MCParticle = getClass( 'MCParticle' , 'EventDict' ) 163 # one knows where to look for class, if not loaded yet 164 Vertex = getClass( 'Vertex' , ['EventDict', 'PhysEventDict'] ) 167 if hasattr(gbl, name):
168 return getattr(gbl, name)
170 if type(libs)
is not list:
174 if hasattr(gbl, name):
175 return getattr(gbl, name)
184 """ holds the value and the documentation string of a property """ 190 if issubclass(
type(prop), GaudiHandleProperty):
192 elif issubclass(
type(prop), GaudiHandleArrayProperty):
193 self.
_value = prop.value()
197 self.
_value = eval(prop.toString(), {}, {})
199 if hasattr(prop,
'value'):
200 self.
_value = prop.value()
202 self.
_value = prop.toString()
204 self.
__doc__ +=
" --- Default value = " + str(self.
_value) +
" --- " 205 if prop.documentation() !=
'none':
217 "Return the underlying property itself " 231 """ Python equivalent to the C++ Property interface """ 237 self.__dict__[
'_ip'] =
None 238 self.__dict__[
'_svcloc'] = gbl.Gaudi.svcLocator()
239 optsvc = Helper.service(self._svcloc,
'JobOptionsSvc')
242 gbl.IJobOptionsSvc)(optsvc)
244 self.__dict__[
'_optsvc'] =
None 245 self.__dict__[
'_name'] = name
256 if not getattr(self, ifname):
257 self.retrieveInterface()
258 return getattr(getattr(self, ifname), method)(*args)
262 The method which is used for setting the property from the given value. 263 - In the case of the valid instance it sets the property through IProperty interface 264 - In the case of placeholder the property is added to JobOptionsCatalogue 266 if hasattr(value,
'toStringProperty'):
268 value =
'%s' % value.toStringProperty()
271 if not gbl.Gaudi.Utils.hasProperty(ip, name):
272 raise AttributeError(
'property %s does not exist' % name)
273 prop = ip.getProperty(name)
276 canSetValue = (hasattr(prop,
'value')
277 and 'const&[' not in prop.value.func_doc
278 and type(value) ==
type(prop.value()))
280 canSetValue = (hasattr(prop,
'value')
281 and type(value) ==
type(prop.value()))
284 if not prop.setValue(value):
285 raise AttributeError(
286 'property %s could not be set from %s' % (name, value))
288 if tuple ==
type(value):
290 elif hasattr(value,
'toString'):
291 value = value.toString()
292 elif not long ==
type(value):
297 sc = cppyy.gbl.GaudiPython.Helper.setPropertyFromString(
300 sc = prop.fromString(value)
302 raise AttributeError(
303 'property %s could not be set from %s' % (name, value))
305 if type(value) == str:
306 value =
'"%s"' % value
307 elif type(value) == tuple:
309 elif hasattr(value,
'toString'):
310 value = value.toString()
311 elif type(value) == long:
313 sp = gbl.GaudiPython.Helpers.mkStringProperty(name, str(value))
314 self._optsvc.addPropertyToCatalogue(self._name, sp).ignore()
318 The method which returns the value for the given property 319 - In the case of the valid instance it returns the valid property value through IProperty interface 320 - In the case of placeholder the property value is retrieved from JobOptionsCatalogue 324 if not gbl.Gaudi.Utils.hasProperty(ip, name):
325 raise AttributeError(
'property %s does not exist' % name)
326 prop = ip.getProperty(name)
327 if StringProperty ==
type(prop):
329 elif StringPropertyRef ==
type(prop):
332 return eval(prop.toString(), {}, {})
336 props = self._optsvc.getProperties(self._name)
338 if not p.name() == name:
342 return eval(p.value(), {}, {})
345 raise AttributeError(
'property %s does not exist' % name)
352 props = ip.getProperties()
353 propsFrom = self._name
355 props = self._optsvc.getProperties(self._name)
356 propsFrom =
"jobOptionsSvc" 361 except (ValueError, TypeError)
as e:
362 raise ValueError(
"gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s" % \
363 (e.__class__.__name__, e.args,
364 propsFrom, p.name(), p.value()))
375 """ Python equivalent to IProperty interface """ 378 iProperty.__init__(self, name, isvc)
382 self.__dict__[
'_isvc'] =
None 385 isvc = Helper.service(self._svcloc, self._name)
387 iService.__init__(self, self._name, isvc)
418 """ Python equivalent to IAlgorithm interface """ 421 iProperty.__init__(self, name, ialg)
425 self.__dict__[
'_ialg'] =
None 428 ialg = Helper.algorithm(
431 iAlgorithm.__init__(self, self._name, ialg)
480 """ Python equivalent to IAlgTool interface (not completed yet) """ 483 iProperty.__init__(self, name, itool)
485 self.__dict__[
'_itool'] = itool
487 self.__dict__[
'_itool'] =
None 488 svc = Helper.service(self._svcloc,
'ToolSvc',
True)
489 self.__dict__[
'_toolsvc'] =
iToolSvc(
'ToolSvc', svc)
492 itool = self._toolsvc._retrieve(self._name)
494 iAlgTool.__init__(self, self._name, itool)
507 return self._itool.name()
517 iService.__init__(self, name, idp)
518 self.__dict__[
'_idp'] =
InterfaceCast(gbl.IDataProviderSvc)(idp)
519 self.__dict__[
'_idm'] =
InterfaceCast(gbl.IDataManagerSvc)(idp)
523 raise AttributeError(
524 'C++ service %s does not exist' % self.__dict__[
'_name'])
525 return Helper.registerObject(self._idp, path, obj)
529 raise AttributeError(
530 'C++ service %s does not exist' % self.__dict__[
'_name'])
531 return Helper.unregisterObject(self._idp, path)
536 return Helper.dataobject(self._idp, path)
543 Get the existing object in TransientStore for the given location 545 - loading of object from persistency is NOT triggered 546 - 'data-on-demand' action is NOT triggered 548 >>> svc = ... ## get the service 549 >>> path = ... ## get the path in Transient Store 550 >>> data = svc.findObject ( path ) ## use the method 555 'C++ service %s does not exist' % self.__dict__[
'_name'])
556 return Helper.findobject(self._idp, path)
561 Get object from Transient Store for the given location 564 - path : Location of object in Transient Store 565 - retrieve (bool) True : retrieve versus find 566 - disable on-demand (bool) False : temporary disable 'on-demand' actions 568 >>> svc = ... ## get the service 569 >>> path = ... ## get the path 571 >>> data = svc.getObject ( path , False ) ## find object in Transient Store 573 ## find object in Transient Store 574 # load form tape or use 'on-demand' action for missing objects : 575 >>> data = svc.getObject ( path , True ) 577 ## find object in Transient Store 578 # load from tape or for missing objects, disable 'on-demand'-actions 579 >>> data = svc.getObject ( path , True , True ) 584 'C++ service %s does not exist' % self.__dict__[
'_name'])
585 return Helper.getobject(self._idp, path, *args)
590 'C++ service %s does not exist' % self.__dict__[
'_name'])
591 return Helper.dataobject(self._idp, path)
596 'C++ service %s does not exist' % self.__dict__[
'_name'])
602 'C++ service %s does not exist' % self.__dict__[
'_name'])
608 ll = gbl.std.vector(
'IRegistry*')()
609 if type(node)
is str:
613 if self._idm.objectLeaves(node, ll).isSuccess():
620 node = root.registry()
623 print node.identifier()
625 for l
in self.
leaves(node):
628 def getList(self, node=None, lst=[], rootFID=None):
632 node = root.registry()
633 rootFID = node.address().
par()
637 Helper.dataobject(self._idp, node.identifier())
639 lst.append(node.identifier())
640 for l
in self.
leaves(node):
641 if l.address()
and l.address().
par() == rootFID:
651 node = root.registry()
656 Helper.dataobject(self._idp, node.identifier())
658 lst.append(node.identifier())
659 for l
in self.
leaves(node):
669 'C++ service %s does not exist' % self.__dict__[
'_name'])
670 return self._idm.setRoot(name, obj)
675 'C++ service %s does not exist' % self.__dict__[
'_name'])
676 return self._idm.clearStore()
682 self.__dict__[
'_ihs'] =
InterfaceCast(gbl.IHistogramSvc)(ihs)
683 iDataSvc.__init__(self, name, ihs)
686 return Helper.histo1D(self._ihs, path)
689 return Helper.histo2D(self._ihs, path)
692 return Helper.histo3D(self._ihs, path)
695 return Helper.profile1D(self._ihs, path)
698 return Helper.profile2D(self._ihs, path)
702 Retrieve AIDA histogram or AIDA profile histogram by path in Histogram Transient Store 704 >>> histo = svc.retrieve ( 'path/to/my/histogram' ) 719 Book the histograms(1D,2D&3D) , see IHistogramSvc::book 721 >>> histo = svc.book( .... ) 723 return self._ihs.book(*args)
727 Book the profile(1D&2D) histograms, see IHistogramSvc::bookProf 729 >>> histo = svc.bookProf( .... ) 731 return self._ihs.bookProf(*args)
735 Retrieve the object from Histogram Transient Store (by path) 736 The reference to AIDA histogram is returned (if possible) 738 >>> histo = svc['path/to/my/histogram'] 743 return iDataSvc.__getitem__(self, path)
747 Retrieve the histogram from Histogram Transient Store (by path) 748 The reference to AIDA histogram is returned (if possible) 750 >>> histo = svc.getAsAIDA ( 'path/to/my/histogram' ) 756 Retrieve the histogram from Histogram Transient Store (by path) 757 The Underlying native ROOT object is returned (if possible) 759 >>> histo = svc.getAsROOT ( 'path/to/my/histogram' ) 761 fun = gbl.Gaudi.Utils.Aida2ROOT.aida2root
774 iDataSvc.__init__(self, name, ints)
777 return self._ints.book(*args)
780 """ Defines the mapping between logical names and the output file 782 defineOutput({'LUN1':'MyFile1.root', 'LUN2':'Myfile2.root'}, svc='Gaudi::RootCnvSvc') 784 import Persistency
as prs
785 helper = prs.get(typ)
786 helper.configure(
AppMgr())
788 helper.formatOutput(files[lun], lun=lun)
for lun
in files
790 if AppMgr().HistogramPersistency ==
'NONE':
791 AppMgr().HistogramPersistency =
"ROOT" 794 return iDataSvc.__getitem__(self, path)
801 iService.__init__(self, name, its)
804 sol = _gaudi.OutputLevel
807 if name.rfind(
'.') == -1:
808 itool = Helper.tool(self._its,
'', name,
None,
False)
809 elif name[0:8] ==
'ToolSvc.':
810 itool = Helper.tool(self._its,
'', name[8:],
None,
False)
811 elif name.count(
'.') > 1:
812 ptool = self.
_retrieve(name[:name.rfind(
'.')])
813 itool = Helper.tool(self._its,
'', name[name.rfind(
'.') + 1:],
816 prop = _gaudi.property(name[:name.rfind(
'.')])
817 itool = Helper.tool(self._its,
'', name[name.rfind(
'.') + 1:],
826 def create(self, typ, name=None, parent=None, interface=None):
829 itool = Helper.tool(self._its, typ, name, parent,
True)
836 if type(itool)
is iAlgTool:
837 self._its.releaseTool(itool._itool)
845 Python-image of C++ class IJobOptionsSvc 852 self.__dict__[
'_optsvc'] =
InterfaceCast(gbl.IJobOptionsSvc)(svc)
853 return iService.__init__(self, name, svc)
857 Extract *ALL* properties of the given component 859 >>> jos = gaudi.optSvc() 860 >>> props = jos.getProperties( 'Name' ) 862 props = self._optsvc.getProperties(component)
867 prop = p.name().upper()
869 value = eval(p.value(), {}, {})
878 Get a certain property of the certain component 881 >>> extServices = jos.getProperty( 'ApplicationMgr', 'ExtSvc' ) 885 return all.get(name.upper(),
None)
894 self,
'EventSelector',
895 Helper.service(gbl.Gaudi.svcLocator(),
'EventSelector'))
896 self.__dict__[
'g'] =
AppMgr()
898 def open(self, stream, typ='Gaudi::RootCnvSvc
', **kwargs): 899 import Persistency
as prs
900 helper = prs.get(typ)
901 helper.configure(self.g)
902 self.
Input = helper.formatInput(stream, **kwargs)
917 newobj = object.__new__(cls)
918 cls.
__init__(newobj, *args, **kwargs)
927 self._evtpro.release()
928 self._svcloc.release()
929 self._appmgr.release()
946 self.__dict__[
'_exit_called'] =
False 948 self.__dict__[
'_gaudi_ns'] = Gaudi
950 from GaudiKernel.Proxy.Configurable
import expandvars
956 if dllname
and factname:
957 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr(
960 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr(dllname)
962 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr()
963 self.__dict__[
'_svcloc'] = gbl.Gaudi.svcLocator()
964 self.__dict__[
'_algmgr'] =
InterfaceCast(gbl.IAlgManager)(self._appmgr)
965 self.__dict__[
'_evtpro'] =
InterfaceCast(gbl.IEventProcessor)(
967 self.__dict__[
'_svcmgr'] =
InterfaceCast(gbl.ISvcManager)(self._appmgr)
968 self.__dict__[
'pyalgorithms'] = []
969 iService.__init__(self,
'ApplicationMgr', self._appmgr)
972 ) < Gaudi.StateMachine.CONFIGURED:
978 import GaudiKernel.Proxy.Configurable
979 if hasattr(GaudiKernel.Proxy.Configurable,
980 "applyConfigurableUsers"):
981 GaudiKernel.Proxy.Configurable.applyConfigurableUsers()
984 selfprops = Configurable.allConfigurables.get(
'ApplicationMgr', {})
986 selfprops =
expandvars(selfprops.getValuedProperties())
987 for p, v
in selfprops.items():
989 for p, v
in selfoptions.items():
992 if outputlevel != -1:
996 ms = self.
service(
'MessageSvc')
997 if 'MessageSvc' in Configurable.allConfigurables:
998 msprops = Configurable.allConfigurables[
'MessageSvc']
999 ms = self.
service(
'MessageSvc')
1000 if hasattr(msprops,
"getValuedProperties"):
1001 msprops =
expandvars(msprops.getValuedProperties())
1002 for p, v
in msprops.items():
1004 if outputlevel != -1:
1005 ms.OutputLevel = outputlevel
1007 self.__dict__[
'_optsvc'] =
InterfaceCast(gbl.IJobOptionsSvc)(
1008 Helper.service(self._svcloc,
'JobOptionsSvc'))
1010 mkStringProperty = gbl.GaudiPython.Helpers.mkStringProperty
1012 c = Configurable.allConfigurables[n]
1013 if n
in [
'ApplicationMgr',
'MessageSvc']:
1015 for p, v
in c.getValuedProperties().items():
1018 if hasattr(Configurable,
"PropertyReference")
and type(
1019 v) == Configurable.PropertyReference:
1025 elif type(v) == long:
1027 self._optsvc.addPropertyToCatalogue(
1028 n, mkStringProperty(p, str(v)))
1029 if hasattr(Configurable,
"_configurationLocked"):
1030 Configurable._configurationLocked =
True 1034 atexit.register(self.
exit)
1038 root_handler_installed =
False 1039 for h
in atexit._exithandlers:
1041 if hasattr(func,
"__module__")
and func.__module__ ==
"ROOT":
1042 root_handler_installed =
True 1048 if not root_handler_installed:
1049 orig_register = atexit.register
1051 def register(func, *targs, **kargs):
1052 orig_register(func, *targs, **kargs)
1053 if hasattr(func,
"__module__")
and func.__module__ ==
"ROOT":
1054 orig_register(self.
exit)
1058 register.__doc__ = (
1059 orig_register.__doc__ +
1060 "\nNote: version hacked by GaudiPython to work " +
1061 "around a problem with the ROOT exit handler")
1062 atexit.register = register
1065 return self._isvc.FSMState()
1068 return self._isvc.FSMState()
1071 return self._isvc.targetFSMState()
1074 svc = Helper.service(self._svcloc, name)
1081 self._svcmgr.declareSvcType(svcname, svctype)
1084 return Helper.service(self._svcloc, name,
True)
1087 l = self._svcloc.getServices()
1088 return [s.name()
for s
in l]
1091 alg = Helper.algorithm(self._algmgr, name, createIf)
1098 l = self._algmgr.getAlgorithms()
1099 return [a.name()
for a
in l]
1113 if self.
state() == Gaudi.StateMachine.CONFIGURED:
1115 svc = Helper.service(self._svcloc, name)
1119 return self.
datasvc(
'EventDataSvc')
1122 return self.
datasvc(
'DetectorDataSvc')
1125 return self.
datasvc(
'FileRecordDataSvc')
1128 if self.
state() == Gaudi.StateMachine.CONFIGURED:
1130 if not hasattr(self,
'_evtsel'):
1135 svc = Helper.service(self._svcloc, name)
1139 if name
not in self.ExtSvc:
1140 self.ExtSvc += [name]
1142 svc = Helper.service(self._svcloc, name,
True)
1146 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1148 svc = Helper.service(self._svcloc,
'ParticlePropertySvc')
1152 svc = Helper.service(self._svcloc, name,
True)
1156 svc = Helper.service(self._svcloc, name,
True)
1160 return self._optsvc.readOptions(file)
1163 """ Add an Algorithm to the list of Top algorithms. It can be either a instance of 1164 an Algorithm class or it name """ 1165 if type(alg)
is str:
1168 self.pyalgorithms.append(alg)
1174 self.
topAlg += [alg.name()]
1177 """ Set the list of Top Algorithms. 1178 It can be an individual of a list of algorithms names or instances """ 1179 if type(algs)
is not list:
1183 if type(alg)
is str:
1186 self.pyalgorithms.append(alg)
1191 names.append(alg.name())
1195 """ Remove an Algorithm to the list of Top algorithms. It can be either a instance of 1196 an Algorithm class or it name """ 1198 if type(alg)
is str:
1201 tmp.remove(alg.name())
1202 self.pyalgorithms.remove(alg)
1208 Print the sequence of Algorithms. 1211 def printAlgo(algName, appMgr, prefix=' '):
1212 print prefix + algName
1213 alg = appMgr.algorithm(algName.split(
"/")[-1])
1214 prop = alg.properties()
1215 if prop.has_key(
"Members"):
1216 subs = prop[
"Members"].value()
1218 printAlgo(i.strip(
'"'), appMgr, prefix +
" ")
1221 prefix =
'ApplicationMgr SUCCESS ' 1222 print prefix +
"****************************** Algorithm Sequence ****************************" 1223 for i
in mp[
"TopAlg"].value():
1224 printAlgo(i, self, prefix)
1225 print prefix +
"******************************************************************************" 1229 Simple utility to perform the configuration of Gaudi application. 1230 It reads the set of input job-options files, and set few 1231 additional parameters 'options' through the usage of temporary *.opts file 1233 gaudi.config( files = [ '$GAUSSOPTS/Gauss.opts' , 1234 '$DECFILESROOT/options/10022_010.0GeV.opts' ] , 1235 options = [ 'EventSelector.PrintFreq = 5 ' ] ) 1237 files = args.get(
'files', [])
1241 raise RuntimeError(
' Unable to read file "' + file +
'" ')
1242 options = args.get(
'options',
None)
1245 tmpfilename = tempfile.mktemp()
1246 tmpfile = open(tmpfilename,
'w')
1247 tmpfile.write(
'#pragma print on \n')
1248 tmpfile.write(
'/// File "' + tmpfilename +
1249 '" generated by GaudiPython \n\n')
1251 if type(options)
is dict:
1252 tmpfile.write(
' \t ' + opt +
' = ' + options[opt] +
1253 ' ; // added by GaudiPython \n')
1255 tmpfile.write(
' \t ' + opt +
1256 ' ; // added by GaudiPython \n')
1257 tmpfile.write(
'/// End of file "' + tmpfilename +
1258 '" generated by GaudiPython \n\n')
1262 raise RuntimeError(
' Unable to read file "' + tmpfilename +
1264 os.remove(tmpfilename)
1267 if self.
FSMState() != Gaudi.StateMachine.OFFLINE:
1273 _dlls = jos.getProperty(self.
name(),
'DLLs')
1276 libs = [l
for l
in _dlls
if not l
in self.DLLs]
1281 _svcs = jos.getProperty(self.
name(),
'ExtSvc')
1284 svcs = [s
for s
in _svcs
if not s
in self.ExtSvc]
1289 props = jos.getProperties(self.
name())
1292 if 'DLLS' == key
or 'EXTSVC' == key:
1298 return self._appmgr.configure()
1301 return self._appmgr.start()
1304 return self._appmgr.terminate()
1307 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1309 if sc.isFailure()
or self.ReturnCode != 0:
1311 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1313 if sc.isFailure()
or self.ReturnCode != 0:
1315 return self._evtpro.executeRun(n)
1318 return self._evtpro.executeEvent()
1321 return self._evtpro.executeEvent()
1324 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1328 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1333 if not hasattr(self,
'_perssvc'):
1334 self.__dict__[
'_perssvc'] = self.
service(
'EventPersistencySvc',
1336 if not hasattr(self,
'_filecat'):
1337 self.__dict__[
'_filecat'] = self.
service(
'FileCatalog',
1338 'Gaudi::IFileCatalog')
1339 if not hasattr(self,
'_evtmgr'):
1340 self.__dict__[
'_evtmgr'] = self.
service(
'EventDataSvc',
1343 if pfn.find(
'PFN:') == 0:
1347 if not self._filecat.existsFID(fid):
1348 self._filecat.registerPFN(fid, pfn,
'')
1350 if type(events)
is not list:
1354 gadd = gbl.GenericAddress(0x02, 1, fid,
'/Event', 0, evt)
1356 self._perssvc.createAddress(gadd.svcType(), gadd.clID(),
1357 gadd.par(), gadd.ipar(), oadd)
1359 self._evtmgr.clearStore()
1360 self._evtmgr.setRoot(
'/Event', oadd)
1361 self._evtpro.executeEvent()
1365 if not self._exit_called:
1366 self.__dict__[
'_exit_called'] =
True 1367 Gaudi = self._gaudi_ns
1368 if self.
FSMState() == Gaudi.StateMachine.RUNNING:
1369 self._appmgr.stop().ignore()
1370 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1371 self._appmgr.finalize().ignore()
1372 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1373 self._appmgr.terminate()
1383 ntupleSvc = ntuplesvc
1394 tfile = gbl.TFile.Open(pfn)
1396 raise IOError(
'Cannot open ROOT file {0}'.
format(pfn))
1397 tree = tfile.Get(
'##Params')
1399 text = tree.db_string
1400 if 'NAME=FID' in text:
1401 fid = text[text.rfind(
'VALUE=') + 6:-1]
1402 nevt = tfile.Get(
'_Event').GetEntries()
1411 """ Get all the properties of a component as a Python dictionary. 1412 The component is instantiated using the component library 1415 if name ==
'GaudiCoreSvc':
1416 if Helper.loadDynamicLib(name) != 1:
1417 raise ImportError(
'Error loading component library ' + name)
1418 factorylist = gbl.FactoryTable.instance().getEntries()
1420 g =
AppMgr(outputlevel=7)
1422 g =
AppMgr(outputlevel=7)
1423 if Helper.loadDynamicLib(name) != 1:
1424 raise ImportError(
'Error loading component library ' + name)
1425 factorylist = gbl.FactoryTable.instance().getEntries()
1427 svcloc = gbl.Gaudi.svcLocator()
1428 dummysvc = gbl.Service(
'DummySvc', svcloc)
1429 for factory
in factories:
1436 elif factory.ident() ==
'ApplicationMgr':
1437 ctype =
'ApplicationMgr' 1440 cname = factory.ident().split()[-1]
1441 if ctype
in (
'Algorithm',
'Service',
'AlgTool',
'ApplicationMgr'):
1443 if ctype ==
'AlgTool':
1444 obj = factory.instantiate(dummysvc)
1446 obj = factory.instantiate(svcloc)
1447 except RuntimeError
as text:
1448 print 'Error instantiating', cname,
' from ', name
1452 properties[cname] = [ctype, prop.properties()]
1462 for i
in range(factories.size()):
1463 factory = factories.front()
1464 result.append(factory)
1465 factories.pop_front()
1466 for factory
in result:
1467 factories.push_back(factory)
1473 _CallbackStreamBufBase = gbl.GaudiPython.CallbackStreamBuf
1478 _CallbackStreamBufBase.__init__(self, self)
1490 _PyAlgorithm = gbl.GaudiPython.PyAlgorithm
1496 name = self.__class__.__name__
1497 _PyAlgorithm.__init__(self, self, name)
1500 sc = self._algmgr.addAlgorithm(self)
1502 raise RuntimeError(
'Unable to add Algorithm')
1505 sc = self._algmgr.removeAlgorithm(self)
1535 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)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
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)
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)
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)