1 #ifndef __PARTICLE_DEF__
2 #define __PARTICLE_DEF__
14 const double ELECTRON_MASS = 0.0005111;
15 const double MUON_MASS = 0.105659;
16 const double TAU_MASS = 1.777;
24 Particle():_px(0),_py(0),_pz(0),_e(0),_pdgid(0) {}
25 Particle(
double px,
double py,
double pz,
double e,
int id):_px(px),_py(py),_pz(pz),_e(e),_pdgid(
id) {}
31 double px()
const {
return _px; }
32 double py()
const {
return _py; }
33 double pz()
const {
return _pz; }
34 double e ()
const {
return _e; }
35 int pdgid()
const {
return _pdgid; }
38 double recalculated_mass()
const
40 double p2 = _px*_px + _py*_py + _pz*_pz;
44 if ( m2 < 0.0 )
return -sqrt( -m2 );
49 void setPx(
double px) { _px = px; }
50 void setPy(
double py) { _py = py; }
51 void setPz(
double pz) { _pz = pz; }
52 void setE (
double e ) { _e = e; }
55 if(_pdgid) printf(
"%4d: %15.8e %15.8e %15.8e %15.8e | %15.8e\n",
56 pdgid(),px(), py(), pz(), e(), recalculated_mass());
57 else printf(
" SUM: %15.8e %15.8e %15.8e %15.8e | %15.8e\n",
58 px(), py(), pz(), e(), recalculated_mass());
66 double getAngleTheta();
67 void rotateXZ(
double theta);
68 void rotateXY(
double theta);
69 void boostAlongZ(
double pz,
double e);
71 void boostFromRestFrame(
Particle &p);
73 double _px,_py,_pz,_e;
77 inline double Particle::getAnglePhi()
84 if(fabs(py())<fabs(px()))
86 buf = atan( fabs(py()/px()) );
87 if(px()<0.) buf = M_PI-buf;
89 else buf = acos( px()/sqrt(px()*px()+py()*py()) );
91 if(py()<0.) buf = 2.*M_PI-buf;
96 inline double Particle::getAngleTheta()
104 if(fabs(px())<fabs(pz()))
106 buf = atan( fabs(px()/pz()) );
107 if(pz()<0.) buf = M_PI-buf;
109 else buf = acos( pz()/sqrt(pz()*pz()+px()*px()) );
114 inline void Particle::rotateXZ(
double theta)
119 setPx( cos(theta)*pX + sin(theta)*pZ);
120 setPz(-sin(theta)*pX + cos(theta)*pZ);
123 inline void Particle::rotateXY(
double theta)
128 setPx( cos(theta)*pX - sin(theta)*pY);
129 setPy( sin(theta)*pX + cos(theta)*pY);
132 inline void Particle::boostAlongZ(
double p_pz,
double p_e)
135 double m=sqrt(p_e*p_e-p_pz*p_pz);
139 setPz((p_e *buf_pz + p_pz*buf_e)/m);
140 setE ((p_pz*buf_pz + p_e *buf_e)/m);
143 inline void Particle::boostToRestFrame(Particle &p)
145 double p_len = sqrt(p.px()*p.px()+p.py()*p.py()+p.pz()*p.pz());
146 double phi = p.getAnglePhi();
148 double theta = p.getAngleTheta();
154 boostAlongZ(-1*p_len,p.e());
159 inline void Particle::boostFromRestFrame(Particle &p)
161 double p_len = sqrt(p.px()*p.px()+p.py()*p.py()+p.pz()*p.pz());
162 double phi = p.getAnglePhi();
164 double theta = p.getAngleTheta();
170 boostAlongZ(p_len,p.e());