loop matrix element through python
Dear Madgraph experts,
I'm trying to calculate matrix elements using the python interface as in https:/
I'm using the loop_sm model and I'm working with the u u~ > z > t t~ process.
This is what I'm doing:
import model loop_sm
generate u u~ > z > t t~ [virt=QCD]
output test_virtual (I also tried : output standalone test_virtual)
launch
then, after entering the process library P0_uux_z_ttx I'm doing the following:
make matrix2py.so
which creates check_sa.py. Then when doing: ./check_sa.py or python check_sa.py I get this error:
Traceback (most recent call last):
File "check_sa.py", line 47, in <module>
matrix2py.
AttributeError: 'module' object has no attribute 'ml5_0_initialise'
I also tried to run it through a python script as in https:/
Traceback (most recent call last):
File "MG5-PBZp-
matrix2py.
AttributeError: 'module' object has no attribute 'initialisemodel'
PS: I tested this procedure for LO processes in the sm model file and it works fine.
Thank you in advance,
Best,
Mohammad
Question information
- Language:
- English Edit question
- Status:
- Open
- Assignee:
- Valentin Hirschi Edit question
- Last query:
- 2019-04-03
- Last reply:
PS: I was using version 2_6_4
I have the same problem also with version 2_6_5
Hi,
For Valentin sake,
I can reproduce the issue.
I have also found that the following two functions are defined:
./SubProcesses/
Binary file ./SubProcesses/
./SubProcesses/
In order to make it trough, I had to change check_sa.py to use the following:
# Read the model parameters
matrix2py.
This can be in prinicple be changed in
./iolibs/
But I guess this is too naive... What do you think Valentin?
Cheers,
Olivier
Dear Mohammad,
For the sake of other users, I am copying here my email replies to your direct queries sent to me:
My reply A:
----
The prefixes of the python binding functions such as `ml5_0_initialise` used in the script `.\check_sa.py` are unfoturnately not up to date.
I should fix this.
You can easily check what is the correct prefix and adjust it in the script `check_sa.py` by doing:
```
python
import matrix2py
print dir(matrix2py)
```
and it should show all functions exposed in the python bindings, so you can recognise and adjust the correct index.
I will try to fix this soon.
Alternatively and in the meantime you can also simply use the fortran driver with
```
make check
./check
```
You can adjust things (PS point evaluated for instance) directly in the fortran driver file `check_sa.f`
----
Your request B:
----
Thank you very much for your answer, this solved my problem.
The reason why I want to use python is that I'm using other tools to compare with madgraph and I already have everything written with python.
I have one more question, what if I want to print both loop and born amplitude, how can that be done for the same process.
----
My reply B:
----
Yes, and also in principle you can access individually all terms of the squared order amplitudes individually if you force the specification of the "squared" order at generation time, for instance:
```
generate u u~ > d d~ [virt=QCD] QED^2<=99 QCD^2<=99; output TMP_TESTSQO; launch -f;
[...]
|======
|| Results for process uux > ddx
|======
|| Phase-Space point specification (E,px,py,pz)
|
| 5.0000000000000
| 5.0000000000000
| 4.9999999999999
| 5.0000000000000
|
| Unknown numerical stability because MadLoop is in the initialization stage.
|
|| Total(*) Born contribution (GeV^0):
| Born = 5.4178705933854
|| Total(*) virtual contribution normalized with born*alpha_
| Finite = -4.209057632610
| Single pole = 1.4228818635682
| Double pole = -5.333333333333
| (*) The results above sum all starred contributions below
|
|| Born contribution of split orders *(QCD=4 QED=0) = 5.6645006116010
|| Born contribution of split orders *(QCD=2 QED=2) = -3.595541637026
|| Born contribution of split orders *(QCD=0 QED=4) = 1.1292414548701
|
|| Virtual contribution of split orders *(QCD=6 QED=0):
| Accuracy = -1.0e+00
| Finite = -4.504189464524
| Single pole = 1.5184917947040
| Double pole = -5.673649394828
|| Virtual contribution of split orders *(QCD=4 QED=2):
| Accuracy = -1.0e+00
| Finite = 2.9459712231663
| Single pole = -1.046400200265
| Double pole = 3.6013488269762
|| Virtual contribution of split orders *(QCD=2 QED=4):
| Accuracy = -1.0e+00
| Finite = -7.308779235407
| Single pole = 3.3918349380617
| Double pole = -1.131065302370
|======
```
Now in the python bindings, the function `matrix2py.
But this is just because of the python wrapper (i.e. for instance the fortran driver returns everything, born and poles).
So if you want to access it from within Python I suggest you modify directly the binding. It is pretty straight forward to do, simply follow
the definition of the subroutine `GET_ME` in the file `f2py_wrapper.f` and you will see in it the following:
```
ANS = MATELEM(1,0)
```
But you can decide to return other (or all) entries of this `MATELEM(i,j)` (short for Matrix Element) rank-2 array
i==0 : Born
i==1 : Finite part
i==2 : Single pole
i==3 : Double pole
j=0 : All contributions summed
j>1 : Contribution to the j^th combination of coupling orders (QED^2==X, QCD^2==Y, etc...)
You can find the bi-drectional maps between `j` and (X, Y, ....) using the fortran functions:
`FUNCTION ML5_0_ML5SOINDE
and
`SUBROUTINE ML5_0_ML5GET_
which can also be wrapped into python bindings if necessary (the former must be wrapped within a subroutine first too).
Anyway, I hope this helps and that you manage to access whatever you need from MadLoop from within Python directly.
----
Can you help with this problem?
Provide an answer of your own, or ask Mohammad for more information if necessary.