31
34
import tests.IOTests as IOTests
32
35
import madgraph.interface.master_interface as MGCmd
37
import madgraph.fks.fks_common as fks_common
34
39
_file_path = os.path.dirname(os.path.realpath(__file__))
35
40
_input_file_path = os.path.join(_file_path, os.path.pardir, os.path.pardir,
38
#===============================================================================
40
#===============================================================================
41
class IOExportFKSTest(IOTests.IOTestManager):
42
"""Test class for the export fks module"""
44
def generate(self, process, model, multiparticles=[]):
45
"""Create a process"""
48
interface.exec_cmd(cmd, errorhandling=False, printcmd=False,
49
precmd=True, postcmd=True)
51
interface = MGCmd.MasterCmd()
53
run_cmd('import model %s' % model)
54
for multi in multiparticles:
55
run_cmd('define %s' % multi)
56
if isinstance(process, str):
57
run_cmd('generate %s' % process)
60
run_cmd('add process %s' % p)
63
run_cmd('output %s -f' % self.IOpath)
66
@IOTests.createIOTest()
67
def testIO_test_pptt_fksreal(self):
68
""" target: SubProcesses/[P0.*\/.+\.(inc|f)]"""
69
self.generate(['p p > t t~ [real=QCD]'], 'sm')
71
@IOTests.createIOTest()
72
def testIO_test_tdecay_fksreal(self):
73
""" target: SubProcesses/[P0.*\/.+\.(inc|f)]"""
74
self.generate(['t > j j b [real=QCD]'], 'sm')
76
@IOTests.createIOTest()
77
def testIO_test_pptt_fks_loonly(self):
78
""" target: SubProcesses/[P0.*\/.+\.(inc|f)]"""
79
self.generate(['p p > t t~ [LOonly=QCD]'], 'sm')
43
class TestFKSOutput(unittest.TestCase):
44
""" this class is to test that the new and old nlo generation give
48
def test_w_nlo_gen(self):
49
"""check that the new (memory and cpu efficient) and old generation
50
mode at NLO give the same results for p p > w [QCD]
52
path = tempfile.mkdtemp('', 'TMPWTest', None)
55
interface.exec_cmd(cmd, errorhandling=False, printcmd=False,
56
precmd=True, postcmd=True)
58
interface = MGCmd.MasterCmd()
60
run_cmd('generate p p > w+ [QCD]')
61
run_cmd('output %s' % os.path.join(path, 'W-oldway'))
62
run_cmd('set low_mem_multicore_nlo_generation True')
63
run_cmd('generate p p > w+ [QCD]')
64
run_cmd('output %s' % os.path.join(path, 'W-newway'))
65
run_cmd('set low_mem_multicore_nlo_generation False')
69
(glob.glob(os.path.join(path, 'W-oldway', 'SubProcesses', 'P0*', '*.inc')) + \
70
glob.glob(os.path.join(path, 'W-oldway', 'SubProcesses', 'P0*', '*.f')) + \
71
[os.path.join(path, 'W-oldway', 'SubProcesses', 'proc_characteristics')]):
73
if os.path.islink(oldf):
76
newf = oldf.replace('oldway', 'newway')
78
for old_l, new_l in zip(open(oldf), open(newf)):
79
self.assertEqual(old_l, new_l)
83
(glob.glob(os.path.join(path, 'W-oldway', 'SubProcesses', 'P0*', 'V0*', '*.inc')) + \
84
glob.glob(os.path.join(path, 'W-oldway', 'SubProcesses', 'P0*', 'V0*', '*.f'))):
86
if os.path.islink(oldf):
89
newf = oldf.replace('oldway', 'newway')
91
for old_l, new_l in zip(open(oldf), open(newf)):
92
self.assertEqual(old_l, new_l)
95
def test_w_nlo_gen_gosam(self):
96
"""check that the new generation mode works when gosam is set
99
path = tempfile.mkdtemp('', 'TMPWTest', None)
102
interface.exec_cmd(cmd, errorhandling=False, printcmd=False,
103
precmd=True, postcmd=True)
105
interface = MGCmd.MasterCmd()
107
run_cmd('set low_mem_multicore_nlo_generation True')
108
run_cmd('set OLP GoSam')
109
run_cmd('generate p p > w+ [QCD]')
111
run_cmd('output %s' % os.path.join(path, 'W-newway'))
112
except fks_common.FKSProcessError, err:
113
# catch the error if gosam is not there
114
if not 'Generation of the virtuals with GoSam failed' in str(err):
116
run_cmd('set low_mem_multicore_nlo_generation False')
117
run_cmd('set OLP MadLoop')