ThePEG  1.8.0
LorentzTensor.h
1 // -*- C++ -*-
2 //
3 // LorentzTensor.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 2003-2011 Peter Richardson, Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_LorentzTensor_H
10 #define ThePEG_LorentzTensor_H
11 // This is the declaration of the LorentzTensor class.
12 
13 
14 #include "ThePEG/Config/ThePEG.h"
15 #include "LorentzPolarizationVector.h"
16 
17 namespace ThePEG {
18 namespace Helicity {
19 
20 // compiler magic needs these pre-declarations to make friend templates work
21 template<typename Value> class LorentzTensor;
22 
36 template<typename Value>
38 
39 public:
40 
47  for(unsigned int ix=0;ix<4;++ix)
48  for(unsigned int iy=0;iy<4;++iy)
49  _tensor[ix][iy]=Value();
50  }
51 
55  LorentzTensor(complex<Value> xx, complex<Value> xy,
56  complex<Value> xz, complex<Value> xt,
57  complex<Value> yx, complex<Value> yy,
58  complex<Value> yz, complex<Value> yt,
59  complex<Value> zx, complex<Value> zy,
60  complex<Value> zz, complex<Value> zt,
61  complex<Value> tx, complex<Value> ty,
62  complex<Value> tz, complex<Value> tt){
63  _tensor[0][0]=xx;_tensor[0][1]=xy;_tensor[0][2]=xz;_tensor[0][3]=xt;
64  _tensor[1][0]=yx;_tensor[1][1]=yy;_tensor[1][2]=yz;_tensor[1][3]=yt;
65  _tensor[2][0]=zx;_tensor[2][1]=zy;_tensor[2][2]=zz;_tensor[2][3]=zt;
66  _tensor[3][0]=tx;_tensor[3][1]=ty;_tensor[3][2]=tz;_tensor[3][3]=tt;
67  }
68 
73  const LorentzPolarizationVector & q) {
74  setXX(p.x() * q.x()); setYX(p.y() * q.x());
75  setZX(p.z() * q.x()); setTX(p.t() * q.x());
76  setXY(p.x() * q.y()); setYY(p.y() * q.y());
77  setZY(p.z() * q.y()); setTY(p.t() * q.y());
78  setXZ(p.x() * q.z()); setYZ(p.y() * q.z());
79  setZZ(p.z() * q.z()); setTZ(p.t() * q.z());
80  setXT(p.x() * q.t()); setYT(p.y() * q.t());
81  setZT(p.z() * q.t()); setTT(p.t() * q.t());
82  }
84 
90  complex<Value> xx() const {return _tensor[0][0];}
91 
95  complex<Value> yx() const {return _tensor[1][0];}
99  complex<Value> zx() const {return _tensor[2][0];}
100 
104  complex<Value> tx() const {return _tensor[3][0];}
105 
109  complex<Value> xy() const {return _tensor[0][1];}
110 
114  complex<Value> yy() const {return _tensor[1][1];}
115 
119  complex<Value> zy() const {return _tensor[2][1];}
120 
124  complex<Value> ty() const {return _tensor[3][1];}
125 
129  complex<Value> xz() const {return _tensor[0][2];}
130 
134  complex<Value> yz() const {return _tensor[1][2];}
135 
139  complex<Value> zz() const {return _tensor[2][2];}
140 
144  complex<Value> tz() const {return _tensor[3][2];}
145 
149  complex<Value> xt() const {return _tensor[0][3];}
150 
154  complex<Value> yt() const {return _tensor[1][3];}
155 
159  complex<Value> zt() const {return _tensor[2][3];}
160 
164  complex<Value> tt() const {return _tensor[3][3];}
165 
169  void setXX(complex<Value> a) {_tensor[0][0]=a;}
170 
174  void setYX(complex<Value> a) {_tensor[1][0]=a;}
175 
179  void setZX(complex<Value> a) {_tensor[2][0]=a;}
180 
184  void setTX(complex<Value> a) {_tensor[3][0]=a;}
185 
189  void setXY(complex<Value> a) {_tensor[0][1]=a;}
190 
194  void setYY(complex<Value> a) {_tensor[1][1]=a;}
195 
199  void setZY(complex<Value> a) {_tensor[2][1]=a;}
200 
204  void setTY(complex<Value> a) {_tensor[3][1]=a;}
205 
209  void setXZ(complex<Value> a) {_tensor[0][2]=a;}
210 
214  void setYZ(complex<Value> a) {_tensor[1][2]=a;}
215 
219  void setZZ(complex<Value> a) {_tensor[2][2]=a;}
220 
224  void setTZ(complex<Value> a) {_tensor[3][2]=a;}
225 
229  void setXT(complex<Value> a) {_tensor[0][3]=a;}
230 
234  void setYT(complex<Value> a) {_tensor[1][3]=a;}
235 
239  void setZT(complex<Value> a) {_tensor[2][3]=a;}
240 
244  void setTT(complex<Value> a) {_tensor[3][3]=a;}
245 
249  complex<Value> operator () (int i, int j) const {
250  assert( i>=0 && i<=3 && j>=0 && j<=3);
251  return _tensor[i][j];
252  }
253 
257  complex<Value> & operator () (int i, int j) {
258  assert( i>=0 && i<=3 && j>=0 && j<=3);
259  return _tensor[i][j];
260  }
262 
268  LorentzTensor & boost(double,double,double);
269 
274  return boost(b.x(), b.y(), b.z());
275  }
276 
281  unsigned int ix,iy,ixa,iya;
282  LorentzTensor<Value> output;
283  complex<Value> temp;
284  for(ix=0;ix<4;++ix) {
285  for(iy=0;iy<4;++iy) {
286  temp=complex<Value>();
287  for(ixa=0;ixa<4;++ixa) {
288  for(iya=0;iya<4;++iya)
289  temp+=r(ix,ixa)*r(iy,iya)*(*this)(ixa,iya);
290  }
291  output(ix,iy)=temp;
292  }
293  }
294  *this=output;
295  return *this;
296  }
297 
302  return LorentzTensor<Value>(conj(xx()), conj(xy()), conj(xz()), conj(xt()),
303  conj(yx()), conj(yy()), conj(yz()), conj(yt()),
304  conj(zx()), conj(zy()), conj(zz()), conj(zt()),
305  conj(tx()), conj(ty()), conj(tz()), conj(tt()));
306  }
307 
309 
316  for(int ix=0;ix<4;++ix)
317  for(int iy=0;iy<4;++iy) _tensor[ix][iy]*=a;
318  return *this;
319  }
320 
324  template <typename T, typename U>
325  friend complex<typename BinaryOpTraits<T,U>::MulT>
326  operator*(const LorentzTensor<T> & t, const LorentzTensor<U> & u);
327 
332  return LorentzTensor<Value>(xx()+in.xx(),xy()+in.xy(),xz()+in.xz(),xt()+in.xt(),
333  yx()+in.yx(),yy()+in.yy(),yz()+in.yz(),yt()+in.yt(),
334  zx()+in.zx(),zy()+in.zy(),zz()+in.zz(),zt()+in.zt(),
335  tx()+in.tx(),ty()+in.ty(),tz()+in.tz(),tt()+in.tt());
336  }
337 
342  return LorentzTensor<Value>(xx()-in.xx(),xy()-in.xy(),xz()-in.xz(),xt()-in.xt(),
343  yx()-in.yx(),yy()-in.yy(),yz()-in.yz(),yt()-in.yt(),
344  zx()-in.zx(),zy()-in.zy(),zz()-in.zz(),zt()-in.zt(),
345  tx()-in.tx(),ty()-in.ty(),tz()-in.tz(),tt()-in.tt());
346  }
347 
351  complex<Value> trace() const {
352  return _tensor[3][3]-_tensor[0][0]-_tensor[1][1]-_tensor[2][2];
353  }
355 
365  output.setX(vec.t()*_tensor[3][0]-vec.x()*_tensor[0][0]-
366  vec.y()*_tensor[1][0]-vec.z()*_tensor[2][0]);
367  output.setY(vec.t()*_tensor[3][1]-vec.x()*_tensor[0][1]-
368  vec.y()*_tensor[1][1]-vec.z()*_tensor[2][1]);
369  output.setZ(vec.t()*_tensor[3][2]-vec.x()*_tensor[0][2]-
370  vec.y()*_tensor[1][2]-vec.z()*_tensor[2][2]);
371  output.setT(vec.t()*_tensor[3][3]-vec.x()*_tensor[0][3]-
372  vec.y()*_tensor[1][3]-vec.z()*_tensor[2][3]);
373  return output;
374  }
375 
381  output.setX(vec.t()*_tensor[0][3]-vec.x()*_tensor[0][0]-
382  vec.y()*_tensor[0][1]-vec.z()*_tensor[0][2]);
383  output.setY(vec.t()*_tensor[1][3]-vec.x()*_tensor[1][0]-
384  vec.y()*_tensor[1][1]-vec.z()*_tensor[1][2]);
385  output.setZ(vec.t()*_tensor[2][3]-vec.x()*_tensor[2][0]-
386  vec.y()*_tensor[2][1]-vec.z()*_tensor[2][2]);
387  output.setT(vec.t()*_tensor[3][3]-vec.x()*_tensor[3][0]-
388  vec.y()*_tensor[3][1]-vec.z()*_tensor[3][2]);
389  return output;
390  }
391 
396  preDot (const Lorentz5Momentum & vec) const {
398  output.setX(vec.t()*_tensor[3][0]-vec.x()*_tensor[0][0]-
399  vec.y()*_tensor[1][0]-vec.z()*_tensor[2][0]);
400  output.setY(vec.t()*_tensor[3][1]-vec.x()*_tensor[0][1]-
401  vec.y()*_tensor[1][1]-vec.z()*_tensor[2][1]);
402  output.setZ(vec.t()*_tensor[3][2]-vec.x()*_tensor[0][2]-
403  vec.y()*_tensor[1][2]-vec.z()*_tensor[2][2]);
404  output.setT(vec.t()*_tensor[3][3]-vec.x()*_tensor[0][3]-
405  vec.y()*_tensor[1][3]-vec.z()*_tensor[2][3]);
406  return output;
407  }
408 
413  postDot(const Lorentz5Momentum & vec) const {
415  output.setX(vec.t()*_tensor[0][3]-vec.x()*_tensor[0][0]-
416  vec.y()*_tensor[0][1]-vec.z()*_tensor[0][2]);
417  output.setY(vec.t()*_tensor[1][3]-vec.x()*_tensor[1][0]-
418  vec.y()*_tensor[1][1]-vec.z()*_tensor[1][2]);
419  output.setZ(vec.t()*_tensor[2][3]-vec.x()*_tensor[2][0]-
420  vec.y()*_tensor[2][1]-vec.z()*_tensor[2][2]);
421  output.setT(vec.t()*_tensor[3][3]-vec.x()*_tensor[3][0]-
422  vec.y()*_tensor[3][1]-vec.z()*_tensor[3][2]);
423  return output;
424  }
426 private:
427 
431  complex<Value> _tensor[4][4];
432 
433 };
434 
438 template<typename T, typename U>
440 operator*(complex<U> a, const LorentzTensor<T> & t) {
442  (a*t.xx(), a*t.xy(), a*t.xz(), a*t.xt(),
443  a*t.yx(), a*t.yy(), a*t.yz(), a*t.yt(),
444  a*t.zx(), a*t.zy(), a*t.zz(), a*t.zt(),
445  a*t.tx(), a*t.ty(), a*t.tz(), a*t.tt());
446 }
447 
451 template<typename T, typename U>
454  const LorentzTensor<T> & inten) {
456  outvec.setX(invec.t()*inten(3,0)-invec.x()*inten(0,0)
457  -invec.y()*inten(1,0)-invec.z()*inten(2,0));
458  outvec.setY(invec.t()*inten(3,1)-invec.x()*inten(0,1)
459  -invec.y()*inten(1,1)-invec.z()*inten(2,1));
460  outvec.setZ(invec.t()*inten(3,2)-invec.x()*inten(0,2)
461  -invec.y()*inten(1,2)-invec.z()*inten(2,2));
462  outvec.setT(invec.t()*inten(3,3)-invec.x()*inten(0,3)
463  -invec.y()*inten(1,3)-invec.z()*inten(2,3));
464  return outvec;
465 }
466 
470 template<typename T, typename U>
472 operator*(const LorentzTensor<T> & inten, const LorentzVector<U> & invec){
474  outvec.setX(invec.t()*inten(0,3)-invec.x()*inten(0,0)
475  -invec.y()*inten(0,1)-invec.z()*inten(0,2));
476  outvec.setY(invec.t()*inten(1,3)-invec.x()*inten(1,0)
477  -invec.y()*inten(1,1)-invec.z()*inten(1,2));
478  outvec.setZ(invec.t()*inten(2,3)-invec.x()*inten(2,0)
479  -invec.y()*inten(2,1)-invec.z()*inten(2,2));
480  outvec.setT(invec.t()*inten(3,3)-invec.x()*inten(3,0)
481  -invec.y()*inten(3,1)-invec.z()*inten(3,2));
482  return outvec;
483 }
484 
488 template <typename T, typename U>
489 inline complex<typename BinaryOpTraits<T,U>::MulT>
491  typedef complex<typename BinaryOpTraits<T,U>::MulT> RetT;
492  RetT output=RetT(),temp;
493  for(unsigned int ix=0;ix<4;++ix) {
494  temp = t._tensor[ix][3]*u._tensor[ix][3];
495  for(unsigned int iy=0;iy<3;++iy) {
496  temp+= t._tensor[ix][iy]*u._tensor[ix][iy];
497  }
498  if(ix<3) output-=temp;
499  else output+=temp;
500  }
501  return output;
502 }
503 
504 }
505 }
506 
507 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
508 #include "LorentzTensor.tcc"
509 #endif
510 
511 #endif