MINT2
SymmLorentzMatrix.h
Go to the documentation of this file.
1 #ifndef SYMM_LORENTZ_MATRIX_HH
2 #define SYMM_LORENTZ_MATRIX_HH
3 
4 #include "LorentzMatrix.h"
5 #include "TLorentzVector.h"
6 
8  protected:
10  static void makeGmunu();
11 
12  // we'll follow the x, y, z, E convention, i.e. E is 4
13  bool symmetrize(){
14  // clumsy but save
15  X().SetY(Y().X());
16  X().SetZ(Z().X());
17  X().SetT(T().X());
18 
19  Y().SetX(X().Y());
20  Y().SetZ(Z().Y());
21  Y().SetT(T().Y());
22 
23  Z().SetX(X().Z());
24  Z().SetY(Y().Z());
25  Z().SetT(T().Z());
26 
27  T().SetX(X().T());
28  T().SetY(Y().T());
29  T().SetZ(Z().T());
30  return true;
31  }
32  bool makeZero(){
33  X().SetXYZT(0,0,0,0);
34  Y().SetXYZT(0,0,0,0);
35  Z().SetXYZT(0,0,0,0);
36  T().SetXYZT(0,0,0,0);
37  return true;
38  }
39  public:
40  static const SymmLorentzMatrix& gmunu();
42  SymmLorentzMatrix(const TLorentzVector p[4])
43  : LorentzMatrix(p) {};
44 
45  SymmLorentzMatrix(const TLorentzVector p){
46  X().SetX(p.X() * p.X());
47  X().SetY(p.X() * p.Y());
48  X().SetZ(p.X() * p.Z());
49  X().SetT(p.X() * p.T());
50 
51  Y().SetX(p.Y() * p.X());
52  Y().SetY(p.Y() * p.Y());
53  Y().SetZ(p.Y() * p.Z());
54  Y().SetT(p.Y() * p.T());
55 
56  Z().SetX(p.Z() * p.X());
57  Z().SetY(p.Z() * p.Y());
58  Z().SetZ(p.Z() * p.Z());
59  Z().SetT(p.Z() * p.T());
60 
61  T().SetX(p.T() * p.X());
62  T().SetY(p.T() * p.Y());
63  T().SetZ(p.T() * p.Z());
64  T().SetT(p.T() * p.T());
65  }
67  : LorentzMatrix(other){}
68 
70  for(int i=0; i < 4; i++) _v[i] += other._v[i];
71  return *this;
72  }
74  for(int i=0; i < 4; i++) _v[i] -= other._v[i];
75  return *this;
76  }
78  for(int i=0; i < 4; i++) _v[i] *= s;
79  return *this;
80  }
82  for(int i=0; i < 4; i++) _v[i] *= (1./s);
83  return *this;
84  }
85  TLorentzVector Contract(const TLorentzVector& vec){
86  // M^{mu nu} g_{nu alpha} v^{alpha}
87  // M^{mu nu} v_{alpha}
88  return vec.T()*T() - vec.X()*X() - vec.Y()*Y() -vec.Z()*Z();
89  }
91  // One pair of indices gets contracted. Since
92  // both matrices are symmetric, it doesnt matter which.
93  //
94  // O^{mu alpha} g_{alpha beta} M^{beta nu} = R^{mu nu}
95  // O^{mu alpha} M_{beta}^{nu}
96  LorentzMatrix R;
97  R.X() = this->Contract(M.X());
98  R.Y() = this->Contract(M.Y());
99  R.Z() = this->Contract(M.Z());
100  R.T() = this->Contract(M.T()); // signs?
101 
102  return R;
103  }
104  double Contract_2(const SymmLorentzMatrix& M){
105  // Both pairs of indices are contracted.
106  // since the matrices are symmetric, it does
107  // not matter which index from this with which form M.
108  //
109  // O^{mu alpha} g_{alpha beta} M^{beta nu} g_{mu nu}
111  // R^{mu nu} R_{mu nu}
112  double xx = R.X().X();//Dot(R.X());
113  double yy = R.Y().Y();//Dot(R.Y());
114  double zz = R.Z().Z();//Dot(R.Z());
115  double tt = R.T().T();//Dot(R.T());
116 
117  return tt - xx - yy - zz; // signs?
118  }
119 
121  return add(rhs);
122  }
124  return mult(rhs);
125  }
127  return subtract(rhs);
128  }
130  return div(rhs);
131  }
133  for(int i=0; i<4; i++) _v[i] = other._v[i];
134  return *this;
135  }
137  SymmLorentzMatrix returnVal(*this);
138  returnVal += rhs;
139  return returnVal;
140  }
142  SymmLorentzMatrix returnVal(*this);
143  returnVal -= rhs;
144  return returnVal;
145  }
146  SymmLorentzMatrix operator*(double rhs)const{
147  SymmLorentzMatrix returnVal(*this);
148  returnVal *= rhs;
149  return returnVal;
150  }
151  SymmLorentzMatrix operator/(double rhs)const{
152  SymmLorentzMatrix returnVal(*this);
153  returnVal /= rhs;
154  return returnVal;
155  }
156 
157 };
158 
159 SymmLorentzMatrix operator*(double lhs, const SymmLorentzMatrix& rhs);
160 SymmLorentzMatrix operator/(double lhs, const SymmLorentzMatrix& rhs);
161 
162 #endif
163 //
double Contract_2(const SymmLorentzMatrix &M)
SymmLorentzMatrix & operator *=(double rhs)
SymmLorentzMatrix & div(double s)
static SymmLorentzMatrix * __gmunu
SymmLorentzMatrix & operator-=(const SymmLorentzMatrix &rhs)
SymmLorentzMatrix & operator+=(const SymmLorentzMatrix &rhs)
SymmLorentzMatrix operator-(const SymmLorentzMatrix &rhs) const
const TLorentzVector & T() const
Definition: LorentzMatrix.h:31
SymmLorentzMatrix operator *(double lhs, const SymmLorentzMatrix &rhs)
static const double s
SymmLorentzMatrix & operator=(const SymmLorentzMatrix &other)
SymmLorentzMatrix & operator/=(double rhs)
const TLorentzVector & X() const
Definition: LorentzMatrix.h:28
SymmLorentzMatrix(const SymmLorentzMatrix &other)
TLorentzVector _v[4]
Definition: LorentzMatrix.h:9
const TLorentzVector & Y() const
Definition: LorentzMatrix.h:29
static void makeGmunu()
static const SymmLorentzMatrix & gmunu()
SymmLorentzMatrix operator+(const SymmLorentzMatrix &rhs) const
SymmLorentzMatrix & subtract(const SymmLorentzMatrix &other)
LorentzMatrix Contract_1(const SymmLorentzMatrix &M)
SymmLorentzMatrix operator *(double rhs) const
SymmLorentzMatrix operator/(double rhs) const
SymmLorentzMatrix operator/(double lhs, const SymmLorentzMatrix &rhs)
SymmLorentzMatrix(const TLorentzVector p[4])
SymmLorentzMatrix & add(const SymmLorentzMatrix &other)
SymmLorentzMatrix(const TLorentzVector p)
const TLorentzVector & Z() const
Definition: LorentzMatrix.h:30
SymmLorentzMatrix & mult(double s)
TLorentzVector Contract(const TLorentzVector &vec)