216{
218 static const G4double expxl = -expxu;
219
223
224 static const G4int numMul = 1200;
225 static const G4int numMulAn = 400;
226 static const G4int numSec = 60;
227
230
233
234 static G4bool first =
true;
235 static G4double protmul[numMul], protnorm[numSec];
236 static G4double protmulAn[numMulAn],protnormAn[numSec];
237 static G4double neutmul[numMul], neutnorm[numSec];
238 static G4double neutmulAn[numMulAn],neutnormAn[numSec];
239
240
241
242
243 G4int i, counter, nt, npos, nneg, nzero;
244
245 if( first )
246 {
247 first = false;
248 for( i=0; i<numMul ; i++ ) protmul[i] = 0.0;
249 for( i=0; i<numSec ; i++ ) protnorm[i] = 0.0;
250 counter = -1;
251 for( npos=0; npos<(numSec/3); npos++ )
252 {
253 for( nneg=std::max(0,npos-2); nneg<=npos; nneg++ )
254 {
255 for( nzero=0; nzero<numSec/3; nzero++ )
256 {
257 if( ++counter < numMul )
258 {
259 nt = npos+nneg+nzero;
260 if( (nt>0) && (nt<=numSec) )
261 {
262 protmul[counter] =
pmltpc(npos,nneg,nzero,nt,protb,c);
263 protnorm[nt-1] += protmul[counter];
264 }
265 }
266 }
267 }
268 }
269 for( i=0; i<numMul; i++ )neutmul[i] = 0.0;
270 for( i=0; i<numSec; i++ )neutnorm[i] = 0.0;
271 counter = -1;
272 for( npos=0; npos<numSec/3; npos++ )
273 {
274 for( nneg=std::max(0,npos-1); nneg<=(npos+1); nneg++ )
275 {
276 for( nzero=0; nzero<numSec/3; nzero++ )
277 {
278 if( ++counter < numMul )
279 {
280 nt = npos+nneg+nzero;
281 if( (nt>0) && (nt<=numSec) )
282 {
283 neutmul[counter] =
pmltpc(npos,nneg,nzero,nt,neutb,c);
284 neutnorm[nt-1] += neutmul[counter];
285 }
286 }
287 }
288 }
289 }
290 for( i=0; i<numSec; i++ )
291 {
292 if( protnorm[i] > 0.0 )protnorm[i] = 1.0/protnorm[i];
293 if( neutnorm[i] > 0.0 )neutnorm[i] = 1.0/neutnorm[i];
294 }
295
296 for( i=0; i<numMulAn ; i++ ) protmulAn[i] = 0.0;
297 for( i=0; i<numSec ; i++ ) protnormAn[i] = 0.0;
298 counter = -1;
299 for( npos=1; npos<(numSec/3); npos++ )
300 {
301 nneg = std::max(0,npos-1);
302 for( nzero=0; nzero<numSec/3; nzero++ )
303 {
304 if( ++counter < numMulAn )
305 {
306 nt = npos+nneg+nzero;
307 if( (nt>1) && (nt<=numSec) )
308 {
309 protmulAn[counter] =
pmltpc(npos,nneg,nzero,nt,protb,c);
310 protnormAn[nt-1] += protmulAn[counter];
311 }
312 }
313 }
314 }
315 for( i=0; i<numMulAn; i++ ) neutmulAn[i] = 0.0;
316 for( i=0; i<numSec; i++ ) neutnormAn[i] = 0.0;
317 counter = -1;
318 for( npos=0; npos<numSec/3; npos++ )
319 {
320 nneg = npos;
321 for( nzero=0; nzero<numSec/3; nzero++ )
322 {
323 if( ++counter < numMulAn )
324 {
325 nt = npos+nneg+nzero;
326 if( (nt>1) && (nt<=numSec) )
327 {
328 neutmulAn[counter] =
pmltpc(npos,nneg,nzero,nt,neutb,c);
329 neutnormAn[nt-1] += neutmulAn[counter];
330 }
331 }
332 }
333 }
334 for( i=0; i<numSec; i++ )
335 {
336 if( protnormAn[i] > 0.0 )protnormAn[i] = 1.0/protnormAn[i];
337 if( neutnormAn[i] > 0.0 )neutnormAn[i] = 1.0/neutnormAn[i];
338 }
339 }
340
341
342
343
344 pv[0] = incidentParticle;
345 pv[1] = targetParticle;
346 vecLen = 2;
347
348 if( !inElastic )
349 {
351 {
352 G4double cech[] = {0.50, 0.45, 0.40, 0.35, 0.30, 0.25, 0.06, 0.04, 0.005, 0.};
353
354 G4int iplab = std::min(9,
G4int( incidentTotalMomentum*2.5));
355 if(
G4UniformRand() < cech[iplab]/std::pow(atomicWeight,0.42) )
356 {
359 }
360 }
361 return;
362 }
364 return;
365
366
367
368 npos = 0, nneg = 0, nzero = 0;
369 G4double anhl[] = {1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 0.97, 0.88,
370 0.85, 0.81, 0.75, 0.64, 0.64, 0.55, 0.55, 0.45, 0.47, 0.40,
371 0.39, 0.36, 0.33, 0.10, 0.01};
372 G4int iplab =
G4int( incidentTotalMomentum*10.);
373 if ( iplab > 9) iplab = 10 +
G4int( (incidentTotalMomentum -1.)*5. );
374 if ( iplab > 14) iplab = 15 +
G4int( incidentTotalMomentum -2. );
375 if ( iplab > 22) iplab = 23 +
G4int( (incidentTotalMomentum -10.)/10.);
376 iplab = std::min(24, iplab);
377
379 {
380
383
384 G4double supp[] = {0., 0.4, 0.55, 0.65, 0.75, 0.82, 0.86, 0.90, 0.94, 0.98};
386 {
387
388
390 if( targetCode == protonCode )
391 {
392 w0 = -
sqr(1.+protb)/(2.*c*c);
393 w0 = wp = std::exp(w0);
395 { npos = 0; nneg = 0; nzero = 1; }
396 else
397 { npos = 1; nneg = 0; nzero = 0; }
398 }
399 else
400 {
401 w0 = -
sqr(1.+neutb)/(2.*c*c);
402 w0 = wp = std::exp(w0);
403 wm = -
sqr(-1.+neutb)/(2.*c*c);
404 wm = std::exp(wm);
405 wt = w0+wp+wm;
406 wp = w0+wp;
408 if( ran < w0/wt)
409 { npos = 0; nneg = 0; nzero = 1; }
410 else if( ran < wp/wt)
411 { npos = 1; nneg = 0; nzero = 0; }
412 else
413 { npos = 0; nneg = 1; nzero = 0; }
414 }
415 }
416 else
417 {
418
419
420 G4double aleab = std::log(availableEnergy);
421 G4double n = 3.62567+aleab*(0.665843+aleab*(0.336514
422 + aleab*(0.117712+0.0136912*aleab))) - 2.0;
423
424
425
427
428 for (nt=1; nt<=numSec; nt++) {
429 test = std::exp( std::min( expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
430 dum =
pi*nt/(2.0*
n*
n);
431
432 if (std::fabs(dum) < 1.0) {
433 if( test >= 1.0e-10 )anpn += dum*test;
434 } else {
435 anpn += dum*test;
436 }
437 }
438
441 if (targetCode == protonCode) {
442 counter = -1;
443 for (npos=0; npos<numSec/3; npos++) {
444 for (nneg=std::max(0,npos-2); nneg<=npos; nneg++) {
445 for (nzero=0; nzero<numSec/3; nzero++) {
446 if (++counter < numMul) {
447 nt = npos+nneg+nzero;
448 if ( (nt>0) && (nt<=numSec) ) {
449 test = std::exp( std::min( expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
450 dum = (
pi/anpn)*nt*protmul[counter]*protnorm[nt-1]/(2.0*n*n);
451
452 if (std::fabs(dum) < 1.0) {
453 if( test >= 1.0e-10 )excs += dum*test;
454 } else {
455 excs += dum*test;
456 }
457
458 if (ran < excs) goto outOfLoop;
459 }
460 }
461 }
462 }
463 }
464
465
466 inElastic = false;
467 return;
468
469 } else {
470 counter = -1;
471 for (npos=0; npos<numSec/3; npos++) {
472 for (nneg=std::max(0,npos-1); nneg<=(npos+1); nneg++) {
473 for (nzero=0; nzero<numSec/3; nzero++) {
474 if (++counter < numMul) {
475 nt = npos+nneg+nzero;
476 if ((nt>0) && (nt<=numSec) ) {
477 test = std::exp( std::min( expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
478 dum = (
pi/anpn)*nt*neutmul[counter]*neutnorm[nt-1]/(2.0*n*n);
479 if (std::fabs(dum) < 1.0) {
480 if( test >= 1.0e-10 )excs += dum*test;
481 } else {
482 excs += dum*test;
483 }
484
485 if (ran < excs) goto outOfLoop;
486 }
487 }
488 }
489 }
490 }
491
492 inElastic = false;
493 return;
494 }
495 }
496 outOfLoop:
497
498 if( targetCode == protonCode)
499 {
500 if( npos == nneg)
501 {
502 }
503 else if (npos == (nneg+1))
504 {
506 {
508 }
509 else
510 {
512 }
513 }
514 else
515 {
518 }
519 }
520 else
521 {
522 if( npos == nneg)
523 {
525 {
528 }
529 else
530 {
531 }
532 }
533 else if ( npos == (nneg-1))
534 {
536 }
537 else
538 {
540 }
541 }
542
543 }
544 else
545 {
547 {
548
549 G4double aleab = std::log(availableEnergy);
550 G4double n = 3.62567+aleab*(0.665843+aleab*(0.336514
551 + aleab*(0.117712+0.0136912*aleab))) - 2.0;
552
553
554
556
557 for (nt=2; nt<=numSec; nt++) {
558 test = std::exp( std::min( expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
559 dum =
pi*nt/(2.0*
n*
n);
560 if (std::fabs(dum) < 1.0) {
561 if( test >= 1.0e-10 )anpn += dum*test;
562 } else {
563 anpn += dum*test;
564 }
565 }
566
569 if (targetCode == protonCode) {
570 counter = -1;
571 for (npos=1; npos<numSec/3; npos++) {
572 nneg = npos-1;
573 for (nzero=0; nzero<numSec/3; nzero++) {
574 if (++counter < numMulAn) {
575 nt = npos+nneg+nzero;
576 if ( (nt>1) && (nt<=numSec) ) {
577 test = std::exp( std::min( expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
578 dum = (
pi/anpn)*nt*protmulAn[counter]*protnormAn[nt-1]/(2.0*n*n);
579
580 if (std::fabs(dum) < 1.0) {
581 if( test >= 1.0e-10 )excs += dum*test;
582 } else {
583 excs += dum*test;
584 }
585
586 if (ran < excs) goto outOfLoopAn;
587 }
588 }
589 }
590 }
591
592 inElastic = false;
593 return;
594
595 } else {
596 counter = -1;
597 for (npos=0; npos<numSec/3; npos++) {
598 nneg = npos;
599 for (nzero=0; nzero<numSec/3; nzero++) {
600 if (++counter < numMulAn) {
601 nt = npos+nneg+nzero;
602 if ( (nt>1) && (nt<=numSec) ) {
603 test = std::exp( std::min( expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
604 dum = (
pi/anpn)*nt*neutmulAn[counter]*neutnormAn[nt-1]/(2.0*n*n);
605
606 if (std::fabs(dum) < 1.0) {
607 if( test >= 1.0e-10 )excs += dum*test;
608 } else {
609 excs += dum*test;
610 }
611
612 if (ran < excs) goto outOfLoopAn;
613 }
614 }
615 }
616 }
617 inElastic = false;
618 return;
619 }
620 outOfLoopAn:
621 vecLen = 0;
622 }
623 }
624
625 nt = npos + nneg + nzero;
626 while ( nt > 0)
627 {
630 {
631 if( npos > 0 )
633 npos--;
634 }
635 }
636 else if ( ran < (
G4double)(npos+nneg)/nt)
637 {
638 if( nneg > 0 )
639 {
641 nneg--;
642 }
643 }
644 else
645 {
646 if( nzero > 0 )
647 {
649 nzero--;
650 }
651 }
652 nt = npos + nneg + nzero;
653 }
655 {
656 G4cout <<
"Particles produced: " ;
659 for (i=2; i < vecLen; i++)
660 {
662 }
664 }
665 return;
666 }
G4double pmltpc(G4int np, G4int nm, G4int nz, G4int n, G4double b, G4double c)
G4double getTotalMomentum() const