60 G4int theNumberOfDaughters,
98 G4cout <<
"G4PhaseSpaceDecayChannel::DecayIt ";
118 G4cout <<
"G4PhaseSpaceDecayChannel::DecayIt ";
137 delete parentparticle;
145 G4cout <<
"G4PhaseSpaceDecayChannel::OneBodyDecayIt ";
146 G4cout <<
" create decay products in rest frame " <<
G4endl;
162 G4double daughtermass[2], daughterwidth[2];
174 delete parentparticle;
176 G4bool withWidth = (daughterwidth[0]>1.0e-3*daughtermass[0]) || (daughterwidth[1]>1.0e-3*daughtermass[1]);
178 G4double sumofdaughterwidthsq = daughterwidth[0]*daughterwidth[0]+daughterwidth[1]*daughterwidth[1];
180 G4double maxDev = (parentmass - daughtermass[0] - daughtermass[1] )/std::sqrt(sumofdaughterwidthsq);
184 G4cout <<
"G4PhaseSpaceDecayChannel::TwoBodyDecayIt "
185 <<
"sum of daughter mass is larger than parent mass" <<
G4endl;
191 G4Exception(
"G4PhaseSpaceDecayChannel::TwoBodyDecayIt",
193 "Can not create decay products: sum of daughter mass is larger than parent mass");
198 while (dm1+dm2>parentmass){
199 dm1=
DynamicalMass(daughtermass[0],daughterwidth[0], maxDev);
200 dm2=
DynamicalMass(daughtermass[1],daughterwidth[1], maxDev);
202 daughtermass[0] = dm1;
203 daughtermass[1] = dm2;
205 if (parentmass < daughtermass[0] + daughtermass[1] ){
208 G4cout <<
"G4PhaseSpaceDecayChannel::TwoBodyDecayIt "
209 <<
"sum of daughter mass is larger than parent mass" <<
G4endl;
215 G4Exception(
"G4PhaseSpaceDecayChannel::TwoBodyDecayIt",
217 "Can not create decay products: sum of daughter mass is larger than parent mass");
223 daughtermomentum =
Pmx(parentmass,daughtermass[0],daughtermass[1]);
226 G4double sintheta = std::sqrt((1.0 - costheta)*(1.0 + costheta));
228 G4ThreeVector direction(sintheta*std::cos(phi),sintheta*std::sin(phi),costheta);
231 G4double Ekin = std::sqrt(daughtermomentum*daughtermomentum + daughtermass[0]*daughtermass[0]) - daughtermass[0];
234 Ekin = std::sqrt(daughtermomentum*daughtermomentum + daughtermass[1]*daughtermass[1]) - daughtermass[1];
240 G4cout <<
"G4PhaseSpaceDecayChannel::TwoBodyDecayIt ";
241 G4cout <<
" create decay products in rest frame " <<
G4endl;
257 G4double daughtermass[3], daughterwidth[3];
259 G4double sumofdaughterwidthsq = 0.0;
261 for (
G4int index=0; index<3; index++){
263 sumofdaughtermass += daughtermass[index];
265 sumofdaughterwidthsq += daughterwidth[index]*daughterwidth[index];
266 withWidth = withWidth ||(daughterwidth[index]>1.0e-3*daughtermass[index]);
276 delete parentparticle;
279 G4double maxDev = (parentmass - sumofdaughtermass )/std::sqrt(sumofdaughterwidthsq) ;
283 G4cout <<
"G4PhaseSpaceDecayChannel::ThreeBodyDecayIt "
284 <<
"sum of daughter mass is larger than parent mass" <<
G4endl;
291 G4Exception(
"G4PhaseSpaceDecayChannel::ThreeBodyDecayIt",
293 "Can not create decay products: sum of daughter mass is larger than parent mass");
299 while (dm1+dm2+dm3>parentmass){
300 dm1=
DynamicalMass(daughtermass[0],daughterwidth[0], maxDev);
301 dm2=
DynamicalMass(daughtermass[1],daughterwidth[1], maxDev);
302 dm3=
DynamicalMass(daughtermass[2],daughterwidth[2], maxDev);
304 daughtermass[0] = dm1;
305 daughtermass[1] = dm2;
306 daughtermass[2] = dm3;
309 if (sumofdaughtermass >parentmass) {
312 G4cout <<
"G4PhaseSpaceDecayChannel::ThreeBodyDecayIt "
313 <<
"sum of daughter mass is larger than parent mass" <<
G4endl;
320 G4Exception(
"G4PhaseSpaceDecayChannel::ThreeBodyDecayIt",
322 "Can not create decay products: sum of daughter mass is larger than parent mass");
333 G4double momentummax=0.0, momentumsum = 0.0;
347 energy = rd2*(parentmass - sumofdaughtermass);
348 daughtermomentum[0] = std::sqrt(energy*energy + 2.0*energy* daughtermass[0]);
349 if ( daughtermomentum[0] >momentummax )momentummax = daughtermomentum[0];
350 momentumsum += daughtermomentum[0];
352 energy = (1.-rd1)*(parentmass - sumofdaughtermass);
353 daughtermomentum[1] = std::sqrt(energy*energy + 2.0*energy* daughtermass[1]);
354 if ( daughtermomentum[1] >momentummax )momentummax = daughtermomentum[1];
355 momentumsum += daughtermomentum[1];
357 energy = (rd1-rd2)*(parentmass - sumofdaughtermass);
358 daughtermomentum[2] = std::sqrt(energy*energy + 2.0*energy* daughtermass[2]);
359 if ( daughtermomentum[2] >momentummax )momentummax = daughtermomentum[2];
360 momentumsum += daughtermomentum[2];
361 }
while (momentummax > momentumsum - momentummax );
365 G4cout <<
" daughter 0:" << daughtermomentum[0]/
GeV <<
"[GeV/c]" <<
G4endl;
366 G4cout <<
" daughter 1:" << daughtermomentum[1]/
GeV <<
"[GeV/c]" <<
G4endl;
367 G4cout <<
" daughter 2:" << daughtermomentum[2]/
GeV <<
"[GeV/c]" <<
G4endl;
373 G4double costheta, sintheta, phi, sinphi, cosphi;
374 G4double costhetan, sinthetan, phin, sinphin, cosphin;
376 sintheta = std::sqrt((1.0-costheta)*(1.0+costheta));
378 sinphi = std::sin(phi);
379 cosphi = std::cos(phi);
381 G4ThreeVector direction0(sintheta*cosphi,sintheta*sinphi,costheta);
382 G4double Ekin = std::sqrt(daughtermomentum[0]*daughtermomentum[0] + daughtermass[0]*daughtermass[0]) - daughtermass[0];
385 Ekin, daughtermass[0]);
388 costhetan = (daughtermomentum[1]*daughtermomentum[1]-daughtermomentum[2]*daughtermomentum[2]-daughtermomentum[0]*daughtermomentum[0])/(2.0*daughtermomentum[2]*daughtermomentum[0]);
389 sinthetan = std::sqrt((1.0-costhetan)*(1.0+costhetan));
391 sinphin = std::sin(phin);
392 cosphin = std::cos(phin);
394 direction2.setX( sinthetan*cosphin*costheta*cosphi - sinthetan*sinphin*sinphi + costhetan*sintheta*cosphi);
395 direction2.setY( sinthetan*cosphin*costheta*sinphi + sinthetan*sinphin*cosphi + costhetan*sintheta*sinphi);
396 direction2.setZ( -sinthetan*cosphin*sintheta + costhetan*costheta);
397 G4ThreeVector pmom = daughtermomentum[2]*direction2/direction2.mag();
398 Ekin = std::sqrt(pmom.mag2() + daughtermass[2]*daughtermass[2]) - daughtermass[2];
401 Ekin, daughtermass[2]);
404 pmom = (direction0*daughtermomentum[0] + direction2*(daughtermomentum[2]/direction2.mag()))*(-1.0);
405 Ekin = std::sqrt(pmom.mag2() + daughtermass[1]*daughtermass[1]) - daughtermass[1];
409 Ekin, daughtermass[1]);
414 G4cout <<
"G4PhaseSpaceDecayChannel::ThreeBodyDecayIt ";
415 G4cout <<
" create decay products in rest frame " <<
G4endl;
448 sumofdaughtermass += daughtermass[index];
458 G4int numberOfTry = 0;
465 for(index =1; index < numberOfDaughters -1; index++) rd[index] =
G4UniformRand();
466 rd[ numberOfDaughters -1] = 0.0;
467 for(index =1; index < numberOfDaughters -1; index++) {
469 if (rd[index] < rd[index2]){
471 rd[index] = rd[index2];
478 tmas = parentmass - sumofdaughtermass;
479 temp = sumofdaughtermass;
481 sm[index] = rd[index]*tmas + temp;
482 temp -= daughtermass[index];
484 G4cout << index <<
" rundom number:" << rd[index];
492 index =numberOfDaughters-1;
493 daughtermomentum[index]=
Pmx( sm[index-1],daughtermass[index-1], sm[index]);
497 G4cout <<
" momentum:" << daughtermomentum[index]/
GeV <<
"[GeV/c]" <<
G4endl;
500 for(index =numberOfDaughters-2; index>=0; index--) {
502 daughtermomentum[index]=
Pmx( sm[index],daughtermass[index], sm[index +1]);
503 if(daughtermomentum[index] < 0.0) {
507 G4cout <<
"G4PhaseSpaceDecayChannel::ManyBodyDecayIt ";
508 G4cout <<
" can not calculate daughter momentum " <<
G4endl;
512 G4cout <<
" mass:" << daughtermass[index]/
GeV <<
"[GeV/c/c]" ;
513 G4cout <<
" mass:" << daughtermomentum[index]/
GeV <<
"[GeV/c]" <<
G4endl;
517 delete [] daughtermass;
518 delete [] daughtermomentum;
520 G4Exception(
"G4PhaseSpaceDecayChannel::ManyBodyDecayIt",
522 "Can not create decay products: sum of daughter mass is larger than parent mass");
528 weight *= daughtermomentum[index]/sm[index];
532 G4cout <<
" momentum:" << daughtermomentum[index]/
GeV <<
"[GeV/c]" <<
G4endl;
545 if (numberOfTry++ >100) {
548 G4cout <<
"G4PhaseSpaceDecayChannel::ManyBodyDecayIt: ";
549 G4cout <<
" can not determine Decay Kinematics " <<
G4endl;
558 G4Exception(
"G4PhaseSpaceDecayChannel::ManyBodyDecayIt: ",
560 " Cannot decay : Decay Kinematics cannot be calculated ");
563 delete [] daughtermass;
564 delete [] daughtermomentum;
571 G4cout <<
"Start calulation of daughters momentum vector "<<
G4endl;
579 index = numberOfDaughters -2;
581 sintheta = std::sqrt((1.0-costheta)*(1.0+costheta));
583 direction.setZ(costheta);
584 direction.setY(sintheta*std::sin(phi));
585 direction.setX(sintheta*std::cos(phi));
589 for (index = numberOfDaughters -3; index >= 0; index--) {
592 sintheta = std::sqrt((1.0-costheta)*(1.0+costheta));
594 direction.setZ(costheta);
595 direction.setY(sintheta*std::sin(phi));
596 direction.setX(sintheta*std::cos(phi));
599 beta = daughtermomentum[index];
600 beta /= std::sqrt( daughtermomentum[index]*daughtermomentum[index] + sm[index+1]*sm[index+1] );
607 p4.boost( direction.x()*beta, direction.y()*beta, direction.z()*beta);
618 direction.setX(1.0); direction.setY(0.0); direction.setZ(0.0);
621 delete parentparticle;
628 G4cout <<
"G4PhaseSpaceDecayChannel::ManyBodyDecayIt ";
629 G4cout <<
" create decay products in rest frame " <<
G4endl;
634 delete [] daughterparticle;
635 delete [] daughtermomentum;
636 delete [] daughtermass;
646 G4double ppp = (e+p1+
p2)*(e+p1-p2)*(e-p1+
p2)*(e-p1-p2)/(4.0*e*e);
647 if (ppp>0)
return std::sqrt(ppp);
virtual G4DecayProducts * DecayIt(G4double)
G4double * G4MT_daughters_mass
CLHEP::Hep3Vector G4ThreeVector
G4int PushProducts(G4DynamicParticle *aParticle)
G4ParticleDefinition * G4MT_parent
G4ParticleDefinition ** G4MT_daughters
G4double G4MT_parent_mass
G4DecayProducts * ManyBodyDecayIt()
G4DecayProducts * OneBodyDecayIt()
const G4String & GetParticleName() const
G4DecayProducts * ThreeBodyDecayIt()
virtual ~G4PhaseSpaceDecayChannel()
G4GLOB_DLL std::ostream G4cout
G4DecayProducts * TwoBodyDecayIt()
G4LorentzVector Get4Momentum() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4ThreadLocal G4double current_parent_mass
void Set4Momentum(const G4LorentzVector &momentum)
G4int GetVerboseLevel() const
G4double * G4MT_daughters_width
G4double energy(const ThreeVector &p, const G4double m)
G4double DynamicalMass(G4double massPDG, G4double width, G4double maxDev=+1.) const
G4PhaseSpaceDecayChannel(G4int Verbose=1)
G4String ** daughters_name
static G4double Pmx(G4double e, G4double p1, G4double p2)
CLHEP::HepLorentzVector G4LorentzVector