9 #include "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]);
46 double m2(Wave4 w1, Wave4 w2) {
48 return real(w1(0)) * real(w2(0)) - real(w1(1)) * real(w2(1))
49 - real(w1(2)) * real(w2(2)) - real(w1(3)) * real(w2(3));
57 ostream& operator<< (ostream& os, Wave4 w) {
59 os << left << setprecision(2);
60 for (
int i = 0; i < 4; i++) os << setw(20) << w.val[i];
73 GammaMatrix::GammaMatrix(
int mu) {
75 COMPLEXZERO = complex( 0., 0.);
78 val[0] = 1.; val[1] = 1.; val[2] = 1.; val[3] = 1.;
79 index[0] = 2; index[1] = 3; index[2] = 0; index[3] = 1;
82 val[0] = -1.; val[1] = -1.; val[2] = 1.; val[3] = 1.;
83 index[0] = 3; index[1] = 2; index[2] = 1; index[3] = 0;
86 val[0] = complex(0.,-1.); val[1] = complex(0.,1.);
87 val[2] = complex(0.,1.); val[3] = complex(0.,-1.);
88 index[0] = 3; index[1] = 2; index[2] = 1; index[3] = 0;
91 val[0] = -1.; val[1] = 1.; val[2] = 1.; val[3] = -1.;
92 index[0] = 2; index[1] = 3; index[2] = 0; index[3] = 1;
95 val[0] = 1.; val[1] = -1.; val[2] = -1.; val[3] = -1.;
96 index[0] = 0; index[1] = 1; index[2] = 2; index[3] = 3;
99 val[0] = -1.; val[1] = -1.; val[2] = 1.; val[3] = 1.;
100 index[0] = 0; index[1] = 1; index[2] = 2; index[3] = 3;
109 Wave4 operator*(Wave4 w, GammaMatrix g) {
111 complex w0 = w(g.index[0]);
112 complex w1 = w(g.index[1]);
113 complex w2 = w(g.index[2]);
114 complex w3 = w(g.index[3]);
115 w(0) = w0 * g.val[0];
116 w(1) = w1 * g.val[1];
117 w(2) = w2 * g.val[2];
118 w(3) = w3 * g.val[3];
127 GammaMatrix operator*(complex s, GammaMatrix g) {
129 g.val[0] = s * g.val[0];
130 g.val[1] = s*g.val[1];
131 g.val[2] = s * g.val[2];
132 g.val[3] = s*g.val[3];
141 GammaMatrix operator-(complex s, GammaMatrix g) {
143 g.val[0] = s - g.val[0];
144 g.val[1] = s - g.val[1];
145 g.val[2] = s - g.val[2];
146 g.val[3] = s - g.val[3];
155 GammaMatrix operator+(complex s, GammaMatrix g) {
157 g.val[0] = s + g.val[0];
158 g.val[1] = s + g.val[1];
159 g.val[2] = s + g.val[2];
160 g.val[3] = s + g.val[3];
169 ostream& operator<< (ostream& os, GammaMatrix g) {
171 os << left << setprecision(2);
172 for (
int i = 0; i < 4; i++) {
173 for (
int j = 0; j < 4; j++) os << setw(20) << g(i,j);
196 const double HelicityParticle::TOLERANCE = 0.000001;
202 Wave4 HelicityParticle::wave(
int h) {
208 if (spinType() == 2) {
212 double n = sqrtpos(2*P*(P+pz()));
213 bool aligned = (abs(P+pz()) < TOLERANCE);
216 vector< vector<complex> > xi(2, vector<complex>(2));
218 xi[0][0] = aligned ? -1 : complex(-px(),py())/n;
219 xi[0][1] = aligned ? 0 : (P+pz())/n;
221 xi[1][0] = aligned ? 0 : (P+pz())/n;
222 xi[1][1] = aligned ? 1 : complex(px(),py())/n;
225 vector<double> omega(2);
226 omega[0] = sqrtpos(e()-P);
227 omega[1] = sqrtpos(e()+P);
228 vector<double> hsign(2,1);
232 if (this->
id() > 0) {
233 w(0) = omega[!h] * xi[h][0];
234 w(1) = omega[!h] * xi[h][1];
235 w(2) = omega[h] * xi[h][0];
236 w(3) = omega[h] * xi[h][1];
240 w(0) = hsign[!h] * omega[h] * xi[!h][0];
241 w(1) = hsign[!h] * omega[h] * xi[!h][1];
242 w(2) = hsign[h] * omega[!h] * xi[!h][0];
243 w(3) = hsign[h] * omega[!h] * xi[!h][1];
247 }
else if (spinType() == 3) {
252 if (h >= 0 && h <= 1) {
253 double hsign = h ? -1 : 1;
254 if (PT > TOLERANCE) {
256 w(1) = complex(hsign * px() * pz() / (P * PT), -py() / PT);
257 w(2) = complex(hsign * py() * pz() / (P * PT), px() / PT);
258 w(3) = complex(-hsign * PT / P, 0);
267 }
else if (h == 2 && m() > TOLERANCE) {
269 w(1) = px() * e() / (m() * P);
270 w(2) = py() * e() / (m() * P);
271 w(3) = pz() * e() / (m() * P);
291 Wave4 HelicityParticle::waveBar(
int h) {
293 if (spinType() == 2)
return conj(wave(h)) * GammaMatrix(0);
294 else return conj(wave(h));
302 void HelicityParticle::normalize(vector< vector<complex> >& matrix) {
305 for (
unsigned int i = 0; i < matrix.size(); i++) trace += matrix[i][i];
306 for (
unsigned int i = 0; i < matrix.size(); i++) {
307 for (
unsigned int j = 0; j < matrix.size(); j++) {
308 if (trace != complex(0,0)) matrix[i][j] /= trace;
309 else matrix[i][j] = 1 /
static_cast<double>(matrix.size());