~maddevelopers/mg5amcnlo/2.9.4

« back to all changes in this revision

Viewing changes to tests/unit_tests/loop/test_loop_diagram_generation.py

pass to v2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
################################################################################
 
2
#
 
3
# Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors
 
4
#
 
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.
 
8
#
 
9
# It is subject to the MadGraph5_aMC@NLO license which should accompany this 
 
10
# distribution.
 
11
#
 
12
# For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch
 
13
#
 
14
################################################################################
 
15
 
 
16
"""Unit test library for the various properties of objects in 
 
17
   loop_diagram_generaiton"""
 
18
 
 
19
import copy
 
20
import itertools
 
21
import logging
 
22
import math
 
23
import os
 
24
import sys
 
25
 
 
26
root_path = os.path.split(os.path.dirname(os.path.realpath( __file__ )))[0]
 
27
sys.path.append(os.path.join(root_path, os.path.pardir, os.path.pardir))
 
28
 
 
29
 
 
30
import tests.unit_tests as unittest
 
31
 
 
32
 
 
33
import madgraph.core.drawing as draw_lib
 
34
import madgraph.iolibs.drawing_eps as draw
 
35
import madgraph.core.base_objects as base_objects
 
36
import madgraph.core.diagram_generation as diagram_generation
 
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.iolibs.save_load_object as save_load_object
 
40
import models.import_ufo as models
 
41
from madgraph import MadGraph5Error
 
42
 
 
43
_file_path = os.path.dirname(os.path.realpath(__file__))
 
44
_input_file_path = os.path.join(_file_path, os.path.pardir, os.path.pardir,
 
45
                                'input_files')
 
46
_model_file_path = os.path.join(_file_path, os.path.pardir, os.path.pardir,
 
47
                                os.path.pardir,'models')
 
48
#===============================================================================
 
49
# Function to load a toy hardcoded Loop Model
 
50
#===============================================================================
 
51
 
 
52
def loadLoopModel():
 
53
    """Setup the NLO model"""
 
54
    
 
55
    mypartlist = base_objects.ParticleList()
 
56
    myinterlist = base_objects.InteractionList()
 
57
    myloopmodel = loop_base_objects.LoopModel()
 
58
 
 
59
    # A gluon
 
60
    mypartlist.append(base_objects.Particle({'name':'g',
 
61
                  'antiname':'g',
 
62
                  'spin':3,
 
63
                  'color':8,
 
64
                  'mass':'zero',
 
65
                  'width':'zero',
 
66
                  'texname':'g',
 
67
                  'antitexname':'g',
 
68
                  'line':'curly',
 
69
                  'charge':0.,
 
70
                  'pdg_code':21,
 
71
                  'propagating':True,
 
72
                  'is_part':True,
 
73
                  'self_antipart':True,
 
74
                  'counterterm':{('QCD',((),)):{-1:'GWfct'}}}))
 
75
    
 
76
    # A quark U and its antiparticle
 
77
    mypartlist.append(base_objects.Particle({'name':'u',
 
78
                  'antiname':'u~',
 
79
                  'spin':2,
 
80
                  'color':3,
 
81
                  'mass':'umass',
 
82
                  'width':'zero',
 
83
                  'texname':'u',
 
84
                  'antitexname':'\bar u',
 
85
                  'line':'straight',
 
86
                  'charge':2. / 3.,
 
87
                  'pdg_code':2,
 
88
                  'propagating':True,
 
89
                  'is_part':True,
 
90
                  'self_antipart':False}))
 
91
    antiu = copy.copy(mypartlist[1])
 
92
    antiu.set('is_part', False)
 
93
    mypartlist[1].set('counterterm',{('QCD',((),)):{-1:'UQCDWfct'},
 
94
                                     ('QED',((),)):{-1:'UQEDWfct'}})
 
95
 
 
96
    # A quark D and its antiparticle
 
97
    mypartlist.append(base_objects.Particle({'name':'d',
 
98
                  'antiname':'d~',
 
99
                  'spin':2,
 
100
                  'color':3,
 
101
                  'mass':'dmass',
 
102
                  'width':'zero',
 
103
                  'texname':'d',
 
104
                  'antitexname':'\bar d',
 
105
                  'line':'straight',
 
106
                  'charge':-1. / 3.,
 
107
                  'pdg_code':1,
 
108
                  'propagating':True,
 
109
                  'is_part':True,
 
110
                  'self_antipart':False}))
 
111
    antid = copy.copy(mypartlist[2])
 
112
    antid.set('is_part', False)
 
113
    mypartlist[2].set('counterterm',{('QCD',((),)):{-1:'DQCDWfct'},
 
114
                                     ('QED',((),)):{-1:'DQEDWfct'}})
 
115
 
 
116
    # A photon
 
117
    mypartlist.append(base_objects.Particle({'name':'a',
 
118
                  'antiname':'a',
 
119
                  'spin':3,
 
120
                  'color':1,
 
121
                  'mass':'zero',
 
122
                  'width':'zero',
 
123
                  'texname':'\gamma',
 
124
                  'antitexname':'\gamma',
 
125
                  'line':'wavy',
 
126
                  'charge':0.,
 
127
                  'pdg_code':22,
 
128
                  'propagating':True,
 
129
                  'is_part':True,
 
130
                  'self_antipart':True}))
 
131
 
 
132
    # A electron and positron
 
133
    mypartlist.append(base_objects.Particle({'name':'e-',
 
134
                  'antiname':'e+',
 
135
                  'spin':2,
 
136
                  'color':1,
 
137
                  'mass':'zero',
 
138
                  'width':'zero',
 
139
                  'texname':'e^-',
 
140
                  'antitexname':'e^+',
 
141
                  'line':'straight',
 
142
                  'charge':-1.,
 
143
                  'pdg_code':11,
 
144
                  'propagating':True,
 
145
                  'is_part':True,
 
146
                  'self_antipart':False}))
 
147
    antie = copy.copy(mypartlist[4])
 
148
    antie.set('is_part', False)
 
149
 
 
150
    # First set up the base interactions.
 
151
 
 
152
    # 3 gluon vertex
 
153
    myinterlist.append(base_objects.Interaction({
 
154
                  'id': 1,
 
155
                  'particles': base_objects.ParticleList(\
 
156
                                        [mypartlist[0]] * 3),
 
157
                  'color': [],
 
158
                  'lorentz':['L1'],
 
159
                  'couplings':{(0, 0):'G'},
 
160
                  'orders':{'QCD':1}}))
 
161
 
 
162
    # 4 gluon vertex
 
163
    myinterlist.append(base_objects.Interaction({
 
164
                  'id': 2,
 
165
                  'particles': base_objects.ParticleList(\
 
166
                                        [mypartlist[0]] * 4),
 
167
                  'color': [],
 
168
                  'lorentz':['L1'],
 
169
                  'couplings':{(0, 0):'G^2'},
 
170
                  'orders':{'QCD':2}}))
 
171
 
 
172
    # Gluon and photon couplings to quarks
 
173
    myinterlist.append(base_objects.Interaction({
 
174
                  'id': 3,
 
175
                  'particles': base_objects.ParticleList(\
 
176
                                        [mypartlist[1], \
 
177
                                         antiu, \
 
178
                                         mypartlist[0]]),
 
179
                  'color': [],
 
180
                  'lorentz':['L1'],
 
181
                  'couplings':{(0, 0):'GQQ'},
 
182
                  'orders':{'QCD':1}}))
 
183
 
 
184
    myinterlist.append(base_objects.Interaction({
 
185
                  'id': 4,
 
186
                  'particles': base_objects.ParticleList(\
 
187
                                        [mypartlist[1], \
 
188
                                         antiu, \
 
189
                                         mypartlist[3]]),
 
190
                  'color': [],
 
191
                  'lorentz':['L1'],
 
192
                  'couplings':{(0, 0):'GQED'},
 
193
                  'orders':{'QED':1}}))
 
194
 
 
195
    myinterlist.append(base_objects.Interaction({
 
196
                  'id': 5,
 
197
                  'particles': base_objects.ParticleList(\
 
198
                                        [mypartlist[2], \
 
199
                                         antid, \
 
200
                                         mypartlist[0]]),
 
201
                  'color': [],
 
202
                  'lorentz':['L1'],
 
203
                  'couplings':{(0, 0):'GQQ'},
 
204
                  'orders':{'QCD':1}}))
 
205
 
 
206
    myinterlist.append(base_objects.Interaction({
 
207
                  'id': 6,
 
208
                  'particles': base_objects.ParticleList(\
 
209
                                        [mypartlist[2], \
 
210
                                         antid, \
 
211
                                         mypartlist[3]]),
 
212
                  'color': [],
 
213
                  'lorentz':['L1'],
 
214
                  'couplings':{(0, 0):'GQED'},
 
215
                  'orders':{'QED':1}}))
 
216
 
 
217
    # Coupling of e to gamma
 
218
 
 
219
    myinterlist.append(base_objects.Interaction({
 
220
                  'id': 7,
 
221
                  'particles': base_objects.ParticleList(\
 
222
                                        [mypartlist[4], \
 
223
                                         antie, \
 
224
                                         mypartlist[3]]),
 
225
                  'color': [],
 
226
                  'lorentz':['L1'],
 
227
                  'couplings':{(0, 0):'GQED'},
 
228
                  'orders':{'QED':1}}))
 
229
 
 
230
    # Then set up the R2 interactions proportional to those existing in the
 
231
    # tree-level model.
 
232
 
 
233
    # 3 gluon vertex
 
