MINT2
LorentzMatrix.h
Go to the documentation of this file.
1 #ifndef LORENTZ_MATRIX_HH
2 #define LORENTZ_MATRIX_HH
3 
4 
5 #include "TLorentzVector.h"
6 
8  protected:
9  TLorentzVector _v[4];
10  // we'll follow the x, y, z, E convention, i.e. E is 4
11  bool makeZero(){
12  X().SetXYZT(0,0,0,0);
13  Y().SetXYZT(0,0,0,0);
14  Z().SetXYZT(0,0,0,0);
15  T().SetXYZT(0,0,0,0);
16  return true;
17  }
18  public:
19  const TLorentzVector& v(int i) const{return _v[i];}
20 
22  LorentzMatrix(const TLorentzVector p[4]){
23  for(int i=0; i<4; i++) _v[i] = p[i];
24  }
26  for(int i=0; i<4; i++) _v[i] = other._v[i];
27  }
28  const TLorentzVector& X() const{return _v[0];}
29  const TLorentzVector& Y() const{return _v[1];}
30  const TLorentzVector& Z() const{return _v[2];}
31  const TLorentzVector& T() const{return _v[3];}
32 
33  TLorentzVector& X() {return _v[0];}
34  TLorentzVector& Y() {return _v[1];}
35  TLorentzVector& Z() {return _v[2];}
36  TLorentzVector& T() {return _v[3];}
37 
38  const TLorentzVector& operator[](int i) const{return _v[i];}
39  TLorentzVector& operator[](int i){return _v[i];}
40 
42  for(int i=0; i < 4; i++) _v[i] += other._v[i];
43  return *this;
44  }
46  for(int i=0; i < 4; i++) _v[i] -= other._v[i];
47  return *this;
48  }
49  LorentzMatrix& mult(double s){
50  for(int i=0; i < 4; i++) _v[i] *= s;
51  return *this;
52  }
53  LorentzMatrix& div(double s){
54  for(int i=0; i < 4; i++) _v[i] *= (1./s);
55  return *this;
56  }
57 
59  return add(rhs);
60  }
61  LorentzMatrix& operator*=(double rhs){
62  return mult(rhs);
63  }
65  return subtract(rhs);
66  }
67  LorentzMatrix& operator/=(double rhs){
68  return div(rhs);
69  }
71  for(int i=0; i<4; i++) _v[i] = other._v[i];
72  return *this;
73  }
75  LorentzMatrix returnVal(*this);
76  returnVal += rhs;
77  return returnVal;
78  }
80  LorentzMatrix returnVal(*this);
81  returnVal -= rhs;
82  return returnVal;
83  }
84  LorentzMatrix operator*(double rhs)const{
85  LorentzMatrix returnVal(*this);
86  returnVal *= rhs;
87  return returnVal;
88  }
89  LorentzMatrix operator/(double rhs)const{
90  LorentzMatrix returnVal(*this);
91  returnVal /= rhs;
92  return returnVal;
93  }
94 
95 };
96 #endif
97 //
LorentzMatrix operator/(double rhs) const
Definition: LorentzMatrix.h:89
LorentzMatrix & operator-=(const LorentzMatrix &rhs)
Definition: LorentzMatrix.h:64
const TLorentzVector & T() const
Definition: LorentzMatrix.h:31
static const double s
TLorentzVector & X()
Definition: LorentzMatrix.h:33
LorentzMatrix operator *(double rhs) const
Definition: LorentzMatrix.h:84
LorentzMatrix(const LorentzMatrix &other)
Definition: LorentzMatrix.h:25
const TLorentzVector & X() const
Definition: LorentzMatrix.h:28
TLorentzVector _v[4]
Definition: LorentzMatrix.h:9
LorentzMatrix & operator=(const LorentzMatrix &other)
Definition: LorentzMatrix.h:70
const TLorentzVector & Y() const
Definition: LorentzMatrix.h:29
LorentzMatrix & operator *=(double rhs)
Definition: LorentzMatrix.h:61
LorentzMatrix & operator/=(double rhs)
Definition: LorentzMatrix.h:67
LorentzMatrix operator+(const LorentzMatrix &rhs) const
Definition: LorentzMatrix.h:74
LorentzMatrix & subtract(const LorentzMatrix &other)
Definition: LorentzMatrix.h:45
TLorentzVector & Z()
Definition: LorentzMatrix.h:35
LorentzMatrix & div(double s)
Definition: LorentzMatrix.h:53
LorentzMatrix & add(const LorentzMatrix &other)
Definition: LorentzMatrix.h:41
TLorentzVector & T()
Definition: LorentzMatrix.h:36
const TLorentzVector & v(int i) const
Definition: LorentzMatrix.h:19
TLorentzVector & Y()
Definition: LorentzMatrix.h:34
const TLorentzVector & operator[](int i) const
Definition: LorentzMatrix.h:38
LorentzMatrix operator-(const LorentzMatrix &rhs) const
Definition: LorentzMatrix.h:79
LorentzMatrix(const TLorentzVector p[4])
Definition: LorentzMatrix.h:22
LorentzMatrix & operator+=(const LorentzMatrix &rhs)
Definition: LorentzMatrix.h:58
const TLorentzVector & Z() const
Definition: LorentzMatrix.h:30
LorentzMatrix & mult(double s)
Definition: LorentzMatrix.h:49
TLorentzVector & operator[](int i)
Definition: LorentzMatrix.h:39