c++ output for custom models ?
Dear MG'ers,
I'm trying to understand what is the best way to get the matrix element offline at any point in the phase-space, from a c++ code.
The model I'm using is described here: https:/
So, my question divides into 2:
(1) can MG give a c++ formatted matrix element (averaged and squared) for models which do not ship with MG by default (e.g. ggHFullLoop) ?
(2) an alternative could be to link the objects coming from the generated fortran code, with a c++ code using the "extern" feature. The question is which function should be called and how to initialise the procedure ?
For (2) I actually managed to do something like that after having the process generated (see code below).
However, I'm not sure which of the fortran functions I should call from my c++ code. I have tried:
SMATRIX1(...) --> runtime problems with initialising NTRY(2)
DSIG1(...) --> same as for SMATRIX1
DSIG(...) --> executes well but seems to return sigma=0 always
Any prompt help would be highly appreciated !
Cheers,
Noam
///////
//// C++ code to link with MG fortran ////
//// Makefile is trivial ///////
///////
#include <iostream>
using namespace std;
extern "C" {
void smatrix1_(double** pp, double* ans);
}
extern "C" {
double dsig1_(double** pp, double* wgt, int* imode);
}
extern "C" {
double dsig_(double** pp, double* wgt, int* imode);
}
int main()
{
double** pp = new double*[4];
for (int i=0; i<4; ++i) pp[i] = new double[5];
double* wgt = new double; *wgt = 1;
int* imode = new int; *imode = 1;
// example gg-->ttbar event, in the ggHFullLoop model with only the pseudo-scalar turned on, taken from the lhe file
pp[0][0] = 0.00000000000E+00; pp[0][1] = 0.00000000000E+00; pp[0][2] = 0.40139316999E+03; pp[0][3] = 0.40139316999E+03;
pp[1][0] = 0.00000000000E+00; pp[1][1] = 0.00000000000E+00; pp[1][2] = -0.25134778946E+03; pp[1][3] = 0.25134778946E+03;
pp[2][0] = 0.50428638474E+02; pp[2][1] = 0.61397720859E+02; pp[2][2] = -0.18658101548E+03; pp[2][3] = 0.26623570956E+03;
pp[3][0] = -0.50428638474E+02; pp[3][1] = -0.61397720859E+02; pp[3][2] = 0.33662639601E+03; pp[3][3] = 0.38650524989E+03;
// DSIG(...) works but returns 0
*imode = 1; // initialize ?
dsig_
*imode = 0; // run ?
double xs = dsig_(pp,
cout << "xs=" << xs << endl;
// DSIG1(...) issues with initialization
// *imode = 5; // should give only the matrix element
// double xs = dsig1_(
// cout << "xs=" << xs << endl;
// SMATRIX1(...) issues with runtime initialization
// smatrix1_(pp,ans);
// cout << "ans=" << ans << endl;
return 0;
}
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Olivier Mattelaer
- Solved:
- Last query:
- Last reply: