00001
00002
00003
00004
00005
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
00019
00020
00021
00022
00023
00024
00025 import gaudimodule
00026
00027 SUCCESS = gaudimodule.SUCCESS
00028
00029
00030
00031 def configure ( gaudi = None ) :
00032 """ the configurtaion of the job """
00033
00034
00035 if not gaudi : gaudi = gaudimodule.AppMgr()
00036
00037
00038 gaudi.config ( files = [ '../options/Common.opts' ] )
00039
00040
00041
00042 gaudi.TopAlg = [ "ExtendedProperties/xProps" ]
00043 gaudi.EvtSel = 'NONE'
00044 gaudi.HistogramPersistency = 'NONE'
00045
00046 xProps = gaudi.algorithm( 'xProps' )
00047
00048
00049
00050
00051
00052
00053
00054 xProps.VectorOfPairsDD = [ (0,1), (1,2), (2,3), (3,4) ]
00055
00056
00057 xProps.VectorOfVectorsString = [
00058 [ "a", "b" , "c" ] , [ "A", "B" , "C" ] ]
00059
00060
00061 xProps.VectorOfVectorsDouble = [
00062 [ 0 , 1 , 2 ] , [ 0 , -0.5 , -0.25 ] ]
00063
00064
00065
00066 xProps.MapIntDouble = {
00067 1 : 0.1 , 2 : 0.2 , 3 : 0.3 }
00068
00069
00070 xProps.MapStringString = {
00071 'a' : 'sddsgsgsdgdggf' ,
00072 'b' : 'sddsgsgsdgdggf' ,
00073 'c' : 'sddsgsgsdgdggf' }
00074
00075
00076
00077 xProps.MapStringInt = {
00078 'a' : 1 ,
00079 'b' : 2 ,
00080 "c" : 3 }
00081
00082
00083 xProps.MapStringDouble = {
00084 'aa' : 0.1 ,
00085 'bb' : 0.2 ,
00086 "cc" : 3 }
00087
00088
00089 xProps.MapStringVectorOfStrings = {
00090 'aaa' : [ 'a' , 'b' ,'c' ] ,
00091 'bbb' : [ 'a' , 'b' ,'c' ] ,
00092 'ccc' : [ 'a' , 'b' ,'c' ] }
00093
00094
00095 xProps.MapStringVectorOfDoubles = {
00096 'aaa' : [ 1 , 2 , 3 ] ,
00097 'bbb' : [ 1. , 2. , 3. ] ,
00098 'ccc' : [ 0.1 , 0.2 , 0.3 ] }
00099
00100
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
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
00122
00123
00124
00125
00126
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
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
00147