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. 18 from __future__
import absolute_import, print_function
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' 28 from GaudiKernel
import ROOT6WorkAroundEnabled
37 with warnings.catch_warnings():
38 warnings.simplefilter(
"ignore")
41 if sys.version_info >= (3, ):
51 from .
import Pythonizations
54 from GaudiKernel.Proxy.Configurable
import Configurable, getNeededConfigurables
63 gbl.gInterpreter.Declare(
'#include "GaudiKernel/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)
73 if hasattr(cppyy,
'nullptr'):
74 nullptr = cppyy.nullptr
75 elif hasattr(gbl,
'nullptr'):
80 cppyy.gbl.gInterpreter.Declare(
''' 81 namespace GaudiPython { namespace Helpers { 82 Gaudi::Property<std::string> mkStringProperty(const std::string &name, 83 const std::string &value) { 84 return Gaudi::Property<std::string>{name, value}; 89 for l
in [l
for l
in dir(Helper)
if re.match(
"^to.*Array$", l)]:
90 exec(
"%s = Helper.%s" % (l, l))
94 if hasattr(Helper,
"toArray"):
98 return getattr(Helper,
"toArray")
102 return getattr(Helper,
"toArray<%s>" % typ)
107 if hasattr(cppyy,
'libPyROOT'):
108 ROOT = cppyy.libPyROOT
111 makeNullPointer = ROOT.MakeNullPointer
112 setOwnership = ROOT.SetOwnership
116 warnings.warn(
'GaudiPython: ' + message, DeprecationWarning, stacklevel=3)
123 """ Helper class to obtain the adequate interface from a component 124 by using the Gaudi queryInterface() mechanism """ 135 if obj.queryInterface(self.
type.interfaceID(), ip).isSuccess():
138 print(
"ERROR: queryInterface failed for", obj,
139 "interface:", self.
type)
140 except Exception
as e:
141 print(
"ERROR: exception", e,
142 "caught when retrieving interface", self.
type,
145 traceback.print_stack()
157 InterfaceCast.__init__(self, t)
167 """ Load a LCG dictionary using various mechanisms""" 168 if Helper.loadDynamicLib(dict) == 1:
174 raise ImportError(
'Error loading dictionary library')
182 Function to retrieve a certain C++ class by name and to load dictionary if requested 186 from gaudimodule import getClass 187 # one knows that class is already loaded 188 AppMgr = getClass( 'ApplicationMgr' ) 189 # one knows where to look for class, if not loaded yet 190 MCParticle = getClass( 'MCParticle' , 'EventDict' ) 191 # one knows where to look for class, if not loaded yet 192 Vertex = getClass( 'Vertex' , ['EventDict', 'PhysEventDict'] ) 195 if hasattr(gbl, name):
196 return getattr(gbl, name)
198 if type(libs)
is not list:
202 if hasattr(gbl, name):
203 return getattr(gbl, name)
212 """ holds the value and the documentation string of a property """ 218 if issubclass(
type(prop), GaudiHandleProperty):
220 elif issubclass(
type(prop), GaudiHandleArrayProperty):
221 self.
_value = prop.value()
225 self.
_value = eval(prop.toString(), {}, {})
227 if hasattr(prop,
'value'):
228 self.
_value = prop.value()
230 self.
_value = prop.toString()
232 self.
__doc__ +=
" --- Default value = " + str(self.
_value) +
" --- " 233 if prop.documentation() !=
'none':
245 "Return the underlying property itself " 259 """ Python equivalent to the C++ Property interface """ 265 self.__dict__[
'_ip'] =
None 266 self.__dict__[
'_svcloc'] = gbl.Gaudi.svcLocator()
267 optsvc = Helper.service(self._svcloc,
'JobOptionsSvc')
270 gbl.IJobOptionsSvc)(optsvc)
272 self.__dict__[
'_optsvc'] =
None 273 self.__dict__[
'_name'] = name
284 if not getattr(self, ifname):
285 self.retrieveInterface()
286 return getattr(getattr(self, ifname), method)(*args)
290 The method which is used for setting the property from the given value. 291 - In the case of the valid instance it sets the property through IProperty interface 292 - In the case of placeholder the property is added to JobOptionsCatalogue 294 if hasattr(value,
'toStringProperty'):
296 value =
'%s' % value.toStringProperty()
299 if not gbl.Gaudi.Utils.hasProperty(ip, name):
300 raise AttributeError(
'property %s does not exist' % name)
301 prop = ip.getProperty(name)
304 canSetValue = (hasattr(prop,
'value')
305 and 'const&[' not in prop.value.func_doc
306 and type(value) ==
type(prop.value()))
308 canSetValue = (hasattr(prop,
'value')
309 and type(value) ==
type(prop.value()))
312 if not prop.setValue(value):
313 raise AttributeError(
314 'property %s could not be set from %s' % (name, value))
316 if tuple ==
type(value):
318 elif hasattr(value,
'toString'):
319 value = value.toString()
320 elif not long ==
type(value):
325 sc = cppyy.gbl.GaudiPython.Helper.setPropertyFromString(
328 sc = prop.fromString(value)
330 raise AttributeError(
331 'property %s could not be set from %s' % (name, value))
333 if type(value) == str:
334 value =
'"%s"' % value
335 elif type(value) == tuple:
337 elif hasattr(value,
'toString'):
338 value = value.toString()
339 elif type(value) == long:
341 sp = gbl.GaudiPython.Helpers.mkStringProperty(name, str(value))
346 The method which returns the value for the given property 347 - In the case of the valid instance it returns the valid property value through IProperty interface 348 - In the case of placeholder the property value is retrieved from JobOptionsCatalogue 352 if not gbl.Gaudi.Utils.hasProperty(ip, name):
353 raise AttributeError(
'property %s does not exist' % name)
354 prop = ip.getProperty(name)
355 if StringProperty ==
type(prop):
357 elif StringPropertyRef ==
type(prop):
360 return eval(prop.toString(), {}, {})
364 props = self._optsvc.getProperties(self._name)
366 if not p.name() == name:
370 return eval(p.value(), {}, {})
373 raise AttributeError(
'property %s does not exist' % name)
380 props = ip.getProperties()
381 propsFrom = self._name
383 props = self._optsvc.getProperties(self._name)
384 propsFrom =
"jobOptionsSvc" 389 except (ValueError, TypeError)
as e:
390 raise ValueError(
"gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s" % \
391 (e.__class__.__name__, e.args,
392 propsFrom, p.name(), p.value()))
403 """ Python equivalent to IProperty interface """ 406 iProperty.__init__(self, name, isvc)
410 self.__dict__[
'_isvc'] =
None 413 isvc = Helper.service(self._svcloc, self._name)
415 iService.__init__(self, self._name, isvc)
446 """ Python equivalent to IAlgorithm interface """ 449 iProperty.__init__(self, name, ialg)
453 self.__dict__[
'_ialg'] =
None 456 ialg = Helper.algorithm(
459 iAlgorithm.__init__(self, self._name, ialg)
508 """ Python equivalent to IAlgTool interface (not completed yet) """ 511 iProperty.__init__(self, name, itool)
513 self.__dict__[
'_itool'] = itool
515 self.__dict__[
'_itool'] =
None 516 svc = Helper.service(self._svcloc,
'ToolSvc',
True)
517 self.__dict__[
'_toolsvc'] =
iToolSvc(
'ToolSvc', svc)
520 itool = self._toolsvc._retrieve(self._name)
522 iAlgTool.__init__(self, self._name, itool)
535 return self._itool.
name()
545 iService.__init__(self, name, idp)
546 self.__dict__[
'_idp'] =
InterfaceCast(gbl.IDataProviderSvc)(idp)
547 self.__dict__[
'_idm'] =
InterfaceCast(gbl.IDataManagerSvc)(idp)
551 raise AttributeError(
552 'C++ service %s does not exist' % self.__dict__[
'_name'])
553 return Helper.registerObject(self._idp, path, obj)
557 raise AttributeError(
558 'C++ service %s does not exist' % self.__dict__[
'_name'])
559 return Helper.unregisterObject(self._idp, path)
564 return Helper.dataobject(self._idp, path)
571 Get the existing object in TransientStore for the given location 573 - loading of object from persistency is NOT triggered 574 - 'data-on-demand' action is NOT triggered 576 >>> svc = ... ## get the service 577 >>> path = ... ## get the path in Transient Store 578 >>> data = svc.findObject ( path ) ## use the method 583 'C++ service %s does not exist' % self.__dict__[
'_name'])
584 return Helper.findobject(self._idp, path)
589 Get object from Transient Store for the given location 592 - path : Location of object in Transient Store 593 - retrieve (bool) True : retrieve versus find 594 - disable on-demand (bool) False : temporary disable 'on-demand' actions 596 >>> svc = ... ## get the service 597 >>> path = ... ## get the path 599 >>> data = svc.getObject ( path , False ) ## find object in Transient Store 601 ## find object in Transient Store 602 # load form tape or use 'on-demand' action for missing objects : 603 >>> data = svc.getObject ( path , True ) 605 ## find object in Transient Store 606 # load from tape or for missing objects, disable 'on-demand'-actions 607 >>> data = svc.getObject ( path , True , True ) 612 'C++ service %s does not exist' % self.__dict__[
'_name'])
613 return Helper.getobject(self._idp, path, *args)
618 'C++ service %s does not exist' % self.__dict__[
'_name'])
619 return Helper.dataobject(self._idp, path)
624 'C++ service %s does not exist' % self.__dict__[
'_name'])
630 'C++ service %s does not exist' % self.__dict__[
'_name'])
636 ll = gbl.std.vector(
'IRegistry*')()
637 if type(node)
is str:
641 if self._idm.objectLeaves(node, ll).isSuccess():
648 node = root.registry()
651 print(node.identifier())
653 for l
in self.
leaves(node):
656 def getList(self, node=None, lst=[], rootFID=None):
660 node = root.registry()
661 rootFID = node.address().
par()
665 Helper.dataobject(self._idp, node.identifier())
667 lst.append(node.identifier())
668 for l
in self.
leaves(node):
669 if l.address()
and l.address().
par() == rootFID:
679 node = root.registry()
684 Helper.dataobject(self._idp, node.identifier())
686 lst.append(node.identifier())
687 for l
in self.
leaves(node):
697 'C++ service %s does not exist' % self.__dict__[
'_name'])
698 return self._idm.
setRoot(name, obj)
703 'C++ service %s does not exist' % self.__dict__[
'_name'])
710 self.__dict__[
'_ihs'] =
InterfaceCast(gbl.IHistogramSvc)(ihs)
711 iDataSvc.__init__(self, name, ihs)
714 return Helper.histo1D(self._ihs, path)
717 return Helper.histo2D(self._ihs, path)
720 return Helper.histo3D(self._ihs, path)
723 return Helper.profile1D(self._ihs, path)
726 return Helper.profile2D(self._ihs, path)
730 Retrieve AIDA histogram or AIDA profile histogram by path in Histogram Transient Store 732 >>> histo = svc.retrieve ( 'path/to/my/histogram' ) 747 Book the histograms(1D,2D&3D) , see IHistogramSvc::book 749 >>> histo = svc.book( .... ) 751 return self._ihs.
book(*args)
755 Book the profile(1D&2D) histograms, see IHistogramSvc::bookProf 757 >>> histo = svc.bookProf( .... ) 763 Retrieve the object from Histogram Transient Store (by path) 764 The reference to AIDA histogram is returned (if possible) 766 >>> histo = svc['path/to/my/histogram'] 771 return iDataSvc.__getitem__(self, path)
775 Retrieve the histogram from Histogram Transient Store (by path) 776 The reference to AIDA histogram is returned (if possible) 778 >>> histo = svc.getAsAIDA ( 'path/to/my/histogram' ) 784 Retrieve the histogram from Histogram Transient Store (by path) 785 The Underlying native ROOT object is returned (if possible) 787 >>> histo = svc.getAsROOT ( 'path/to/my/histogram' ) 789 fun = gbl.Gaudi.Utils.Aida2ROOT.aida2root
802 iDataSvc.__init__(self, name, ints)
805 return self._ints.
book(*args)
808 """ Defines the mapping between logical names and the output file 810 defineOutput({'LUN1':'MyFile1.root', 'LUN2':'Myfile2.root'}, svc='Gaudi::RootCnvSvc') 812 from .
import Persistency
as prs
813 helper = prs.get(typ)
814 helper.configure(
AppMgr())
816 helper.formatOutput(files[lun], lun=lun)
for lun
in files
818 if AppMgr().HistogramPersistency ==
'NONE':
819 AppMgr().HistogramPersistency =
"ROOT" 822 return iDataSvc.__getitem__(self, path)
829 iService.__init__(self, name, its)
832 sol = _gaudi.OutputLevel
835 if name.rfind(
'.') == -1:
836 itool = Helper.tool(self._its,
'', name, nullptr,
False)
837 elif name[0:8] ==
'ToolSvc.':
838 itool = Helper.tool(self._its,
'', name[8:], nullptr,
False)
839 elif name.count(
'.') > 1:
840 ptool = self.
_retrieve(name[:name.rfind(
'.')])
841 itool = Helper.tool(self._its,
'', name[name.rfind(
'.') + 1:],
844 prop = _gaudi.property(name[:name.rfind(
'.')])
845 itool = Helper.tool(self._its,
'', name[name.rfind(
'.') + 1:],
854 def create(self, typ, name=None, parent=nullptr, interface=None):
857 itool = Helper.tool(self._its, typ, name, parent,
True)
864 if type(itool)
is iAlgTool:
865 self._its.releaseTool(itool._itool)
873 Python-image of C++ class IJobOptionsSvc 880 self.__dict__[
'_optsvc'] =
InterfaceCast(gbl.IJobOptionsSvc)(svc)
881 return iService.__init__(self, name, svc)
885 Extract *ALL* properties of the given component 887 >>> jos = gaudi.optSvc() 888 >>> props = jos.getProperties( 'Name' ) 895 prop = p.name().upper()
897 value = eval(p.value(), {}, {})
906 Get a certain property of the certain component 909 >>> extServices = jos.getProperty( 'ApplicationMgr', 'ExtSvc' ) 913 return all.get(name.upper(),
None)
922 self,
'EventSelector',
923 Helper.service(gbl.Gaudi.svcLocator(),
'EventSelector'))
924 self.__dict__[
'g'] =
AppMgr()
926 def open(self, stream, typ='Gaudi::RootCnvSvc
', **kwargs): 927 from .
import Persistency
as prs
928 helper = prs.get(typ)
929 helper.configure(self.g)
930 self.
Input = helper.formatInput(stream, **kwargs)
945 newobj = object.__new__(cls)
946 cls.
__init__(newobj, *args, **kwargs)
955 self._evtpro.release()
956 self._svcloc.release()
957 self._appmgr.release()
976 self.__dict__[
'_exit_called'] =
False 978 self.__dict__[
'_gaudi_ns'] = Gaudi
980 from GaudiKernel.Proxy.Configurable
import expandvars
986 if dllname
and factname:
987 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr(
990 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr(dllname)
992 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr()
993 self.__dict__[
'_svcloc'] = gbl.Gaudi.svcLocator()
994 self.__dict__[
'_algmgr'] =
InterfaceCast(gbl.IAlgManager)(self._appmgr)
995 self.__dict__[
'_evtpro'] =
InterfaceCast(gbl.IEventProcessor)(
997 self.__dict__[
'_svcmgr'] =
InterfaceCast(gbl.ISvcManager)(self._appmgr)
998 self.__dict__[
'pyalgorithms'] = []
999 iService.__init__(self,
'ApplicationMgr', self._appmgr)
1002 ) < Gaudi.StateMachine.CONFIGURED:
1008 import GaudiKernel.Proxy.Configurable
1009 if hasattr(GaudiKernel.Proxy.Configurable,
1010 "applyConfigurableUsers"):
1011 GaudiKernel.Proxy.Configurable.applyConfigurableUsers()
1015 appMgr = Configurable.allConfigurables[
'ApplicationMgr']
1016 selfprops =
expandvars(appMgr.getValuedProperties())
1019 for p, v
in selfprops.items():
1021 for p, v
in selfoptions.items():
1024 if outputlevel != -1:
1028 ms = self.
service(
'MessageSvc')
1029 if 'MessageSvc' in Configurable.allConfigurables:
1030 msprops = Configurable.allConfigurables[
'MessageSvc']
1031 ms = self.
service(
'MessageSvc')
1032 if hasattr(msprops,
"getValuedProperties"):
1033 msprops =
expandvars(msprops.getValuedProperties())
1034 for p, v
in msprops.items():
1036 if outputlevel != -1:
1037 ms.OutputLevel = outputlevel
1039 self.__dict__[
'_optsvc'] =
InterfaceCast(gbl.IJobOptionsSvc)(
1040 Helper.service(self._svcloc,
'JobOptionsSvc'))
1042 mkStringProperty = gbl.GaudiPython.Helpers.mkStringProperty
1044 c = Configurable.allConfigurables[n]
1045 if n
in [
'ApplicationMgr',
'MessageSvc']:
1047 for p, v
in c.getValuedProperties().
items():
1050 if hasattr(Configurable,
"PropertyReference")
and type(
1051 v) == Configurable.PropertyReference:
1057 elif type(v) == long:
1060 n, mkStringProperty(p, str(v)))
1061 if hasattr(Configurable,
"_configurationLocked"):
1062 Configurable._configurationLocked =
True 1067 """Ensure that the exit method is called when exiting from Python, and 1068 try to ensure that ROOT doesn't intefere too much.""" 1070 atexit.register(self.
exit)
1073 exit_handlers = atexit._exithandlers
1074 except AttributeError:
1081 root_handler_installed =
False 1082 for h
in exit_handlers:
1084 if hasattr(func,
"__module__")
and func.__module__ ==
"ROOT":
1085 root_handler_installed =
True 1091 if not root_handler_installed:
1092 orig_register = atexit.register
1094 def register(func, *targs, **kargs):
1095 orig_register(func, *targs, **kargs)
1096 if hasattr(func,
"__module__")
and func.__module__ ==
"ROOT":
1097 orig_register(self.
exit)
1101 register.__doc__ = (
1102 orig_register.__doc__ +
1103 "\nNote: version hacked by GaudiPython to work " +
1104 "around a problem with the ROOT exit handler")
1105 atexit.register = register
1117 svc = Helper.service(self._svcloc, name)
1124 self._svcmgr.declareSvcType(svcname, svctype)
1127 return Helper.service(self._svcloc, name,
True)
1130 l = self._svcloc.getServices()
1131 return [s.name()
for s
in l]
1134 alg = Helper.algorithm(self._algmgr, name, createIf)
1141 l = self._algmgr.getAlgorithms()
1142 return [a.name()
for a
in l]
1156 if self.
state() == Gaudi.StateMachine.CONFIGURED:
1158 svc = Helper.service(self._svcloc, name)
1162 return self.
datasvc(
'EventDataSvc')
1165 return self.
datasvc(
'DetectorDataSvc')
1168 return self.
datasvc(
'FileRecordDataSvc')
1171 if self.
state() == Gaudi.StateMachine.CONFIGURED:
1173 if not hasattr(self,
'_evtsel'):
1178 svc = Helper.service(self._svcloc, name)
1182 if name
not in self.ExtSvc:
1183 self.ExtSvc += [name]
1185 svc = Helper.service(self._svcloc, name,
True)
1189 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1191 svc = Helper.service(self._svcloc,
'ParticlePropertySvc')
1195 svc = Helper.service(self._svcloc, name,
True)
1199 svc = Helper.service(self._svcloc, name,
True)
1206 """ Add an Algorithm to the list of Top algorithms. It can be either a instance of 1207 an Algorithm class or it name """ 1208 if type(alg)
is str:
1211 self.pyalgorithms.append(alg)
1217 self.
topAlg += [alg.name()]
1220 """ Set the list of Top Algorithms. 1221 It can be an individual of a list of algorithms names or instances """ 1222 if type(algs)
is not list:
1226 if type(alg)
is str:
1229 self.pyalgorithms.append(alg)
1234 names.append(alg.name())
1238 """ Remove an Algorithm to the list of Top algorithms. It can be either a instance of 1239 an Algorithm class or it name """ 1241 if type(alg)
is str:
1244 tmp.remove(alg.name())
1245 self.pyalgorithms.remove(alg)
1251 Print the sequence of Algorithms. 1254 def printAlgo(algName, appMgr, prefix=' '):
1255 print(prefix + algName)
1256 alg = appMgr.algorithm(algName.split(
"/")[-1])
1257 prop = alg.properties()
1258 if "Members" in prop:
1259 subs = prop[
"Members"].value()
1261 printAlgo(i.strip(
'"'), appMgr, prefix +
" ")
1264 prefix =
'ApplicationMgr SUCCESS ' 1267 "****************************** Algorithm Sequence ****************************" 1269 for i
in mp[
"TopAlg"].value():
1270 printAlgo(i, self, prefix)
1273 "******************************************************************************" 1278 Simple utility to perform the configuration of Gaudi application. 1279 It reads the set of input job-options files, and set few 1280 additional parameters 'options' through the usage of temporary *.opts file 1282 gaudi.config( files = [ '$GAUSSOPTS/Gauss.opts' , 1283 '$DECFILESROOT/options/10022_010.0GeV.opts' ] , 1284 options = [ 'EventSelector.PrintFreq = 5 ' ] ) 1286 files = args.get(
'files', [])
1290 raise RuntimeError(
' Unable to read file "' + file +
'" ')
1291 options = args.get(
'options',
None)
1294 tmpfilename = tempfile.mktemp()
1295 tmpfile = open(tmpfilename,
'w')
1296 tmpfile.write(
'#pragma print on \n')
1297 tmpfile.write(
'/// File "' + tmpfilename +
1298 '" generated by GaudiPython \n\n')
1300 if type(options)
is dict:
1301 tmpfile.write(
' \t ' + opt +
' = ' + options[opt] +
1302 ' ; // added by GaudiPython \n')
1304 tmpfile.write(
' \t ' + opt +
1305 ' ; // added by GaudiPython \n')
1306 tmpfile.write(
'/// End of file "' + tmpfilename +
1307 '" generated by GaudiPython \n\n')
1311 raise RuntimeError(
' Unable to read file "' + tmpfilename +
1313 os.remove(tmpfilename)
1316 if self.
FSMState() != Gaudi.StateMachine.OFFLINE:
1322 _dlls = jos.getProperty(self.
name(),
'DLLs')
1325 libs = [l
for l
in _dlls
if not l
in self.DLLs]
1330 _svcs = jos.getProperty(self.
name(),
'ExtSvc')
1333 svcs = [s
for s
in _svcs
if not s
in self.ExtSvc]
1338 props = jos.getProperties(self.
name())
1341 if 'DLLS' == key
or 'EXTSVC' == key:
1350 return self._appmgr.
start()
1356 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1358 if sc.isFailure()
or self.ReturnCode != 0:
1360 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1362 if sc.isFailure()
or self.ReturnCode != 0:
1373 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1377 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1382 if not hasattr(self,
'_perssvc'):
1383 self.__dict__[
'_perssvc'] = self.
service(
'EventPersistencySvc',
1385 if not hasattr(self,
'_filecat'):
1386 self.__dict__[
'_filecat'] = self.
service(
'FileCatalog',
1387 'Gaudi::IFileCatalog')
1388 if not hasattr(self,
'_evtmgr'):
1389 self.__dict__[
'_evtmgr'] = self.
service(
'EventDataSvc',
1392 if pfn.find(
'PFN:') == 0:
1396 if not self._filecat.existsFID(fid):
1397 self._filecat.registerPFN(fid, pfn,
'')
1399 if type(events)
is not list:
1403 gadd = gbl.GenericAddress(0x02, 1, fid,
'/Event', 0, evt)
1405 self._perssvc.createAddress(gadd.svcType(), gadd.clID(),
1406 gadd.par(), gadd.ipar(), oadd)
1408 self._evtmgr.clearStore()
1409 self._evtmgr.setRoot(
'/Event', oadd)
1414 if not self._exit_called:
1415 self.__dict__[
'_exit_called'] =
True 1416 Gaudi = self._gaudi_ns
1417 if self.
FSMState() == Gaudi.StateMachine.RUNNING:
1418 self._appmgr.
stop().ignore()
1419 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1421 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1432 ntupleSvc = ntuplesvc
1443 tfile = gbl.TFile.Open(pfn)
1445 raise IOError(
'Cannot open ROOT file {0}'.
format(pfn))
1446 tree = tfile.Get(
'##Params')
1448 text = tree.db_string
1449 if 'NAME=FID' in text:
1450 fid = text[text.rfind(
'VALUE=') + 6:-1]
1451 nevt = tfile.Get(
'_Event').GetEntries()
1460 """ Get all the properties of a component as a Python dictionary. 1461 The component is instantiated using the component library 1464 if name ==
'GaudiCoreSvc':
1465 if Helper.loadDynamicLib(name) != 1:
1466 raise ImportError(
'Error loading component library ' + name)
1467 factorylist = gbl.FactoryTable.instance().getEntries()
1469 g =
AppMgr(outputlevel=7)
1471 g =
AppMgr(outputlevel=7)
1472 if Helper.loadDynamicLib(name) != 1:
1473 raise ImportError(
'Error loading component library ' + name)
1474 factorylist = gbl.FactoryTable.instance().getEntries()
1476 svcloc = gbl.Gaudi.svcLocator()
1477 dummysvc = gbl.Service(
'DummySvc', svcloc)
1478 for factory
in factories:
1485 elif factory.ident() ==
'ApplicationMgr':
1486 ctype =
'ApplicationMgr' 1489 cname = factory.ident().split()[-1]
1490 if ctype
in (
'Algorithm',
'Service',
'AlgTool',
'ApplicationMgr'):
1492 if ctype ==
'AlgTool':
1493 obj = factory.instantiate(dummysvc)
1495 obj = factory.instantiate(svcloc)
1496 except RuntimeError
as text:
1497 print(
'Error instantiating', cname,
' from ', name)
1501 properties[cname] = [ctype, prop.properties()]
1511 for i
in range(factories.size()):
1512 factory = factories.front()
1513 result.append(factory)
1514 factories.pop_front()
1515 for factory
in result:
1516 factories.push_back(factory)
1522 _CallbackStreamBufBase = gbl.GaudiPython.CallbackStreamBuf
1527 _CallbackStreamBufBase.__init__(self, self)
1539 _PyAlgorithm = gbl.GaudiPython.PyAlgorithm
1545 name = self.__class__.__name__
1546 _PyAlgorithm.__init__(self, self, name)
1549 sc = self.
_algmgr.addAlgorithm(self)
1551 raise RuntimeError(
'Unable to add Algorithm')
1554 sc = self.
_algmgr.removeAlgorithm(self)
1578 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 _install_exit_handlers(self)
bool PyHelper() addPropertyToCatalogue(IInterface *p, char *comp, char *name, char *value)
def retrieveProfile1D(self, path)
def getAsAIDA(self, path)
def getProperties(self, component)
def _getFIDandEvents(pfn)
def __init__(self, name, ialg=None)
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 __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 open(self, stream, typ='Gaudi::RootCnvSvc', **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")
def addAlgorithm(self, alg)
def retrieveProfile2D(self, path)
def retrieve2D(self, path)
def __call_interface_method__(self, ifname, method, *args)
def __new__(cls, *args, **kwargs)
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 bookProf(self, *args)
def getAsROOT(self, path)
def dump(self, node=None)
def retrieveObject(self, path)
def __getitem__(self, path)
def _copyFactoriesFromList(factories)
def setRoot(self, name, obj)
def __init__(self, name=None)
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
def registerObject(self, path, obj)
def optSvc(self, name='JobOptionsSvc')
return ep &&ep executeRun(maxevt).isSuccess()
def getComponentProperties(name)
def getObject(self, path, *args)
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)