50 parentmass(0.), theDaughterMasses(0)
57 G4int theNumberOfDaughters,
84 G4int theNumberOfDaughters,
94 parentmass(theParentMass),
103 G4int theNumberOfDaughters,
110 theNumberOfDaughters,
114 parentmass(theParentMass),
115 theDaughterMasses(masses)
123 G4int theNumberOfDaughters,
131 theNumberOfDaughters,
136 parentmass(theParentMass),
137 theDaughterMasses(masses)
157 G4cout <<
"G4GeneralPhaseSpaceDecay::DecayIt ";
175 G4cout <<
"G4GeneralPhaseSpaceDecay::DecayIt ";
194 delete parentparticle;
202 G4cout <<
"G4GeneralPhaseSpaceDecay::OneBodyDecayIt ";
203 G4cout <<
" create decay products in rest frame " <<
G4endl;
216 if ( theDaughterMasses )
218 daughtermass[0]= *(theDaughterMasses);
219 daughtermass[1] = *(theDaughterMasses+1);
233 delete parentparticle;
236 daughtermomentum =
Pmx(parentmass,daughtermass[0],daughtermass[1]);
238 G4double sintheta = std::sqrt((1.0 - costheta)*(1.0 + costheta));
243 G4double Etotal= std::sqrt(daughtermass[0]*daughtermass[0] + daughtermomentum*daughtermomentum);
246 Etotal= std::sqrt(daughtermass[1]*daughtermass[1] + daughtermomentum*daughtermomentum);
252 G4cout <<
"G4GeneralPhaseSpaceDecay::TwoBodyDecayIt ";
253 G4cout <<
" create decay products in rest frame " <<
G4endl;
267 for (
G4int index=0; index<3; index++)
269 if ( theDaughterMasses )
271 daughtermass[index]= *(theDaughterMasses+index);
275 sumofdaughtermass += daughtermass[index];
284 delete parentparticle;
290 G4double momentummax=0.0, momentumsum = 0.0;
292 const G4int maxNumberOfLoops = 10000;
293 G4int loopCounter = 0;
309 energy = rd2*(parentmass - sumofdaughtermass);
310 daughtermomentum[0] = std::sqrt(energy*energy + 2.0*energy* daughtermass[0]);
311 if ( daughtermomentum[0] >momentummax )momentummax = daughtermomentum[0];
312 momentumsum += daughtermomentum[0];
315 energy = (1.-rd1)*(parentmass - sumofdaughtermass);
316 daughtermomentum[1] = std::sqrt(energy*energy + 2.0*energy* daughtermass[1]);
317 if ( daughtermomentum[1] >momentummax )momentummax = daughtermomentum[1];
318 momentumsum += daughtermomentum[1];
321 energy = (rd1-rd2)*(parentmass - sumofdaughtermass);
322 daughtermomentum[2] = std::sqrt(energy*energy + 2.0*energy* daughtermass[2]);
323 if ( daughtermomentum[2] >momentummax )momentummax = daughtermomentum[2];
324 momentumsum += daughtermomentum[2];
325 }
while ( ( momentummax > momentumsum - momentummax ) &&
326 ++loopCounter < maxNumberOfLoops );
327 if ( loopCounter >= maxNumberOfLoops ) {
329 ed <<
" Failed sampling after maxNumberOfLoops attempts : forced exit" <<
G4endl;
335 G4cout <<
" daughter 0:" << daughtermomentum[0]/GeV <<
"[GeV/c]" <<
G4endl;
336 G4cout <<
" daughter 1:" << daughtermomentum[1]/GeV <<
"[GeV/c]" <<
G4endl;
337 G4cout <<
" daughter 2:" << daughtermomentum[2]/GeV <<
"[GeV/c]" <<
G4endl;
338 G4cout <<
" momentum sum:" << momentumsum/GeV <<
"[GeV/c]" <<
G4endl;
342 G4double costheta, sintheta, phi, sinphi, cosphi;
343 G4double costhetan, sinthetan, phin, sinphin, cosphin;
345 sintheta = std::sqrt((1.0-costheta)*(1.0+costheta));
347 sinphi = std::sin(phi);
348 cosphi = std::cos(phi);
350 G4double Etotal=std::sqrt( daughtermass[0]*daughtermass[0] + daughtermomentum[0]*daughtermomentum[0]);
355 costhetan = (daughtermomentum[1]*daughtermomentum[1]-daughtermomentum[2]*daughtermomentum[2]-daughtermomentum[0]*daughtermomentum[0])/(2.0*daughtermomentum[2]*daughtermomentum[0]);
356 sinthetan = std::sqrt((1.0-costhetan)*(1.0+costhetan));
358 sinphin = std::sin(phin);
359 cosphin = std::cos(phin);
361 direction2.
setX( sinthetan*cosphin*costheta*cosphi - sinthetan*sinphin*sinphi + costhetan*sintheta*cosphi);
362 direction2.
setY( sinthetan*cosphin*costheta*sinphi + sinthetan*sinphin*cosphi + costhetan*sintheta*sinphi);
363 direction2.
setZ( -sinthetan*cosphin*sintheta + costhetan*costheta);
364 Etotal=std::sqrt( daughtermass[2]*daughtermass[2] + daughtermomentum[2]*daughtermomentum[2]/direction2.
mag2());
367 G4ThreeVector mom=(direction0*daughtermomentum[0] + direction2*(daughtermomentum[2]/direction2.
mag()))*(-1.0);
368 Etotal= std::sqrt( daughtermass[1]*daughtermass[1] + mom.
mag2() );
374 G4cout <<
"G4GeneralPhaseSpaceDecay::ThreeBodyDecayIt ";
375 G4cout <<
" create decay products in rest frame " <<
G4endl;
402 sumofdaughtermass += daughtermass[index];
412 G4int numberOfTry = 0;
425 if (rd[index1] < rd[index2]){
427 rd[index1] = rd[index2];
434 tmas = parentmass - sumofdaughtermass;
435 temp = sumofdaughtermass;
437 sm[index1] = rd[index1]*tmas + temp;
438 temp -= daughtermass[index1];
440 G4cout << index1 <<
" rundom number:" << rd[index1];
441 G4cout <<
" virtual mass:" << sm[index1]/GeV <<
"[GeV/c/c]" <<
G4endl;
449 daughtermomentum[index1]=
Pmx( sm[index1-1],daughtermass[index1-1],sm[index1]);
452 G4cout <<
" momentum:" << daughtermomentum[index1]/GeV <<
"[GeV/c]" <<
G4endl;
456 daughtermomentum[index1]=
Pmx( sm[index1],daughtermass[index1], sm[index1 +1]);
457 if(daughtermomentum[index1] < 0.0) {
460 G4cout <<
"G4GeneralPhaseSpaceDecay::ManyBodyDecayIt ";
461 G4cout <<
" can not calculate daughter momentum " <<
G4endl;
463 G4cout <<
" mass:" << parentmass/GeV <<
"[GeV/c/c]" <<
G4endl;
465 G4cout <<
" mass:" << daughtermass[index1]/GeV <<
"[GeV/c/c]" ;
466 G4cout <<
" mass:" << daughtermomentum[index1]/GeV <<
"[GeV/c]" <<
G4endl;
469 delete [] daughtermass;
470 delete [] daughtermomentum;
475 weight *= daughtermomentum[index1]/sm[index1];
478 G4cout <<
" momentum:" << daughtermomentum[index1]/GeV <<
"[GeV/c]" <<
G4endl;
487 if (numberOfTry++ >100) {
489 G4cout <<
"G4GeneralPhaseSpaceDecay::ManyBodyDecayIt: ";
490 G4cout <<
" can not determine Decay Kinematics " <<
G4endl;
493 delete [] daughtermass;
494 delete [] daughtermomentum;
499 G4cout <<
"Start calculation of daughters momentum vector "<<
G4endl;
508 sintheta = std::sqrt((1.0-costheta)*(1.0+costheta));
510 direction.
setZ(costheta);
511 direction.
setY(sintheta*std::sin(phi));
512 direction.
setX(sintheta*std::cos(phi));
519 sintheta = std::sqrt((1.0-costheta)*(1.0+costheta));
521 direction.
setZ(costheta);
522 direction.
setY(sintheta*std::sin(phi));
523 direction.
setX(sintheta*std::cos(phi));
526 beta = daughtermomentum[index1];
527 beta /= std::sqrt( daughtermomentum[index1]*daughtermomentum[index1] + sm[index1+1]*sm[index1+1] );
534 p4.
boost( direction.
x()*beta, direction.
y()*beta, direction.
z()*beta);
545 direction.
setX(1.0); direction.
setY(0.0); direction.
setZ(0.0);
548 delete parentparticle;
553 G4cout <<
"G4GeneralPhaseSpaceDecay::ManyBodyDecayIt ";
554 G4cout <<
" create decay products in rest frame " <<
G4endl;
558 delete [] daughterparticle;
559 delete [] daughtermomentum;
560 delete [] daughtermass;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
HepLorentzVector & boost(double, double, double)
G4int PushProducts(G4DynamicParticle *aParticle)
G4LorentzVector Get4Momentum() const
void Set4Momentum(const G4LorentzVector &momentum)
G4DecayProducts * OneBodyDecayIt()
static G4double Pmx(G4double e, G4double p1, G4double p2)
virtual ~G4GeneralPhaseSpaceDecay()
G4DecayProducts * ThreeBodyDecayIt()
G4DecayProducts * ManyBodyDecayIt()
G4DecayProducts * TwoBodyDecayIt()
virtual G4DecayProducts * DecayIt(G4double mass=0.0)
G4GeneralPhaseSpaceDecay(G4int Verbose=1)
G4double GetPDGMass() const
G4ParticleDefinition ** G4MT_daughters
void CheckAndFillParent()
G4String ** daughters_name
G4int GetVerboseLevel() const
G4ParticleDefinition * G4MT_parent
void CheckAndFillDaughters()