51 parentmass(0.), theDaughterMasses(0)
58 G4int theNumberOfDaughters,
85 G4int theNumberOfDaughters,
95 parentmass(theParentMass),
104 G4int theNumberOfDaughters,
111 theNumberOfDaughters,
115 parentmass(theParentMass),
116 theDaughterMasses(masses)
124 G4int theNumberOfDaughters,
132 theNumberOfDaughters,
137 parentmass(theParentMass),
138 theDaughterMasses(masses)
158 G4cout <<
"G4GeneralPhaseSpaceDecay::DecayIt ";
176 G4cout <<
"G4GeneralPhaseSpaceDecay::DecayIt ";
195 delete parentparticle;
203 G4cout <<
"G4GeneralPhaseSpaceDecay::OneBodyDecayIt ";
204 G4cout <<
" create decay products in rest frame " <<
G4endl;
217 if ( theDaughterMasses )
219 daughtermass[0]= *(theDaughterMasses);
220 daughtermass[1] = *(theDaughterMasses+1);
234 delete parentparticle;
237 daughtermomentum =
Pmx(parentmass,daughtermass[0],daughtermass[1]);
239 G4double sintheta = std::sqrt((1.0 - costheta)*(1.0 + costheta));
244 G4double Etotal= std::sqrt(daughtermass[0]*daughtermass[0] + daughtermomentum*daughtermomentum);
247 Etotal= std::sqrt(daughtermass[1]*daughtermass[1] + daughtermomentum*daughtermomentum);
253 G4cout <<
"G4GeneralPhaseSpaceDecay::TwoBodyDecayIt ";
254 G4cout <<
" create decay products in rest frame " <<
G4endl;
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;
403 sumofdaughtermass += daughtermass[index];
413 G4int numberOfTry = 0;
421 for(index1 =1; index1 < numberOfDaughters -1; index1++)
423 rd[ numberOfDaughters -1] = 0.0;
424 for(index1 =1; index1 < numberOfDaughters -1; index1++) {
426 if (rd[index1] < rd[index2]){
428 rd[index1] = rd[index2];
435 tmas = parentmass - sumofdaughtermass;
436 temp = sumofdaughtermass;
438 sm[index1] = rd[index1]*tmas + temp;
439 temp -= daughtermass[index1];
441 G4cout << index1 <<
" rundom number:" << rd[index1];
449 index1 =numberOfDaughters-1;
450 daughtermomentum[index1]=
Pmx( sm[index1-1],daughtermass[index1-1],sm[index1]);
453 G4cout <<
" momentum:" << daughtermomentum[index1]/
GeV <<
"[GeV/c]" <<
G4endl;
455 for(index1 =numberOfDaughters-2; index1>=0; index1--) {
457 daughtermomentum[index1]=
Pmx( sm[index1],daughtermass[index1], sm[index1 +1]);
458 if(daughtermomentum[index1] < 0.0) {
461 G4cout <<
"G4GeneralPhaseSpaceDecay::ManyBodyDecayIt ";
462 G4cout <<
" can not calculate daughter momentum " <<
G4endl;
466 G4cout <<
" mass:" << daughtermass[index1]/
GeV <<
"[GeV/c/c]" ;
467 G4cout <<
" mass:" << daughtermomentum[index1]/
GeV <<
"[GeV/c]" <<
G4endl;
470 delete [] daughtermass;
471 delete [] daughtermomentum;
476 weight *= daughtermomentum[index1]/sm[index1];
479 G4cout <<
" momentum:" << daughtermomentum[index1]/
GeV <<
"[GeV/c]" <<
G4endl;
488 if (numberOfTry++ >100) {
490 G4cout <<
"G4GeneralPhaseSpaceDecay::ManyBodyDecayIt: ";
491 G4cout <<
" can not determine Decay Kinematics " <<
G4endl;
494 delete [] daughtermass;
495 delete [] daughtermomentum;
500 G4cout <<
"Start calulation of daughters momentum vector "<<
G4endl;
507 index1 = numberOfDaughters -2;
509 sintheta = std::sqrt((1.0-costheta)*(1.0+costheta));
511 direction.
setZ(costheta);
512 direction.
setY(sintheta*std::sin(phi));
513 direction.
setX(sintheta*std::cos(phi));
517 for (index1 = numberOfDaughters -3; index1 >= 0; index1--) {
520 sintheta = std::sqrt((1.0-costheta)*(1.0+costheta));
522 direction.
setZ(costheta);
523 direction.
setY(sintheta*std::sin(phi));
524 direction.
setX(sintheta*std::cos(phi));
527 beta = daughtermomentum[index1];
528 beta /= std::sqrt( daughtermomentum[index1]*daughtermomentum[index1] + sm[index1+1]*sm[index1+1] );
535 p4.
boost( direction.
x()*beta, direction.
y()*beta, direction.
z()*beta);
546 direction.
setX(1.0); direction.
setY(0.0); direction.
setZ(0.0);
549 delete parentparticle;
554 G4cout <<
"G4GeneralPhaseSpaceDecay::ManyBodyDecayIt ";
555 G4cout <<
" create decay products in rest frame " <<
G4endl;
559 delete [] daughterparticle;
560 delete [] daughtermomentum;
561 delete [] daughtermass;
void CheckAndFillDaughters()
std::ostringstream G4ExceptionDescription
G4int PushProducts(G4DynamicParticle *aParticle)
G4DecayProducts * ManyBodyDecayIt()
G4ParticleDefinition * G4MT_parent
G4ParticleDefinition ** G4MT_daughters
G4GeneralPhaseSpaceDecay(G4int Verbose=1)
static constexpr double rad
G4DecayProducts * ThreeBodyDecayIt()
static constexpr double twopi
G4GLOB_DLL std::ostream G4cout
virtual ~G4GeneralPhaseSpaceDecay()
HepLorentzVector & boost(double, double, double)
G4DecayProducts * TwoBodyDecayIt()
G4LorentzVector Get4Momentum() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual G4DecayProducts * DecayIt(G4double mass=0.0)
void Set4Momentum(const G4LorentzVector &momentum)
G4int GetVerboseLevel() const
static G4double Pmx(G4double e, G4double p1, G4double p2)
G4double GetPDGMass() const
G4double energy(const ThreeVector &p, const G4double m)
G4DecayProducts * OneBodyDecayIt()
static constexpr double GeV
G4String ** daughters_name
void CheckAndFillParent()