9 #include "Pythia8/HelicityBasics.h"
22 Wave4 operator*(complex s,
const Wave4& w) {
24 return Wave4( s * w.val[0], s * w.val[1], s * w.val[2], s * w.val[3]);
32 Wave4 operator*(
double s,
const Wave4& w) {
34 return Wave4( s * w.val[0], s * w.val[1], s * w.val[2], s * w.val[3]);
56 Wave4 epsilon(Wave4 w1, Wave4 w2, Wave4 w3) {
59 w4(0) = -(w1(1) * w2(2) * w3(3)) + (w1(1) * w2(3) * w3(2))
60 + (w1(2) * w2(1) * w3(3)) - (w1(2) * w2(3) * w3(1))
61 - (w1(3) * w2(1) * w3(2)) + (w1(3) * w2(2) * w3(1));
62 w4(1) = -(w1(0) * w2(2) * w3(3)) + (w1(0) * w2(3) * w3(2))
63 + (w1(2) * w2(0) * w3(3)) - (w1(2) * w2(3) * w3(0))
64 - (w1(3) * w2(0) * w3(2)) + (w1(3) * w2(2) * w3(0));
65 w4(2) = (w1(0) * w2(1) * w3(3)) - (w1(0) * w2(3) * w3(1))
66 - (w1(1) * w2(0) * w3(3)) + (w1(1) * w2(3) * w3(0))
67 + (w1(3) * w2(0) * w3(1)) - (w1(3) * w2(1) * w3(0));
68 w4(3) = -(w1(0) * w2(1) * w3(2)) + (w1(0) * w2(2) * w3(1))
69 + (w1(1) * w2(0) * w3(2)) - (w1(1) * w2(2) * w3(0))
70 - (w1(2) * w2(0) * w3(1)) + (w1(2) * w2(1) * w3(0));
81 return real(w(0)) * real(w(0)) - real(w(1)) * real(w(1))
82 - real(w(2)) * real(w(2)) - real(w(3)) * real(w(3));
86 double m2(Wave4 w1, Wave4 w2) {
88 return real(w1(0)) * real(w2(0)) - real(w1(1)) * real(w2(1))
89 - real(w1(2)) * real(w2(2)) - real(w1(3)) * real(w2(3));
97 ostream& operator<< (ostream& os, Wave4 w) {
99 os << left << setprecision(2);
100 for (
int i = 0; i < 4; i++) os << setw(20) << w.val[i];
113 GammaMatrix::GammaMatrix(
int mu) : index() {
115 COMPLEXZERO = complex( 0., 0.);
118 val[0] = 1.; val[1] = 1.; val[2] = 1.; val[3] = 1.;
119 index[0] = 2; index[1] = 3; index[2] = 0; index[3] = 1;
121 }
else if (mu == 1) {
122 val[0] = -1.; val[1] = -1.; val[2] = 1.; val[3] = 1.;
123 index[0] = 3; index[1] = 2; index[2] = 1; index[3] = 0;
125 }
else if (mu == 2) {
126 val[0] = complex(0.,-1.); val[1] = complex(0.,1.);
127 val[2] = complex(0.,1.); val[3] = complex(0.,-1.);
128 index[0] = 3; index[1] = 2; index[2] = 1; index[3] = 0;
130 }
else if (mu == 3) {
131 val[0] = -1.; val[1] = 1.; val[2] = 1.; val[3] = -1.;
132 index[0] = 2; index[1] = 3; index[2] = 0; index[3] = 1;
134 }
else if (mu == 4) {
135 val[0] = 1.; val[1] = -1.; val[2] = -1.; val[3] = -1.;
136 index[0] = 0; index[1] = 1; index[2] = 2; index[3] = 3;
138 }
else if (mu == 5) {
139 val[0] = -1.; val[1] = -1.; val[2] = 1.; val[3] = 1.;
140 index[0] = 0; index[1] = 1; index[2] = 2; index[3] = 3;
149 Wave4 operator*(Wave4 w, GammaMatrix g) {
151 complex w0 = w(g.index[0]);
152 complex w1 = w(g.index[1]);
153 complex w2 = w(g.index[2]);
154 complex w3 = w(g.index[3]);
155 w(0) = w0 * g.val[0];
156 w(1) = w1 * g.val[1];
157 w(2) = w2 * g.val[2];
158 w(3) = w3 * g.val[3];
167 GammaMatrix operator*(complex s, GammaMatrix g) {
169 g.val[0] = s * g.val[0];
170 g.val[1] = s*g.val[1];
171 g.val[2] = s * g.val[2];
172 g.val[3] = s*g.val[3];
181 GammaMatrix operator-(complex s, GammaMatrix g) {
183 g.val[0] = s - g.val[0];
184 g.val[1] = s - g.val[1];
185 g.val[2] = s - g.val[2];
186 g.val[3] = s - g.val[3];
195 GammaMatrix operator+(complex s, GammaMatrix g) {
197 g.val[0] = s + g.val[0];
198 g.val[1] = s + g.val[1];
199 g.val[2] = s + g.val[2];
200 g.val[3] = s + g.val[3];
209 ostream& operator<< (ostream& os, GammaMatrix g) {
211 os << left << setprecision(2);
212 for (
int i = 0; i < 4; i++) {
213 for (
int j = 0; j < 4; j++) os << setw(20) << g(i,j);
235 Wave4 HelicityParticle::wave(
int h) {
241 if (spinType() == 2) {
245 double n = sqrtpos(2*P*(P+pz()));
246 bool aligned = P + pz() == 0;
249 vector< vector<complex> > xi(2, vector<complex>(2));
251 xi[0][0] = aligned ? -1 : complex(-px(),py())/n;
252 xi[0][1] = aligned ? 0 : (P+pz())/n;
254 xi[1][0] = aligned ? 0 : (P+pz())/n;
255 xi[1][1] = aligned ? 1 : complex(px(),py())/n;
258 vector<double> omega(2);
259 omega[0] = sqrtpos(e()-P);
260 omega[1] = sqrtpos(e()+P);
261 vector<double> hsign(2,1);
265 if (this->
id() > 0) {
266 w(0) = omega[!h] * xi[h][0];
267 w(1) = omega[!h] * xi[h][1];
268 w(2) = omega[h] * xi[h][0];
269 w(3) = omega[h] * xi[h][1];
273 w(0) = hsign[!h] * omega[h] * xi[!h][0];
274 w(1) = hsign[!h] * omega[h] * xi[!h][1];
275 w(2) = hsign[h] * omega[!h] * xi[!h][0];
276 w(3) = hsign[h] * omega[!h] * xi[!h][1];
280 }
else if (spinType() == 3) {
285 if (h >= 0 && h <= 1) {
286 double hsign = h ? -1 : 1;
289 w(1) = hsign / sqrt(2);
290 w(2) = complex(0, 1/sqrt(2));
292 }
else if (PT == 0) {
294 w(1) = hsign / sqrt(2);
295 w(2) = complex(0, (pz() > 0 ? 1 : -1) / sqrt(2));
296 w(3) = complex(-hsign * PT / P, 0) / sqrt(2);
299 w(1) = complex(hsign * px() * pz() / (P * PT), -py() / PT) / sqrt(2);
300 w(2) = complex(hsign * py() * pz() / (P * PT), px() / PT) / sqrt(2);
301 w(3) = complex(-hsign * PT / P, 0) / sqrt(2);
305 }
else if (h == 2 && spinStates() == 3) {
313 w(1) = px() * e() / (m() * P);
314 w(2) = py() * e() / (m() * P);
315 w(3) = pz() * e() / (m() * P);
336 Wave4 HelicityParticle::waveBar(
int h) {
338 if (spinType() == 2)
return conj(wave(h)) * GammaMatrix(0);
339 else return conj(wave(h));
347 void HelicityParticle::normalize(vector< vector<complex> >& matrix) {
350 for (
unsigned int i = 0; i < matrix.size(); i++) trace += matrix[i][i];
351 for (
unsigned int i = 0; i < matrix.size(); i++) {
352 for (
unsigned int j = 0; j < matrix.size(); j++) {
353 if (trace != complex(0,0)) matrix[i][j] /= trace;
354 else matrix[i][j] = 1 /
static_cast<double>(matrix.size());
364 int HelicityParticle::spinStates() {
367 if (sT == 0)
return 1;
368 else if (sT != 2 && m() == 0)
return sT - 1;