|
Gaudi Framework, version v22r0 |
| Home | Generated: 9 Feb 2011 |


Public Member Functions | |
| def | __new__ |
| def | __reset__ |
| def | __init__ |
| def | state |
| def | FSMState |
| def | targetFSMState |
| def | loaddict |
| def | service |
| def | declSvcType |
| def | createSvc |
| def | services |
| def | algorithm |
| def | algorithms |
| def | tool |
| def | property |
| def | datasvc |
| def | evtsvc |
| def | detsvc |
| def | filerecordsvc |
| def | evtsel |
| def | histsvc |
| def | ntuplesvc |
| def | partsvc |
| def | toolsvc |
| def | optSvc |
| def | readOptions |
| def | addAlgorithm |
| def | setAlgorithms |
| def | removeAlgorithm |
| def | config |
| def | configure |
| def | start |
| def | run |
| def | executeEvent |
| def | execute |
| def | runSelectedEvents |
| def | exit |
| def | __del__ |
| Custom destructor to ensure that the application is correctly finalized when exiting from python. | |
Public Attributes | |
| JobOptionsType | |
| OutputLevel | |
| topAlg | |
Static Public Attributes | |
| evtSvc = evtsvc | |
| histSvc = histsvc | |
| ntupleSvc = ntuplesvc | |
| evtSel = evtsel | |
| detSvc = detsvc | |
| toolSvc = toolsvc | |
| partSvc = partsvc | |
Definition at line 656 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::__del__ | ( | self | ) |
Custom destructor to ensure that the application is correctly finalized when exiting from python.
Definition at line 1009 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::__init__ | ( | self, | ||
outputlevel = -1, |
||||
joboptions = None, |
||||
selfoptions = {}, |
||||
dllname = None, |
||||
factname = None | ||||
| ) |
Definition at line 677 of file Bindings.py.
00677 {}, 00678 dllname = None, factname = None) : 00679 global _gaudi 00680 if _gaudi : return 00681 # Protection against multiple calls to exit() if the finalization fails 00682 self.__dict__['_exit_called'] = False 00683 # keep the Gaudi namespace around (so it is still available during atexit shutdown)... 00684 self.__dict__['_gaudi_ns'] = Gaudi 00685 try: 00686 from GaudiKernel.Proxy.Configurable import expandvars 00687 except ImportError: 00688 # pass-through implementation if expandvars is not defined (AthenaCommon) 00689 expandvars = lambda data : data 00690 if dllname and factname: 00691 self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr(dllname,factname) 00692 elif dllname: 00693 self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr(dllname) 00694 else: 00695 self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr() 00696 self.__dict__['_svcloc'] = gbl.Gaudi.svcLocator() 00697 self.__dict__['_algmgr'] = InterfaceCast(gbl.IAlgManager)(self._appmgr) 00698 self.__dict__['_evtpro'] = InterfaceCast(gbl.IEventProcessor)(self._appmgr) 00699 self.__dict__['_svcmgr'] = InterfaceCast(gbl.ISvcManager)(self._appmgr) 00700 self.__dict__['pyalgorithms'] = [] 00701 iService.__init__(self, 'ApplicationMgr', self._appmgr ) 00702 #------python specific initialization------------------------------------- 00703 if self.FSMState() < Gaudi.StateMachine.CONFIGURED : # Not yet configured 00704 self.JobOptionsType = 'NONE' 00705 if joboptions : 00706 from GaudiKernel.ProcessJobOptions import importOptions 00707 importOptions(joboptions) 00708 # Ensure that the ConfigurableUser instances have been applied 00709 import GaudiKernel.Proxy.Configurable 00710 if hasattr(GaudiKernel.Proxy.Configurable, "applyConfigurableUsers"): 00711 GaudiKernel.Proxy.Configurable.applyConfigurableUsers() 00712 # This is the default and could be overridden with "selfopts" 00713 self.OutputLevel = 3 00714 selfprops = Configurable.allConfigurables.get('ApplicationMgr',{}) 00715 if selfprops : selfprops = expandvars(selfprops.getValuedProperties()) 00716 for p,v in selfprops.items() : setattr(self, p, v) 00717 for p,v in selfoptions.items() : setattr(self, p, v) 00718 # Override job options 00719 if outputlevel != -1 : self.OutputLevel = outputlevel 00720 self.configure() 00721 #---MessageSvc------------------------------------------------------------ 00722 ms = self.service('MessageSvc') 00723 if 'MessageSvc' in Configurable.allConfigurables: 00724 msprops = Configurable.allConfigurables['MessageSvc'] 00725 ms = self.service('MessageSvc') 00726 if hasattr(msprops,"getValuedProperties"): 00727 msprops = expandvars(msprops.getValuedProperties()) 00728 for p,v in msprops.items(): 00729 setattr(ms, p, v) 00730 if outputlevel != -1 : ms.OutputLevel = outputlevel 00731 #---JobOptions------------------------------------------------------------ 00732 self.__dict__['_optsvc'] = InterfaceCast(gbl.IJobOptionsSvc)(Helper.service(self._svcloc,'JobOptionsSvc')) 00733 #------Configurables initialization (part2)------------------------------- 00734 for n in getNeededConfigurables(): 00735 c = Configurable.allConfigurables[n] 00736 if n in ['ApplicationMgr','MessageSvc'] : continue # These are already done--- 00737 for p, v in c.getValuedProperties().items() : 00738 v = expandvars(v) 00739 # Note: AthenaCommon.Configurable does not have Configurable.PropertyReference 00740 if hasattr(Configurable,"PropertyReference") and type(v) == Configurable.PropertyReference: 00741 # this is done in "getFullName", but the exception is ignored, 00742 # so we do it again to get it 00743 v = v.__resolve__() 00744 if type(v) == str : v = '"%s"' % v # need double quotes 00745 elif type(v) == long: v = '%d' % v # prevent pending 'L' 00746 self._optsvc.addPropertyToCatalogue(n, StringProperty(p,str(v))) 00747 if hasattr(Configurable,"_configurationLocked"): 00748 Configurable._configurationLocked = True 00749 00750 # Ensure that the exit method is called when exiting from Python 00751 import atexit 00752 atexit.register(self.exit) 00753 00754 #---Hack to avoid bad interactions with the ROOT exit handler 00755 # Look for an exit handler installed by ROOT 00756 root_handler_installed = False 00757 for h in atexit._exithandlers: 00758 func = h[0] 00759 if hasattr(func, "__module__") and func.__module__ == "ROOT": 00760 root_handler_installed = True 00761 break 00762 00763 # If the handler is not yet installed, let's install our private version 00764 # that detects that the ROOT exit handler is installed and add our own 00765 # after it to ensure it is called before. 00766 if not root_handler_installed: 00767 orig_register = atexit.register 00768 def register(func, *targs, **kargs): 00769 orig_register(func, *targs, **kargs) 00770 if hasattr(func, "__module__") and func.__module__ == "ROOT": 00771 orig_register(self.exit) 00772 # we do not need to remove out handler from the list because 00773 # it can be safely called more than once 00774 register.__doc__ = (orig_register.__doc__ + 00775 "\nNote: version hacked by GaudiPython to work " + 00776 "around a problem with the ROOT exit handler") 00777 atexit.register = register 00778
| def GaudiPython::Bindings::AppMgr::__new__ | ( | cls, | ||
| args, | ||||
| kwargs | ||||
| ) |
Definition at line 657 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::__reset__ | ( | self | ) |
Definition at line 664 of file Bindings.py.
00665 : 00666 global _gaudi 00667 # Stop, Finalize and Terminate the current AppMgr 00668 self.exit() 00669 # release interfaces 00670 self._evtpro.release() 00671 self._svcloc.release() 00672 self._appmgr.release() 00673 # Reset the C++ globals 00674 gbl.Gaudi.setInstance(makeNullPointer('ISvcLocator')) 00675 gbl.Gaudi.setInstance(makeNullPointer('IAppMgrUI')) 00676 # Reset the Python global _gaudi = None
| def GaudiPython::Bindings::AppMgr::addAlgorithm | ( | self, | ||
| alg | ||||
| ) |
Add an Algorithm to the list of Top algorithms. It can be either a instance of
an Algorithm class or it name Definition at line 854 of file Bindings.py.
00855 : 00856 """ Add an Algorithm to the list of Top algorithms. It can be either a instance of 00857 an Algorithm class or it name """ 00858 if type(alg) is str : 00859 self.topAlg += [alg] 00860 else : 00861 self.pyalgorithms.append(alg) 00862 setOwnership(alg,0) 00863 if self.targetFSMState() >= Gaudi.StateMachine.INITIALIZED : 00864 alg.sysInitialize() 00865 if self.targetFSMState() == Gaudi.StateMachine.RUNNING : 00866 alg.sysStart() self.topAlg += [alg.name()]
| def GaudiPython::Bindings::AppMgr::algorithm | ( | self, | ||
| name, | ||||
createIf = False | ||||
| ) |
Definition at line 802 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::algorithms | ( | self | ) |
Definition at line 806 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::config | ( | self, | ||
| args | ||||
| ) |
Simple utility to perform the configuration of Gaudi application.
It reads the set of input job-options files, and set few
additional parameters 'options' through the usage of temporary *.opts file
Usage:
gaudi.config( files = [ '$GAUSSOPTS/Gauss.opts' ,
'$DECFILESROOT/options/10022_010.0GeV.opts' ] ,
options = [ 'EventSelector.PrintFreq = 5 ' ] )
Definition at line 893 of file Bindings.py.
00894 : 00895 """ 00896 Simple utility to perform the configuration of Gaudi application. 00897 It reads the set of input job-options files, and set few 00898 additional parameters 'options' through the usage of temporary *.opts file 00899 Usage: 00900 gaudi.config( files = [ '$GAUSSOPTS/Gauss.opts' , 00901 '$DECFILESROOT/options/10022_010.0GeV.opts' ] , 00902 options = [ 'EventSelector.PrintFreq = 5 ' ] ) 00903 """ 00904 files = args.get('files',[]) 00905 for file in files : 00906 sc = self.readOptions(file) 00907 if sc.isFailure() : 00908 raise RuntimeError , ' Unable to read file "' + file +'" ' 00909 options = args.get('options',None) 00910 if options : 00911 import tempfile 00912 tmpfilename = tempfile.mktemp() 00913 tmpfile = open( tmpfilename, 'w' ) 00914 tmpfile.write ( '#pragma print on \n' ) 00915 tmpfile.write ( '/// File "' + tmpfilename+'" generated by GaudiPython \n\n' ) 00916 for opt in options : 00917 if type(options) is dict : 00918 tmpfile.write( ' \t ' + opt + ' = '+ options[opt]+ ' ; // added by GaudiPython \n' ) 00919 else : 00920 tmpfile.write( ' \t ' + opt + ' ; // added by GaudiPython \n' ) 00921 tmpfile.write ( '/// End of file "' + tmpfilename+'" generated by GaudiPython \n\n' ) 00922 tmpfile.close() 00923 sc = self.readOptions( tmpfilename ) 00924 if sc.isFailure() : 00925 raise RuntimeError , ' Unable to read file "' + tmpfilename +'" ' 00926 os.remove( tmpfilename ) 00927 # We need to make sure that the options are taken by the ApplicationMgr 00928 if self.FSMState() != Gaudi.StateMachine.OFFLINE : # The state is already configured, so we need to do something.... 00929 00930 ## get job-options-service, @see class iJobOptSvc 00931 jos = self.optSvc() 00932 00933 ## list of all libraries 00934 _dlls = jos.getProperty ( self.name() , 'DLLs' ) 00935 ## take care about libraries : APPEND if not done yet 00936 if _dlls : 00937 libs = [ l for l in _dlls if not l in self.DLLs ] 00938 if libs : self.DLLs += libs 00939 00940 ## all external services 00941 _svcs = jos.getProperty ( self.name() , 'ExtSvc' ) 00942 ## take care about services : APPEND if not done yet 00943 if _svcs : 00944 svcs = [ s for s in _svcs if not s in self.ExtSvc ] 00945 if svcs : self.ExtSvc += svcs 00946 00947 ## get all properties 00948 props = jos.getProperties ( self.name() ) 00949 ## finally treat all other properties (presumably scalar properties) 00950 for key in props : 00951 if 'DLLS' == key or 'EXTSVC' == key : continue 00952 self.__setattr__( key , props[key] ) return SUCCESS # RETURN
| def GaudiPython::Bindings::AppMgr::configure | ( | self | ) |
Definition at line 953 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::createSvc | ( | self, | ||
| name | ||||
| ) |
Definition at line 792 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::datasvc | ( | self, | ||
| name | ||||
| ) |
Definition at line 820 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::declSvcType | ( | self, | ||
| svcname, | ||||
| svctype | ||||
| ) |
Definition at line 790 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::detsvc | ( | self | ) |
Definition at line 826 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::evtsel | ( | self | ) |
Definition at line 830 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::evtsvc | ( | self | ) |
Definition at line 824 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::execute | ( | self | ) |
Definition at line 967 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::executeEvent | ( | self | ) |
Definition at line 965 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::exit | ( | self | ) |
Definition at line 996 of file Bindings.py.
00997 : 00998 # Protection against multiple calls to exit() if the finalization fails 00999 if not self._exit_called: 01000 self.__dict__['_exit_called'] = True 01001 Gaudi = self._gaudi_ns 01002 if self.FSMState() == Gaudi.StateMachine.RUNNING: 01003 self._appmgr.stop().ignore() 01004 if self.FSMState() == Gaudi.StateMachine.INITIALIZED: 01005 self._appmgr.finalize().ignore() 01006 if self.FSMState() == Gaudi.StateMachine.CONFIGURED: 01007 self._appmgr.terminate() return SUCCESS
| def GaudiPython::Bindings::AppMgr::filerecordsvc | ( | self | ) |
Definition at line 828 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::FSMState | ( | self | ) |
Definition at line 780 of file Bindings.py.
00780 : return self._isvc.FSMState()
| def GaudiPython::Bindings::AppMgr::histsvc | ( | self, | ||
name = 'HistogramDataSvc' | ||||
| ) |
Definition at line 834 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::loaddict | ( | self, | ||
| dict | ||||
| ) |
Definition at line 782 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::ntuplesvc | ( | self, | ||
name = 'NTupleSvc' | ||||
| ) |
Definition at line 837 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::optSvc | ( | self, | ||
name = 'JobOptionsSvc' | ||||
| ) |
Definition at line 849 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::partsvc | ( | self | ) |
Definition at line 842 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::property | ( | self, | ||
| name | ||||
| ) |
Definition at line 816 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::readOptions | ( | self, | ||
| file | ||||
| ) |
Definition at line 852 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::removeAlgorithm | ( | self, | ||
| alg | ||||
| ) |
Remove an Algorithm to the list of Top algorithms. It can be either a instance of
an Algorithm class or it name Definition at line 882 of file Bindings.py.
00883 : 00884 """ Remove an Algorithm to the list of Top algorithms. It can be either a instance of 00885 an Algorithm class or it name """ 00886 tmp = self.topAlg 00887 if type(alg) is str : 00888 tmp.remove(alg) 00889 else : 00890 tmp.remove(alg.name()) 00891 self.pyalgorithms.remove(alg) 00892 setOwnership(alg,1) self.topAlg = tmp
| def GaudiPython::Bindings::AppMgr::run | ( | self, | ||
| n | ||||
| ) |
Definition at line 957 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::runSelectedEvents | ( | self, | ||
| pfn, | ||||
| events | ||||
| ) |
Definition at line 969 of file Bindings.py.
00970 : 00971 if self.FSMState() == Gaudi.StateMachine.CONFIGURED : 00972 sc = self.initialize() 00973 if sc.isFailure(): return sc 00974 if self.FSMState() == Gaudi.StateMachine.INITIALIZED : 00975 sc = self.start() 00976 if sc.isFailure(): return sc 00977 #--- Access a number of services ---- 00978 if not hasattr(self,'_perssvc'): self.__dict__['_perssvc'] = self.service('EventPersistencySvc','IAddressCreator') 00979 if not hasattr(self,'_filecat'): self.__dict__['_filecat'] = self.service('FileCatalog','Gaudi::IFileCatalog') 00980 if not hasattr(self,'_evtmgr'): self.__dict__['_evtmgr'] = self.service('EventDataSvc','IDataManagerSvc') 00981 #--- Get FID from PFN and number of events in file 00982 if pfn.find('PFN:') == 0: pfn = pfn[4:] 00983 fid, maxevt = _getFIDandEvents(pfn) 00984 #--- Add FID into catalog if needed --- 00985 if not self._filecat.existsFID(fid) : self._filecat.registerPFN(fid, pfn, '') 00986 #--- Loop over events 00987 if type(events) is not list : events = (events,) 00988 for evt in events : 00989 #--- Create POOL Address from Generic Address 00990 gadd = gbl.GenericAddress(0x202, 1, fid, '/Event', 0, evt) 00991 oadd = makeNullPointer('IOpaqueAddress') 00992 self._perssvc.createAddress(gadd.svcType(),gadd.clID(),gadd.par(),gadd.ipar(),oadd) 00993 #--- Clear TES, set root and run all algorithms 00994 self._evtmgr.clearStore() 00995 self._evtmgr.setRoot('/Event',oadd) self._evtpro.executeEvent()
| def GaudiPython::Bindings::AppMgr::service | ( | self, | ||
| name, | ||||
interface = None | ||||
| ) |
Definition at line 784 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::services | ( | self | ) |
Definition at line 794 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::setAlgorithms | ( | self, | ||
| algs | ||||
| ) |
Set the list of Top Algorithms.
It can be an individual of a list of algorithms names or instances Definition at line 867 of file Bindings.py.
00868 : 00869 """ Set the list of Top Algorithms. 00870 It can be an individual of a list of algorithms names or instances """ 00871 if type(algs) is not list : algs = [algs] 00872 names = [] 00873 for alg in algs : 00874 if type(alg) is str : names.append(alg) 00875 else : 00876 self.pyalgorithms.append(alg) 00877 if self.targetFSMState() >= Gaudi.StateMachine.INITIALIZED : 00878 alg.sysInitialize() 00879 if self.targetFSMState() == Gaudi.StateMachine.RUNNING : 00880 alg.sysStart() 00881 names.append(alg.name()) self.topAlg = names
| def GaudiPython::Bindings::AppMgr::start | ( | self | ) |
Definition at line 955 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::state | ( | self | ) |
Definition at line 779 of file Bindings.py.
00779 : return self._isvc.FSMState()
| def GaudiPython::Bindings::AppMgr::targetFSMState | ( | self | ) |
Definition at line 781 of file Bindings.py.
00781 : return self._isvc.targetFSMState()
| def GaudiPython::Bindings::AppMgr::tool | ( | self, | ||
| name | ||||
| ) |
Definition at line 814 of file Bindings.py.
| def GaudiPython::Bindings::AppMgr::toolsvc | ( | self, | ||
name = 'ToolSvc' | ||||
| ) |
Definition at line 846 of file Bindings.py.
GaudiPython::Bindings::AppMgr::detSvc = detsvc [static] |
Definition at line 1015 of file Bindings.py.
GaudiPython::Bindings::AppMgr::evtSel = evtsel [static] |
Definition at line 1014 of file Bindings.py.
GaudiPython::Bindings::AppMgr::evtSvc = evtsvc [static] |
Definition at line 1011 of file Bindings.py.
GaudiPython::Bindings::AppMgr::histSvc = histsvc [static] |
Definition at line 1012 of file Bindings.py.
Definition at line 703 of file Bindings.py.
GaudiPython::Bindings::AppMgr::ntupleSvc = ntuplesvc [static] |
Definition at line 1013 of file Bindings.py.
Definition at line 712 of file Bindings.py.
GaudiPython::Bindings::AppMgr::partSvc = partsvc [static] |
Definition at line 1017 of file Bindings.py.
GaudiPython::Bindings::AppMgr::toolSvc = toolsvc [static] |
Definition at line 1016 of file Bindings.py.
Definition at line 881 of file Bindings.py.