#ifndef PARTICLE_H #define PARTICLE_H ///////////////////////////////////////////////// // // // Particle Class // // // ///////////////////////////////////////////////// class particle { public: int Decay2body(particle &dau1,particle &dau2) const; double InvMass(particle & other)const; private: void Boost(double bx, double by, double bz); }; #endif int particle::Decay2body(particle &dau1,particle &dau2) const { if(GetMass() == 0.0){ printf("Decayment cannot be preformed if mass is zero\n"); return 1; } double massMot = GetMass(); double massDau1 = dau1.GetMass(); double massDau2 = dau2.GetMass(); if(fIparticle > -1){ // add width effect // gaussian random numbers float x1, x2, w, y1, y2; double invnum = 1./RAND_MAX; do { x1 = 2.0 * rand()*invnum - 1.0; x2 = 2.0 * rand()*invnum - 1.0; w = x1 * x1 + x2 * x2; } while ( w >= 1.0 ); w = sqrt( (-2.0 * log( w ) ) / w ); y1 = x1 * w; y2 = x2 * w; massMot += fParticleType[fIparticle]->GetWidth() * y1; } if(massMot < massDau1 + massDau2){ printf("Decayment cannot be preformed because mass is too low in this channel\n"); return 2; } double pout = sqrt((massMot*massMot - (massDau1+massDau2)*(massDau1+massDau2))*(massMot*massMot - (massDau1-massDau2)*(massDau1-massDau2)))/massMot*0.5; double norm = 6.283/RAND_MAX; double phi = rand()*norm; double theta = rand()*norm*0.5 - 1.57075; dau1.SetP(pout*sin(theta)*cos(phi),pout*sin(theta)*sin(phi),pout*cos(theta)); dau2.SetP(-pout*sin(theta)*cos(phi),-pout*sin(theta)*sin(phi),-pout*cos(theta)); double energy = sqrt(fPx*fPx + fPy*fPy + fPz*fPz + massMot*massMot); double bx = fPx/energy; double by = fPy/energy; double bz = fPz/energy; dau1.Boost(bx,by,bz); dau2.Boost(bx,by,bz); return 0; } void particle::Boost(double bx, double by, double bz) { double energy = GetEnergy(); //Boost this Lorentz vector double b2 = bx*bx + by*by + bz*bz; double gamma = 1.0 / sqrt(1.0 - b2); double bp = bx*fPx + by*fPy + bz*fPz; double gamma2 = b2 > 0 ? (gamma - 1.0)/b2 : 0.0; fPx += gamma2*bp*bx + gamma*bx*energy; fPy += gamma2*bp*by + gamma*by*energy; fPz += gamma2*bp*bz + gamma*bz*energy; }