234
    myinterlist.append(base_objects.Interaction({
 
235
                  'id': 8,
 
236
                  'particles': base_objects.ParticleList(\
 
237
                                        [mypartlist[0]] * 3),
 
238
                  'color': [],
 
239
                  'lorentz':['L1'],
 
240
                  'couplings':{(0, 0):'G'},
 
241
                  'orders':{'QCD':3},
 
242
                  'loop_particles':[[]],
 
243
                  'perturbation_type':'QCD',
 
244
                  'type':'R2'}))
 
245
 
 
246
    # 4 gluon vertex
 
247
    myinterlist.append(base_objects.Interaction({
 
248
                  'id': 9,
 
249
                  'particles': base_objects.ParticleList(\
 
250
                                        [mypartlist[0]] * 4),
 
251
                  'color': [],
 
252
                  'lorentz':['L1'],
 
253
                  'couplings':{(0, 0):'G^2'},
 
254
                  'orders':{'QCD':4},
 
255
                  'loop_particles':[[]],
 
256
                  'perturbation_type':'QCD',
 
257
                  'type':'R2'}))
 
258
 
 
259
    # Gluon and photon couplings to quarks
 
260
    myinterlist.append(base_objects.Interaction({
 
261
                  'id': 10,
 
262
                  'particles': base_objects.ParticleList(\
 
263
                                        [mypartlist[1], \
 
264
                                         antiu, \
 
265
                                         mypartlist[0]]),
 
266
                  'color': [],
 
267
                  'lorentz':['L1'],
 
268
                  'couplings':{(0, 0):'GQQ'},
 
269
                  'orders':{'QCD':3},
 
270
                  'loop_particles':[[]],
 
271
                  'perturbation_type':'QCD',
 
272
                  'type':'R2'}))
 
273
        
 
274
    myinterlist.append(base_objects.Interaction({
 
275
                  'id': 11,
 
276
                  'particles': base_objects.ParticleList(\
 
277
                                        [mypartlist[1], \
 
278
                                         antiu, \
 
279
                                         mypartlist[0]]),
 
280
                  'color': [],
 
281
                  'lorentz':['L1'],
 
282
                  'couplings':{(0, 0):'GQQ'},
 
283
                  'orders':{'QCD':1, 'QED':2},
 
284
                  'loop_particles':[[]],
 
285
                  'perturbation_type':'QED',
 
286
                  'type':'R2'}))
 
287
 
 
288
    myinterlist.append(base_objects.Interaction({
 
289
                  'id': 12,
 
290
                  'particles': base_objects.ParticleList(\
 
291
                                        [mypartlist[1], \
 
292
                                         antiu, \
 
293
                                         mypartlist[3]]),
 
294
                  'color': [],
 
295
                  'lorentz':['L1'],
 
296
                  'couplings':{(0, 0):'GQED'},
 
297
                  'orders':{'QED':1, 'QCD':2},
 
298
                  'perturbation_type':'QCD',
 
299
                  'loop_particles':[[]],
 
300
                  'type':'R2'}))
 
301
 
 
302
    myinterlist.append(base_objects.Interaction({
 
303
                  'id': 13,
 
304
                  'particles': base_objects.ParticleList(\
 
305
                                        [mypartlist[1], \
 
306
                                         antiu, \
 
307
                                         mypartlist[3]]),
 
308
                  'color': [],
 
309
                  'lorentz':['L1'],
 
310
                  'couplings':{(0, 0):'GQED'},
 
311
                  'orders':{'QED':3},
 
312
                  'loop_particles':[[]],
 
313
                  'perturbation_type':'QED',
 
314
                  'type':'R2'}))
 
315
 
 
316
    myinterlist.append(base_objects.Interaction({
 
317
                  'id': 14,
 
318
                  'particles': base_objects.ParticleList(\
 
319
                                        [mypartlist[2], \
 
320
                                         antid, \
 
321
                                         mypartlist[0]]),
 
322
                  'color': [],
 
323
                  'lorentz':['L1'],
 
324
                  'couplings':{(0, 0):'GQQ'},
 
325
                  'orders':{'QCD':3},
 
326
                  'loop_particles':[[]],
 
327
                  'perturbation_type':'QCD',
 
328
                  'type':'R2'}))
 
329
 
 
330
    myinterlist.append(base_objects.Interaction({
 
331
                  'id': 15,
 
332
                  'particles': base_objects.ParticleList(\
 
333
                                        [mypartlist[2], \
 
334
                                         antid, \
 
335
                                         mypartlist[0]]),
 
336
                  'color': [],
 
337
                  'lorentz':['L1'],
 
338
                  'couplings':{(0, 0):'GQQ'},
 
339
                  'orders':{'QCD':1, 'QED':2},
 
340
                  'loop_particles':[[]],
 
341
                  'perturbation_type':'QED',
 
342
                  'type':'R2'}))
 
343
 
 
344
    myinterlist.append(base_objects.Interaction({
 
345
                  'id': 16,
 
346
                  'particles': base_objects.ParticleList(\
 
347
                                        [mypartlist[2], \
 
348
                                         antid, \
 
349
                                         mypartlist[3]]),
 
350
                  'color': [],
 
351
                  'lorentz':['L1'],
 
352
                  'couplings':{(0, 0):'GQED'},
 
353
                  'orders':{'QED':1, 'QCD':2},
 
354
                  'loop_particles':[[]],
 
355
                  'perturbation_type':'QCD',
 
356
                  'type':'R2'}))
 
357
 
 
358
    myinterlist.append(base_objects.Interaction({
 
359
                  'id': 17,
 
360
                  'particles': base_objects.ParticleList(\
 
361
                                        [mypartlist[2], \
 
362
                                         antid, \
 
363
                                         mypartlist[3]]),
 
364
                  'color': [],
 
365
                  'lorentz':['L1'],
 
366
                  'couplings':{(0, 0):'GQED'},
 
367
                  'orders':{'QED':3},
 
368
                  'loop_particles':[[]],
 
369
                  'perturbation_type':'QED',
 
370
                  'type':'R2'}))
 
371
 
 
372
    # Coupling of e to gamma
 
373
 
 
374
    myinterlist.append(base_objects.Interaction({
 
375
                  'id': 18,
 
376
                  'particles': base_objects.ParticleList(\
 
377
                                        [mypartlist[4], \
 
378
                                         antie, \
 
379
                                         mypartlist[3]]),
 
380
                  'color': [],
 
381
                  'lorentz':['L1'],
 
382
                  'couplings':{(0, 0):'GQED'},
 
383
                  'orders':{'QED':3},
 
384
                  'loop_particles':[[]],
 
385
                  'perturbation_type':'QED',
 
386
                  'type':'R2'}))
 
387
 
 
388
    # R2 interactions not proportional to the base interactions
 
389
 
 
390
    # Two point interactions
 
391
 
 
392
    # The gluon
 
393
    myinterlist.append(base_objects.Interaction({
 
394
                  'id': 19,
 
395
                  'particles': base_objects.ParticleList(\
 
396
                                        [mypartlist[0]] * 2),
 
397
                  'color': [],
 
398
                  'lorentz':['L1'],
 
399
                  'couplings':{(0, 0):'G'},
 
400
                  'orders':{'QCD':2},
 
401
                  'loop_particles':[[]],
 
402
                  'perturbation_type':'QCD',
 
403
                  'type':'R2'}))
 
404
 
 
405
    # The photon
 
406
    myinterlist.append(base_objects.Interaction({
 
407
                  'id': 20,
 
408
                  'particles': base_objects.ParticleList(\
 
409
                                        [mypartlist[3]] * 2),
 
410
                  'color': [],
 
411
                  'lorentz':['L1'],
 
412
                  'couplings':{(0, 0):'G'},
 
413
                  'orders':{'QED':2},
 
414
                  'loop_particles':[[]],
 
415
                  'perturbation_type':'QED',
 
416
                  'type':'R2'}))
 
417
 
 
418
    # The electron
 
419
    myinterlist.append(base_objects.Interaction({
 
420
                  'id': 21,
 
421
                  'particles': base_objects.ParticleList([\
 
422
                                        mypartlist[4], \
 
423
                                         antie]),
 
424
                  'color': [],
 
425
                  'lorentz':['L1'],
 
426
                  'couplings':{(0, 0):'G'},
 
427
                  'orders':{'QED':2},
 
428
                  'loop_particles':[[]],
 
429
                  'perturbation_type':'QED',
 
430
                  'type':'R2'}))
 
431
 
 
432
    # The up quark, R2QED
 
433
    myinterlist.append(base_objects.Interaction({
 
434
                  'id': 22,
 
435
                  'particles': base_objects.ParticleList([\
 
436
                                        mypartlist[2], \
 
437
                                         antid]),
 
438
                  'color': [],
 
439
                  'lorentz':['L1'],
 
440
                  'couplings':{(0, 0):'G'},
 
441
                  'orders':{'QED':2},
 
442
                  'loop_particles':[[]],
 
443
                  'perturbation_type':'QED',
 
444
                  'type':'R2'}))
 
445
 
 
446
    # The up quark, R2QCD
 
447
    myinterlist.append(base_objects.Interaction({
 
448
                  'id': 23,
 
449
                  'particles': base_objects.ParticleList([\
 
450
                                        mypartlist[2], \
 
451
                                         antid]),
 
452
                  'color': [],
 
453
                  'lorentz':['L1'],
 
454
                  'couplings':{(0, 0):'G'},
 
455
                  'orders':{'QCD':2},
 
456
                  'loop_particles':[[]],
 
457
                  'perturbation_type':'QCD',
 
458
                  'type':'R2'}))
 
459
 
 
460
    # The down quark, R2QED
 
