16
16
if os.path.isfile(pjoin(root_path,'makefile')) and \
17
17
os.path.isfile(pjoin(root_path,'f2py_wrapper.f')) and \
18
18
not os.path.isfile(pjoin(root_path,'matrix2py.so')):
19
print "Trying to automatically generate the python module 'matrix2py.so' with f2py..."
19
print("Trying to automatically generate the python module 'matrix2py.so' with f2py...")
20
20
p = subprocess.Popen(['make','matrix2py.so'], stdout=subprocess.PIPE,
21
21
stderr=subprocess.PIPE, cwd=root_path)
22
22
(out, err) = p.communicate()
23
23
if p.returncode or not os.path.isfile(pjoin(root_path,'matrix2py.so')):
24
print "ERROR: Failed to produce 'matrix2py.so' with 'make matrix2py.so' in '%s'. The error was:\n%s"%(root_path,err)
24
print("ERROR: Failed to produce 'matrix2py.so' with 'make matrix2py.so' in '%s'. The error was:\n%s"%(root_path,err))
29
print "ERROR: Could not load the f2py module 'matrix2py.so'. The following error occurred:\n",sys.exc_info()[0]
29
print("ERROR: Could not load the f2py module 'matrix2py.so'. The following error occurred:\n",sys.exc_info()[0])
32
32
if os.path.exists(pjoin(root_path,'matrix2py.so')):
33
print "ERROR: Could not load the f2py module 'matrix2py.so'. The following error occurred:\n",sys.exc_info()[0]
33
print("ERROR: Could not load the f2py module 'matrix2py.so'. The following error occurred:\n",sys.exc_info()[0])
36
print "ERROR: Could not find the 'matrix2py.so' f2py module. Please generate it by running:\n"+\
36
print("ERROR: Could not find the 'matrix2py.so' f2py module. Please generate it by running:\n"+\
37
37
" > make matrix2py.so\n"+\
38
"in the <PROC_OUTPUT>/SubProcesses/P<chosen_proc> directory."
38
"in the <PROC_OUTPUT>/SubProcesses/P<chosen_proc> directory.")
41
41
# Now we can use this MadLoop python module.
44
44
# print help(matrix2py)
46
46
# Read the model parameters
47
matrix2py.{2}initialise(os.path.abspath(pjoin(root_path,os.pardir,os.pardir,'Cards','param_card.dat')))
48
matrix2py.{2}initialise(os.path.abspath(pjoin(root_path,os.pardir,os.pardir,'Cards','param_card.dat')))
50
matrix2py.initialise(os.path.abspath(pjoin(root_path,os.pardir,os.pardir,'Cards','param_card.dat')))
50
52
def invert_momenta(p):
51
53
""" fortran/C-python do not order table in the same order"""
64
66
if p[0][0] is None:
65
67
if not os.path.isfile(pjoin(root_path,'PS.input')):
66
print "\n\n==================================================================================================================="
67
print "* No kinematics defined! *"
68
print "* ------------------------------------- *"
69
print "* Please either define your kinematic configuration directly in check_sa.py or in a file 'PS.input'. Exiting now. *"
70
print "===================================================================================================================\n\n"
68
print( "\n\n===================================================================================================================")
69
print( "* No kinematics defined! *")
70
print( "* ------------------------------------- *")
71
print( "* Please either define your kinematic configuration directly in check_sa.py or in a file 'PS.input'. Exiting now. *")
72
print( "===================================================================================================================\n\n")
73
75
for i, line in enumerate(open(pjoin(root_path,'PS.input'),'r').readlines()):
74
76
if i==len(p): break
75
77
p[i]=[float(line.split()[j]) for j in range(4)]
77
print "ERROR: File PS.input is malformed. Error was:\n",sys.exc_info()[0]
79
print("ERROR: File PS.input is malformed. Error was:\n",sys.exc_info()[0])
79
81
P =invert_momenta(p)
86
88
# Choice of renormalization scale
87
89
renormalization_scale = 91.188
89
finite_loop_me, return_code = matrix2py.{2}get_me(P, alphas, renormalization_scale, nhel)
93
print '* %-108s *'%' MadLoop evaluation for the process '
94
print '* %-108s *'%' {1}'
95
print '* %-108s *'%' and the kinematic configuration:'
96
print '* %-108s *'%((' %-3s'+' %-25s'*4)%('#','E',' p_x',' p_y',' p_z'))
92
finite_loop_me, return_code = matrix2py.{2}get_me(P, alphas, renormalization_scale, nhel)
94
finite_loop_me, return_code = matrix2py.get_me(P, alphas, renormalization_scale, nhel)
97
print( '* %-108s *'%' MadLoop evaluation for the process ')
98
print( '* %-108s *'%' {1}')
99
print( '* %-108s *'%' and the kinematic configuration:')
100
print( '* %-108s *'%((' %-3s'+' %-25s'*4)%('#','E',' p_x',' p_y',' p_z')))
97
101
for i,k in enumerate(p):
98
102
# The complicated printout below is just so as to align the digits negative numbers with positive ones
99
print '* %-108s *'%((' %-3d%s')%(i,
100
''.join([' %-25.15e'%e if j==0 or e<0.0 else ' %-24.15e'%e for j,e in enumerate(k)])))
101
print '* %-108s *'%('-'*108)
102
print '* %-108s *'%(' Finite part obtained for the loop matrix element (Madloop return_code=%d )'%return_code)
103
print '* %-108s *'%''
104
print '* %-108s *'%(' %.18e'%finite_loop_me)
105
print '* %-108s *'%''
103
print( '* %-108s *'%((' %-3d%s')%(i,
104
''.join([' %-25.15e'%e if j==0 or e<0.0 else ' %-24.15e'%e for j,e in enumerate(k)]))))
105
print( '* %-108s *'%('-'*108))
106
print( '* %-108s *'%(' Finite part obtained for the loop matrix element (Madloop return_code=%d )'%return_code))
107
print( '* %-108s *'%'')
108
print( '* %-108s *'%(' %.18e'%finite_loop_me))
109
print( '* %-108s *'%'')