268 for (
G4int index=0; index<3; index++)
270 if ( theDaughterMasses )
272 daughtermass[index]= *(theDaughterMasses+index);
276 sumofdaughtermass += daughtermass[index];
285 delete parentparticle;
291 G4double momentummax=0.0, momentumsum = 0.0;
293 const G4int maxNumberOfLoops = 10000;
294 G4int loopCounter = 0;
310 energy = rd2*(parentmass - sumofdaughtermass);
311 daughtermomentum[0] = std::sqrt(energy*energy + 2.0*energy* daughtermass[0]);
312 if ( daughtermomentum[0] >momentummax )momentummax = daughtermomentum[0];
313 momentumsum += daughtermomentum[0];
316 energy = (1.-rd1)*(parentmass - sumofdaughtermass);
317 daughtermomentum[1] = std::sqrt(energy*energy + 2.0*energy* daughtermass[1]);
318 if ( daughtermomentum[1] >momentummax )momentummax = daughtermomentum[1];
319 momentumsum += daughtermomentum[1];
322 energy = (rd1-rd2)*(parentmass - sumofdaughtermass);
323 daughtermomentum[2] = std::sqrt(energy*energy + 2.0*energy* daughtermass[2]);
324 if ( daughtermomentum[2] >momentummax )momentummax = daughtermomentum[2];
325 momentumsum += daughtermomentum[2];
326 }
while ( ( momentummax > momentumsum - momentummax ) &&
327 ++loopCounter < maxNumberOfLoops );
328 if ( loopCounter >= maxNumberOfLoops ) {
330 ed <<
" Failed sampling after maxNumberOfLoops attempts : forced exit" <<
G4endl;
336 G4cout <<
" daughter 0:" << daughtermomentum[0]/
GeV <<
"[GeV/c]" <<
G4endl;
337 G4cout <<
" daughter 1:" << daughtermomentum[1]/
GeV <<
"[GeV/c]" <<
G4endl;
338 G4cout <<
" daughter 2:" << daughtermomentum[2]/
GeV <<
"[GeV/c]" <<
G4endl;
343 G4double costheta, sintheta, phi, sinphi, cosphi;
344 G4double costhetan, sinthetan, phin, sinphin, cosphin;
346 sintheta = std::sqrt((1.0-costheta)*(1.0+costheta));
348 sinphi = std::sin(phi);
349 cosphi = std::cos(phi);
351 G4double Etotal=std::sqrt( daughtermass[0]*daughtermass[0] + daughtermomentum[0]*daughtermomentum[0]);
356 costhetan = (daughtermomentum[1]*daughtermomentum[1]-daughtermomentum[2]*daughtermomentum[2]-daughtermomentum[0]*daughtermomentum[0])/(2.0*daughtermomentum[2]*daughtermomentum[0]);
357 sinthetan = std::sqrt((1.0-costhetan)*(1.0+costhetan));
359 sinphin = std::sin(phin);
360 cosphin = std::cos(phin);
362 direction2.
setX( sinthetan*cosphin*costheta*cosphi - sinthetan*sinphin*sinphi + costhetan*sintheta*cosphi);
363 direction2.
setY( sinthetan*cosphin*costheta*sinphi + sinthetan*sinphin*cosphi + costhetan*sintheta*sinphi);
364 direction2.
setZ( -sinthetan*cosphin*sintheta + costhetan*costheta);
365 Etotal=std::sqrt( daughtermass[2]*daughtermass[2] + daughtermomentum[2]*daughtermomentum[2]/direction2.
mag2());
368 G4ThreeVector mom=(direction0*daughtermomentum[0] + direction2*(daughtermomentum[2]/direction2.
mag()))*(-1.0);
369 Etotal= std::sqrt( daughtermass[1]*daughtermass[1] + mom.
mag2() );
375 G4cout <<
"G4GeneralPhaseSpaceDecay::ThreeBodyDecayIt ";
376 G4cout <<
" create decay products in rest frame " <<
G4endl;
std::ostringstream G4ExceptionDescription
G4int PushProducts(G4DynamicParticle *aParticle)
G4ParticleDefinition * G4MT_parent
G4ParticleDefinition ** G4MT_daughters
static constexpr double rad
static constexpr double twopi
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4int GetVerboseLevel() const
G4double GetPDGMass() const
G4double energy(const ThreeVector &p, const G4double m)
static constexpr double GeV