461
    myinterlist.append(base_objects.Interaction({
 
462
                  'id': 24,
 
463
                  'particles': base_objects.ParticleList([\
 
464
                                        mypartlist[1], \
 
465
                                         antiu]),
 
466
                  'color': [],
 
467
                  'lorentz':['L1'],
 
468
                  'couplings':{(0, 0):'G'},
 
469
                  'orders':{'QED':2},
 
470
                  'loop_particles':[[]],
 
471
                  'perturbation_type':'QED',
 
472
                  'type':'R2'}))
 
473
 
 
474
    # The down quark, R2QCD
 
475
    myinterlist.append(base_objects.Interaction({
 
476
                  'id': 25,
 
477
                  'particles': base_objects.ParticleList([\
 
478
                                        mypartlist[1], \
 
479
                                         antid]),
 
480
                  'color': [],
 
481
                  'lorentz':['L1'],
 
482
                  'couplings':{(0, 0):'G'},
 
483
                  'orders':{'QCD':2},
 
484
                  'loop_particles':[[]],
 
485
                  'perturbation_type':'QCD',
 
486
                  'type':'R2'}))
 
487
 
 
488
    # The R2 three and four point interactions not proportional to the
 
489
    # base interaction
 
490
 
 
491
    # 3 photons
 
492
    myinterlist.append(base_objects.Interaction({
 
493
                  'id': 26,
 
494
                  'particles': base_objects.ParticleList(\
 
495
                                        [mypartlist[3]] * 3),
 
496
                  'color': [],
 
497
                  'lorentz':['L1'],
 
498
                  'couplings':{(0, 0):'G'},
 
499
                  'orders':{'QED':3},
 
500
                  'loop_particles':[[]],
 
501
                  'perturbation_type':'QED',
 
502
                  'type':'R2'}))
 
503
 
 
504
    # 2 photon and 1 gluons
 
505
    myinterlist.append(base_objects.Interaction({
 
506
                  'id': 27,
 
507
                  'particles': base_objects.ParticleList(\
 
508
                                        [mypartlist[3],\
 
509
                                        mypartlist[3],\
 
510
                                        mypartlist[0],]),
 
511
                  'color': [],
 
512
                  'lorentz':['L1'],
 
513
                  'couplings':{(0, 0):'G'},
 
514
                  'orders':{'QED':2, 'QCD':1},
 
515
                  'loop_particles':[[]],
 
516
                  'perturbation_type':'QED',
 
517
                  'type':'R2'}))
 
518
 
 
519
    # 1 photon and 2 gluons
 
520
    myinterlist.append(base_objects.Interaction({
 
521
                  'id': 28,
 
522
                  'particles': base_objects.ParticleList(\
 
523
                                        [mypartlist[3],\
 
524
                                        mypartlist[0],\
 
525
                                        mypartlist[0],]),
 
526
                  'color': [],
 
527
                  'lorentz':['L1'],
 
528
                  'couplings':{(0, 0):'G'},
 
529
                  'orders':{'QED':1, 'QCD':2},
 
530
                  'loop_particles':[[]],
 
531
                  'perturbation_type':'QCD',
 
532
                  'type':'R2'}))
 
533
 
 
534
    # 4 photons
 
535
    myinterlist.append(base_objects.Interaction({
 
536
                  'id': 29,
 
537
                  'particles': base_objects.ParticleList(\
 
538
                                        [mypartlist[3]] * 4),
 
539
                  'color': [],
 
540
                  'lorentz':['L1'],
 
541
                  'couplings':{(0, 0):'G'},
 
542
                  'orders':{'QED':4},
 
543
                  'loop_particles':[[]],
 
544
                  'perturbation_type':'QED',
 
545
                  'type':'R2'}))
 
546
 
 
547
    # 3 photons and 1 gluon
 
548
    myinterlist.append(base_objects.Interaction({
 
549
                  'id': 30,
 
550
                  'particles': base_objects.ParticleList(\
 
551
                                        [mypartlist[3],\
 
552
                                        mypartlist[3],\
 
553
                                        mypartlist[3],\
 
554
                                        mypartlist[0]]),
 
555
                  'color': [],
 
556
                  'lorentz':['L1'],
 
557
                  'couplings':{(0, 0):'G'},
 
558
                  'orders':{'QED':3,'QCD':1},
 
559
                  'loop_particles':[[]],
 
560
                  'type':'R2'}))
 
561
 
 
562
    # 2 photons and 2 gluons
 
563
    myinterlist.append(base_objects.Interaction({
 
564
                  'id': 31,
 
565
                  'particles': base_objects.ParticleList(\
 
566
                                        [mypartlist[3],\
 
567
                                        mypartlist[3],\
 
568
                                        mypartlist[0],\
 
569
                                        mypartlist[0]]),
 
570
                  'color': [],
 
571
                  'lorentz':['L1'],
 
572
                  'couplings':{(0, 0):'G'},
 
573
                  'orders':{'QED':2,'QCD':2},
 
574
                  'loop_particles':[[]],
 
575
                  'type':'R2'}))
 
576
 
 
577
    # 1 photon and 3 gluons
 
578
    myinterlist.append(base_objects.Interaction({
 
579
                  'id': 32,
 
580
                  'particles': base_objects.ParticleList(\
 
581
                                        [mypartlist[3],\
 
582
                                        mypartlist[0],\
 
583
                                        mypartlist[0],\
 
584
                                        mypartlist[0]]),
 
585
                  'color': [],
 
586
                  'lorentz':['L1'],
 
587
                  'couplings':{(0, 0):'G'},
 
588
                  'orders':{'QED':1,'QCD':3},
 
589
                  'loop_particles':[[]],
 
590
                  'type':'R2'})) 
 
591
 
 
592
    # Finally the UV interactions Counter-Terms
 
593
 
 
594
    # 3 gluon vertex CT
 
595
    myinterlist.append(base_objects.Interaction({
 
596
                  'id': 33,
 
597
                  'particles': base_objects.ParticleList(\
 
598
                                        [mypartlist[0]] * 3),
 
599
                  'color': [],
 
600
                  'lorentz':['L1'],
 
601
                  'couplings':{(0, 0):'G'},
 
602
                  'orders':{'QCD':3},
 
603
                  'loop_particles':[[]],
 
604
                  'perturbation_type':'QCD',
 
605
                  'type':'UVtree1eps'}))
 
606
 
 
607
    # 4 gluon vertex CT
 
608
    myinterlist.append(base_objects.Interaction({
 
609
                  'id': 34,
 
610
                  'particles': base_objects.ParticleList(\
 
611
                                        [mypartlist[0]] * 4),
 
612
                  'color': [],
 
613
                  'lorentz':['L1'],
 
614
                  'couplings':{(0, 0):'G^2'},
 
615
                  'orders':{'QCD':4},
 
616
                  'loop_particles':[[]],
 
617
                  'perturbation_type':'QCD',
 
618
                  'type':'UVtree1eps'}))
 
619
 
 
620
    # Gluon and photon couplings to quarks CT
 
621
    myinterlist.append(base_objects.Interaction({
 
622
                  'id': 35,
 
623
                  'particles': base_objects.ParticleList(\
 
624
                                        [mypartlist[1], \
 
625
                                         antiu, \
 
626
                                         mypartlist[0]]),
 
627
                  'color': [],
 
628
                  'lorentz':['L1'],
 
629
                  'couplings':{(0, 0):'GQQ'},
 
630
                  'orders':{'QCD':3},
 
631
                  'loop_particles':[[]],
 
632
                  'perturbation_type':'QCD',
 
633
                  'type':'UVtree1eps'}))
 
634
    
 
635
    # this is the CT for the renormalization of the QED corrections to alpha_QCD
 
636
    myinterlist.append(base_objects.Interaction({
 
637
                  'id': 36,
 
638
                  'particles': base_objects.ParticleList(\
 
639
                                        [mypartlist[1], \
 
640
                                         antiu, \
 
641
                                         mypartlist[0]]),
 
642
                  'color': [],
 
643
                  'lorentz':['L1'],
 
644
                  'couplings':{(0, 0):'GQQ'},
 
645
                  'orders':{'QED':2,'QCD':1},
 
646
                  'loop_particles':[[]],
 
647
                  'perturbation_type':'QED',
 
648
                  'type':'UVtree1eps'}))
 
649
 
 
650
    myinterlist.append(base_objects.Interaction({
 
651
                  'id': 37,
 
652
                  'particles': base_objects.ParticleList(\
 
653
                                        [mypartlist[1], \
 
654
                                         antiu, \
 
655
                                         mypartlist[3]]),
 
656
                  'color': [],
 
657
                  'lorentz':['L1'],
 
658
                  'couplings':{(0, 0):'GQED'},
 
659
                  'orders':{'QCD':2,'QED':1},
 
660
                  'loop_particles':[[]],
 
661
                  'perturbation_type':'QCD',
 
662
                  'type':'UVtree1eps'}))
 
663
 
 
664
    myinterlist.append(base_objects.Interaction({
 
665
                  'id': 38,
 
666
                  'particles': base_objects.ParticleList(\
 
667
                                        [mypartlist[1], \
 
668
                                         antiu, \
 
669
                                         mypartlist[3]]),
 
670
                  'color': [],
 
671
                  'lorentz':['L1'],
 
672
                  'couplings':{(0, 0):'GQED'},
 
673
                  'orders':{'QED':3},
 
674
                  'loop_particles':[[]],
 
675
                  'perturbation_type':'QED',
 
676
                  'type':'UVtree1eps'}))
 
