|
Gaudi Framework, version v21r4 |
| Home | Generated: 7 Sep 2009 |


Definition at line 571 of file Bindings.py.
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 | 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 |
Public Attributes | |
| JobOptionsType | |
| OutputLevel | |
| topAlg | |
Static Public Attributes | |
| evtSvc = evtsvc | |
| histSvc = histsvc | |
| ntupleSvc = ntuplesvc | |
| evtSel = evtsel | |
| detSvc = detsvc | |
| toolSvc = toolsvc | |
| partSvc = partsvc | |
| def GaudiPython::Bindings::AppMgr::__new__ | ( | cls, | ||
| args, | ||||
| kwargs | ||||
| ) |
Definition at line 572 of file Bindings.py.
00572 : 00573 global _gaudi 00574 if not _gaudi : 00575 newobj = object.__new__( cls, *args, **kwargs ) 00576 cls.__init__(newobj, *args, **kwargs) 00577 _gaudi = newobj 00578 return _gaudi def __reset__(self):
| def GaudiPython::Bindings::AppMgr::__reset__ | ( | self | ) |
Definition at line 579 of file Bindings.py.
00579 : 00580 global _gaudi 00581 # Stop, Finalize and Terminate the current AppMgr 00582 self.exit() 00583 # release interfaces 00584 self._evtpro.release() 00585 self._svcloc.release() 00586 self._appmgr.release() 00587 # Reset the C++ globals 00588 gbl.Gaudi.setInstance(makeNullPointer('ISvcLocator')) 00589 gbl.Gaudi.setInstance(makeNullPointer('IAppMgrUI')) 00590 # Reset the Python global 00591 _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 592 of file Bindings.py.
00592 {}, 00593 dllname = None, factname = None) : 00594 global _gaudi 00595 if _gaudi : return 00596 try: 00597 from GaudiKernel.Proxy.Configurable import expandvars 00598 except ImportError: 00599 # pass-through implementation if expandvars is not defined (AthenaCommon) 00600 expandvars = lambda data : data 00601 if dllname and factname: 00602 self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr(dllname,factname) 00603 elif dllname: 00604 self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr(dllname) 00605 else: 00606 self.__dict__['_appmgr'] = gbl.Gaudi.createApplicationMgr() 00607 self.__dict__['_svcloc'] = gbl.Gaudi.svcLocator() 00608 self.__dict__['_algmgr'] = InterfaceCast(gbl.IAlgManager)(self._appmgr) 00609 self.__dict__['_evtpro'] = InterfaceCast(gbl.IEventProcessor)(self._appmgr) 00610 self.__dict__['_svcmgr'] = InterfaceCast(gbl.ISvcManager)(self._appmgr) 00611 self.__dict__['pyalgorithms'] = [] 00612 iService.__init__(self, 'ApplicationMgr', self._appmgr ) 00613 #------python specific initialization------------------------------------- 00614 if self.FSMState() < Gaudi.StateMachine.CONFIGURED : # Not yet configured 00615 self.JobOptionsType = 'NONE' 00616 if joboptions : 00617 from GaudiKernel.ProcessJobOptions import importOptions 00618 importOptions(joboptions) 00619 # Ensure that the ConfigurableUser instances have been applied 00620 import GaudiKernel.Proxy.Configurable 00621 if hasattr(GaudiKernel.Proxy.Configurable, "applyConfigurableUsers"): 00622 GaudiKernel.Proxy.Configurable.applyConfigurableUsers() 00623 # This is the default and could be overridden with "selfopts" 00624 self.OutputLevel = 3 00625 selfprops = Configurable.allConfigurables.get('ApplicationMgr',{}) 00626 if selfprops : selfprops = expandvars(selfprops.getValuedProperties()) 00627 for p,v in selfprops.items() : setattr(self, p, v) 00628 for p,v in selfoptions.items() : setattr(self, p, v) 00629 # Override job options 00630 if outputlevel != -1 : self.OutputLevel = outputlevel 00631 self.configure() 00632 #---MessageSvc------------------------------------------------------------ 00633 ms = self.service('MessageSvc') 00634 if 'MessageSvc' in Configurable.allConfigurables: 00635 msprops = Configurable.allConfigurables['MessageSvc'] 00636 ms = self.service('MessageSvc') 00637 if hasattr(msprops,"getValuedProperties"): 00638 msprops = expandvars(msprops.getValuedProperties()) 00639 for p,v in msprops.items(): 00640 setattr(ms, p, v) 00641 if outputlevel != -1 : ms.OutputLevel = outputlevel 00642 #---JobOptions------------------------------------------------------------ 00643 self.__dict__['_optsvc'] = InterfaceCast(gbl.IJobOptionsSvc)(Helper.service(self._svcloc,'JobOptionsSvc')) 00644 #------Configurables initialization (part2)------------------------------- 00645 for n in getNeededConfigurables(): 00646 c = Configurable.allConfigurables[n] 00647 if n in ['ApplicationMgr','MessageSvc'] : continue # These are already done--- 00648 for p, v in c.getValuedProperties().items() : 00649 v = expandvars(v) 00650 # Note: AthenaCommon.Configurable does not have Configurable.PropertyReference 00651 if hasattr(Configurable,"PropertyReference") and type(v) == Configurable.PropertyReference: 00652 # this is done in "getFullName", but the exception is ignored, 00653 # so we do it again to get it 00654 v = v.__resolve__() 00655 if type(v) == str : v = '"%s"' % v # need double quotes 00656 elif type(v) == long: v = '%d' % v # prevent pending 'L' 00657 self._optsvc.addPropertyToCatalogue(n, StringProperty(p,str(v))) 00658 if hasattr(Configurable,"_configurationLocked"): 00659 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 665 of file Bindings.py.
00665 : 00666 svc = Helper.service( self._svcloc, name ) 00667 if interface : 00668 return InterfaceCast(interface)(svc) 00669 else : 00670 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 675 of file Bindings.py.
00675 : 00676 l = self._svcloc.getServices() 00677 nl = l.__class__(l) # get a copy 00678 s = [] 00679 for i in range(l.size()) : 00680 s.append(nl.front().name()) 00681 nl.pop_front() 00682 return s def algorithm(self, name ) :
| def GaudiPython::Bindings::AppMgr::algorithm | ( | self, | ||
| name | ||||
| ) |
Definition at line 683 of file Bindings.py.
00683 : 00684 alg = Helper.algorithm( self._algmgr, name ) 00685 return iAlgorithm(name, alg ) def algorithms(self) :
| def GaudiPython::Bindings::AppMgr::algorithms | ( | self | ) |
Definition at line 686 of file Bindings.py.
00686 : 00687 l = self._algmgr.getAlgorithms() 00688 nl = l.__class__(l) # get a copy 00689 s = [] 00690 for i in range(l.size()) : 00691 s.append(nl.front().name()) 00692 nl.pop_front() 00693 return s def tool(self, name ) :
| def GaudiPython::Bindings::AppMgr::tool | ( | self, | ||
| name | ||||
| ) |
| def GaudiPython::Bindings::AppMgr::property | ( | self, | ||
| name | ||||
| ) |
Definition at line 696 of file Bindings.py.
00696 : 00697 if name in self.algorithms() : return self.algorithm( name ) 00698 elif name in self.services() : return self.service(name ) 00699 else : return iProperty( name ) def datasvc(self, name) :
| def GaudiPython::Bindings::AppMgr::datasvc | ( | self, | ||
| name | ||||
| ) |
Definition at line 700 of file Bindings.py.
00700 : 00701 if self.state() == Gaudi.StateMachine.CONFIGURED : self.initialize() 00702 svc = Helper.service( self._svcloc, name ) 00703 return iDataSvc(name, svc) def evtsvc(self) :
| def GaudiPython::Bindings::AppMgr::evtsvc | ( | self | ) |
| def GaudiPython::Bindings::AppMgr::detsvc | ( | self | ) |
| def GaudiPython::Bindings::AppMgr::evtsel | ( | self | ) |
Definition at line 708 of file Bindings.py.
00708 : 00709 if self.state() == Gaudi.StateMachine.CONFIGURED : self.initialize() 00710 if not hasattr(self,'_evtsel') : self.__dict__['_evtsel'] = iEventSelector() 00711 return self._evtsel def histsvc(self, name='HistogramDataSvc') :
| def GaudiPython::Bindings::AppMgr::histsvc | ( | self, | ||
name = 'HistogramDataSvc' | ||||
| ) |
Definition at line 712 of file Bindings.py.
00712 : 00713 svc = Helper.service( self._svcloc, name ) 00714 return iHistogramSvc(name, svc) def ntuplesvc(self, name='NTupleSvc') :
| def GaudiPython::Bindings::AppMgr::ntuplesvc | ( | self, | ||
name = 'NTupleSvc' | ||||
| ) |
Definition at line 715 of file Bindings.py.
00715 : 00716 if name not in self.ExtSvc : self.ExtSvc += [name] 00717 # if self.HistogramPersistency == 'NONE' : self.HistogramPersistency = 'ROOT' 00718 svc = Helper.service( self._svcloc, name, True ) 00719 return iNTupleSvc(name, svc) def partsvc(self ) :
| def GaudiPython::Bindings::AppMgr::partsvc | ( | self | ) |
Definition at line 720 of file Bindings.py.
00720 : 00721 if self.FSMState() == Gaudi.StateMachine.CONFIGURED : self.initialize() 00722 svc = Helper.service( self._svcloc, 'ParticlePropertySvc' ) 00723 return InterfaceCast(gbl.IParticlePropertySvc)(svc) def toolsvc(self, name='ToolSvc') :
| def GaudiPython::Bindings::AppMgr::toolsvc | ( | self, | ||
name = 'ToolSvc' | ||||
| ) |
Definition at line 724 of file Bindings.py.
00724 : 00725 svc = Helper.service( self._svcloc, name, True ) 00726 return iToolSvc(name, svc) def optSvc (self, name='JobOptionsSvc') :
| def GaudiPython::Bindings::AppMgr::optSvc | ( | self, | ||
name = 'JobOptionsSvc' | ||||
| ) |
Definition at line 727 of file Bindings.py.
00727 : 00728 svc = Helper.service( self._svcloc, name, True ) 00729 return iJobOptSvc(name, svc) def readOptions(self, file) :
| def GaudiPython::Bindings::AppMgr::readOptions | ( | self, | ||
| file | ||||
| ) |
Definition at line 730 of file Bindings.py.
00730 : 00731 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 732 of file Bindings.py.
00732 : 00733 """ Add an Algorithm to the list of Top algorithms. It can be either a instance of 00734 an Algorithm class or it name """ 00735 if type(alg) is str : 00736 self.topAlg += [alg] 00737 else : 00738 self.pyalgorithms.append(alg) 00739 setOwnership(alg,0) 00740 if self.targetFSMState() >= Gaudi.StateMachine.INITIALIZED : 00741 alg.sysInitialize() 00742 if self.targetFSMState() == Gaudi.StateMachine.RUNNING : 00743 alg.sysStart() 00744 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 745 of file Bindings.py.
00745 : 00746 """ Set the list of Top Algorithms. 00747 It can be an individual of a list of algorithms names or instances """ 00748 if type(algs) is not list : algs = [algs] 00749 names = [] 00750 for alg in algs : 00751 if type(alg) is str : names.append(alg) 00752 else : 00753 self.pyalgorithms.append(alg) 00754 if self.targetFSMState() >= Gaudi.StateMachine.INITIALIZED : 00755 alg.sysInitialize() 00756 if self.targetFSMState() == Gaudi.StateMachine.RUNNING : 00757 alg.sysStart() 00758 names.append(alg.name()) 00759 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 760 of file Bindings.py.
00760 : 00761 """ Remove an Algorithm to the list of Top algorithms. It can be either a instance of 00762 an Algorithm class or it name """ 00763 tmp = self.topAlg 00764 if type(alg) is str : 00765 tmp.remove(alg) 00766 else : 00767 tmp.remove(alg.name()) 00768 self.pyalgorithms.remove(alg) 00769 setOwnership(alg,1) 00770 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 771 of file Bindings.py.
00771 : 00772 """ 00773 Simple utility to perform the configuration of Gaudi application. 00774 It reads the set of input job-options files, and set few 00775 additional parameters 'options' through the usage of temporary *.opts file 00776 Usage: 00777 gaudi.config( files = [ '$GAUSSOPTS/Gauss.opts' , 00778 '$DECFILESROOT/options/10022_010.0GeV.opts' ] , 00779 options = [ 'EventSelector.PrintFreq = 5 ' ] ) 00780 """ 00781 files = args.get('files',[]) 00782 for file in files : 00783 sc = self.readOptions(file) 00784 if sc.isFailure() : 00785 raise RuntimeError , ' Unable to read file "' + file +'" ' 00786 options = args.get('options',None) 00787 if options : 00788 import tempfile 00789 tmpfilename = tempfile.mktemp() 00790 tmpfile = open( tmpfilename, 'w' ) 00791 tmpfile.write ( '#pragma print on \n' ) 00792 tmpfile.write ( '/// File "' + tmpfilename+'" generated by GaudiPython \n\n' ) 00793 for opt in options : 00794 if type(options) is dict : 00795 tmpfile.write( ' \t ' + opt + ' = '+ options[opt]+ ' ; // added by GaudiPython \n' ) 00796 else : 00797 tmpfile.write( ' \t ' + opt + ' ; // added by GaudiPython \n' ) 00798 tmpfile.write ( '/// End of file "' + tmpfilename+'" generated by GaudiPython \n\n' ) 00799 tmpfile.close() 00800 sc = self.readOptions( tmpfilename ) 00801 if sc.isFailure() : 00802 raise RuntimeError , ' Unable to read file "' + tmpfilename +'" ' 00803 os.remove( tmpfilename ) 00804 # We need to make sure that the options are taken by the ApplicationMgr 00805 if self.FSMState() != Gaudi.StateMachine.OFFLINE : # The state is already configured, so we need to do something.... 00806 00807 ## get job-options-service, @see class iJobOptSvc 00808 jos = self.optSvc() 00809 00810 ## list of all libraries 00811 _dlls = jos.getProperty ( self.name() , 'DLLs' ) 00812 ## take care about libraries : APPEND if not done yet 00813 if _dlls : 00814 libs = [ l for l in _dlls if not l in self.DLLs ] 00815 if libs : self.DLLs += libs 00816 00817 ## all external services 00818 _svcs = jos.getProperty ( self.name() , 'ExtSvc' ) 00819 ## take care about services : APPEND if not done yet 00820 if _svcs : 00821 svcs = [ s for s in _svcs if not s in self.ExtSvc ] 00822 if svcs : self.ExtSvc += svcs 00823 00824 ## get all properties 00825 props = jos.getProperties ( self.name() ) 00826 ## finally treat all other properties (presumably scalar properties) 00827 for key in props : 00828 if 'DLLS' == key or 'EXTSVC' == key : continue 00829 self.__setattr__( key , props[key] ) 00830 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 835 of file Bindings.py.
00835 : 00836 if self.FSMState() == Gaudi.StateMachine.CONFIGURED : 00837 sc = self.initialize() 00838 if sc.isFailure(): return sc 00839 if self.FSMState() == Gaudi.StateMachine.INITIALIZED : 00840 sc = self.start() 00841 if sc.isFailure(): return sc 00842 return self._evtpro.executeRun(n) def executeEvent(self) :
| def GaudiPython::Bindings::AppMgr::executeEvent | ( | self | ) |
| def GaudiPython::Bindings::AppMgr::execute | ( | self | ) |
Definition at line 845 of file Bindings.py.
00845 : 00846 return self._evtpro.executeEvent() def runSelectedEvents(self, pfn, events):
| def GaudiPython::Bindings::AppMgr::runSelectedEvents | ( | self, | ||
| pfn, | ||||
| events | ||||
| ) |
Definition at line 847 of file Bindings.py.
00847 : 00848 if self.FSMState() == Gaudi.StateMachine.CONFIGURED : 00849 sc = self.initialize() 00850 if sc.isFailure(): return sc 00851 if self.FSMState() == Gaudi.StateMachine.INITIALIZED : 00852 sc = self.start() 00853 if sc.isFailure(): return sc 00854 #--- Access a number of services ---- 00855 if not hasattr(self,'_perssvc'): self.__dict__['_perssvc'] = self.service('EventPersistencySvc','IAddressCreator') 00856 if not hasattr(self,'_filecat'): self.__dict__['_filecat'] = self.service('FileCatalog','Gaudi::IFileCatalog') 00857 if not hasattr(self,'_evtmgr'): self.__dict__['_evtmgr'] = self.service('EventDataSvc','IDataManagerSvc') 00858 #--- Get FID from PFN and number of events in file 00859 if pfn.find('PFN:') == 0: pfn = pfn[4:] 00860 fid, maxevt = _getFIDandEvents(pfn) 00861 #--- Add FID into catalog if needed --- 00862 if not self._filecat.existsFID(fid) : self._filecat.registerPFN(fid, pfn, '') 00863 #--- Loop over events 00864 if type(events) is not list : events = (events,) 00865 for evt in events : 00866 #--- Create POOL Address from Generic Address 00867 gadd = gbl.GenericAddress(0x202, 1, fid, '/Event', 0, evt) 00868 oadd = makeNullPointer('IOpaqueAddress') 00869 self._perssvc.createAddress(gadd.svcType(),gadd.clID(),gadd.par(),gadd.ipar(),oadd) 00870 #--- Clear TES, set root and run all algorithms 00871 self._evtmgr.clearStore() 00872 self._evtmgr.setRoot('/Event',oadd) 00873 self._evtpro.executeEvent() def exit(self) :
| def GaudiPython::Bindings::AppMgr::exit | ( | self | ) |
Definition at line 874 of file Bindings.py.
00874 : 00875 if self.FSMState() == Gaudi.StateMachine.RUNNING: self._appmgr.stop().ignore() 00876 if self.FSMState() == Gaudi.StateMachine.INITIALIZED: self._appmgr.finalize().ignore() 00877 return self._appmgr.terminate() evtSvc = evtsvc
GaudiPython::Bindings::AppMgr::evtSvc = evtsvc [static] |
Definition at line 878 of file Bindings.py.
GaudiPython::Bindings::AppMgr::histSvc = histsvc [static] |
Definition at line 879 of file Bindings.py.
GaudiPython::Bindings::AppMgr::ntupleSvc = ntuplesvc [static] |
Definition at line 880 of file Bindings.py.
GaudiPython::Bindings::AppMgr::evtSel = evtsel [static] |
Definition at line 881 of file Bindings.py.
GaudiPython::Bindings::AppMgr::detSvc = detsvc [static] |
Definition at line 882 of file Bindings.py.
GaudiPython::Bindings::AppMgr::toolSvc = toolsvc [static] |
Definition at line 883 of file Bindings.py.
GaudiPython::Bindings::AppMgr::partSvc = partsvc [static] |
Definition at line 884 of file Bindings.py.
Definition at line 614 of file Bindings.py.
Definition at line 623 of file Bindings.py.
Definition at line 759 of file Bindings.py.