30
30
import madgraph.iolibs.drawing_eps as drawing_eps
31
31
import madgraph.iolibs.import_v4 as import_v4
32
32
from madgraph import MG5DIR
33
import decay.decay_objects as decay_objects
33
import mg5decay.decay_objects as decay_objects
34
34
import tests.input_files.import_vertexlist as import_vertexlist
85
85
# Setup vertexlist for test
86
86
full_vertexlist = import_vertexlist.full_vertexlist
87
# (54, 24): t b~ w-; (66,24): ve e- w-
88
88
self.my_2bodyvertexlist = base_objects.VertexList([
89
full_vertexlist[(41, 24)], full_vertexlist[(63, 24)]])
90
fake_vertex = copy.deepcopy(full_vertexlist[(41, 24)])
89
full_vertexlist[(54, 24)], full_vertexlist[(66, 24)]])
90
fake_vertex = copy.deepcopy(full_vertexlist[(54, 24)])
91
91
fake_vertex['legs'].append(base_objects.Leg({'id':22}))
92
fake_vertex2 = copy.deepcopy(full_vertexlist[(63, 24)])
92
fake_vertex2 = copy.deepcopy(full_vertexlist[(66, 24)])
93
93
fake_vertex2['legs'].append(base_objects.Leg({'id': 11}))
94
94
self.my_3bodyvertexlist = base_objects.VertexList([
95
95
fake_vertex, fake_vertex2])
97
# (33, -24): t~ b w+; (54,-6): b~ w- t
97
98
self.my_2bodyvertexlist_wrongini = base_objects.VertexList([
98
full_vertexlist[(50, -24)], full_vertexlist[(41, -6)]])
99
fake_vertex3 = copy.deepcopy(full_vertexlist[(50, -24 )])
99
full_vertexlist[(33, -24)], full_vertexlist[(54, -6)]])
100
fake_vertex3 = copy.deepcopy(full_vertexlist[(33, -24 )])
100
101
fake_vertex3['legs'].append(base_objects.Leg({'id':12}))
101
102
self.my_3bodyvertexlist_wrongini = base_objects.VertexList([
104
fake_vertex4 = copy.deepcopy(full_vertexlist[(41, 24 )])
105
fake_vertex4 = copy.deepcopy(full_vertexlist[(54, 24 )])
105
106
fake_vertex4['legs'].append(base_objects.Leg({'id':24}))
106
107
self.my_3bodyvertexlist_radiactive = base_objects.VertexList([
176
177
self.assertRaises(AssertionError, decay_objects.DecayParticle,myNondict)
177
self.assertRaises(decay_objects.DecayParticle.PhysicsObjectError,
178
decay_objects.DecayParticle, myWrongdict)
178
# Do not check if the input dict has wrong dict!
179
#self.assertRaises(decay_objects.DecayParticle.PhysicsObjectError,
180
# decay_objects.DecayParticle, myWrongdict)
181
183
self.assertRaises(AssertionError, self.mypart.get, myNondict)
197
199
'right_list':['h', 'e+', 'e-', 'u~',
198
200
'k++', 'k--', 'T', 'u+~'],
199
'wrong_list':['', 'x ', 'e?', '{}', '9x', 'd~3', 'd+g',
201
'wrong_list':['', 'x ', 'e?', '{}']},
202
203
'right_list':[1, 2, 3, 4, 5],
203
204
'wrong_list':[-1, 0, 'a', 6]},
429
430
#Test the correctness of vertexlist by t quark
430
431
tquark = decay_objects.DecayParticle(self.my_testmodel.get_particle(6),True)
431
432
tquark.find_vertexlist(self.my_testmodel)
432
#Name convention: 'pdg_code'+'particle #'+'on-shell'
434
#Name convention: 'pdg_code'+'particle #'+'on-shell' (0: offshell, 1:onshell)
433
436
my_vertexlist620 = base_objects.VertexList()
435
my_vertexlist621 = base_objects.VertexList([full_vertexlist[(50, 6)]])
438
my_vertexlist621 = base_objects.VertexList([full_vertexlist[(33, 6)]])
436
439
my_vertexlist630 = base_objects.VertexList()
437
440
my_vertexlist631 = base_objects.VertexList()
438
441
rightlist6 = [my_vertexlist620, my_vertexlist621, my_vertexlist630, my_vertexlist631]
442
445
wboson_p.find_vertexlist(self.my_testmodel)
443
446
#List must follow the order of interaction id so as to be consistent
444
447
#with the find_vertexlist function
446
my_vertexlist2420 = base_objects.VertexList([full_vertexlist[(41, 24)]])
447
my_vertexlist2421 = base_objects.VertexList([full_vertexlist[(63, 24)]])
449
my_vertexlist2420 = base_objects.VertexList([full_vertexlist[(54, 24)]])
451
my_vertexlist2421 = base_objects.VertexList([full_vertexlist[(66, 24)]])
448
452
my_vertexlist2430 = base_objects.VertexList()
449
453
my_vertexlist2431 = base_objects.VertexList()
450
454
#List of the total decay vertex list for W+
481
485
def test_setget_channel(self):
482
486
""" Test of the get_channel set_channel functions (and the underlying
483
487
check_channels.)"""
484
489
# Prepare the channel
485
490
full_vertexlist = import_vertexlist.full_vertexlist
487
492
vert_0 = base_objects.Vertex({'id': 0, 'legs': base_objects.LegList([\
488
493
base_objects.Leg({'id':25, 'number':1, 'state': False}),
489
494
base_objects.Leg({'id':25, 'number':2})])})
491
vert_1 = copy.deepcopy(full_vertexlist[(59, 25)])
497
vert_1 = copy.deepcopy(full_vertexlist[(62, 25)])
492
498
vert_1['legs'][0]['number'] = 2
493
499
vert_1['legs'][1]['number'] = 3
494
500
vert_1['legs'][2]['number'] = 2
496
vert_2 = copy.deepcopy(full_vertexlist[(41, -6)])
501
# t > b w+ = (t~ b w+)
502
vert_2 = copy.deepcopy(full_vertexlist[(54, -6)])
497
503
vert_2['legs'][0]['number'] = 2
498
504
vert_2['legs'][1]['number'] = 4
499
505
vert_2['legs'][2]['number'] = 2
501
vert_3 = copy.deepcopy(full_vertexlist[(50, 6)])
506
# t~ > b~ w- = (t b~ w-)
507
vert_3 = copy.deepcopy(full_vertexlist[(33, 6)])
502
508
vert_3['legs'][0]['number'] = 3
503
509
vert_3['legs'][1]['number'] = 5
504
510
vert_3['legs'][2]['number'] = 3
968
974
Second, set the neutrinos as massless."""
970
976
# Import the full sm with param_card
971
# NO massless particle, i.e. neutrinos, leptons, quarks all have masses.
972
full_sm_base = import_ufo.import_full_model(\
974
'tests', 'input_files',
977
sm_path = import_ufo.find_ufo_path('sm')
978
full_sm_base = import_ufo.import_full_model(sm_path)
976
979
full_sm = decay_objects.DecayModel(full_sm_base, True)
977
980
param_path = os.path.join(_file_path,
978
981
'../input_files/param_card_full_sm.dat')
979
982
full_sm.read_param_card(param_path)
984
# Stage 1: Find stable particles with
985
# nonzero neutrino masses, quark masses
986
# Turned on light quark and neutrino masses
987
neutrinos = [12, 14, 16]
988
lightquarks1 = [1, 3]
989
for npid in neutrinos:
990
full_sm.get_particle(npid)['mass'] = '1E-6'
991
full_sm.get_particle(-npid)['mass'] = '1E-6'
992
for qpid in lightquarks1:
993
full_sm.get_particle(qpid)['mass'] = '5'
994
full_sm.get_particle(2)['mass'] = '1'
982
# Stage 1: nonzero neutrino masses
983
996
# the stable particles are the ones with lightest mass in
985
998
goal_groups_1 = set([(21,22, 23,25), # 23 and 25 are calculated
1055
1068
param_path = os.path.join(_file_path,
1056
1069
'../input_files/param_card_full_sm.dat')
1057
1070
full_sm.read_param_card(param_path)
1072
# Stage 1: Find stable particles with
1073
# nonzero neutrino masses, quark masses
1074
# Turned on light quark and neutrino masses
1075
neutrinos = [12, 14, 16]
1076
lightquarks1 = [1, 3]
1077
for npid in neutrinos:
1078
full_sm.get_particle(npid)['mass'] = '1E-6'
1079
full_sm.get_particle(-npid)['mass'] = '1E-6'
1080
for qpid in lightquarks1:
1081
full_sm.get_particle(qpid)['mass'] = '5'
1082
full_sm.get_particle(2)['mass'] = '1'
1059
# Stage 1: nonzero neutrino masses
1084
# Find stable particles with given spectrum
1060
1085
goal_stable_pid_1 = [2, 11, 12,14,16,21,22]
1061
1086
full_sm.find_stable_particles_advance()
1217
1242
#Setup the vertexlist for my_testmodel and save this model (optional)
1218
1243
import_vertexlist.make_vertexlist(self.my_testmodel)
1245
# Save files to check vertices number
1246
# check input_files/model_name/interaction.py for vertex number
1219
1247
#save_model.save_model(os.path.join(MG5DIR, 'tests/input_files',
1220
#self.my_testmodel['name']), self.my_testmodel)
1248
# self.my_testmodel['name']), self.my_testmodel)
1222
1250
full_vertexlist = import_vertexlist.full_vertexlist
1223
1251
vert_0 = base_objects.Vertex({'id': 0, 'legs': base_objects.LegList([\
1224
1252
base_objects.Leg({'id':25, 'number':1, 'state': False}), \
1225
1253
base_objects.Leg({'id':25, 'number':2})])})
1226
1254
# h > t t~ > b b~ w+ w-
1227
vert_1 = copy.deepcopy(full_vertexlist[(59, 25)])
1256
vert_1 = copy.deepcopy(full_vertexlist[(62, 25)])
1228
1257
vert_1['legs'][0]['number'] = 2
1229
1258
vert_1['legs'][1]['number'] = 3
1230
1259
vert_1['legs'][2]['number'] = 2
1231
vert_2 = copy.deepcopy(full_vertexlist[(50, 6)])
1261
vert_2 = copy.deepcopy(full_vertexlist[(33, 6)])
1232
1262
vert_2['id'] = -vert_2['id']
1233
1263
vert_2['legs'][0]['number'] = 2
1234
1264
vert_2['legs'][0]['id'] = -vert_2['legs'][0]['id']
1236
1266
vert_2['legs'][1]['id'] = -vert_2['legs'][1]['id']
1237
1267
vert_2['legs'][2]['number'] = 2
1238
1268
vert_2['legs'][2]['id'] = -vert_2['legs'][2]['id']
1239
vert_3 = copy.deepcopy(full_vertexlist[(50, 6)])
1270
vert_3 = copy.deepcopy(full_vertexlist[(33, 6)])
1240
1271
vert_3['legs'][0]['number'] = 3
1241
1272
vert_3['legs'][1]['number'] = 5
1242
1273
vert_3['legs'][2]['number'] = 3
1243
vert_4 = copy.deepcopy(full_vertexlist[(63, 24)])
1275
vert_4 = copy.deepcopy(full_vertexlist[(66, 24)])
1244
1276
vert_4['id'] = -vert_4['id']
1245
1277
vert_4['legs'][0]['number'] = 4
1246
1278
vert_4['legs'][0]['id'] = -vert_4['legs'][0]['id']
1248
1280
vert_4['legs'][1]['id'] = -vert_4['legs'][1]['id']
1249
1281
vert_4['legs'][2]['number'] = 4
1250
1282
vert_4['legs'][2]['id'] = -vert_4['legs'][2]['id']
1251
vert_5 = copy.deepcopy(full_vertexlist[(63, 24)])
1284
vert_5 = copy.deepcopy(full_vertexlist[(66, 24)])
1252
1285
vert_5['legs'][0]['number'] = 5
1253
1286
vert_5['legs'][1]['number'] = 7
1254
1287
vert_5['legs'][2]['number'] = 5
1553
1586
# h > z (z > e e~)
1554
1587
vert_0 = self.h_tt_bbmmvv.get('vertices')[-1]
1555
1588
vert_1 = import_vertexlist.full_vertexlist[(13, 25)]
1556
vert_2 = import_vertexlist.full_vertexlist[(60, 23)]
1589
vert_2 = import_vertexlist.full_vertexlist[(40, 23)]
1557
1590
#print vert_1, vert_2
1558
1591
channel_a = decay_objects.Channel({'vertices': base_objects.VertexList(\
1576
1609
# Create two equivalent channels
1577
1610
# h > w+ w- > e+ ve~ e- ve
1578
1611
vert_3 = import_vertexlist.full_vertexlist[(7, 25)]
1579
vert_4 = import_vertexlist.full_vertexlist[(63, 24)]
1612
vert_4 = import_vertexlist.full_vertexlist[(66, 24)]
1580
1613
channel_c = decay_objects.Channel({'vertices': base_objects.VertexList(\
1582
1615
channel_d = decay_objects.Channel({'vertices': base_objects.VertexList(\
1593
1626
self.my_testmodel)
1594
1627
channel_d = higgs.connect_channel_vertex(channel_d, 2, vert_4,
1595
1628
self.my_testmodel)
1596
print channel_c.nice_string(), '\n', channel_d.nice_string()
1629
#print channel_c.nice_string(), '\n', channel_d.nice_string()
1597
1630
channel_c.calculate_orders(self.my_testmodel)
1598
1631
channel_d.calculate_orders(self.my_testmodel)
1607
1640
higgs.find_channels(3, self.my_testmodel)
1608
1641
higgs.find_channels_nextlevel(self.my_testmodel)
1609
1642
result1 = higgs.get_channels(3, True)
1610
print result1.nice_string()
1643
#print result1.nice_string()
1611
1644
# Test if the equivalent channels appear only once.
1613
1646
# For both has_idpart and not has_idpart channels
1625
1658
higgs.find_channels(3, self.my_testmodel)
1626
1659
higgs.find_channels_nextlevel(self.my_testmodel)
1627
1660
result2 = higgs.get_channels(4, True)
1628
print result2.nice_string()
1661
#print result2.nice_string()
1629
1662
self.assertEqual((result2.count(channel_c)+ result2.count(channel_d)),1)
1631
1664
""" Test on MSSM, to get a feeling on the execution time. """
1657
1690
full_sm_base = import_ufo.import_model('sm')
1658
1691
full_sm = decay_objects.DecayModel(full_sm_base, True)
1692
# save interaction/particle content into input_files/sm
1693
#save_model.save_model(os.path.join(MG5DIR, 'tests/input_files',
1694
# full_sm['name']), full_sm)
1660
1696
higgs = self.my_testmodel.get_particle(25)
1661
1697
# Set the higgs mass < Z-boson mass so that identicle particles appear
1668
1704
# Test of the symmetric factor
1669
print higgs.get_channels(3, False).nice_string()
1705
#print higgs.get_channels(3, False).nice_string()
1670
1706
#print higgs.get_channels(4, True).nice_string()
1671
1707
h_zz_llll_1 = higgs.get_channels(4, True)[5]
1672
1708
h_zz_llll_2 = higgs.get_channels(4, True)[6]
1673
1709
# higgs > w (w > l vl)
1674
1710
channel_1 = higgs.get_channels(3, True)[0]
1675
print 'h_zz_llll_symm:', h_zz_llll_1.nice_string(), '\n',\
1676
'h_zz_llll_no_symm:', h_zz_llll_2.nice_string(), '\n',\
1677
'channel_1:', channel_1.nice_string()
1711
#print 'h_zz_llll_symm:', h_zz_llll_1.nice_string(), '\n',\
1712
# 'h_zz_llll_no_symm:', h_zz_llll_2.nice_string(), '\n',\
1713
# 'channel_1:', channel_1.nice_string()
1679
1715
h_zz_llll_1.get_apx_psarea(self.my_testmodel)
1680
1716
h_zz_llll_2.get_apx_psarea(self.my_testmodel)
1723
1759
# Test of matrix element square calculation
1725
1761
E_mean = (MH_new-MW)/3
1726
1763
#print channel_1.get_apx_fnrule(-24, 2*E_mean, False, full_sm)
1727
#print abs(decay_objects.GC_11) **2
1764
#print self.my_testmodel.get_interaction(7), self.my_testmodel.get_interaction(66)
1728
1765
#print channel_1.get_apx_fnrule(24, E_mean+MW, True, self.my_testmodel)
1729
#print abs(decay_objects.GC_22) **2
1730
# couplings: h > w w, w > e ve
1767
# couplings: h > w w (GC_32); w > e ve (GC_17)
1768
#print abs(decay_objects.GC_17) **2
1769
#print abs(decay_objects.GC_32) **2
1731
1770
#print self.my_testmodel.get_interaction(7), self.my_testmodel.get_interaction(63)
1732
1771
self.assertAlmostEqual(
1733
1772
channel_1.get_apx_matrixelement_sq(self.my_testmodel),
1734
1773
((E_mean**2*4*(1-2*(2*E_mean/MW)**2+(2*E_mean/MW)**4)\
1735
1774
/(((2*E_mean)**2-MW **2)**2))*\
1736
1775
(1+(1/MW*(E_mean+MW))**2)*\
1737
abs(decay_objects.GC_64) **2*\
1738
abs(decay_objects.GC_33) **2)
1776
abs(decay_objects.GC_17) **2*\
1777
abs(decay_objects.GC_32) **2)
1741
1780
tau = full_sm.get_particle(15)
1742
1781
tau.find_channels(3, full_sm)
1743
1782
tau_qdecay = tau.get_channels(3, True)[0]
1751
1790
((MTAU/3) **3 *8*3*MTAU*
1752
1791
(1-2*(2*MTAU/(3*MW))**2 +(2*MTAU/(3*MW))**4)/ \
1753
1792
((2*MTAU/3) ** 2 - MW **2) **2 *\
1754
abs(decay_objects.GC_33) **4))
1793
abs(decay_objects.GC_17) **4))
1756
1795
# Test for off-shell estimation of matrix element
1757
1796
h_ww_wtb = higgs.get_channels(3, False)[0]
1758
1797
E_est_mean = MH_new/4
1759
#h_ww_wtb.get_apx_decaywidth_nextlevel(full_sm)
1798
# h_ww_wtb.get_apx_decaywidth_nextlevel(full_sm)
1760
1799
#print h_ww_wtb.nice_string()
1761
1800
# coupl: as the onshell case
1762
1801
self.assertAlmostEqual(h_ww_wtb.get_apx_matrixelement_sq(full_sm),
1772
1811
h_ww_wtb.get_apx_fnrule(25, MH_new,
1773
1812
True, full_sm)*\
1774
abs(decay_objects.GC_64) **2 *\
1775
abs(decay_objects.GC_33) **2)
1813
abs(decay_objects.GC_32) **2 *\
1814
abs(decay_objects.GC_17) **2)
1777
1816
# Test of phase space area calculation
1778
1817
#print 'Tau decay ps_area', tau_qdecay.get_apx_psarea(full_sm)
1933
1972
# Write decay summary and the decay table
1934
1973
if test_param_card:
1935
"""model.write_summary_decay_table(model_name\
1974
model.write_summary_decay_table(model_name\
1936
1975
+ '_decay_summary_'\
1937
1976
+ test_param_card_suffix \
1939
1978
model.write_decay_table(MG5_param_path, 'cmp',
1941
1980
+ '_decaytable_'\
1945
1984
# file name 1: default name
1946
#model.write_summary_decay_table()
1985
model.write_summary_decay_table()
1947
1986
model.write_decay_table(MG5_param_path, 'cmp')
1978
2017
self.assertTrue(isinstance(amp['exa_decaywidth'], bool) or \
1979
2018
isinstance(amp['exa_decaywidth'], float))
1981
particle = model.get_particle(1000035)
1982
particleb = model.get_particle(2000001)
2020
#particle = model.get_particle(1000035)
2021
#particleb = model.get_particle(2000001)
1983
2022
#channels = particleb.get_channels(3, False)
1984
2023
#channels.sort(decay_objects.channelcmp_width)
1985
2024
#print [c.nice_string() for c in channels[:100]]
1986
a = particle.get_amplitudes(3)[2]
1987
print a.nice_string()#, a['diagrams']
1988
print model.get_interaction(166)
1989
print decay_objects.GC_415, decay_objects.GC_681
2025
#a = particle.get_amplitudes(3)
2027
#print a.nice_string()#, a['diagrams']
2028
#print model.get_interaction(166)
2029
#print decay_objects.GC_415, decay_objects.GC_681
1992
2032
#print particle.get_amplitude([-11, 2000011])['diagrams'].nice_string()
2177
2217
# Set channels and amplitude
2178
2218
self.my_testmodel.find_all_channels(4)
2179
print higgs.get_channels(4, True).nice_string()
2219
#print higgs.get_channels(4, True).nice_string()
2180
2220
h_mmvv_1 = higgs.get_channels(4, True)[0]
2181
2221
h_mmvv_2 = higgs.get_channels(4, True)[9]
2182
2222
amplt_h_mmvv = decay_objects.DecayAmplitude(h_mmvv_1,
2586
2626
return cmp(x[1],y[1])
2587
2627
keylist = sorted(ab_model['abstract_interactions_dict'].keys(), lorentzcmp)
2588
2628
#print normal_sm.get_particle(1000021)['self_antipart']
2589
print "Interaction type (%d):" % len(keylist)
2629
#print "Interaction type (%d):" % len(keylist)
2593
2633
def check_keys(keylist):
3030
3070
ab_amp['process']['model'] = ab_model
3031
3071
ab_amp['ab2real_dicts'][-1]['dia_sn_dict'] = {0:0, 1:1}
3032
3072
ab_amp.generate_variables_dicts(h_zz_eevv)
3033
3074
# Test for initial particle
3034
print ab_amp.nice_string(), h_zz_eevv.nice_string()
3075
#print ab_amp.nice_string(), h_zz_eevv.nice_string()
3035
3076
#print ab_amp['ab2real_dicts'][-1]['mass_dict']
3036
3077
#print ab_amp['ab2real_dicts'][-1]['coup_dict']
3037
#print ab_model['interaction_coupling_dict'][63], self.my_testmodel.get_interaction(63), ab_model['abstract_interactions_dict'][ab_model['interaction_type_dict'][63]]
3078
#print ab_model['interaction_coupling_dict'][54], self.my_testmodel.get_interaction(54), ab_model['abstract_interactions_dict'][ab_model['interaction_type_dict'][54]]
3038
3080
self.assertEqual(ab_amp['ab2real_dicts'][-1]['mass_dict'],
3039
3081
{'MSS1_00':'MH',
3044
3086
'MSV1_00':'MW', 'MSV1_01':'MW',
3045
3087
'MSV1_02':'MZ', 'MSV1_03':'MZ'})
3046
3088
self.assertEqual(ab_amp['ab2real_dicts'][-1]['coup_dict'],
3047
{'G0010000':'GC_64',
3054
'G0060003':'GC_34', 'G0060103':'GC_48'
3101
# : z > e+ e- (lorentz=0)
3103
# : z > e+ e- (lorentz=1)
3056
3106
#----------------------
3057
3107
# Test generate_ab_amplitude
3084
3134
model_type = 'sm'
3085
3135
if model_type == 'full_sm':
3086
normal_sm_base = import_ufo.import_full_model(\
3087
os.path.join(MG5DIR,
3088
'tests', 'input_files',
3090
normal_sm = decay_objects.DecayModel(normal_sm_base, True)
3136
sm_path = import_ufo.find_ufo_path('sm')
3137
full_sm_base = import_ufo.import_full_model(sm_path)
3138
full_sm = decay_objects.DecayModel(full_sm_base, True)
3091
3139
param_path = os.path.join(_file_path,
3092
3140
'../input_files/param_card_full_sm.dat')
3141
full_sm.read_param_card(param_path)
3095
3144
normal_sm_base = import_ufo.import_model(\