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) {
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);
236 const double HelicityParticle::TOLERANCE = 0.000001;
242 Wave4 HelicityParticle::wave(
int h) {
248 if (spinType() == 2) {
252 double n = sqrtpos(2*P*(P+pz()));
253 bool aligned = (abs(P+pz()) < TOLERANCE);
256 vector< vector<complex> > xi(2, vector<complex>(2));
258 xi[0][0] = aligned ? -1 : complex(-px(),py())/n;
259 xi[0][1] = aligned ? 0 : (P+pz())/n;
261 xi[1][0] = aligned ? 0 : (P+pz())/n;
262 xi[1][1] = aligned ? 1 : complex(px(),py())/n;
265 vector<double> omega(2);
266 omega[0] = sqrtpos(e()-P);
267 omega[1] = sqrtpos(e()+P);
268 vector<double> hsign(2,1);
272 if (this->
id() > 0) {
273 w(0) = omega[!h] * xi[h][0];
274 w(1) = omega[!h] * xi[h][1];
275 w(2) = omega[h] * xi[h][0];
276 w(3) = omega[h] * xi[h][1];
280 w(0) = hsign[!h] * omega[h] * xi[!h][0];
281 w(1) = hsign[!h] * omega[h] * xi[!h][1];
282 w(2) = hsign[h] * omega[!h] * xi[!h][0];
283 w(3) = hsign[h] * omega[!h] * xi[!h][1];
287 }
else if (spinType() == 3) {
292 if (h >= 0 && h <= 1) {
293 double hsign = h ? -1 : 1;
294 if (PT > TOLERANCE) {
296 w(1) = complex(hsign * px() * pz() / (P * PT), -py() / PT);
297 w(2) = complex(hsign * py() * pz() / (P * PT), px() / PT);
298 w(3) = complex(-hsign * PT / P, 0);
307 }
else if (h == 2 && m() > TOLERANCE) {
309 w(1) = px() * e() / (m() * P);
310 w(2) = py() * e() / (m() * P);
311 w(3) = pz() * e() / (m() * P);
331 Wave4 HelicityParticle::waveBar(
int h) {
333 if (spinType() == 2)
return conj(wave(h)) * GammaMatrix(0);
334 else return conj(wave(h));
342 void HelicityParticle::normalize(vector< vector<complex> >& matrix) {
345 for (
unsigned int i = 0; i < matrix.size(); i++) trace += matrix[i][i];
346 for (
unsigned int i = 0; i < matrix.size(); i++) {
347 for (
unsigned int j = 0; j < matrix.size(); j++) {
348 if (trace != complex(0,0)) matrix[i][j] /= trace;
349 else matrix[i][j] = 1 /
static_cast<double>(matrix.size());
359 int HelicityParticle::spinStates() {
362 if (sT == 0)
return 1;
363 else if (sT != 2 && m() < TOLERANCE)
return sT - 1;