~maddevelopers/mg5amcnlo/new_clustering

« back to all changes in this revision

Viewing changes to madgraph/iolibs/template_files/loop_optimized/check_sa.py.inc

  • Committer: Rikkert Frederix
  • Date: 2021-09-09 15:51:40 UTC
  • mfrom: (78.75.502 3.2.1)
  • Revision ID: frederix@physik.uzh.ch-20210909155140-rg6umfq68h6h47cf
merge with 3.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
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))
25
25
            sys.exit(0)
26
26
        try:
27
27
            import matrix2py
28
28
        except:
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])
30
30
            sys.exit(0)
31
31
    else:
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])
34
34
            sys.exit(0)
35
35
        else:
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.")
39
39
            sys.exit(0)
40
40
 
41
41
# Now we can use this MadLoop python module.
44
44
# print help(matrix2py)
45
45
 
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
 
 
 
47
try:
 
48
    matrix2py.{2}initialise(os.path.abspath(pjoin(root_path,os.pardir,os.pardir,'Cards','param_card.dat')))
 
49
except:
 
50
    matrix2py.initialise(os.path.abspath(pjoin(root_path,os.pardir,os.pardir,'Cards','param_card.dat')))
49
51
 
50
52
def invert_momenta(p):
51
53
        """ fortran/C-python do not order table in the same order"""
63
65
{0}
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")
71
73
        sys.exit(0)
72
74
    try:
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)]
76
78
    except:
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])
78
80
        sys.exit(0)
79
81
P =invert_momenta(p)
80
82
# Alpha_s value
86
88
# Choice of renormalization scale
87
89
renormalization_scale = 91.188
88
90
 
89
 
finite_loop_me, return_code = matrix2py.{2}get_me(P, alphas, renormalization_scale, nhel)
90
 
 
91
 
 
92
 
print '='*112
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'))
 
91
try:
 
92
    finite_loop_me, return_code = matrix2py.{2}get_me(P, alphas, renormalization_scale, nhel)
 
93
except:
 
94
    finite_loop_me, return_code = matrix2py.get_me(P, alphas, renormalization_scale, nhel)
 
95
 
 
96
print( '='*112)
 
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 *'%''
106
 
print '='*112
 
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 *'%'')
 
110
print( '='*112)