Fork me on GitHub

source: svn/trunk/Utilities/CDFCones/interface/LorentzVector.h@ 10

Last change on this file since 10 was 2, checked in by Xavier Rouby, 16 years ago

first commit

File size: 1.0 KB
Line 
1#ifndef _LORENTZ_VECTOR_HH_
2#define _LORENTZ_VECTOR_HH_
3
4#include <cmath>
5
6class LorentzVector
7{
8 public:
9
10 double px,py,pz,E;
11
12 LorentzVector(): px(0), py(0), pz(0), E(0) {}
13 LorentzVector(double p1, double p2, double p3, double p0): px(p1), py(p2), pz(p3), E(p0) {}
14 LorentzVector(const LorentzVector& p): px(p.px), py(p.py), pz(p.pz), E(p.E) {}
15 double p() const {return sqrt(px*px + py*py + pz*pz);}
16 double pt() const {return sqrt(px*px + py*py);}
17 double y() const {return 0.5*log((E + pz)/(E - pz));}
18 double Et() const {return E/p()*pt();}
19 double eta() const {return 0.5*log((p() + pz)/(p() - pz));}
20 double phi() const
21 {
22 double r = atan2(py,px);
23 if(r < 0)
24 r += 2*M_PI;
25 return r;
26 }
27 void add(LorentzVector v)
28 {
29 px += v.px;
30 py += v.py;
31 pz += v.pz;
32 E += v.E;
33 }
34 void subtract(LorentzVector v)
35 {
36 px -= v.px;
37 py -= v.py;
38 pz -= v.pz;
39 E -= v.E;
40 }
41 bool isEqual(LorentzVector v)
42 {
43 return px == v.px && py == v.py && pz == v.pz && E == v.E;
44 }
45};
46
47#endif
Note: See TracBrowser for help on using the repository browser.