| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

ExtendedProperties.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # =============================================================================
00003 # $Id: ExtendedProperties.py,v 1.4 2007/08/07 13:00:28 marcocle Exp $
00004 # =============================================================================
00005 # CVS tag $Name: GAUDI_v20r4-pre $, version $Revision: 1.4 $
00006 # =============================================================================
00007 """
00008 *******************************************************************************
00009 *                                                                             *
00010 * Simple example (identical to C++ ExtendedProperties.opts) which illustrates *
00011 * the extended job-properties and their C++/Python intercommunication         *
00012 *                                                                             *
00013 *******************************************************************************
00014 """
00015 # =============================================================================
00016 __author__ = 'Vanya BELYAEV ibelyaev@physics.syr.edu'
00017 # =============================================================================
00018 ## @file
00019 #  Simple example (identical to C++ ExtendedProperties.opts) which illustrates 
00020 #  the extended job-properties and their C++/Python intercommunication         
00021 #  @author Vanya BELYAEV ibelyaev@physics.syr.edu
00022 #  @date 2007-02-13
00023 # =============================================================================
00024 
00025 import gaudimodule
00026 
00027 SUCCESS = gaudimodule.SUCCESS 
00028 
00029 # =============================================================================
00030 ## the configurtaion of the job
00031 def configure ( gaudi = None ) :
00032     """ the configurtaion of the job """
00033     
00034     ## create application manager if not done yet 
00035     if not gaudi : gaudi = gaudimodule.AppMgr()
00036     
00037     ## read main configuration files 
00038     gaudi.config ( files = [ '../options/Common.opts' ] )
00039     
00040     ## private algorithm configuration options
00041     
00042     gaudi.TopAlg = [ "ExtendedProperties/xProps" ]
00043     gaudi.EvtSel = 'NONE'
00044     gaudi.HistogramPersistency = 'NONE'
00045 
00046     xProps = gaudi.algorithm( 'xProps' )
00047     
00048     # std::pair<double,double>
00049     # xProps.PairDD = ( 3.141592 , 2.18281828 )
00050     # std::pair<int,int>
00051     # xProps.PairII = ( 3        , 2          )
00052 
00053     # std::vector<std::pair<double,double> > 
00054     xProps.VectorOfPairsDD = [ (0,1), (1,2), (2,3), (3,4) ]
00055     
00056     # std::vector<std::vector<std::string> >
00057     xProps.VectorOfVectorsString = [
00058         [ "a", "b" , "c" ] , [ "A", "B" , "C" ] ]
00059     
00060     # std::vector<std::vector<double> >
00061     xProps.VectorOfVectorsDouble = [ 
00062         [ 0 , 1 , 2 ] , [ 0 , -0.5 , -0.25 ] ]
00063 
00064     
00065     # std::map<int,double>
00066     xProps.MapIntDouble = { 
00067         1 : 0.1 , 2 : 0.2 , 3 : 0.3 }
00068     
00069     # std::map<std::string,std::string>
00070     xProps.MapStringString = {
00071         'a' : 'sddsgsgsdgdggf' , 
00072         'b' : 'sddsgsgsdgdggf' , 
00073         'c' : 'sddsgsgsdgdggf' }
00074 
00075     
00076     # std::map<std::string,int>
00077     xProps.MapStringInt = {
00078         'a' : 1 ,
00079         'b' : 2 ,  
00080         "c" : 3 }
00081     
00082     # std::map<std::string,double>
00083     xProps.MapStringDouble = {
00084         'aa' : 0.1 , 
00085         'bb' : 0.2 ,
00086         "cc" : 3   }
00087     
00088     # std::map<std::string,std::vector<std::string> >
00089     xProps.MapStringVectorOfStrings = {
00090         'aaa' : [ 'a' , 'b' ,'c' ] ,
00091         'bbb' : [ 'a' , 'b' ,'c' ] , 
00092         'ccc' : [ 'a' , 'b' ,'c' ] }
00093     
00094     # std::map<std::string,std::vector<double> >
00095     xProps.MapStringVectorOfDoubles = {
00096         'aaa' : [ 1   , 2   , 3   ] , 
00097         'bbb' : [ 1.  , 2.  , 3.  ] , 
00098         'ccc' : [ 0.1 , 0.2 , 0.3 ] }
00099     
00100     # std::map<std::string,std::vector<int> >
00101     xProps.MapStringVectorOfInts = {
00102         'aaa' : [ 1 , 2 , 3 ] , 
00103         'bbb' : [ 4 , 5 , 6 ] , 
00104         'ccc' : [ 7 , 8 , 9 ] } 
00105     
00106     return SUCCESS
00107 
00108 # =============================================================================
00109 # The actual job excution 
00110 # =============================================================================
00111 if '__main__' == __name__ :
00112     
00113     print __doc__ , __author__
00114     
00115     gaudi = gaudimodule.AppMgr()
00116     configure( gaudi )
00117     gaudi.run(1)
00118 
00119     alg = gaudi.algorithm( 'xProps' )
00120 
00121     ## get all properties throught python
00122     #
00123     # IT DOES NOT WORK ANYMORE after the
00124     # reimplementation of
00125     # gaudimodule.iProperty.properties using
00126     # new class PropertyEntry
00127     #
00128     props = alg.properties()
00129 
00130     print 'All Properties of %s ' % alg.name()
00131     for p in props :
00132         v = props[p].value() 
00133         t = type(v).__name__  
00134         print "Python: Name/Value:  '%s' / '%s' "%(p,v)
00135 
00136     ## get the properties in the form of python dictionary:
00137     print 'All Properties of %s ' % alg.name()
00138     properties = {}
00139     for p in props : properties[p] = props[p].value()
00140 
00141     for p in properties : 
00142         print "Python: Name/Value:  '%s' / '%s' "%(p,properties[p])
00143 
00144         
00145 # =============================================================================
00146 # The END 
00147 # =============================================================================
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:59:39 2011 for GaudiExamples by doxygen 1.4.7