677
 
 
678
    myinterlist.append(base_objects.Interaction({
 
679
                  'id': 39,
 
680
                  'particles': base_objects.ParticleList(\
 
681
                                        [mypartlist[2], \
 
682
                                         antid, \
 
683
                                         mypartlist[0]]),
 
684
                  'color': [],
 
685
                  'lorentz':['L1'],
 
686
                  'couplings':{(0, 0):'GQQ'},
 
687
                  'orders':{'QCD':3},
 
688
                  'loop_particles':[[]],
 
689
                  'perturbation_type':'QCD',
 
690
                  'type':'UVtree1eps'}))
 
691
 
 
692
    myinterlist.append(base_objects.Interaction({
 
693
                  'id': 40,
 
694
                  'particles': base_objects.ParticleList(\
 
695
                                        [mypartlist[2], \
 
696
                                         antid, \
 
697
                                         mypartlist[0]]),
 
698
                  'color': [],
 
699
                  'lorentz':['L1'],
 
700
                  'couplings':{(0, 0):'GQQ'},
 
701
                  'orders':{'QED':2,'QCD':1},
 
702
                  'loop_particles':[[]],
 
703
                  'perturbation_type':'QED',
 
704
                  'type':'UVtree1eps'}))
 
705
 
 
706
    myinterlist.append(base_objects.Interaction({
 
707
                  'id': 41,
 
708
                  'particles': base_objects.ParticleList(\
 
709
                                        [mypartlist[2], \
 
710
                                         antid, \
 
711
                                         mypartlist[3]]),
 
712
                  'color': [],
 
713
                  'lorentz':['L1'],
 
714
                  'couplings':{(0, 0):'GQED'},
 
715
                  'orders':{'QCD':2,'QED':1},
 
716
                  'loop_particles':[[]],
 
717
                  'perturbation_type':'QCD',
 
718
                  'type':'UVtree1eps'}))
 
719
 
 
720
    myinterlist.append(base_objects.Interaction({
 
721
                  'id': 42,
 
722
                  'particles': base_objects.ParticleList(\
 
723
                                        [mypartlist[2], \
 
724
                                         antid, \
 
725
                                         mypartlist[3]]),
 
726
                  'color': [],
 
727
                  'lorentz':['L1'],
 
728
                  'couplings':{(0, 0):'GQED'},
 
729
                  'orders':{'QED':3},
 
730
                  'loop_particles':[[]],
 
731
                  'perturbation_type':'QED',
 
732
                  'type':'UVtree1eps'}))
 
733
    
 
734
    # alpha_QED to electron CT
 
735
 
 
736
    myinterlist.append(base_objects.Interaction({
 
737
                  'id': 43,
 
738
                  'particles': base_objects.ParticleList(\
 
739
                                        [mypartlist[4], \
 
740
                                         antie, \
 
741
                                         mypartlist[3]]),
 
742
                  'color': [],
 
743
                  'lorentz':['L1'],
 
744
                  'couplings':{(0, 0):'GQED'},
 
745
                  'orders':{'QED':3},
 
746
                  'loop_particles':[[]],
 
747
                  'perturbation_type':'QED',
 
748
                  'type':'UVtree1eps'}))
 
749
      
 
750
    # The mass renormalization of the up and down quark granted
 
751
    # a mass for the occasion
 
752
 
 
753
    # The up quark, UVQED
 
754
    myinterlist.append(base_objects.Interaction({
 
755
                  'id': 44,
 
756
                  'particles': base_objects.ParticleList([\
 
757
                                        mypartlist[2], \
 
758
                                         antid]),
 
759
                  'color': [],
 
760
                  'lorentz':['L1'],
 
761
                  'couplings':{(0, 0):'G'},
 
762
                  'orders':{'QED':2},
 
763
                  'loop_particles':[[]],
 
764
                  'perturbation_type':'QED',
 
765
                  'type':'UVmass1eps'}))
 
766
 
 
767
    # The up quark, UVQCD
 
768
    myinterlist.append(base_objects.Interaction({
 
769
                  'id': 45,
 
770
                  'particles': base_objects.ParticleList([\
 
771
                                        mypartlist[2], \
 
772
                                         antid]),
 
773
                  'color': [],
 
774
                  'lorentz':['L1'],
 
775
                  'couplings':{(0, 0):'G'},
 
776
                  'orders':{'QCD':2},
 
777
                  'loop_particles':[[]],
 
778
                  'perturbation_type':'QCD',
 
779
                  'type':'UVmass1eps'}))
 
780
 
 
781
    # The down quark, UVQED
 
782
    myinterlist.append(base_objects.Interaction({
 
783
                  'id': 46,
 
784
                  'particles': base_objects.ParticleList([\
 
785
                                        mypartlist[1], \
 
786
                                         antiu]),
 
787
                  'color': [],
 
788
                  'lorentz':['L1'],
 
789
                  'couplings':{(0, 0):'G'},
 
790
                  'orders':{'QED':2},
 
791
                  'loop_particles':[[]],
 
792
                  'perturbation_type':'QED',
 
793
                  'type':'UVmass1eps'}))
 
794
 
 
795
    # The down quark, UVQCD
 
796
    myinterlist.append(base_objects.Interaction({
 
797
                  'id': 47,
 
798
                  'particles': base_objects.ParticleList([\
 
799
                                        mypartlist[1], \
 
800
                                         antiu]),
 
801
                  'color': [],
 
802
                  'lorentz':['L1'],
 
803
                  'couplings':{(0, 0):'G'},
 
804
                  'orders':{'QCD':2},
 
805
                  'loop_particles':[[]],
 
806
                  'perturbation_type':'QCD',
 
807
                  'type':'UVmass1eps'}))
 
808
 
 
809
 
 
810
 
 
811
    myloopmodel.set('particles', mypartlist)
 
812
    myloopmodel.set('couplings', ['QCD','QED'])        
 
813
    myloopmodel.set('interactions', myinterlist)
 
814
    myloopmodel.set('perturbation_couplings', ['QCD','QED'])
 
815
    myloopmodel.set('order_hierarchy', {'QCD':1,'QED':2})
 
816
 
 
817
    return myloopmodel    
 
818
 
 
819
 
 
820
#===============================================================================
 
821
# LoopDiagramGeneration Test
 
822
#===============================================================================
 
823
 
 
824
class LoopDiagramGenerationTest(unittest.TestCase):
 
825
    """Test class for all functions related to the Loop diagram generation"""
 
826
 
 
827
    mypartlist = base_objects.ParticleList()
 
828
    myinterlist = base_objects.InteractionList()
 
829
    myloopmodel = loop_base_objects.LoopModel()
 
830
    
 
831
    ref_dict_to0 = {}
 
832
    ref_dict_to1 = {}
 
833
 
 
834
    myamplitude = diagram_generation.Amplitude()
 
835
 
 
836
    def setUp(self):
 
837
        """Load different objects for the tests."""
 
838
        
 
839
        #self.myloopmodel = models.import_full_model(os.path.join(\
 
840
        #    _model_file_path,'loop_sm'))
 
841
        #self.myloopmodel.actualize_dictionaries()
 
842
        self.myloopmodel = loadLoopModel()
 
843
        
 
844
        self.mypartlist = self.myloopmodel['particles']
 
845
        self.myinterlist = self.myloopmodel['interactions']
 
846
        self.ref_dict_to0 = self.myinterlist.generate_ref_dict(['QCD','QED'])[0]
 
847
        self.ref_dict_to1 = self.myinterlist.generate_ref_dict(['QCD','QED'])[1]
 
848
        
 
849
    def test_NLOAmplitude(self):
 
850
        """test different features of the NLOAmplitude class"""
 
851
        ampNLOlist=[]
 
852
        ampdefaultlist=[]
 
853
 
 
854
        myleglist = base_objects.LegList()
 
855
        myleglist.append(base_objects.Leg({'id':-11,
 
856
                                         'state':False}))
 
857
        myleglist.append(base_objects.Leg({'id':11,
 
858
                                         'state':False}))
 
859
        myleglist.append(base_objects.Leg({'id':1,
 
860
                                         'state':True}))
 
861
        myleglist.append(base_objects.Leg({'id':-1,
 
862
                                         'state':True}))
 
863
        dummyproc = base_objects.Process({'legs':myleglist,
 
864
                                          'model':self.myloopmodel})
 
865
 
 
866
        ampdefaultlist.append(diagram_generation.Amplitude())
 
867
        ampdefaultlist.append(diagram_generation.Amplitude(dummyproc))
 
868
        ampdefaultlist.append(diagram_generation.Amplitude({'process':dummyproc}))        
 
869
        ampdefaultlist.append(diagram_generation.DecayChainAmplitude(dummyproc,False))
 
870
 
 
871
        dummyproc.set("perturbation_couplings",['QCD','QED'])
 
872
        ampNLOlist.append(loop_diagram_generation.LoopAmplitude({'process':dummyproc}))                
 
873
        ampNLOlist.append(loop_diagram_generation.LoopAmplitude())        
 
874
        ampNLOlist.append(loop_diagram_generation.LoopAmplitude(dummyproc))        
 
875
 
 
876
        # Test the __new__ constructor of NLOAmplitude
 
877
        for ampdefault in ampdefaultlist:
 
878
            self.assertTrue(isinstance(ampdefault,diagram_generation.Amplitude))
 
879
            self.assertFalse(isinstance(ampdefault,loop_diagram_generation.LoopAmplitude))            
 
880
        for ampNLO in ampNLOlist:
 
881
            self.assertTrue(isinstance(ampNLO,loop_diagram_generation.LoopAmplitude))
 
882
 
 
883
        # Now test for the usage of getter/setter of diagrams.
 
884
        ampNLO=loop_diagram_generation.LoopAmplitude(dummyproc)
 
