|
Gaudi Framework, version v21r8 |
| Home | Generated: 17 Mar 2010 |


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::__new__ | ( | cls, | ||
| args, | ||||
| kwargs | ||||
| ) |
Definition at line 657 of file Bindings.py.
00657 : 00658 global _gaudi 00659 if not _gaudi : 00660 newobj = object.__new__( cls, *args, **kwargs ) 00661 cls.__init__(newobj, *args, **kwargs) 00662 _gaudi = newobj 00663 return _gaudi def __reset__(self):
| def GaudiPython::Bindings::AppMgr::__reset__ | ( | self | ) |
Definition at line 664 of file Bindings.py.
00664 : 00665 global _gaudi 00666 # Stop, Finalize and Terminate the current AppMgr 00667 self.exit() 00668 # release interfaces 00669 self._evtpro.release() 00670 self._svcloc.release() 00671 self._appmgr.release() 00672 # Reset the C++ globals 00673 gbl.Gaudi.setInstance(makeNullPointer('ISvcLocator')) 00674 gbl.Gaudi.setInstance(makeNullPointer('IAppMgrUI')) 00675 # Reset the Python global 00676 _gaudi = None def __init__(self, outputlevel = -1, joboptions = None, selfoptions = {},
| 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 try: 00684 from GaudiKernel.Proxy.Configurable import expandvars 00685 except ImportError: 00686 # pass-through implementation if expandvars is not defined (AthenaCommon) 00687 expandvars = lambda data : data 00688 if dllname and factname: 00689 self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr(dllname,factname) 00690 elif dllname: 00691 self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr(dllname) 00692 else: 00693 self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr() 00694 self.__dict__['_svcloc'] = gbl.Gaudi.svcLocator() 00695 self.__dict__['_algmgr'] = InterfaceCast(gbl.IAlgManager)(self._appmgr) 00696 self.__dict__['_evtpro'] = InterfaceCast(gbl.IEventProcessor)(self._appmgr) 00697 self.__dict__['_svcmgr'] = InterfaceCast(gbl.ISvcManager)(self._appmgr) 00698 self.__dict__['pyalgorithms'] = [] 00699 iService.__init__(self, 'ApplicationMgr', self._appmgr ) 00700 #------python specific initialization------------------------------------- 00701 if self.FSMState() < Gaudi.StateMachine.CONFIGURED : # Not yet configured 00702 self.JobOptionsType = 'NONE' 00703 if joboptions : 00704 from GaudiKernel.ProcessJobOptions import importOptions 00705 importOptions(joboptions) 00706 # Ensure that the ConfigurableUser instances have been applied 00707 import GaudiKernel.Proxy.Configurable 00708 if hasattr(GaudiKernel.Proxy.Configurable, "applyConfigurableUsers"): 00709 GaudiKernel.Proxy.Configurable.applyConfigurableUsers() 00710 # This is the default and could be overridden with "selfopts" 00711 self.OutputLevel = 3 00712 selfprops = Configurable.allConfigurables.get('ApplicationMgr',{}) 00713 if selfprops : selfprops = expandvars(selfprops.getValuedProperties()) 00714 for p,v in selfprops.items() : setattr(self, p, v) 00715 for p,v in selfoptions.items() : setattr(self, p, v) 00716 # Override job options 00717 if outputlevel != -1 : self.OutputLevel = outputlevel 00718 self.configure() 00719 #---MessageSvc------------------------------------------------------------ 00720 ms = self.service('MessageSvc') 00721 if 'MessageSvc' in Configurable.allConfigurables: 00722 msprops = Configurable.allConfigurables['MessageSvc'] 00723 ms = self.service('MessageSvc') 00724 if hasattr(msprops,"getValuedProperties"): 00725 msprops = expandvars(msprops.getValuedProperties()) 00726 for p,v in msprops.items(): 00727 setattr(ms, p, v) 00728 if outputlevel != -1 : ms.OutputLevel = outputlevel 00729 #---JobOptions------------------------------------------------------------ 00730 self.__dict__['_optsvc'] = InterfaceCast(gbl.IJobOptionsSvc)(Helper.service(self._svcloc,'JobOptionsSvc')) 00731 #------Configurables initialization (part2)------------------------------- 00732 for n in getNeededConfigurables(): 00733 c = Configurable.allConfigurables[n] 00734 if n in ['ApplicationMgr','MessageSvc'] : continue # These are already done--- 00735 for p, v in c.getValuedProperties().items() : 00736 v = expandvars(v) 00737 # Note: AthenaCommon.Configurable does not have Configurable.PropertyReference 00738 if hasattr(Configurable,"PropertyReference") and type(v) == Configurable.PropertyReference: 00739 # this is done in "getFullName", but the exception is ignored, 00740 # so we do it again to get it 00741 v = v.__resolve__() 00742 if type(v) == str : v = '"%s"' % v # need double quotes 00743 elif type(v) == long: v = '%d' % v # prevent pending 'L' 00744 self._optsvc.addPropertyToCatalogue(n, StringProperty(p,str(v))) 00745 if hasattr(Configurable,"_configurationLocked"): 00746 Configurable._configurationLocked = True
| def GaudiPython::Bindings::AppMgr::state | ( | self | ) |
| def GaudiPython::Bindings::AppMgr::FSMState | ( | self | ) |
| def GaudiPython::Bindings::AppMgr::targetFSMState | ( | self | ) |
| def GaudiPython::Bindings::AppMgr::loaddict | ( | self, | ||
| dict | ||||
| ) |
| def GaudiPython::Bindings::AppMgr::service | ( | self, | ||
| name, | ||||
interface = None | ||||
| ) |
Definition at line 752 of file Bindings.py.
00752 : 00753 svc = Helper.service( self._svcloc, name ) 00754 if interface : 00755 return InterfaceCast(interface)(svc) 00756 else : 00757 return iService(name, svc ) def declSvcType(self, svcname, svctype ) :
| def GaudiPython::Bindings::AppMgr::declSvcType | ( | self, | ||
| svcname, | ||||
| svctype | ||||
| ) |
| def GaudiPython::Bindings::AppMgr::createSvc | ( | self, | ||
| name | ||||
| ) |
| def GaudiPython::Bindings::AppMgr::services | ( | self | ) |
Definition at line 762 of file Bindings.py.
00762 : 00763 l = self._svcloc.getServices() 00764 nl = l.__class__(l) # get a copy 00765 s = [] 00766 for i in range(l.size()) : 00767 s.append(nl.front().name()) 00768 nl.pop_front() 00769 return s def algorithm(self, name ) :
| def GaudiPython::Bindings::AppMgr::algorithm | ( | self, | ||
| name | ||||
| ) |
Definition at line 770 of file Bindings.py.
00770 : 00771 alg = Helper.algorithm( self._algmgr, name ) 00772 return iAlgorithm(name, alg ) def algorithms(self) :
| def GaudiPython::Bindings::AppMgr::algorithms | ( | self | ) |
Definition at line 773 of file Bindings.py.
00773 : 00774 l = self._algmgr.getAlgorithms() 00775 nl = l.__class__(l) # get a copy 00776 s = [] 00777 for i in range(l.size()) : 00778 s.append(nl.front().name()) 00779 nl.pop_front() 00780 return s def tool(self, name ) :
| def GaudiPython::Bindings::AppMgr::tool | ( | self, | ||
| name | ||||
| ) |
| def GaudiPython::Bindings::AppMgr::property | ( | self, | ||
| name | ||||
| ) |
Definition at line 783 of file Bindings.py.
00783 : 00784 if name in self.algorithms() : return self.algorithm( name ) 00785 elif name in self.services() : return self.service(name ) 00786 else : return iProperty( name ) def datasvc(self, name) :
| def GaudiPython::Bindings::AppMgr::datasvc | ( | self, | ||
| name | ||||
| ) |
Definition at line 787 of file Bindings.py.
00787 : 00788 if self.state() == Gaudi.StateMachine.CONFIGURED : self.initialize() 00789 svc = Helper.service( self._svcloc, name ) 00790 return iDataSvc(name, svc) def evtsvc(self) :
| def GaudiPython::Bindings::AppMgr::evtsvc | ( | self | ) |
| def GaudiPython::Bindings::AppMgr::detsvc | ( | self | ) |
Definition at line 793 of file Bindings.py.
00793 : 00794 return self.datasvc('DetectorDataSvc') def filerecordsvc(self) :
| def GaudiPython::Bindings::AppMgr::filerecordsvc | ( | self | ) |
| def GaudiPython::Bindings::AppMgr::evtsel | ( | self | ) |
Definition at line 797 of file Bindings.py.
00797 : 00798 if self.state() == Gaudi.StateMachine.CONFIGURED : self.initialize() 00799 if not hasattr(self,'_evtsel') : self.__dict__['_evtsel'] = iEventSelector() 00800 return self._evtsel def histsvc(self, name='HistogramDataSvc') :
| def GaudiPython::Bindings::AppMgr::histsvc | ( | self, | ||
name = 'HistogramDataSvc' | ||||
| ) |
Definition at line 801 of file Bindings.py.
00801 : 00802 svc = Helper.service( self._svcloc, name ) 00803 return iHistogramSvc(name, svc) def ntuplesvc(self, name='NTupleSvc') :
| def GaudiPython::Bindings::AppMgr::ntuplesvc | ( | self, | ||
name = 'NTupleSvc' | ||||
| ) |
Definition at line 804 of file Bindings.py.
00804 : 00805 if name not in self.ExtSvc : self.ExtSvc += [name] 00806 # if self.HistogramPersistency == 'NONE' : self.HistogramPersistency = 'ROOT' 00807 svc = Helper.service( self._svcloc, name, True ) 00808 return iNTupleSvc(name, svc) def partsvc(self ) :
| def GaudiPython::Bindings::AppMgr::partsvc | ( | self | ) |
Definition at line 809 of file Bindings.py.
00809 : 00810 if self.FSMState() == Gaudi.StateMachine.CONFIGURED : self.initialize() 00811 svc = Helper.service( self._svcloc, 'ParticlePropertySvc' ) 00812 return InterfaceCast(gbl.IParticlePropertySvc)(svc) def toolsvc(self, name='ToolSvc') :
| def GaudiPython::Bindings::AppMgr::toolsvc | ( | self, | ||
name = 'ToolSvc' | ||||
| ) |
Definition at line 813 of file Bindings.py.
00813 : 00814 svc = Helper.service( self._svcloc, name, True ) 00815 return iToolSvc(name, svc) def optSvc (self, name='JobOptionsSvc') :
| def GaudiPython::Bindings::AppMgr::optSvc | ( | self, | ||
name = 'JobOptionsSvc' | ||||
| ) |
Definition at line 816 of file Bindings.py.
00816 : 00817 svc = Helper.service( self._svcloc, name, True ) 00818 return iJobOptSvc(name, svc) def readOptions(self, file) :
| def GaudiPython::Bindings::AppMgr::readOptions | ( | self, | ||
| file | ||||
| ) |
Definition at line 819 of file Bindings.py.
00819 : 00820 return self._optsvc.readOptions(file) def addAlgorithm(self, alg) :
| 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 821 of file Bindings.py.
00821 : 00822 """ Add an Algorithm to the list of Top algorithms. It can be either a instance of 00823 an Algorithm class or it name """ 00824 if type(alg) is str : 00825 self.topAlg += [alg] 00826 else : 00827 self.pyalgorithms.append(alg) 00828 setOwnership(alg,0) 00829 if self.targetFSMState() >= Gaudi.StateMachine.INITIALIZED : 00830 alg.sysInitialize() 00831 if self.targetFSMState() == Gaudi.StateMachine.RUNNING : 00832 alg.sysStart() 00833 self.topAlg += [alg.name()] def setAlgorithms(self, algs) :
| 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 834 of file Bindings.py.
00834 : 00835 """ Set the list of Top Algorithms. 00836 It can be an individual of a list of algorithms names or instances """ 00837 if type(algs) is not list : algs = [algs] 00838 names = [] 00839 for alg in algs : 00840 if type(alg) is str : names.append(alg) 00841 else : 00842 self.pyalgorithms.append(alg) 00843 if self.targetFSMState() >= Gaudi.StateMachine.INITIALIZED : 00844 alg.sysInitialize() 00845 if self.targetFSMState() == Gaudi.StateMachine.RUNNING : 00846 alg.sysStart() 00847 names.append(alg.name()) 00848 self.topAlg = names def removeAlgorithm(self, alg) :
| 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 849 of file Bindings.py.
00849 : 00850 """ Remove an Algorithm to the list of Top algorithms. It can be either a instance of 00851 an Algorithm class or it name """ 00852 tmp = self.topAlg 00853 if type(alg) is str : 00854 tmp.remove(alg) 00855 else : 00856 tmp.remove(alg.name()) 00857 self.pyalgorithms.remove(alg) 00858 setOwnership(alg,1) 00859 self.topAlg = tmp def config ( self, **args ):
| 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 860 of file Bindings.py.
00860 : 00861 """ 00862 Simple utility to perform the configuration of Gaudi application. 00863 It reads the set of input job-options files, and set few 00864 additional parameters 'options' through the usage of temporary *.opts file 00865 Usage: 00866 gaudi.config( files = [ '$GAUSSOPTS/Gauss.opts' , 00867 '$DECFILESROOT/options/10022_010.0GeV.opts' ] , 00868 options = [ 'EventSelector.PrintFreq = 5 ' ] ) 00869 """ 00870 files = args.get('files',[]) 00871 for file in files : 00872 sc = self.readOptions(file) 00873 if sc.isFailure() : 00874 raise RuntimeError , ' Unable to read file "' + file +'" ' 00875 options = args.get('options',None) 00876 if options : 00877 import tempfile 00878 tmpfilename = tempfile.mktemp() 00879 tmpfile = open( tmpfilename, 'w' ) 00880 tmpfile.write ( '#pragma print on \n' ) 00881 tmpfile.write ( '/// File "' + tmpfilename+'" generated by GaudiPython \n\n' ) 00882 for opt in options : 00883 if type(options) is dict : 00884 tmpfile.write( ' \t ' + opt + ' = '+ options[opt]+ ' ; // added by GaudiPython \n' ) 00885 else : 00886 tmpfile.write( ' \t ' + opt + ' ; // added by GaudiPython \n' ) 00887 tmpfile.write ( '/// End of file "' + tmpfilename+'" generated by GaudiPython \n\n' ) 00888 tmpfile.close() 00889 sc = self.readOptions( tmpfilename ) 00890 if sc.isFailure() : 00891 raise RuntimeError , ' Unable to read file "' + tmpfilename +'" ' 00892 os.remove( tmpfilename ) 00893 # We need to make sure that the options are taken by the ApplicationMgr 00894 if self.FSMState() != Gaudi.StateMachine.OFFLINE : # The state is already configured, so we need to do something.... 00895 00896 ## get job-options-service, @see class iJobOptSvc 00897 jos = self.optSvc() 00898 00899 ## list of all libraries 00900 _dlls = jos.getProperty ( self.name() , 'DLLs' ) 00901 ## take care about libraries : APPEND if not done yet 00902 if _dlls : 00903 libs = [ l for l in _dlls if not l in self.DLLs ] 00904 if libs : self.DLLs += libs 00905 00906 ## all external services 00907 _svcs = jos.getProperty ( self.name() , 'ExtSvc' ) 00908 ## take care about services : APPEND if not done yet 00909 if _svcs : 00910 svcs = [ s for s in _svcs if not s in self.ExtSvc ] 00911 if svcs : self.ExtSvc += svcs 00912 00913 ## get all properties 00914 props = jos.getProperties ( self.name() ) 00915 ## finally treat all other properties (presumably scalar properties) 00916 for key in props : 00917 if 'DLLS' == key or 'EXTSVC' == key : continue 00918 self.__setattr__( key , props[key] ) 00919 return SUCCESS # RETURN def configure(self) :
| def GaudiPython::Bindings::AppMgr::configure | ( | self | ) |
| def GaudiPython::Bindings::AppMgr::start | ( | self | ) |
| def GaudiPython::Bindings::AppMgr::run | ( | self, | ||
| n | ||||
| ) |
Definition at line 924 of file Bindings.py.
00924 : 00925 if self.FSMState() == Gaudi.StateMachine.CONFIGURED : 00926 sc = self.initialize() 00927 if sc.isFailure(): return sc 00928 if self.FSMState() == Gaudi.StateMachine.INITIALIZED : 00929 sc = self.start() 00930 if sc.isFailure(): return sc 00931 return self._evtpro.executeRun(n) def executeEvent(self) :
| def GaudiPython::Bindings::AppMgr::executeEvent | ( | self | ) |
| def GaudiPython::Bindings::AppMgr::execute | ( | self | ) |
Definition at line 934 of file Bindings.py.
00934 : 00935 return self._evtpro.executeEvent() def runSelectedEvents(self, pfn, events):
| def GaudiPython::Bindings::AppMgr::runSelectedEvents | ( | self, | ||
| pfn, | ||||
| events | ||||
| ) |
Definition at line 936 of file Bindings.py.
00936 : 00937 if self.FSMState() == Gaudi.StateMachine.CONFIGURED : 00938 sc = self.initialize() 00939 if sc.isFailure(): return sc 00940 if self.FSMState() == Gaudi.StateMachine.INITIALIZED : 00941 sc = self.start() 00942 if sc.isFailure(): return sc 00943 #--- Access a number of services ---- 00944 if not hasattr(self,'_perssvc'): self.__dict__['_perssvc'] = self.service('EventPersistencySvc','IAddressCreator') 00945 if not hasattr(self,'_filecat'): self.__dict__['_filecat'] = self.service('FileCatalog','Gaudi::IFileCatalog') 00946 if not hasattr(self,'_evtmgr'): self.__dict__['_evtmgr'] = self.service('EventDataSvc','IDataManagerSvc') 00947 #--- Get FID from PFN and number of events in file 00948 if pfn.find('PFN:') == 0: pfn = pfn[4:] 00949 fid, maxevt = _getFIDandEvents(pfn) 00950 #--- Add FID into catalog if needed --- 00951 if not self._filecat.existsFID(fid) : self._filecat.registerPFN(fid, pfn, '') 00952 #--- Loop over events 00953 if type(events) is not list : events = (events,) 00954 for evt in events : 00955 #--- Create POOL Address from Generic Address 00956 gadd = gbl.GenericAddress(0x202, 1, fid, '/Event', 0, evt) 00957 oadd = makeNullPointer('IOpaqueAddress') 00958 self._perssvc.createAddress(gadd.svcType(),gadd.clID(),gadd.par(),gadd.ipar(),oadd) 00959 #--- Clear TES, set root and run all algorithms 00960 self._evtmgr.clearStore() 00961 self._evtmgr.setRoot('/Event',oadd) 00962 self._evtpro.executeEvent() def exit(self):
| def GaudiPython::Bindings::AppMgr::exit | ( | self | ) |
Definition at line 963 of file Bindings.py.
00963 : 00964 # Protection against multiple calls to exit() if the finalization fails 00965 if not self._exit_called: 00966 self.__dict__['_exit_called'] = True 00967 if self.FSMState() == Gaudi.StateMachine.RUNNING: 00968 self._appmgr.stop().ignore() 00969 if self.FSMState() == Gaudi.StateMachine.INITIALIZED: 00970 self._appmgr.finalize().ignore() 00971 if self.FSMState() == Gaudi.StateMachine.CONFIGURED: 00972 self._appmgr.terminate() 00973 return SUCCESS ## Custom destructor to ensure that the application is correctly finalized when exiting from python.
| def GaudiPython::Bindings::AppMgr::__del__ | ( | self | ) |
Custom destructor to ensure that the application is correctly finalized when exiting from python.
Definition at line 975 of file Bindings.py.
GaudiPython::Bindings::AppMgr::evtSvc = evtsvc [static] |
Definition at line 977 of file Bindings.py.
GaudiPython::Bindings::AppMgr::histSvc = histsvc [static] |
Definition at line 978 of file Bindings.py.
GaudiPython::Bindings::AppMgr::ntupleSvc = ntuplesvc [static] |
Definition at line 979 of file Bindings.py.
GaudiPython::Bindings::AppMgr::evtSel = evtsel [static] |
Definition at line 980 of file Bindings.py.
GaudiPython::Bindings::AppMgr::detSvc = detsvc [static] |
Definition at line 981 of file Bindings.py.
GaudiPython::Bindings::AppMgr::toolSvc = toolsvc [static] |
Definition at line 982 of file Bindings.py.
GaudiPython::Bindings::AppMgr::partSvc = partsvc [static] |
Definition at line 983 of file Bindings.py.
Definition at line 701 of file Bindings.py.
Definition at line 710 of file Bindings.py.
Definition at line 848 of file Bindings.py.