261{
263
264
267 for (
G4int index=0; index<3; index++)
268 {
269 if ( theDaughterMasses )
270 {
271 daughtermass[index]= *(theDaughterMasses+index);
272 } else {
274 }
275 sumofdaughtermass += daughtermass[index];
276 }
277
278
281
282
284 delete parentparticle;
285
286
287
290 G4double momentummax=0.0, momentumsum = 0.0;
292 const G4int maxNumberOfLoops = 10000;
293 G4int loopCounter = 0;
294
295 do
296 {
299 if (rd2 > rd1)
300 {
301 rd = rd1;
302 rd1 = rd2;
303 rd2 = rd;
304 }
305 momentummax = 0.0;
306 momentumsum = 0.0;
307
308
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];
313
314
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];
319
320
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;
331 }
332
333
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;
339 }
340
341
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]);
354
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() );
369 daughterparticle =
372
374 G4cout <<
"G4GeneralPhaseSpaceDecay::ThreeBodyDecayIt ";
375 G4cout <<
" create decay products in rest frame " <<
G4endl;
377 }
378 return products;
379}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4double energy(const ThreeVector &p, const G4double m)