885
        mydiaglist=base_objects.DiagramList([loop_base_objects.LoopDiagram({'type':0}),\
 
886
                                             loop_base_objects.LoopDiagram({'type':0}),\
 
887
                                             loop_base_objects.LoopDiagram({'type':0}),\
 
888
                                             loop_base_objects.LoopDiagram({'type':0}),\
 
889
                                             loop_base_objects.LoopDiagram({'type':0}),\
 
890
                                             loop_base_objects.LoopDiagram({'type':0}),\
 
891
                                             loop_base_objects.LoopDiagram({'type':1}),\
 
892
                                             loop_base_objects.LoopDiagram({'type':2}),\
 
893
                                             loop_base_objects.LoopDiagram({'type':3}),\
 
894
                                             loop_base_objects.LoopDiagram({'type':4}),\
 
895
                                             loop_base_objects.LoopUVCTDiagram()])        
 
896
        ampNLO.set('diagrams',mydiaglist)
 
897
        self.assertEqual(len(ampNLO.get('diagrams')),11)
 
898
        self.assertEqual(len(ampNLO.get('born_diagrams')),6)
 
899
        self.assertEqual(len(ampNLO.get('loop_diagrams')),4)  
 
900
        self.assertEqual(len(ampNLO.get('loop_UVCT_diagrams')),1)              
 
901
        mydiaglist=base_objects.DiagramList([loop_base_objects.LoopDiagram({'type':0}),\
 
902
                                             loop_base_objects.LoopDiagram({'type':0}),\
 
903
                                             loop_base_objects.LoopDiagram({'type':0})])
 
904
        ampNLO.set('born_diagrams',mydiaglist)
 
905
        self.assertEqual(len(ampNLO.get('born_diagrams')),3)        
 
906
 
 
907
    def test_diagram_generation_epem_ddx(self):
 
908
        """Test the number of loop diagrams generated for e+e->dd~ (s channel)
 
909
           with different choices for the perturbation couplings and squared orders.
 
910
        """
 
911
        
 
912
        myleglist = base_objects.LegList()
 
913
        myleglist.append(base_objects.Leg({'id':-11,
 
914
                                         'state':False}))
 
915
        myleglist.append(base_objects.Leg({'id':11,
 
916
                                         'state':False}))
 
917
        myleglist.append(base_objects.Leg({'id':1,
 
918
                                         'state':True}))
 
919
        myleglist.append(base_objects.Leg({'id':-1,
 
920
                                         'state':True}))
 
921
 
 
922
        ordersChoices=[({},['QCD'],{},1),\
 
923
                       ({},['QED'],{},7),\
 
924
                       ({},['QCD','QED'],{},10),\
 
925
                       ({},['QED','QCD'],{'QED':-1},3),\
 
926
                       ({},['QED','QCD'],{'QCD':-1},7)]
 
927
        for (bornOrders,pert,sqOrders,nDiagGoal) in ordersChoices:
 
928
            myproc = base_objects.Process({'legs':copy.copy(myleglist),
 
929
                                           'model':self.myloopmodel,
 
930
                                           'orders':bornOrders,
 
931
                                           'perturbation_couplings':pert,
 
932
                                           'squared_orders':sqOrders})
 
933
    
 
934
            myloopamplitude = loop_diagram_generation.LoopAmplitude()
 
935
            myloopamplitude.set('process', myproc)
 
936
            myloopamplitude.generate_diagrams()
 
937
            self.assertEqual(len(myloopamplitude.get('loop_diagrams')),nDiagGoal)
 
938
            
 
939
            #self.assertEqual(len([1 for diag in \
 
940
            #  myloopamplitude.get('loop_diagrams') if not isinstance(diag,
 
941
            #  loop_base_objects.LoopWavefunctionCTDiagram)]),nDiagGoal)
 
942
 
 
943
            ### This is to plot the diagrams obtained
 
944
            diaglist=[diag for diag in \
 
945
              myloopamplitude.get('loop_diagrams') if not isinstance(diag,
 
946
              loop_base_objects.LoopUVCTDiagram)]
 
947
            diaglist=myloopamplitude.get('loop_diagrams')
 
948
            options = draw_lib.DrawOption()
 
949
            filename = os.path.join('/tmp/' + \
 
950
                          myloopamplitude.get('process').shell_string() + ".eps")
 
951
            plot = draw.MultiEpsDiagramDrawer(base_objects.DiagramList(diaglist),#myloopamplitude['loop_diagrams'],
 
952
                                              filename,
 
953
                                              model=self.myloopmodel,
 
954
                                              amplitude=myloopamplitude,
 
955
                                              legend=myloopamplitude.get('process').input_string())
 
956
            plot.draw(opt=options)
 
957
 
 
958
            ### This is to display some informations
 
959
            #mydiag1=myloopamplitude.get('loop_diagrams')[0]
 
960
            #mydiag2=myloopamplitude.get('loop_diagrams')[5]      
 
961
            #print "I got tag for diag 1=",mydiag1['canonical_tag']
 
962
            #print "I got tag for diag 2=",mydiag2['canonical_tag']
 
963
            #print "I got vertices for diag 1=",mydiag1['vertices']
 
964
            #print "I got vertices for diag 2=",mydiag2['vertices']
 
965
            #print "mydiag=",str(mydiag)
 
966
            #mydiag1.tag(trial,5,6,self.myloopmodel)
 
967
            #print "I got tag=",mydiag['tag']
 
968
            #print "I got struct[0]=\n",myloopamplitude['structure_repository'][0].nice_string()
 
969
            #print "I got struct[2]=\n",myloopamplitude['structure_repository'][2].nice_string()   
 
970
            #print "I got struct[3]=\n",myloopamplitude['structure_repository'][3].nice_string()
 
971
 
 
972
    def test_diagram_generation_uux_ga(self):
 
973
        """Test the number of loop diagrams generated for uu~>g gamma (s channel)
 
974
           with different choices for the perturbation couplings and squared orders.
 
975
        """
 
976
 
 
977
        myleglist = base_objects.LegList()
 
978
        myleglist.append(base_objects.Leg({'id':2,
 
979
                                         'state':False}))
 
980
        myleglist.append(base_objects.Leg({'id':-2,
 
981
                                         'state':False}))
 
982
        myleglist.append(base_objects.Leg({'id':21,
 
983
                                         'state':True}))
 
984
        myleglist.append(base_objects.Leg({'id':22,
 
985
                                         'state':True}))
 
986
 
 
987
        ordersChoices=[
 
988
                       ({},['QCD','QED'],{},37,12,4,18),
 
989
                       ({},['QCD'],{},15,5,2,10)]
 
990
        for (bornOrders,pert,sqOrders,nDiagGoal,nR2Goal,nUVmassGoal,nUVCTGoal) in ordersChoices:
 
991
            myproc = base_objects.Process({'legs':copy.copy(myleglist),
 
992
                                           'model':self.myloopmodel,
 
993
                                           'orders':bornOrders,
 
994
                                           'perturbation_couplings':pert,
 
995
                                           'squared_orders':sqOrders})
 
996
    
 
997
            myloopamplitude = loop_diagram_generation.LoopAmplitude()
 
998
            myloopamplitude.set('process', myproc)
 
999
            myloopamplitude.generate_diagrams()
 
1000
            
 
1001
            ### This is to plot the diagrams obtained
 
1002
            #options = draw_lib.DrawOption()
 
1003
            #filename = os.path.join('/Users/Spooner/Documents/PhD/MG5/NLO', 'diagramsVall_' + \
 
1004
            #              myloopamplitude.get('process').shell_string() + ".eps")
 
1005
            #plot = draw.MultiEpsDiagramDrawer(myloopamplitude.get('diagrams'),
 
1006
            #                                  filename,
 
1007
            #                                  model=self.myloopmodel,
 
1008
            #                                  amplitude=myloopamplitude,
 
1009
            #                                  legend=myloopamplitude.get('process').input_string())
 
1010
            #plot.draw(opt=options)
 
1011
            
 
1012
            sumR2=0
 
1013
            sumUV=0
 
1014
            for i, diag in enumerate(myloopamplitude.get('loop_diagrams')):
 
1015
                sumR2+=len(diag.get_CT(self.myloopmodel,'R2'))
 
1016
                sumUV+=len(diag.get_CT(self.myloopmodel,'UV'))
 
1017
            self.assertEqual(len(myloopamplitude.get('loop_diagrams')),nDiagGoal)
 
1018
            self.assertEqual(sumR2, nR2Goal)
 
1019
            self.assertEqual(sumUV, nUVmassGoal)
 
1020
            sumUVCT=0
 
1021
            for loop_UVCT_diag in myloopamplitude.get('loop_UVCT_diagrams'):
 
1022
                sumUVCT+=len(loop_UVCT_diag.get('UVCT_couplings'))
 
1023
            self.assertEqual(sumUVCT,nUVCTGoal)
 
1024
 
 
1025
    def test_diagram_generation_gg_ng(self):
 
1026
        """Test the number of loop diagrams generated for gg>ng. n being in [1,2,3]
 
1027
        """
 
1028
        
 
1029
        # For quick test 
 
1030
        nGluons = [(1,8,0,1,4),(2,81,0,10,23)]
 
1031
        # For a longer one
 
1032
        # (still 4 need to be re-tested)
 
1033
        # nGluons += [(3,905,0,105,190),(4,11850,0,1290,2075)]
 
1034
 
 
1035
        for (n, nDiagGoal, nUVmassGoal, nR2Goal, nUVCTGoal) in nGluons:
 
1036
            myleglist=base_objects.LegList([base_objects.Leg({'id':21,
 
1037
                                              'number':num,
 
1038
                                              'loop_line':False}) \
 
1039
                                              for num in range(1, (n+3))])
 
