Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DLorentzVector.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DLorentzVector.h
4 //
5 // This header file is a replacement of a subset of TLorentzVector intended to
6 // be consistent with the SIMDized version DVector3.
7 //
8 
9 #ifndef _DLorentzVector_
10 #define _DLorentzVector_
11 
12 #ifndef USE_SSE2
13 
14 #include <TLorentzVector.h>
15 typedef TLorentzVector DLorentzVector;
16 
17 #else
18 
19 #include "DVector3.h"
20 #include <math.h>
21 #include <emmintrin.h>
22 #include <iostream>
23 using namespace std;
24 
25 class DLorentzVector{
26  public:
28  mP.SetXYZ(0.,0.,0.);
29  mE=0.;
30  };
31  DLorentzVector(const double x,const double y,const double z,const double t){
32  mP.SetXYZ(x,y,z);
33  mE=t;
34  };
35  DLorentzVector(const DVector3 &v, const double t){
36  mP=v;
37  mE=t;
38  };
39  ~DLorentzVector(){};
40  void SetXYZT(const double x,const double y,const double z,const double t){
41  mP.SetXYZ(x,y,z);
42  mE=t;
43  }
44  // Set the 3-momentum or position part of the 4-vector
45  void SetVect(const DVector3 &p){
46  mP=p;
47  }
48  // Set the time or energy component
49  void SetT(const double t){ mE=t;};
50  // Set position components
51  void SetX(const double x){mP.SetX(x);};
52  void SetY(const double y){mP.SetY(y);};
53  void SetZ(const double z){mP.SetZ(z);};
54 
55  // Routines to get position and time
56  double X() const {return mP.x();};
57  double Y() const {return mP.y();};
58  double Z() const {return mP.z();};
59  double T() const {return mE;};
60 
61  // Routine to get full 3-vector;
62  DVector3 Vect() const {return mP;};
63 
64  // Routines to get momentum and energy
65  double Px() const {return mP.x();};
66  double Py() const {return mP.y();};
67  double Pz() const {return mP.z();};
68  double Pt() const {return mP.Perp();};
69  double P() const {return mP.Mag();};
70  double E() const {return mE;};
71  double Energy() const {return mE;};
72 
73  // Spherical coordinates of spatial component
74  double Rho() const { return mP.Mag();};
75 
76  // Angles
77  double Theta() const {return mP.Theta();};
78  double Phi() const {return mP.Phi();};
79 
80  // Kinematical quantities
81  double Beta() const { return P()/E();};
82  double Mag2() const {return mE*mE-mP.Mag2();};
83  double M() const{
84  double mm = Mag2();
85  return mm < 0.0 ? -sqrt(-mm) : sqrt(mm);
86  }
87  double M2() const {return Mag2();};
88  double Mag() const {return M();};
89 
90  // Addition and subtraction
91  DLorentzVector &operator+=(const DLorentzVector &v1){
92  mP+=v1.Vect();
93  mE+=v1.E();
94  return *this;
95  }
96  DLorentzVector &operator-=(const DLorentzVector &v1){
97  mP-=v1.Vect();
98  mE-=v1.E();
99  return *this;
100  }
101 
102 
103  void Print() const{
104  cout << "DLorentzVector (x,y,z,t)=(" << X() << "," << Y() << "," << Z()
105  << "," << T() << ")" << endl;
106 
107  };
108 
109  private:
110  DVector3 mP; // momentum or position vector
111  double mE; // Energy or time component
112 };
113 
114 // Addition
115 inline DLorentzVector operator+(const DLorentzVector &v1,const DLorentzVector &v2){
116  return DLorentzVector(v1.Vect()+v2.Vect(),v1.E()+v2.E());
117 }
118 //Subtraction
119 inline DLorentzVector operator-(const DLorentzVector &v1,const DLorentzVector &v2){
120  return DLorentzVector(v1.Vect()-v2.Vect(),v1.E()-v2.E());
121 }
122 
123 #endif // USE_SSE2
124 
125 #endif // _DLorentzVector_
126 
TVector3 DVector3
Definition: DVector3.h:14
DVector2S operator+(const DVector2S &vec1, const DVector2S &vec2)
Definition: DVector2S.h:54
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
locHist_ADCmulti Print()
#define y
TLorentzVector DLorentzVector
#define X(str)
Definition: hddm-c.cpp:83
double sqrt(double)
DVector2S operator-(const DVector2S &vec1, const DVector2S &vec2)
Definition: DVector2S.h:59