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. 8 from __future__
import absolute_import, print_function
11 'gbl',
'InterfaceCast',
'Interface',
'PropertyEntry',
'AppMgr',
12 'PyAlgorithm',
'CallbackStreamBuf',
'iAlgorithm',
'iDataSvc',
13 'iHistogramSvc',
'iNTupleSvc',
'iService',
'iAlgTool',
'Helper',
'SUCCESS',
14 'FAILURE',
'toArray',
'ROOT',
'makeNullPointer',
'setOwnership',
15 'getClass',
'loaddict',
'deprecation' 18 from GaudiKernel
import ROOT6WorkAroundEnabled
29 print(
"# WARNING: using PyCintex as cppyy implementation")
30 import PyCintex
as cppyy
32 if sys.version_info >= (3, ):
42 from .
import Pythonizations
45 from GaudiKernel.Proxy.Configurable
import Configurable, getNeededConfigurables
54 gbl.gInterpreter.Declare(
'#include "GaudiKernel/Property.h"')
55 Helper = gbl.GaudiPython.Helper
56 StringProperty = gbl.Gaudi.Property(
'std::string')
57 StringPropertyRef = gbl.Gaudi.Property(
'std::string&')
58 GaudiHandleProperty = gbl.GaudiHandleProperty
59 GaudiHandleArrayProperty = gbl.GaudiHandleArrayProperty
60 DataObject = gbl.DataObject
61 SUCCESS = gbl.StatusCode(gbl.StatusCode.SUCCESS,
True)
62 FAILURE = gbl.StatusCode(gbl.StatusCode.FAILURE,
True)
64 cppyy.gbl.gInterpreter.Declare(
''' 65 namespace GaudiPython { namespace Helpers { 66 Gaudi::Property<std::string> mkStringProperty(const std::string &name, 67 const std::string &value) { 68 return Gaudi::Property<std::string>{name, value}; 73 for l
in [l
for l
in dir(Helper)
if re.match(
"^to.*Array$", l)]:
74 exec (
"%s = Helper.%s" % (l, l))
78 if hasattr(Helper,
"toArray"):
82 return getattr(Helper,
"toArray")
86 return getattr(Helper,
"toArray<%s>" % typ)
90 ROOT = cppyy.libPyROOT
91 makeNullPointer = cppyy.libPyROOT.MakeNullPointer
92 setOwnership = cppyy.libPyROOT.SetOwnership
96 warnings.warn(
'GaudiPython: ' + message, DeprecationWarning, stacklevel=3)
103 """ Helper class to obtain the adequate interface from a component 104 by using the Gaudi queryInterface() mechanism """ 115 if obj.queryInterface(self.
type.interfaceID(), ip).isSuccess():
118 print(
"ERROR: queryInterface failed for", obj,
119 "interface:", self.
type)
120 except Exception
as e:
121 print(
"ERROR: exception", e,
122 "caught when retrieving interface", self.
type,
125 traceback.print_stack()
137 InterfaceCast.__init__(self, t)
147 """ Load a LCG dictionary using various mechanisms""" 148 if Helper.loadDynamicLib(dict) == 1:
154 raise ImportError(
'Error loading dictionary library')
162 Function to retrieve a certain C++ class by name and to load dictionary if requested 166 from gaudimodule import getClass 167 # one knows that class is already loaded 168 AppMgr = getClass( 'ApplicationMgr' ) 169 # one knows where to look for class, if not loaded yet 170 MCParticle = getClass( 'MCParticle' , 'EventDict' ) 171 # one knows where to look for class, if not loaded yet 172 Vertex = getClass( 'Vertex' , ['EventDict', 'PhysEventDict'] ) 175 if hasattr(gbl, name):
176 return getattr(gbl, name)
178 if type(libs)
is not list:
182 if hasattr(gbl, name):
183 return getattr(gbl, name)
192 """ holds the value and the documentation string of a property """ 198 if issubclass(
type(prop), GaudiHandleProperty):
200 elif issubclass(
type(prop), GaudiHandleArrayProperty):
201 self.
_value = prop.value()
205 self.
_value = eval(prop.toString(), {}, {})
207 if hasattr(prop,
'value'):
208 self.
_value = prop.value()
210 self.
_value = prop.toString()
212 self.
__doc__ +=
" --- Default value = " + str(self.
_value) +
" --- " 213 if prop.documentation() !=
'none':
225 "Return the underlying property itself " 239 """ Python equivalent to the C++ Property interface """ 245 self.__dict__[
'_ip'] =
None 246 self.__dict__[
'_svcloc'] = gbl.Gaudi.svcLocator()
247 optsvc = Helper.service(self._svcloc,
'JobOptionsSvc')
250 gbl.IJobOptionsSvc)(optsvc)
252 self.__dict__[
'_optsvc'] =
None 253 self.__dict__[
'_name'] = name
264 if not getattr(self, ifname):
265 self.retrieveInterface()
266 return getattr(getattr(self, ifname), method)(*args)
270 The method which is used for setting the property from the given value. 271 - In the case of the valid instance it sets the property through IProperty interface 272 - In the case of placeholder the property is added to JobOptionsCatalogue 274 if hasattr(value,
'toStringProperty'):
276 value =
'%s' % value.toStringProperty()
279 if not gbl.Gaudi.Utils.hasProperty(ip, name):
280 raise AttributeError(
'property %s does not exist' % name)
281 prop = ip.getProperty(name)
284 canSetValue = (hasattr(prop,
'value')
285 and 'const&[' not in prop.value.func_doc
286 and type(value) ==
type(prop.value()))
288 canSetValue = (hasattr(prop,
'value')
289 and type(value) ==
type(prop.value()))
292 if not prop.setValue(value):
293 raise AttributeError(
294 'property %s could not be set from %s' % (name, value))
296 if tuple ==
type(value):
298 elif hasattr(value,
'toString'):
299 value = value.toString()
300 elif not long ==
type(value):
305 sc = cppyy.gbl.GaudiPython.Helper.setPropertyFromString(
308 sc = prop.fromString(value)
310 raise AttributeError(
311 'property %s could not be set from %s' % (name, value))
313 if type(value) == str:
314 value =
'"%s"' % value
315 elif type(value) == tuple:
317 elif hasattr(value,
'toString'):
318 value = value.toString()
319 elif type(value) == long:
321 sp = gbl.GaudiPython.Helpers.mkStringProperty(name, str(value))
326 The method which returns the value for the given property 327 - In the case of the valid instance it returns the valid property value through IProperty interface 328 - In the case of placeholder the property value is retrieved from JobOptionsCatalogue 332 if not gbl.Gaudi.Utils.hasProperty(ip, name):
333 raise AttributeError(
'property %s does not exist' % name)
334 prop = ip.getProperty(name)
335 if StringProperty ==
type(prop):
337 elif StringPropertyRef ==
type(prop):
340 return eval(prop.toString(), {}, {})
344 props = self._optsvc.getProperties(self._name)
346 if not p.name() == name:
350 return eval(p.value(), {}, {})
353 raise AttributeError(
'property %s does not exist' % name)
360 props = ip.getProperties()
361 propsFrom = self._name
363 props = self._optsvc.getProperties(self._name)
364 propsFrom =
"jobOptionsSvc" 369 except (ValueError, TypeError)
as e:
370 raise ValueError(
"gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s" % \
371 (e.__class__.__name__, e.args,
372 propsFrom, p.name(), p.value()))
383 """ Python equivalent to IProperty interface """ 386 iProperty.__init__(self, name, isvc)
390 self.__dict__[
'_isvc'] =
None 393 isvc = Helper.service(self._svcloc, self._name)
395 iService.__init__(self, self._name, isvc)
426 """ Python equivalent to IAlgorithm interface """ 429 iProperty.__init__(self, name, ialg)
433 self.__dict__[
'_ialg'] =
None 436 ialg = Helper.algorithm(
439 iAlgorithm.__init__(self, self._name, ialg)
488 """ Python equivalent to IAlgTool interface (not completed yet) """ 491 iProperty.__init__(self, name, itool)
493 self.__dict__[
'_itool'] = itool
495 self.__dict__[
'_itool'] =
None 496 svc = Helper.service(self._svcloc,
'ToolSvc',
True)
497 self.__dict__[
'_toolsvc'] =
iToolSvc(
'ToolSvc', svc)
500 itool = self._toolsvc._retrieve(self._name)
502 iAlgTool.__init__(self, self._name, itool)
515 return self._itool.
name()
525 iService.__init__(self, name, idp)
526 self.__dict__[
'_idp'] =
InterfaceCast(gbl.IDataProviderSvc)(idp)
527 self.__dict__[
'_idm'] =
InterfaceCast(gbl.IDataManagerSvc)(idp)
531 raise AttributeError(
532 'C++ service %s does not exist' % self.__dict__[
'_name'])
533 return Helper.registerObject(self._idp, path, obj)
537 raise AttributeError(
538 'C++ service %s does not exist' % self.__dict__[
'_name'])
539 return Helper.unregisterObject(self._idp, path)
544 return Helper.dataobject(self._idp, path)
551 Get the existing object in TransientStore for the given location 553 - loading of object from persistency is NOT triggered 554 - 'data-on-demand' action is NOT triggered 556 >>> svc = ... ## get the service 557 >>> path = ... ## get the path in Transient Store 558 >>> data = svc.findObject ( path ) ## use the method 563 'C++ service %s does not exist' % self.__dict__[
'_name'])
564 return Helper.findobject(self._idp, path)
569 Get object from Transient Store for the given location 572 - path : Location of object in Transient Store 573 - retrieve (bool) True : retrieve versus find 574 - disable on-demand (bool) False : temporary disable 'on-demand' actions 576 >>> svc = ... ## get the service 577 >>> path = ... ## get the path 579 >>> data = svc.getObject ( path , False ) ## find object in Transient Store 581 ## find object in Transient Store 582 # load form tape or use 'on-demand' action for missing objects : 583 >>> data = svc.getObject ( path , True ) 585 ## find object in Transient Store 586 # load from tape or for missing objects, disable 'on-demand'-actions 587 >>> data = svc.getObject ( path , True , True ) 592 'C++ service %s does not exist' % self.__dict__[
'_name'])
593 return Helper.getobject(self._idp, path, *args)
598 'C++ service %s does not exist' % self.__dict__[
'_name'])
599 return Helper.dataobject(self._idp, path)
604 'C++ service %s does not exist' % self.__dict__[
'_name'])
610 'C++ service %s does not exist' % self.__dict__[
'_name'])
616 ll = gbl.std.vector(
'IRegistry*')()
617 if type(node)
is str:
621 if self._idm.objectLeaves(node, ll).isSuccess():
628 node = root.registry()
631 print(node.identifier())
633 for l
in self.
leaves(node):
636 def getList(self, node=None, lst=[], rootFID=None):
640 node = root.registry()
641 rootFID = node.address().
par()
645 Helper.dataobject(self._idp, node.identifier())
647 lst.append(node.identifier())
648 for l
in self.
leaves(node):
649 if l.address()
and l.address().
par() == rootFID:
659 node = root.registry()
664 Helper.dataobject(self._idp, node.identifier())
666 lst.append(node.identifier())
667 for l
in self.
leaves(node):
677 'C++ service %s does not exist' % self.__dict__[
'_name'])
678 return self._idm.
setRoot(name, obj)
683 'C++ service %s does not exist' % self.__dict__[
'_name'])
690 self.__dict__[
'_ihs'] =
InterfaceCast(gbl.IHistogramSvc)(ihs)
691 iDataSvc.__init__(self, name, ihs)
694 return Helper.histo1D(self._ihs, path)
697 return Helper.histo2D(self._ihs, path)
700 return Helper.histo3D(self._ihs, path)
703 return Helper.profile1D(self._ihs, path)
706 return Helper.profile2D(self._ihs, path)
710 Retrieve AIDA histogram or AIDA profile histogram by path in Histogram Transient Store 712 >>> histo = svc.retrieve ( 'path/to/my/histogram' ) 727 Book the histograms(1D,2D&3D) , see IHistogramSvc::book 729 >>> histo = svc.book( .... ) 731 return self._ihs.
book(*args)
735 Book the profile(1D&2D) histograms, see IHistogramSvc::bookProf 737 >>> histo = svc.bookProf( .... ) 743 Retrieve the object from Histogram Transient Store (by path) 744 The reference to AIDA histogram is returned (if possible) 746 >>> histo = svc['path/to/my/histogram'] 751 return iDataSvc.__getitem__(self, path)
755 Retrieve the histogram from Histogram Transient Store (by path) 756 The reference to AIDA histogram is returned (if possible) 758 >>> histo = svc.getAsAIDA ( 'path/to/my/histogram' ) 764 Retrieve the histogram from Histogram Transient Store (by path) 765 The Underlying native ROOT object is returned (if possible) 767 >>> histo = svc.getAsROOT ( 'path/to/my/histogram' ) 769 fun = gbl.Gaudi.Utils.Aida2ROOT.aida2root
782 iDataSvc.__init__(self, name, ints)
785 return self._ints.
book(*args)
788 """ Defines the mapping between logical names and the output file 790 defineOutput({'LUN1':'MyFile1.root', 'LUN2':'Myfile2.root'}, svc='Gaudi::RootCnvSvc') 792 from .
import Persistency
as prs
793 helper = prs.get(typ)
794 helper.configure(
AppMgr())
796 helper.formatOutput(files[lun], lun=lun)
for lun
in files
798 if AppMgr().HistogramPersistency ==
'NONE':
799 AppMgr().HistogramPersistency =
"ROOT" 802 return iDataSvc.__getitem__(self, path)
809 iService.__init__(self, name, its)
812 sol = _gaudi.OutputLevel
815 if name.rfind(
'.') == -1:
816 itool = Helper.tool(self._its,
'', name,
None,
False)
817 elif name[0:8] ==
'ToolSvc.':
818 itool = Helper.tool(self._its,
'', name[8:],
None,
False)
819 elif name.count(
'.') > 1:
820 ptool = self.
_retrieve(name[:name.rfind(
'.')])
821 itool = Helper.tool(self._its,
'', name[name.rfind(
'.') + 1:],
824 prop = _gaudi.property(name[:name.rfind(
'.')])
825 itool = Helper.tool(self._its,
'', name[name.rfind(
'.') + 1:],
834 def create(self, typ, name=None, parent=None, interface=None):
837 itool = Helper.tool(self._its, typ, name, parent,
True)
844 if type(itool)
is iAlgTool:
845 self._its.releaseTool(itool._itool)
853 Python-image of C++ class IJobOptionsSvc 860 self.__dict__[
'_optsvc'] =
InterfaceCast(gbl.IJobOptionsSvc)(svc)
861 return iService.__init__(self, name, svc)
865 Extract *ALL* properties of the given component 867 >>> jos = gaudi.optSvc() 868 >>> props = jos.getProperties( 'Name' ) 875 prop = p.name().upper()
877 value = eval(p.value(), {}, {})
886 Get a certain property of the certain component 889 >>> extServices = jos.getProperty( 'ApplicationMgr', 'ExtSvc' ) 893 return all.get(name.upper(),
None)
902 self,
'EventSelector',
903 Helper.service(gbl.Gaudi.svcLocator(),
'EventSelector'))
904 self.__dict__[
'g'] =
AppMgr()
906 def open(self, stream, typ='Gaudi::RootCnvSvc
', **kwargs): 907 from .
import Persistency
as prs
908 helper = prs.get(typ)
909 helper.configure(self.g)
910 self.
Input = helper.formatInput(stream, **kwargs)
925 newobj = object.__new__(cls)
926 cls.
__init__(newobj, *args, **kwargs)
935 self._evtpro.release()
936 self._svcloc.release()
937 self._appmgr.release()
956 self.__dict__[
'_exit_called'] =
False 958 self.__dict__[
'_gaudi_ns'] = Gaudi
960 from GaudiKernel.Proxy.Configurable
import expandvars
966 if dllname
and factname:
967 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr(
970 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr(dllname)
972 self.__dict__[
'_appmgr'] = gbl.Gaudi.createApplicationMgr()
973 self.__dict__[
'_svcloc'] = gbl.Gaudi.svcLocator()
974 self.__dict__[
'_algmgr'] =
InterfaceCast(gbl.IAlgManager)(self._appmgr)
975 self.__dict__[
'_evtpro'] =
InterfaceCast(gbl.IEventProcessor)(
977 self.__dict__[
'_svcmgr'] =
InterfaceCast(gbl.ISvcManager)(self._appmgr)
978 self.__dict__[
'pyalgorithms'] = []
979 iService.__init__(self,
'ApplicationMgr', self._appmgr)
982 ) < Gaudi.StateMachine.CONFIGURED:
988 import GaudiKernel.Proxy.Configurable
989 if hasattr(GaudiKernel.Proxy.Configurable,
990 "applyConfigurableUsers"):
991 GaudiKernel.Proxy.Configurable.applyConfigurableUsers()
995 appMgr = Configurable.allConfigurables[
'ApplicationMgr']
996 selfprops =
expandvars(appMgr.getValuedProperties())
999 for p, v
in selfprops.items():
1001 for p, v
in selfoptions.items():
1004 if outputlevel != -1:
1008 ms = self.
service(
'MessageSvc')
1009 if 'MessageSvc' in Configurable.allConfigurables:
1010 msprops = Configurable.allConfigurables[
'MessageSvc']
1011 ms = self.
service(
'MessageSvc')
1012 if hasattr(msprops,
"getValuedProperties"):
1013 msprops =
expandvars(msprops.getValuedProperties())
1014 for p, v
in msprops.items():
1016 if outputlevel != -1:
1017 ms.OutputLevel = outputlevel
1019 self.__dict__[
'_optsvc'] =
InterfaceCast(gbl.IJobOptionsSvc)(
1020 Helper.service(self._svcloc,
'JobOptionsSvc'))
1022 mkStringProperty = gbl.GaudiPython.Helpers.mkStringProperty
1024 c = Configurable.allConfigurables[n]
1025 if n
in [
'ApplicationMgr',
'MessageSvc']:
1027 for p, v
in c.getValuedProperties().
items():
1030 if hasattr(Configurable,
"PropertyReference")
and type(
1031 v) == Configurable.PropertyReference:
1037 elif type(v) == long:
1040 n, mkStringProperty(p, str(v)))
1041 if hasattr(Configurable,
"_configurationLocked"):
1042 Configurable._configurationLocked =
True 1047 """Ensure that the exit method is called when exiting from Python, and 1048 try to ensure that ROOT doesn't intefere too much.""" 1050 atexit.register(self.
exit)
1053 exit_handlers = atexit._exithandlers
1054 except AttributeError:
1061 root_handler_installed =
False 1062 for h
in exit_handlers:
1064 if hasattr(func,
"__module__")
and func.__module__ ==
"ROOT":
1065 root_handler_installed =
True 1071 if not root_handler_installed:
1072 orig_register = atexit.register
1074 def register(func, *targs, **kargs):
1075 orig_register(func, *targs, **kargs)
1076 if hasattr(func,
"__module__")
and func.__module__ ==
"ROOT":
1077 orig_register(self.
exit)
1081 register.__doc__ = (
1082 orig_register.__doc__ +
1083 "\nNote: version hacked by GaudiPython to work " +
1084 "around a problem with the ROOT exit handler")
1085 atexit.register = register
1097 svc = Helper.service(self._svcloc, name)
1104 self._svcmgr.declareSvcType(svcname, svctype)
1107 return Helper.service(self._svcloc, name,
True)
1110 l = self._svcloc.getServices()
1111 return [s.name()
for s
in l]
1114 alg = Helper.algorithm(self._algmgr, name, createIf)
1121 l = self._algmgr.getAlgorithms()
1122 return [a.name()
for a
in l]
1136 if self.
state() == Gaudi.StateMachine.CONFIGURED:
1138 svc = Helper.service(self._svcloc, name)
1142 return self.
datasvc(
'EventDataSvc')
1145 return self.
datasvc(
'DetectorDataSvc')
1148 return self.
datasvc(
'FileRecordDataSvc')
1151 if self.
state() == Gaudi.StateMachine.CONFIGURED:
1153 if not hasattr(self,
'_evtsel'):
1158 svc = Helper.service(self._svcloc, name)
1162 if name
not in self.ExtSvc:
1163 self.ExtSvc += [name]
1165 svc = Helper.service(self._svcloc, name,
True)
1169 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1171 svc = Helper.service(self._svcloc,
'ParticlePropertySvc')
1175 svc = Helper.service(self._svcloc, name,
True)
1179 svc = Helper.service(self._svcloc, name,
True)
1186 """ Add an Algorithm to the list of Top algorithms. It can be either a instance of 1187 an Algorithm class or it name """ 1188 if type(alg)
is str:
1191 self.pyalgorithms.append(alg)
1197 self.
topAlg += [alg.name()]
1200 """ Set the list of Top Algorithms. 1201 It can be an individual of a list of algorithms names or instances """ 1202 if type(algs)
is not list:
1206 if type(alg)
is str:
1209 self.pyalgorithms.append(alg)
1214 names.append(alg.name())
1218 """ Remove an Algorithm to the list of Top algorithms. It can be either a instance of 1219 an Algorithm class or it name """ 1221 if type(alg)
is str:
1224 tmp.remove(alg.name())
1225 self.pyalgorithms.remove(alg)
1231 Print the sequence of Algorithms. 1234 def printAlgo(algName, appMgr, prefix=' '):
1235 print(prefix + algName)
1236 alg = appMgr.algorithm(algName.split(
"/")[-1])
1237 prop = alg.properties()
1238 if "Members" in prop:
1239 subs = prop[
"Members"].value()
1241 printAlgo(i.strip(
'"'), appMgr, prefix +
" ")
1244 prefix =
'ApplicationMgr SUCCESS ' 1247 "****************************** Algorithm Sequence ****************************" 1249 for i
in mp[
"TopAlg"].value():
1250 printAlgo(i, self, prefix)
1253 "******************************************************************************" 1258 Simple utility to perform the configuration of Gaudi application. 1259 It reads the set of input job-options files, and set few 1260 additional parameters 'options' through the usage of temporary *.opts file 1262 gaudi.config( files = [ '$GAUSSOPTS/Gauss.opts' , 1263 '$DECFILESROOT/options/10022_010.0GeV.opts' ] , 1264 options = [ 'EventSelector.PrintFreq = 5 ' ] ) 1266 files = args.get(
'files', [])
1270 raise RuntimeError(
' Unable to read file "' + file +
'" ')
1271 options = args.get(
'options',
None)
1274 tmpfilename = tempfile.mktemp()
1275 tmpfile = open(tmpfilename,
'w')
1276 tmpfile.write(
'#pragma print on \n')
1277 tmpfile.write(
'/// File "' + tmpfilename +
1278 '" generated by GaudiPython \n\n')
1280 if type(options)
is dict:
1281 tmpfile.write(
' \t ' + opt +
' = ' + options[opt] +
1282 ' ; // added by GaudiPython \n')
1284 tmpfile.write(
' \t ' + opt +
1285 ' ; // added by GaudiPython \n')
1286 tmpfile.write(
'/// End of file "' + tmpfilename +
1287 '" generated by GaudiPython \n\n')
1291 raise RuntimeError(
' Unable to read file "' + tmpfilename +
1293 os.remove(tmpfilename)
1296 if self.
FSMState() != Gaudi.StateMachine.OFFLINE:
1302 _dlls = jos.getProperty(self.
name(),
'DLLs')
1305 libs = [l
for l
in _dlls
if not l
in self.DLLs]
1310 _svcs = jos.getProperty(self.
name(),
'ExtSvc')
1313 svcs = [s
for s
in _svcs
if not s
in self.ExtSvc]
1318 props = jos.getProperties(self.
name())
1321 if 'DLLS' == key
or 'EXTSVC' == key:
1330 return self._appmgr.
start()
1336 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1338 if sc.isFailure()
or self.ReturnCode != 0:
1340 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1342 if sc.isFailure()
or self.ReturnCode != 0:
1353 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1357 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1362 if not hasattr(self,
'_perssvc'):
1363 self.__dict__[
'_perssvc'] = self.
service(
'EventPersistencySvc',
1365 if not hasattr(self,
'_filecat'):
1366 self.__dict__[
'_filecat'] = self.
service(
'FileCatalog',
1367 'Gaudi::IFileCatalog')
1368 if not hasattr(self,
'_evtmgr'):
1369 self.__dict__[
'_evtmgr'] = self.
service(
'EventDataSvc',
1372 if pfn.find(
'PFN:') == 0:
1376 if not self._filecat.existsFID(fid):
1377 self._filecat.registerPFN(fid, pfn,
'')
1379 if type(events)
is not list:
1383 gadd = gbl.GenericAddress(0x02, 1, fid,
'/Event', 0, evt)
1385 self._perssvc.createAddress(gadd.svcType(), gadd.clID(),
1386 gadd.par(), gadd.ipar(), oadd)
1388 self._evtmgr.clearStore()
1389 self._evtmgr.setRoot(
'/Event', oadd)
1394 if not self._exit_called:
1395 self.__dict__[
'_exit_called'] =
True 1396 Gaudi = self._gaudi_ns
1397 if self.
FSMState() == Gaudi.StateMachine.RUNNING:
1398 self._appmgr.
stop().ignore()
1399 if self.
FSMState() == Gaudi.StateMachine.INITIALIZED:
1401 if self.
FSMState() == Gaudi.StateMachine.CONFIGURED:
1412 ntupleSvc = ntuplesvc
1423 tfile = gbl.TFile.Open(pfn)
1425 raise IOError(
'Cannot open ROOT file {0}'.
format(pfn))
1426 tree = tfile.Get(
'##Params')
1428 text = tree.db_string
1429 if 'NAME=FID' in text:
1430 fid = text[text.rfind(
'VALUE=') + 6:-1]
1431 nevt = tfile.Get(
'_Event').GetEntries()
1440 """ Get all the properties of a component as a Python dictionary. 1441 The component is instantiated using the component library 1444 if name ==
'GaudiCoreSvc':
1445 if Helper.loadDynamicLib(name) != 1:
1446 raise ImportError(
'Error loading component library ' + name)
1447 factorylist = gbl.FactoryTable.instance().getEntries()
1449 g =
AppMgr(outputlevel=7)
1451 g =
AppMgr(outputlevel=7)
1452 if Helper.loadDynamicLib(name) != 1:
1453 raise ImportError(
'Error loading component library ' + name)
1454 factorylist = gbl.FactoryTable.instance().getEntries()
1456 svcloc = gbl.Gaudi.svcLocator()
1457 dummysvc = gbl.Service(
'DummySvc', svcloc)
1458 for factory
in factories:
1465 elif factory.ident() ==
'ApplicationMgr':
1466 ctype =
'ApplicationMgr' 1469 cname = factory.ident().split()[-1]
1470 if ctype
in (
'Algorithm',
'Service',
'AlgTool',
'ApplicationMgr'):
1472 if ctype ==
'AlgTool':
1473 obj = factory.instantiate(dummysvc)
1475 obj = factory.instantiate(svcloc)
1476 except RuntimeError
as text:
1477 print(
'Error instantiating', cname,
' from ', name)
1481 properties[cname] = [ctype, prop.properties()]
1491 for i
in range(factories.size()):
1492 factory = factories.front()
1493 result.append(factory)
1494 factories.pop_front()
1495 for factory
in result:
1496 factories.push_back(factory)
1502 _CallbackStreamBufBase = gbl.GaudiPython.CallbackStreamBuf
1507 _CallbackStreamBufBase.__init__(self, self)
1519 _PyAlgorithm = gbl.GaudiPython.PyAlgorithm
1525 name = self.__class__.__name__
1526 _PyAlgorithm.__init__(self, self, name)
1529 sc = self.
_algmgr.addAlgorithm(self)
1531 raise RuntimeError(
'Unable to add Algorithm')
1534 sc = self.
_algmgr.removeAlgorithm(self)
1564 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)