1040
            myleglist[0].set('state',False)
 
1041
            myleglist[1].set('state',False)        
 
1042
 
 
1043
            myproc=base_objects.Process({'legs':myleglist,
 
1044
                                       'model':self.myloopmodel,
 
1045
                                       'orders':{},
 
1046
                                       'squared_orders': {},
 
1047
                                       'perturbation_couplings':['QCD']})
 
1048
 
 
1049
            myloopamplitude = loop_diagram_generation.LoopAmplitude()
 
1050
            myloopamplitude.set('process', myproc)
 
1051
            myloopamplitude.generate_diagrams()
 
1052
            sumR2=0
 
1053
            sumUV=0
 
1054
            for i, diag in enumerate(myloopamplitude.get('loop_diagrams')):
 
1055
                sumR2+=len(diag.get_CT(self.myloopmodel,'R2'))
 
1056
                sumUV+=len(diag.get_CT(self.myloopmodel,'UV'))
 
1057
            sumUVCT=0
 
1058
            for loop_UVCT_diag in myloopamplitude.get('loop_UVCT_diagrams'):
 
1059
                sumUVCT+=len(loop_UVCT_diag.get('UVCT_couplings'))
 
1060
            self.assertEqual(len(myloopamplitude.get('loop_diagrams')), nDiagGoal)
 
1061
            self.assertEqual(sumR2, nR2Goal)
 
1062
            self.assertEqual(sumUV, nUVmassGoal)   
 
1063
            self.assertEqual(sumUVCT, nUVCTGoal)                        
 
1064
 
 
1065
    def test_diagram_generation_uux_ddx(self):
 
1066
        """Test the number of loop diagrams generated for uu~>dd~ for different choices
 
1067
           of orders.
 
1068
        """
 
1069
 
 
1070
        myleglist = base_objects.LegList()
 
1071
        myleglist.append(base_objects.Leg({'id':2,
 
1072
                                         'state':False}))
 
1073
        myleglist.append(base_objects.Leg({'id':-2,
 
1074
                                         'state':False}))
 
1075
        myleglist.append(base_objects.Leg({'id':1,
 
1076
                                         'state':True}))
 
1077
        myleglist.append(base_objects.Leg({'id':-1,
 
1078
                                         'state':True}))
 
1079
 
 
1080
        ordersChoices=[({},['QCD','QED'],{},21,7,6,12),\
 
1081
                       ({},['QCD','QED',],{'QED':-99},28,10,8,16),\
 
1082
                       ({},['QCD'],{},9,3,2,4),\
 
1083
                       ({},['QED'],{},2,2,2,4),\
 
1084
                       ({'QED':0},['QCD'],{},9,3,2,4),\
 
1085
                       ({'QCD':0},['QED'],{},7,3,2,4),\
 
1086
                       ({},['QCD','QED'],{'QED':-1},9,3,2,4),\
 
1087
                       ({},['QCD','QED'],{'QCD':-1},7,3,2,4),\
 
1088
                       ({},['QCD','QED'],{'QED':-2},21,7,6,12),\
 
1089
                       ({},['QCD','QED'],{'QED':-3},28,10,8,16)]
 
1090
        
 
1091
        for (bornOrders,pert,sqOrders,nDiagGoal,nR2Goal,nUVGoal,nUVWfctGoal) in ordersChoices:
 
1092
            myproc = base_objects.Process({'legs':copy.copy(myleglist),
 
1093
                                           'model':self.myloopmodel,
 
1094
                                           'orders':bornOrders,
 
1095
                                           'perturbation_couplings':pert,
 
1096
                                           'squared_orders':sqOrders})
 
1097
            myloopamplitude = loop_diagram_generation.LoopAmplitude()
 
1098
            myloopamplitude.set('process', myproc)
 
1099
            myloopamplitude.generate_diagrams()
 
1100
            sumR2=0
 
1101
            sumUV=0
 
1102
            for i, diag in enumerate(myloopamplitude.get('loop_diagrams')):
 
1103
                sumR2+=len(diag.get_CT(self.myloopmodel,'R2'))
 
1104
                sumUV+=len(diag.get_CT(self.myloopmodel,'UV'))
 
1105
            
 
1106
            sumUVwfct=0
 
1107
            for loop_UVCT_diag in myloopamplitude.get('loop_UVCT_diagrams'):
 
1108
                for coupl in loop_UVCT_diag.get('UVCT_couplings'):
 
1109
                    if not isinstance(coupl,str) or not 'Wfct' in coupl:
 
1110
                        sumUV+=1
 
1111
                    else:
 
1112
                        sumUVwfct+=1
 
1113
                    
 
1114
            self.assertEqual(len(myloopamplitude.get('loop_diagrams')), nDiagGoal)
 
1115
            self.assertEqual(sumR2, nR2Goal)
 
1116
            self.assertEqual(sumUV, nUVGoal)  
 
1117
            self.assertEqual(sumUVwfct, nUVWfctGoal)          
 
1118
 
 
1119
    def test_diagram_generation_ddx_ddx(self):
 
1120
        """Test the number of loop diagrams generated for dd~>dd~ for different choices
 
1121
           of orders.
 
1122
        """
 
1123
 
 
1124
        myleglist = base_objects.LegList()
 
1125
        myleglist.append(base_objects.Leg({'id':1,
 
1126
                                         'state':False}))
 
1127
        myleglist.append(base_objects.Leg({'id':-1,
 
1128
                                         'state':False}))
 
1129
        myleglist.append(base_objects.Leg({'id':1,
 
1130
                                         'state':True}))
 
1131
        myleglist.append(base_objects.Leg({'id':-1,
 
1132
                                         'state':True}))
 
1133
 
 
1134
        ordersChoices=[({},['QCD'],{},18,6,0,12),\
 
1135
                       ({},['QED'],{},4,4,0,12),\
 
1136
                       ({},['QCD','QED'],{},42,14,0,36),\
 
1137
                       ({},['QCD','QED',],{'QED':-99},56,20,0,48),\
 
1138
                       ({'QED':0},['QCD'],{},18,6,0,12),\
 
1139
                       ({'QCD':0},['QED'],{},14,6,0,12),\
 
1140
                       ({},['QCD','QED'],{'QED':-1},18,6,0,12),\
 
1141
                       ({},['QCD','QED'],{'QCD':-1},14,6,0,12)]
 
1142
        
 
1143
        for (bornOrders,pert,sqOrders,nDiagGoal,nR2Goal,nUVmassGoal,nUVCTGoal) in ordersChoices:
 
1144
            myproc = base_objects.Process({'legs':copy.copy(myleglist),
 
1145
                                           'model':self.myloopmodel,
 
1146
                                           'orders':bornOrders,
 
1147
                                           'perturbation_couplings':pert,
 
1148
                                           'squared_orders':sqOrders})
 
1149
    
 
1150
            myloopamplitude = loop_diagram_generation.LoopAmplitude()
 
1151
            myloopamplitude.set('process', myproc)
 
1152
            myloopamplitude.generate_diagrams()
 
1153
            sumR2=0
 
1154
            sumUV=0
 
1155
            for i, diag in enumerate(myloopamplitude.get('loop_diagrams')):
 
1156
                sumR2+=len(diag.get_CT(self.myloopmodel,'R2'))
 
1157
                sumUV+=len(diag.get_CT(self.myloopmodel,'UV'))
 
1158
            self.assertEqual(len(myloopamplitude.get('loop_diagrams')),nDiagGoal)
 
1159
            self.assertEqual(sumR2, nR2Goal)
 
1160
            self.assertEqual(sumUV, nUVmassGoal)
 
1161
            sumUVCT=0
 
1162
            for loop_UVCT_diag in myloopamplitude.get('loop_UVCT_diagrams'):
 
1163
                sumUVCT+=len(loop_UVCT_diag.get('UVCT_couplings'))
 
1164
            self.assertEqual(sumUVCT,nUVCTGoal)
 
1165
            
 
1166
    def test_CT_vertices_generation_gg_gg(self):
 
1167
        """ test that the Counter Term vertices are correctly
 
1168
            generated by adding some new CT interactions to the model and
 
1169
            comparing how many CT vertices are generated on the 
 
1170
            process gg_gg for different R2 specifications. """
 
1171
            
 
1172
        newLoopModel=copy.deepcopy(self.myloopmodel)
 
1173
        newInteractionList=base_objects.InteractionList()
 
1174
        for inter in newLoopModel['interactions']:
 
1175
            if inter['type']=='base':
 
1176
                newInteractionList.append(inter)
 
1177
        
 
1178
        myleglist = base_objects.LegList()
 
1179
        myleglist.append(base_objects.Leg({'id':21,
 
1180
                                         'state':False}))
 
1181
        myleglist.append(base_objects.Leg({'id':21,
 
1182
                                         'state':False}))
 
1183
        myleglist.append(base_objects.Leg({'id':21,
 
1184
                                         'state':True}))
 
1185
        myleglist.append(base_objects.Leg({'id':21,
 
1186
                                         'state':True}))
 
1187
                
 
1188
        newInteractionList.append(base_objects.Interaction({
 
1189
                      'id': 666,
 
1190
                      # a dd~d~ R2
 
1191
                      'particles': base_objects.ParticleList(\
 
1192
                                            [self.mypartlist[0]]*4),
 
1193
                      'color': [],
 
1194
                      'lorentz':['L1'],
 
1195
                      'couplings':{(0, 0):'G'},
 
1196
                      'orders':{'QCD':4},
 
1197
                      # We don't specify the loop content here
 
1198
                      'loop_particles':[[]],
 
1199
                      'type':'R2'}))
 
