1
2
3
4
5
6
7
8
9
10
11
12
13 from aloha.aloha_object import *
14 import cmath
15
18
19
20
21
23 """Check that the fermion flow follows the UFO convention
24 1) Only one flow is defined and is 1 -> 2, 3 -> 4, ...
25 2) that 1/3/... are on the left side of any Gamma matrices
26 """
27
28 assert nb_fermion != 0 and (nb_fermion % 2) == 0
29
30
31 expr = eval(expression)
32 expr = expr.simplify()
33
34 if expr.vartype != 1:
35 expr = [expr]
36
37 for term in expr:
38 if term.vartype == 0:
39 if not term.spin_ind in [[1,2], [2,1]]:
40 raise WrongFermionFlow, 'Fermion should be the first particles of any interactions'
41 if isinstance(term, (Gamma, Gamma5, Sigma)):
42 if not term.spin_ind == [2,1]:
43 raise WrongFermionFlow, 'Not coherent Incoming/outcoming fermion flow'
44
45 elif term.vartype == 2:
46 link, rlink = {}, {}
47 for obj in term:
48 if not obj.spin_ind:
49 continue
50 ind1, ind2 = obj.spin_ind
51 if isinstance(obj, (Gamma, Sigma)):
52 if (ind1 in range(1, nb_fermion+1) and ind1 % 2 == 1) or \
53 (ind2 in range(2, nb_fermion+1) and ind2 % 2 == 0 ):
54 raise WrongFermionFlow, 'Not coherent Incoming/outcoming fermion flow'
55 if ind1 not in link.keys():
56 link[ind1] = ind2
57 else:
58 rlink[ind1] = ind2
59 if ind2 not in link.keys():
60 link[ind2] = ind1
61 else:
62 rlink[ind2] = ind1
63 for i in range(1, nb_fermion,2):
64 old = []
65 pos = i
66 while 1:
67 old.append(pos)
68 if pos in link.keys() and link[pos] not in old:
69 pos = link[pos]
70 elif pos in rlink.keys() and rlink[pos] not in old:
71 pos = rlink[pos]
72 elif pos != i+1:
73 raise WrongFermionFlow, 'Not coherent Incoming/outcoming fermion flow'
74 elif pos == i+1:
75 break
76
78 """ return (UFO name, tag , offshell) from a given name """
79
80 output =[]
81 for name in names:
82 data = name.split('_')
83 if len(data) == 2:
84 main, offshell = data
85 multiple = []
86 else:
87 main, multiple, offshell = data[0], data[1:-1],data[-1]
88
89
90 allow_tag = ['C1','C2','C3','C4','C5','C6','C7']
91 tags = []
92 len_tag = -1
93 while len(tags) != len_tag:
94 len_tag = len(tags)
95 for tag in allow_tag:
96 if main.endswith(tag):
97 main = main[:-len(tag)]
98 tags.append(int(tag[1:]))
99 break
100
101
102 lorentz = [main]
103 if multiple:
104 base = main
105 while base[-1].isdigit():
106 base = base[:-1]
107 for nb in multiple:
108 lorentz.append('%s%s' % (base, nb))
109
110
111 output.append((tuple(lorentz), tuple(tags), int(offshell)))
112 return output
113