| 24 | {{{ |
| 25 | import matrix2py |
| 26 | |
| 27 | def invert_momenta(p): |
| 28 | """ fortran/C-python do not order table in the same order""" |
| 29 | new_p = [] |
| 30 | for i in range(len(p[0])): new_p.append([0]*len(p)) |
| 31 | for i, onep in enumerate(p): |
| 32 | for j, x in enumerate(onep): |
| 33 | new_p[j][i] = x |
| 34 | return new_p |
| 35 | |
| 36 | matrix2py.initialisemodel('../../Cards/param_card.dat') |
| 37 | p = [[ 0.5000000E+03, 0.0000000E+00, 0.0000000E+00, 0.5000000E+03], |
| 38 | [ 0.5000000E+03, 0.0000000E+00, 0.0000000E+00, -0.5000000E+03], |
| 39 | [ 0.5000000E+03, 0.1109243E+03, 0.4448308E+03, -0.1995529E+03], |
| 40 | [ 0.5000000E+03, -0.1109243E+03, -0.4448308E+03, 0.1995529E+03]] |
| 41 | |
| 42 | P =invert_momenta(p) |
| 43 | alphas = 0.13 |
| 44 | nhel = -1 # means sum over all helicity |
| 45 | me2 = matrix2py.get_value(P, alphas, nhel) |
| 46 | print me2 |
| 47 | }}} |
| 48 | |
| 49 | === Full library of process in python |
| 50 | |
| 51 | If you are interested to have a single python library for a set of matrix-element. |
| 52 | This is also possible in fortran/python. |
| 53 | This is possible both for loop output ([sqr=virt]) and for tree level. |
| 54 | {{{ |
| 55 | generate p p > t t~ |
| 56 | output standalone PATH --prefix=int |
| 57 | }}} |
| 58 | |
| 59 | then you can compile the library by going to the SubProcesses directory and |
| 60 | {{{ |
| 61 | make allmatrix2py.so |
| 62 | }}} |
| 63 | |
| 64 | Here is one example in that case |
| 65 | {{{ |
| 66 | import allmatrix2py |
| 67 | allmatrix2py.initialise('../Cards/param_card.dat') |
| 68 | |
| 69 | def invert_momenta(p): |
| 70 | """ fortran/C-python do not order table in the same order""" |
| 71 | new_p = [] |
| 72 | for i in range(len(p[0])): new_p.append([0]*len(p)) |
| 73 | for i, onep in enumerate(p): |
| 74 | for j, x in enumerate(onep): |
| 75 | new_p[j][i] = x |
| 76 | return new_p |
| 77 | p =[[ 0.5000000E+03, 0.0000000E+00, 0.0000000E+00, 0.5000000E+03], |
| 78 | [0.5000000E+03, 0.0000000E+00, 0.0000000E+00, -0.5000000E+03], |
| 79 | [ 0.5000000E+03, 0.1040730E+03, 0.4173556E+03, -0.1872274E+03], |
| 80 | [ 0.5000000E+03, -0.1040730E+03, -0.4173556E+03, 0.1872274E+03] |
| 81 | ] |
| 82 | |
| 83 | p =invert_momenta(p) |
| 84 | nhel = -1 # means sum over all helicity |
| 85 | pdgs = [21,21,6,-6] #which pdg is requested |
| 86 | scale2 = 0. #only used for loop matrix element. should be set to 0 for tree-level |
| 87 | alphas=0.13 |
| 88 | |
| 89 | ans = allmatrix2py.smatrixhel(pdgs,p,alphas,scale2,nhel) |
| 90 | print ans |
| 91 | }}} |
| 92 | |
| 93 | === Python for version MG5_aMC version 2.5.x |
| 94 | |
| 95 | For version of the code older than 2.6.0, the syntax was: |
| 96 | |