216{
218 static const G4double expxl = -expxu;
219
223
224 static const G4int numMul = 1200;
225 static const G4int numSec = 60;
226
232
235
236 static G4bool first =
true;
237 static G4double protmul[numMul], protnorm[numSec];
238 static G4double neutmul[numMul], neutnorm[numSec];
239
240
241
242
243 G4int i, counter, nt, npos, nneg, nzero;
244
245 if (first) {
246 first = false;
247 for (i = 0; i < numMul; i++) protmul[i] = 0.0;
248 for (i = 0; i < numSec; i++) protnorm[i] = 0.0;
249 counter = -1;
250 for (npos = 0; npos < (numSec/3); npos++) {
251 for (nneg = std::max(0,npos-2); nneg <= npos; nneg++) {
252 for (nzero = 0; nzero < numSec/3; nzero++) {
253 if (++counter < numMul) {
254 nt = npos+nneg+nzero;
255 if ((nt > 0) && (nt <= numSec) ) {
256 protmul[counter] =
pmltpc(npos,nneg,nzero,nt,protb,c);
257 protnorm[nt-1] += protmul[counter];
258 }
259 }
260 }
261 }
262 }
263
264 for( i=0; i<numMul; i++ )neutmul[i] = 0.0;
265 for( i=0; i<numSec; i++ )neutnorm[i] = 0.0;
266 counter = -1;
267 for (npos = 0; npos < numSec/3; npos++) {
268 for (nneg = std::max(0,npos-1); nneg <= (npos+1); nneg++) {
269 for (nzero = 0; nzero < numSec/3; nzero++) {
270 if (++counter < numMul) {
271 nt = npos+nneg+nzero;
272 if ((nt > 0) && (nt <= numSec) ) {
273 neutmul[counter] =
pmltpc(npos,nneg,nzero,nt,neutb,c);
274 neutnorm[nt-1] += neutmul[counter];
275 }
276 }
277 }
278 }
279 }
280 for (i = 0; i < numSec; i++) {
281 if (protnorm[i] > 0.0) protnorm[i] = 1.0/protnorm[i];
282 if (neutnorm[i] > 0.0) neutnorm[i] = 1.0/neutnorm[i];
283 }
284 }
285
286 pv[0] = incidentParticle;
287 pv[1] = targetParticle;
288 vecLen = 2;
289
291
292
293 npos = 0, nneg = 0, nzero = 0;
294 G4double cech[] = { 1., 1., 1., 0.70, 0.60, 0.55, 0.35, 0.25, 0.18, 0.15};
295 G4int iplab =
G4int( incidentTotalMomentum*5.);
297 G4int ipl = std::min(19,
G4int( incidentTotalMomentum*5.));
298 G4double cnk0[] = {0.17, 0.18, 0.17, 0.24, 0.26, 0.20, 0.22, 0.21, 0.34, 0.45,
299 0.58, 0.55, 0.36, 0.29, 0.29, 0.32, 0.32, 0.33, 0.33, 0.33};
301 if (targetCode == protonCode) {
302 return;
303 } else {
306 return;
307 }
308 }
309
311 if (targetCode == protonCode) {
312 if (ran < 0.25) {
313 } else if (ran < 0.50) {
316 } else if (ran < 0.75) {
317 } else {
320 }
321 } else {
322 if( ran < 0.25 )
323 {
326 }
327 else if (ran < 0.50)
328 {
331 }
332 else if (ran < 0.75)
333 {
336 }
337 else
338 {
341 }
342 }
343 return;
344
345 } else {
346
347 G4double aleab = std::log(availableEnergy);
348 G4double n = 3.62567+aleab*(0.665843+aleab*(0.336514
349 + aleab*(0.117712+0.0136912*aleab))) - 2.0;
350
351
352
354
355 for (nt=1; nt<=numSec; nt++) {
356 test = std::exp(std::min(expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
357 dum =
pi*nt/(2.0*
n*
n);
358 if (std::fabs(dum) < 1.0) {
359 if( test >= 1.0e-10 )anpn += dum*test;
360 } else {
361 anpn += dum*test;
362 }
363 }
364
367 if (targetCode == protonCode) {
368 counter = -1;
369 for (npos=0; npos<numSec/3; npos++) {
370 for (nneg=std::max(0,npos-2); nneg<=npos; nneg++) {
371 for (nzero=0; nzero<numSec/3; nzero++) {
372 if (++counter < numMul) {
373 nt = npos+nneg+nzero;
374 if ((nt>0) && (nt<=numSec) ) {
375 test = std::exp( std::min( expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
376 dum = (
pi/anpn)*nt*protmul[counter]*protnorm[nt-1]/(2.0*n*n);
377
378 if (std::fabs(dum) < 1.0) {
379 if( test >= 1.0e-10 )excs += dum*test;
380 } else {
381 excs += dum*test;
382 }
383
384 if (ran < excs) goto outOfLoop;
385 }
386 }
387 }
388 }
389 }
390
391 inElastic = false;
392 return;
393
394 } else {
395 counter = -1;
396 for (npos=0; npos<numSec/3; npos++) {
397 for (nneg=std::max(0,npos-1); nneg<=(npos+1); nneg++) {
398 for (nzero=0; nzero<numSec/3; nzero++) {
399 if (++counter < numMul) {
400 nt = npos+nneg+nzero;
401 if( (nt>=1) && (nt<=numSec) ) {
402 test = std::exp( std::min( expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
403 dum = (
pi/anpn)*nt*neutmul[counter]*neutnorm[nt-1]/(2.0*n*n);
404
405 if (std::fabs(dum) < 1.0) {
406 if( test >= 1.0e-10 )excs += dum*test;
407 } else {
408 excs += dum*test;
409 }
410
411 if (ran < excs) goto outOfLoop;
412 }
413 }
414 }
415 }
416 }
417
418 inElastic = false;
419 return;
420 }
421 }
422
423 outOfLoop:
424
425 if (targetCode == protonCode) {
426 if (npos == nneg) {
427
428 } else if (npos == (1+nneg)) {
431 } else {
433 }
434 } else {
437 }
438
439 } else {
440 if( npos == nneg)
441 {
443 {
444 }
445 else
446 {
449 }
450 }
451 else if ( npos == (1+nneg))
452 {
454 }
455 else
456 {
458 }
459 }
460
462 if (((pv[0].getCode() == kaonMinusCode)
464 || ((pv[0].
getCode() == kaonZeroCode)
465 && (pv[1].getCode() == protonCode) )
466 || ((pv[0].
getCode() == antiKaonZeroCode)
467 && (pv[1].getCode() == protonCode) ) ) {
468
470 if (pv[1].getCode() == protonCode) {
471 if (ran < 0.68) {
474 } else if (ran < 0.84) {
477 } else {
480 }
481 } else {
482 if(ran < 0.68)
483 {
486 }
487 else if (ran < 0.84)
488 {
491 }
492 else
493 {
496 }
497 }
498 } else {
500 if (ran < 0.67)
501 {
504 }
505 else if (ran < 0.78)
506 {
509 }
510 else if (ran < 0.89)
511 {
514 }
515 else
516 {
519 }
520 }
521 }
522
523 nt = npos + nneg + nzero;
524 while (nt > 0) {
527 if (npos > 0) {
529 npos--;
530 }
531 }
else if (ran < (
G4double)(npos+nneg)/nt) {
532 if (nneg > 0) {
534 nneg--;
535 }
536 } else {
537 if (nzero > 0) {
539 nzero--;
540 }
541 }
542 nt = npos + nneg + nzero;
543 }
544
546 G4cout <<
"Particles produced: " ;
549 for (i=2; i < vecLen; i++) {
551 }
553 }
554
555 return;
556 }
G4double pmltpc(G4int np, G4int nm, G4int nz, G4int n, G4double b, G4double c)
G4double getTotalMomentum() const