1200
        
 
1201
        myproc = base_objects.Process({'legs':myleglist,
 
1202
                                       'model':newLoopModel,
 
1203
                                       'orders':{},
 
1204
                                       'perturbation_couplings':['QCD'],
 
1205
                                       'squared_orders':{'WEIGHTED':99}})
 
1206
 
 
1207
        myloopamplitude = loop_diagram_generation.LoopAmplitude()
 
1208
        myloopamplitude.set('process', myproc)
 
1209
        myloopamplitude.generate_diagrams()
 
1210
        
 
1211
        CTChoice=[([[]],{'QCD':4},1),
 
1212
                  ([[21,]],{'QCD':4},1),
 
1213
                  ([[1,]],{'QCD':4},1),
 
1214
                  ([[2,]],{'QCD':4},1),
 
1215
                  ([[2,],[21,],[1,]],{'QCD':4},3), 
 
1216
                  ([[2,],[21,2],[1,],[22,21,1]],{'QCD':4},2),                 
 
1217
                  ([[21,]],{'QCD':4,'QED':1},0),
 
1218
                  ([[1,2]],{'QCD':4},0)]
 
1219
        
 
1220
        for (parts,orders,nCTGoal) in CTChoice:
 
1221
            newInteractionList[-1]['loop_particles']=parts
 
1222
            newInteractionList[-1]['orders']=orders            
 
1223
            newLoopModel.set('interactions',newInteractionList)
 
1224
            myloopamplitude['process']['model']=newLoopModel
 
1225
            for diag in myloopamplitude.get('loop_diagrams'):
 
1226
                diag['CT_vertices']=base_objects.VertexList()
 
1227
            myloopamplitude.set_LoopCT_vertices()            
 
1228
            sumR2=0
 
1229
            for i, diag in enumerate(myloopamplitude.get('loop_diagrams')):
 
1230
                sumR2+=len(diag.get_CT(newLoopModel,'R2'))
 
1231
            self.assertEqual(sumR2, nCTGoal)
 
1232
 
 
1233
    def test_CT_vertices_generation_ddx_ddx(self):
 
1234
        """ test that the Counter Term vertices are correctly
 
1235
            generated by adding some new CT interactions to the model and
 
1236
            comparing how many CT vertices are generated on the 
 
1237
            process ddx_ddx for different R2 specifications. """
 
1238
            
 
1239
        newLoopModel=copy.deepcopy(self.myloopmodel)
 
1240
        newInteractionList=base_objects.InteractionList()
 
1241
        for inter in newLoopModel['interactions']:
 
1242
            if inter['type']=='base':
 
1243
                newInteractionList.append(inter)
 
1244
        
 
1245
        myleglist = base_objects.LegList()
 
1246
        myleglist.append(base_objects.Leg({'id':1,
 
1247
                                         'state':False}))
 
1248
        myleglist.append(base_objects.Leg({'id':-1,
 
1249
                                         'state':False}))
 
1250
        myleglist.append(base_objects.Leg({'id':1,
 
1251
                                         'state':True}))
 
1252
        myleglist.append(base_objects.Leg({'id':-1,
 
1253
                                         'state':True}))
 
1254
                
 
1255
        antid=copy.copy(self.mypartlist[2])
 
1256
        antid.set('is_part',False)
 
1257
        newInteractionList.append(base_objects.Interaction({
 
1258
                      'id': 666,
 
1259
                      # a dd~d~ R2
 
1260
                      'particles': base_objects.ParticleList(\
 
1261
                                            [self.mypartlist[2],
 
1262
                                             antid,
 
1263
                                             self.mypartlist[2],
 
1264
                                             antid,]),
 
1265
                      'color': [],
 
1266
                      'lorentz':['L1'],
 
1267
                      'couplings':{(0, 0):'G'},
 
1268
                      'orders':{'QCD':4},
 
1269
                      # We don't specify the loop content here
 
1270
                      'loop_particles':[[]],
 
1271
                      'type':'R2'}))
 
1272
        
 
1273
        myproc = base_objects.Process({'legs':myleglist,
 
1274
                                       'model':newLoopModel,
 
1275
                                       'orders':{},
 
1276
                                       'perturbation_couplings':['QCD','QED'],
 
1277
                                       'squared_orders':{'WEIGHTED':99}})
 
1278
    
 
1279
        myloopamplitude = loop_diagram_generation.LoopAmplitude()
 
1280
        myloopamplitude.set('process', myproc)
 
1281
        myloopamplitude.generate_diagrams()
 
1282
        
 
1283
        CTChoice=[([[]],{'QCD':4},1),
 
1284
                  ([[1,21]],{'QCD':4},1),
 
1285
                  ([[1,22]],{'QED':4},1),
 
1286
                  ([[1,22],[1,22]],{'QED':4},2),
 
1287
                  ([[1,21]],{'QED':4},0),
 
1288
                  ([[1,22]],{'QCD':4},0),
 
1289
                  ([[21,]],{'QCD':4},0)]
 
1290
        
 
1291
        for (parts,orders,nCTGoal) in CTChoice:
 
1292
            newInteractionList[-1]['loop_particles']=parts
 
1293
            newInteractionList[-1]['orders']=orders            
 
1294
            newLoopModel.set('interactions',newInteractionList)
 
1295
            myloopamplitude['process']['model']=newLoopModel
 
1296
            for diag in myloopamplitude.get('loop_diagrams'):
 
1297
                diag['CT_vertices']=base_objects.VertexList()
 
1298
            myloopamplitude.set_LoopCT_vertices()            
 
1299
            sumR2=0
 
1300
            for i, diag in enumerate(myloopamplitude.get('loop_diagrams')):
 
1301
                sumR2+=len(diag.get_CT(newLoopModel,'R2'))
 
1302
            self.assertEqual(sumR2, nCTGoal)
 
1303
            
 
1304
#===============================================================================
 
1305
# LoopDiagramFDStruct Test
 
1306
#===============================================================================
 
1307
class LoopDiagramFDStructTest(unittest.TestCase):
 
1308
    """Test class for the tagging functions of LoopDiagram and FDStructure classes"""
 
1309
 
 
1310
    mypartlist = base_objects.ParticleList()
 
1311
    myinterlist = base_objects.InteractionList()
 
1312
    mymodel = base_objects.Model()
 
1313
    myproc = base_objects.Process()
 
1314
    myloopdiag = loop_base_objects.LoopDiagram()
 
1315
 
 
1316
    def setUp(self):
 
1317
        """ Setup a toy-model with gluon and down-quark only """
 
1318
 
 
1319
        # A gluon
 
1320
        self.mypartlist.append(base_objects.Particle({'name':'g',
 
1321
                      'antiname':'g',
 
1322
                      'spin':3,
 
1323
                      'color':8,
 
1324
                      'mass':'zero',
 
1325
                      'width':'zero',
 
1326
                      'texname':'g',
 
1327
                      'antitexname':'g',
 
1328
                      'line':'curly',
 
1329
                      'charge':0.,
 
1330
                      'pdg_code':21,
 
1331
                      'propagating':True,
 
1332
                      'is_part':True,
 
1333
                      'self_antipart':True}))
 
1334
 
 
1335
        # A quark D and its antiparticle
 
1336
        self.mypartlist.append(base_objects.Particle({'name':'d',
 
1337
                      'antiname':'d~',
 
1338
                      'spin':2,
 
1339
                      'color':3,
 
1340
                      'mass':'dmass',
 
1341
                      'width':'zero',
 
1342
                      'texname':'d',
 
1343
                      'antitexname':'\bar d',
 
1344
                      'line':'straight',
 
1345
                      'charge':-1. / 3.,
 
1346
                      'pdg_code':1,
 
1347
                      'propagating':True,
 
1348
                      'is_part':True,
 
1349
                      'self_antipart':False}))
 
1350
        antid = copy.copy(self.mypartlist[1])
 
1351
        antid.set('is_part', False)
 
1352
 
 
1353
        # 3 gluon vertex
 
1354
        self.myinterlist.append(base_objects.Interaction({
 
1355
                      'id': 1,
 
1356
                      'particles': base_objects.ParticleList(\
 
1357
                                            [self.mypartlist[0]] * 3),
 
1358
                      'color': [],
 
1359
                      'lorentz':['L1'],
 
1360
                      'couplings':{(0, 0):'G'},
 
1361
                      'orders':{'QCD':1}}))
 
1362
 
 
1363
        # 4 gluon vertex
 
1364
        self.myinterlist.append(base_objects.Interaction({
 
1365
                      'id': 2,
 
1366
                      'particles': base_objects.ParticleList(\
 
1367
                                            [self.mypartlist[0]] * 4),
 
1368
                      'color': [],
 
1369
                      'lorentz':['L1'],
 
1370
                      'couplings':{(0, 0):'G^2'},
 
1371
                      'orders':{'QCD':2}}))
 
1372
 
 
1373
        # Gluon coupling to the down-quark
 
1374
        self.myinterlist.append(base_objects.Interaction({
 
1375
                      'id': 3,
 
1376
                      'particles': base_objects.ParticleList(\
 
1377
                                            [self.mypartlist[1], \
 
1378
                                             antid, \
 
1379
                                             self.mypartlist[0]]),
 
1380
                      'color': [],
 
1381
                      'lorentz':['L1'],
 
1382
                      'couplings':{(0, 0):'GQQ'},
 
1383
                      'orders':{'QCD':1}}))
 
1384
 
 
1385
        self.mymodel.set('particles', self.mypartlist)
 
1386
        self.mymodel.set('interactions', self.myinterlist)
 
1387
        self.myproc.set('model',self.mymodel)
 
