1
################################################################################
3
# Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors
5
# This file is a part of the MadGraph5_aMC@NLO project, an application which
6
# automatically generates Feynman diagrams and matrix elements for arbitrary
7
# high-energy processes in the Standard Model and beyond.
9
# It is subject to the MadGraph5_aMC@NLO license which should accompany this
12
# For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch
14
################################################################################
16
"""Unit test library for the various properties of objects in
17
loop_helas_objects.py"""
27
root_path = os.path.split(os.path.dirname(os.path.realpath( __file__ )))[0]
28
sys.path.append(os.path.join(root_path, os.path.pardir, os.path.pardir))
30
import tests.unit_tests as unittest
32
import tests.unit_tests.loop.test_loop_diagram_generation as looptest
33
import madgraph.core.base_objects as base_objects
34
import madgraph.core.diagram_generation as diagram_generation
35
import madgraph.core.helas_objects as helas_objects
36
import madgraph.core.color_amp as color_amp
37
import madgraph.loop.loop_base_objects as loop_base_objects
38
import madgraph.loop.loop_diagram_generation as loop_diagram_generation
39
import madgraph.loop.loop_helas_objects as loop_helas_objects
40
import madgraph.core.helas_objects as helas_objects
41
import madgraph.loop.loop_exporters as loop_exporters
42
import madgraph.iolibs.export_v4 as export_v4
43
import madgraph.iolibs.save_load_object as save_load_object
44
import madgraph.iolibs.helas_call_writers as helas_call_writers
45
import models.import_ufo as import_ufo
46
import madgraph.various.misc as misc
47
import tests.IOTests as IOTests
50
from madgraph.iolibs.files import cp, ln, mv
51
from madgraph import MadGraph5Error
56
_file_path = os.path.dirname(os.path.realpath(__file__))
58
_input_file_path = os.path.abspath(os.path.join(_file_path, \
59
os.path.pardir, os.path.pardir,'input_files'))
60
_mgme_file_path = os.path.abspath(os.path.join(_file_path, *([os.path.pardir]*3)))
61
_loop_file_path = os.path.join(_mgme_file_path,'Template','loop_material')
62
_cuttools_file_path = os.path.join(_mgme_file_path, 'vendor','CutTools')
63
_proc_file_path = os.path.join(_mgme_file_path, 'UNITTEST_proc')
65
#===============================================================================
66
# IOExportMadLoopUTest
67
#===============================================================================
68
class IOExportMadLoopUnitTest(IOTests.IOTestManager):
69
"""Test class for the loop exporter modules. It uses hardcoded output
70
for the comparisons."""
72
# A helper function to add more easily IOTests for several exporters.
73
def addIOTestsForProcess(self,testName,testFolder,particles_ids,exporters,orders,
74
files_to_check=IOTests.IOTest.all_files,
75
perturbation_couplings=['QCD'],
79
""" Simply adds a test for the process defined and all the exporters
83
model = self.models['loop_sm']
84
if fortran_model==None:
85
fortran_model = self.fortran_models['fortran_model']
88
if not isinstance(exporters,dict):
89
if self.need(testFolder,testName):
91
elif any(self.need('%s_%s'%(testFolder,exporter) ,testName) for \
92
exporter in exporters.keys()):
97
myleglist = base_objects.LegList()
98
for i, pid in enumerate(particles_ids):
99
myleglist.append(base_objects.Leg({'id':pid,
100
'state':False if i<2 else True}))
101
myproc = base_objects.Process({'legs': myleglist,
104
'perturbation_couplings': perturbation_couplings,
105
'NLO_mode': NLO_mode})
107
myloopamp = loop_diagram_generation.LoopAmplitude(myproc)
108
# Exporter directly given
109
if not isinstance(exporters,dict):
110
test_list = [(testFolder,exporters)]
111
# Several exporters given in a dictionary
113
test_list = [('%s_%s'%(testFolder,exp),exporters[exp]) for exp in \
116
for (folderName, exporter) in test_list:
117
# Make sure to set optimized_output to true in the LoopHelasMatrixElement
118
# constructor if necessary
119
isOptimized = isinstance(exporter, \
120
loop_exporters.LoopProcessOptimizedExporterFortranSA)
121
if self.need(folderName,testName):
122
self.addIOTest(folderName,testName, IOTests.IOTest(\
123
hel_amp=loop_helas_objects.LoopHelasMatrixElement(\
124
myloopamp,optimized_output=isOptimized),
126
helasModel=fortran_model,
127
testedFiles=files_to_check,
128
outputPath=_proc_file_path))
131
"""load the models and exporters if necessary."""
133
if not hasattr(self, 'models') or \
134
not hasattr(self, 'fortran_models') or \
135
not hasattr(self, 'loop_exporters'):\
138
'loop_sm' : import_ufo.import_model('loop_sm')
140
self.fortran_models = {
141
'fortran_model' : helas_call_writers.FortranUFOHelasCallWriter(\
142
self.models['loop_sm'])
145
self.loop_exporters = {
146
'default' : loop_exporters.LoopProcessExporterFortranSA(\
147
_mgme_file_path, _proc_file_path,
148
{'clean':False, 'complex_mass':False,
149
'export_format':'madloop','mp':True,
150
'loop_dir':_loop_file_path,
151
'cuttools_dir':_cuttools_file_path,
152
'fortran_compiler':'gfortran'}),
153
'optimized' : loop_exporters.\
154
LoopProcessOptimizedExporterFortranSA(\
155
_mgme_file_path, _proc_file_path,
156
{'clean':False, 'complex_mass':False,
157
'export_format':'madloop','mp':True,
158
'loop_dir':_loop_file_path,
159
'cuttools_dir':_cuttools_file_path,
160
'fortran_compiler':'gfortran'})
164
self.addIOTestsForProcess( testName = 'gg_ttx',
165
testFolder = 'short_ML_SMQCD',
166
particles_ids = [21,21,6,-6],
167
exporters = self.loop_exporters,
168
orders = {'QCD':2,'QED':0} )
170
# d d > t t~ (only the proc files for this one)
171
self.addIOTestsForProcess( testName = 'ddx_ttx',
172
testFolder = 'short_ML_SMQCD',
173
particles_ids = [1,-1,6,-6],
174
exporters = self.loop_exporters,
175
orders = {'QCD':2,'QED':0},
176
files_to_check=IOTests.IOTest.proc_files)
178
# And the loop induced g g > h h for good measure
179
# Use only one exporter only here
180
self.addIOTestsForProcess( testName = 'gg_hh',
181
testFolder = 'short_ML_SMQCD_LoopInduced',
182
particles_ids = [21,21,25,25],
183
exporters = self.loop_exporters['default'],
184
orders = {'QCD': 2, 'QED': 2} )