00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "gismo/Twobody.h"
00011
00012
00013
00014 #include "Random.h"
00015 #include <cmath>
00016
00017
00018
00019
00020 #include "gismo/GParticle.h"
00021 #include "facilities/error.h"
00022 static inline double sqr(double x){return x*x;}
00023
00024 int TwoBody::decay(GParticle* parent)const
00025 {
00026
00027 if (parent->numChildren() != 2)
00028 { WARNING( "Twobody::decay-- must be two secondaries to decay!");
00029 return 0;
00030 }
00031 GParticle& b = *parent->child(0);
00032 GParticle& c = *parent->child(1);
00033 float m1 = b.mass();
00034 float m2 = c.mass();
00035
00036 float M = parent->mass();
00037
00038 float pstar = (sqr(M)-sqr(m1+m2))*(sqr(M)-sqr(m1-m2));
00039 if (pstar<0.)
00040 { WARNING( "*** decay kinematically forbidden");
00041 return 0;
00042 }
00043 pstar = sqrt(pstar)/(2.0*M);
00044 float costh = Random::flat(-1.0, 1.0);
00045 float phi = Random::flat(2*M_PI);
00046 Vector pcm(0,0,pstar);
00047 pcm.rotateY(acos(costh));
00048 pcm.rotateZ(phi);
00049
00050 b.setMomentum(pcm);
00051 c.setMomentum(-pcm);
00052
00053
00054 return 1;
00055 }
00056