1388
 
 
1389
    def test_gg_5gglgl_bubble_tag(self):
 
1390
        """ Test the gg>ggggg g*g* tagging of a bubble"""
 
1391
 
 
1392
        # Five gluon legs with two initial states
 
1393
        myleglist = base_objects.LegList([base_objects.Leg({'id':21,
 
1394
                                              'number':num,
 
1395
                                              'loop_line':False}) \
 
1396
                                              for num in range(1, 10)])
 
1397
        myleglist[7].set('loop_line', True)
 
1398
        myleglist[8].set('loop_line', True)
 
1399
        l1=myleglist[0]
 
1400
        l2=myleglist[1]
 
1401
        l3=myleglist[2]
 
1402
        l4=myleglist[3]
 
1403
        l5=myleglist[4]
 
1404
        l6=myleglist[5]
 
1405
        l7=myleglist[6]
 
1406
        l8=myleglist[7]
 
1407
        l9=myleglist[8]
 
1408
        lfinal=copy.copy(l9)
 
1409
        lfinal.set('number',9)
 
1410
 
 
1411
        self.myproc.set('legs',myleglist)
 
1412
 
 
1413
        l67 = base_objects.Leg({'id':21,'number':6,'loop_line':False})
 
1414
        l56 = base_objects.Leg({'id':21,'number':5,'loop_line':False})
 
1415
        l235 = base_objects.Leg({'id':21,'number':2,'loop_line':False}) 
 
1416
        l24 = base_objects.Leg({'id':21,'number':2,'loop_line':False})
 
1417
        l28 = base_objects.Leg({'id':21,'number':2,'loop_line':True})
 
1418
        l128 = base_objects.Leg({'id':21,'number':1,'loop_line':True})
 
1419
        l19 = base_objects.Leg({'id':21,'number':1,'loop_line':True})
 
1420
        l18 = base_objects.Leg({'id':21,'number':1,'loop_line':True})
 
1421
        l12 = base_objects.Leg({'id':21,'number':1,'loop_line':True})
 
1422
 
 
1423
        vx19 = base_objects.Vertex({'legs':base_objects.LegList([l1, l9, l19]), 'id': 1})
 
1424
        vx67 = base_objects.Vertex({'legs':base_objects.LegList([l6, l7, l67]), 'id': 1})
 
1425
        vx56 = base_objects.Vertex({'legs':base_objects.LegList([l5, l67, l56]), 'id': 1})
 
1426
        vx235 = base_objects.Vertex({'legs':base_objects.LegList([l2, l3, l56, l235]), 'id': 2})
 
1427
        vx24 = base_objects.Vertex({'legs':base_objects.LegList([l4, l235, l24]), 'id': 1})
 
1428
        vx28 = base_objects.Vertex({'legs':base_objects.LegList([l235, l8, l28]), 'id': 1})
 
1429
        vx0 = base_objects.Vertex({'legs':base_objects.LegList([l19, l28]), 'id': 0})
 
1430
 
 
1431
        myVertexList=base_objects.VertexList([vx19,vx67,vx56,vx235,vx24,vx28,vx0])
 
1432
 
 
1433
        myBubbleDiag=loop_base_objects.LoopDiagram({'vertices':myVertexList,'type':21})
 
1434
 
 
1435
        myStructRep=loop_base_objects.FDStructureList()
 
1436
        myStruct=loop_base_objects.FDStructure()
 
1437
 
 
1438
        goal_canonicalStruct=(((2, 3, 4, 5, 6, 7), 1), ((2, 3, 5, 6, 7), 2), ((5, 6, 7), 1), ((6, 7), 1))
 
1439
        canonicalStruct=myBubbleDiag.construct_FDStructure(5, 0, 2, myStruct)
 
1440
        self.assertEqual(canonicalStruct, goal_canonicalStruct)
 
1441
        
 
1442
        goal_vxList=base_objects.VertexList([vx67,vx56,vx235,vx24])
 
1443
        myStruct.set('canonical',canonicalStruct)
 
1444
        myStruct.generate_vertices(self.myproc)
 
1445
        self.assertEqual(myStruct['vertices'],goal_vxList)
 
1446
 
 
1447
        goal_tag=[[21, [1], 1], [21, [0], 1]]
 
1448
        vx18_tag=base_objects.Vertex({'legs':base_objects.LegList([l1, l8, l18]), 'id': 1})
 
1449
        vx12_tag=base_objects.Vertex({'legs':base_objects.LegList([l24, l18, l12]), 'id': 1})
 
1450
        closing_vx=base_objects.Vertex({'legs':base_objects.LegList([l12, lfinal]), 'id': -1})
 
1451
        goal_vertices=base_objects.VertexList([vx18_tag,vx12_tag,closing_vx])
 
1452
        myBubbleDiag.tag(myStructRep,8,9,self.myproc)
 
1453
        self.assertEqual(myBubbleDiag.get('canonical_tag'), goal_tag)
 
1454
        self.assertEqual(myBubbleDiag.get('vertices'), goal_vertices)
 
1455
 
 
1456
    def test_gg_4gdldxl_penta_tag(self):
 
1457
        """ Test the gg>gggg d*dx* tagging of a quark pentagon"""
 
1458
 
 
1459
        # Five gluon legs with two initial states
 
1460
        myleglist = base_objects.LegList([base_objects.Leg({'id':21,
 
1461
                                              'number':num,
 
1462
                                              'loop_line':False}) \
 
1463
                                              for num in range(1, 7)])
 
1464
        myleglist.append(base_objects.Leg({'id':1,'number':7,'loop_line':True}))
 
1465
        myleglist.append(base_objects.Leg({'id':-1,'number':8,'loop_line':True}))                         
 
1466
        l1=myleglist[0]
 
1467
        l2=myleglist[1]
 
1468
        l3=myleglist[2]
 
1469
        l4=myleglist[3]
 
1470
        l5=myleglist[4]
 
1471
        l6=myleglist[5]
 
1472
        l7=myleglist[6]
 
1473
        l8=myleglist[7]
 
1474
 
 
1475
        self.myproc.set('legs',myleglist)
 
1476
 
 
1477
        # One way of constructing this diagram, with a three-point amplitude
 
1478
        l17 = base_objects.Leg({'id':1,'number':1,'loop_line':True})
 
1479
        l12 = base_objects.Leg({'id':1,'number':1,'loop_line':True})
 
1480
        l68 = base_objects.Leg({'id':-1,'number':6,'loop_line':True}) 
 
1481
        l56 = base_objects.Leg({'id':-1,'number':5,'loop_line':True})
 
1482
        l34 = base_objects.Leg({'id':21,'number':3,'loop_line':False})
 
1483
        l617 = base_objects.Leg({'id':1,'number':1,'loop_line':True})
 
1484
 
 
1485
        vx17 = base_objects.Vertex({'legs':base_objects.LegList([l1, l7, l17]), 'id': 3})
 
1486
        vx12 = base_objects.Vertex({'legs':base_objects.LegList([l17, l2, l12]), 'id': 3})
 
1487
        vx68 = base_objects.Vertex({'legs':base_objects.LegList([l6, l8, l68]), 'id': 3})
 
1488
        vx56 = base_objects.Vertex({'legs':base_objects.LegList([l5, l68, l56]), 'id': 3})
 
1489
        vx34 = base_objects.Vertex({'legs':base_objects.LegList([l3, l4, l34]), 'id': 1})
 
1490
        vx135 = base_objects.Vertex({'legs':base_objects.LegList([l12, l56, l34]), 'id': 3})
 
1491
 
 
1492
        myVertexList1=base_objects.VertexList([vx17,vx12,vx68,vx56,vx34,vx135])
 
1493
 
 
1494
        myPentaDiag1=loop_base_objects.LoopDiagram({'vertices':myVertexList1,'type':1})
 
1495
 
 
1496
        myStructRep=loop_base_objects.FDStructureList()
 
1497
        myStruct=loop_base_objects.FDStructure()
 
1498
        
 
1499
        goal_tag=[[1, [0], 3], [1, [1], 3], [1, [2], 3], [1, [3], 3], [1, [4], 3]]
 
1500
        myPentaDiag1.tag(myStructRep,7,8,self.myproc)
 
1501
        self.assertEqual(myPentaDiag1.get('canonical_tag'), goal_tag)
 
1502
 
 
1503
        vx17_tag=base_objects.Vertex({'legs':base_objects.LegList([l1, l7, l17]), 'id': 3})
 
1504
        vx12_tag=base_objects.Vertex({'legs':base_objects.LegList([l2, l17, l12]), 'id': 3})
 
1505
        vx13_tag=base_objects.Vertex({'legs':base_objects.LegList([l34, l12, l17]), 'id': 3})
 
1506
        vx15_tag=base_objects.Vertex({'legs':base_objects.LegList([l5, l17, l17]), 'id': 3})
 
1507
        vx168_tag=base_objects.Vertex({'legs':base_objects.LegList([l6, l17, l617]), 'id': 3})  
 
1508
        closing_vx=base_objects.Vertex({'legs':base_objects.LegList([l617, l8]), 'id': -1})              
 
1509
        goal_vertices=base_objects.VertexList([vx17_tag,vx12_tag,vx13_tag,vx15_tag,vx168_tag,closing_vx])
 
1510
        self.assertEqual(myPentaDiag1.get('vertices'), goal_vertices)
 
1511
 
 
1512
if __name__ == '__main__':
 
1513
        # Save this model so that it can be loaded by other loop tests
 
1514
        save_load_object.save_to_file(os.path.join(_input_file_path, 'test_toyLoopModel.pkl'),loadLoopModel())
 
1515
        print "test_toyLoopModel.pkl created."