542{
544 static const G4double expxl = -expxu;
545
549
550 static const G4int numMul = 1200;
551 static const G4int numSec = 60;
552
558
561
562 static G4bool first =
true;
563 static G4double protmul[numMul], protnorm[numSec];
564 static G4double neutmul[numMul], neutnorm[numSec];
565
566
567
568
569 G4int i, counter, nt, npos, nneg, nzero;
570
571 if (first) {
572
573 first = false;
574 for( i=0; i<numMul; i++ )protmul[i] = 0.0;
575 for( i=0; i<numSec; i++ )protnorm[i] = 0.0;
576 counter = -1;
577 for(npos=0; npos<(numSec/3); npos++) {
578 for(nneg=std::max(0,npos-2); nneg<=npos; nneg++) {
579 for(nzero=0; nzero<numSec/3; nzero++) {
580 if(++counter < numMul) {
581 nt = npos+nneg+nzero;
582 if( (nt>0) && (nt<=numSec) ) {
583 protmul[counter] =
pmltpc(npos,nneg,nzero,nt,protb,c) ;
584 protnorm[nt-1] += protmul[counter];
585 }
586 }
587 }
588 }
589 }
590
591 for( i=0; i<numMul; i++ )neutmul[i] = 0.0;
592 for( i=0; i<numSec; i++ )neutnorm[i] = 0.0;
593 counter = -1;
594 for(npos=0; npos<numSec/3; npos++) {
595 for(nneg=std::max(0,npos-1); nneg<=(npos+1); nneg++) {
596 for(nzero=0; nzero<numSec/3; nzero++) {
597 if(++counter < numMul) {
598 nt = npos+nneg+nzero;
599 if( (nt>0) && (nt<=numSec) ) {
600 neutmul[counter] =
pmltpc(npos,nneg,nzero,nt,neutb,c);
601 neutnorm[nt-1] += neutmul[counter];
602 }
603 }
604 }
605 }
606 }
607
608 for(i=0; i<numSec; i++) {
609 if( protnorm[i] > 0.0 )protnorm[i] = 1.0/protnorm[i];
610 if( neutnorm[i] > 0.0 )neutnorm[i] = 1.0/neutnorm[i];
611 }
612 }
613
614
615
616 pv[0] = incidentParticle;
617 pv[1] = targetParticle;
618 vecLen = 2;
619
621 return;
622
623
624
625 npos = 0, nneg = 0, nzero = 0;
626 G4double cech[] = { 1., 1., 1., 0.70, 0.60, 0.55, 0.35, 0.25, 0.18, 0.15};
627 G4int iplab =
G4int( incidentTotalMomentum*5.);
629 G4int ipl = std::min(19,
G4int( incidentTotalMomentum*5.));
630 G4double cnk0[] = {0.17, 0.18, 0.17, 0.24, 0.26, 0.20, 0.22, 0.21, 0.34, 0.45,
631 0.58, 0.55, 0.36, 0.29, 0.29, 0.32, 0.32, 0.33, 0.33, 0.33};
633 if(targetCode == protonCode) {
634 return;
635 } else {
638 return;
639 }
640 }
641
643 if(targetCode == protonCode) {
644
645
646 if( ran < 0.25 ) {
647 ;
648 } else if (ran < 0.50) {
651 } else if (ran < 0.75) {
652 ;
653 } else {
656 }
657 } else {
658
659
660 if( ran < 0.25 ) {
663 } else if (ran < 0.50) {
666 } else if (ran < 0.75) {
669 } else {
672 }
673 }
674 return;
675
676 } else {
677
678
679 G4double aleab = std::log(availableEnergy);
680 G4double n = 3.62567+aleab*(0.665843+aleab*(0.336514
681 + aleab*(0.117712+0.0136912*aleab))) - 2.0;
682
683
684
686
687 for (nt=1; nt<=numSec; nt++) {
688 test = std::exp( std::min( expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
689 dum =
pi*nt/(2.0*
n*
n);
690 if (std::fabs(dum) < 1.0) {
691 if( test >= 1.0e-10 )anpn += dum*test;
692 } else {
693 anpn += dum*test;
694 }
695 }
696
699 if (targetCode == protonCode) {
700 counter = -1;
701 for (npos=0; npos<numSec/3; npos++) {
702 for (nneg=std::max(0,npos-2); nneg<=npos; nneg++) {
703 for (nzero=0; nzero<numSec/3; nzero++) {
704 if (++counter < numMul) {
705 nt = npos+nneg+nzero;
706 if( (nt>0) && (nt<=numSec) ) {
707 test = std::exp( std::min( expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
708 dum = (
pi/anpn)*nt*protmul[counter]*protnorm[nt-1]/(2.0*n*n);
709
710 if (std::fabs(dum) < 1.0) {
711 if( test >= 1.0e-10 )excs += dum*test;
712 } else {
713 excs += dum*test;
714 }
715
716 if (ran < excs) goto outOfLoop;
717 }
718 }
719 }
720 }
721 }
722
723 inElastic = false;
724 return;
725
726 } else {
727 counter = -1;
728 for (npos=0; npos<numSec/3; npos++) {
729 for (nneg=std::max(0,npos-1); nneg<=(npos+1); nneg++) {
730 for (nzero=0; nzero<numSec/3; nzero++) {
731 if (++counter < numMul) {
732 nt = npos+nneg+nzero;
733 if( (nt>=1) && (nt<=numSec) ) {
734 test = std::exp( std::min( expxu, std::max( expxl, -(pi/4.0)*(nt*nt)/(n*n) ) ) );
735 dum = (
pi/anpn)*nt*neutmul[counter]*neutnorm[nt-1]/(2.0*n*n);
736
737 if (std::fabs(dum) < 1.0) {
738 if( test >= 1.0e-10 )excs += dum*test;
739 } else {
740 excs += dum*test;
741 }
742
743 if (ran < excs) goto outOfLoop;
744 }
745 }
746 }
747 }
748 }
749
750 inElastic = false;
751 return;
752 }
753 }
754 outOfLoop:
755
756 if( targetCode == protonCode)
757 {
758 if( npos == nneg)
759 {
760 }
761 else if (npos == (1+nneg))
762 {
764 {
766 }
767 else
768 {
770 }
771 }
772 else
773 {
776 }
777 }
778 else
779 {
780 if( npos == nneg)
781 {
783 {
784 }
785 else
786 {
789 }
790 }
791 else if ( npos == (1+nneg))
792 {
794 }
795 else
796 {
798 }
799 }
800
801
803 {
804 if( ( (pv[0].getCode() == kaonMinusCode)
806 || ( (pv[0].
getCode() == kaonZeroCode)
807 && (pv[1].getCode() == protonCode) )
808 || ( (pv[0].
getCode() == antiKaonZeroCode)
809 && (pv[1].getCode() == protonCode) ) )
810 {
812 if( pv[1].getCode() == protonCode)
813 {
814 if(ran < 0.68)
815 {
818 }
819 else if (ran < 0.84)
820 {
823 }
824 else
825 {
828 }
829 }
830 else
831 {
832 if(ran < 0.68)
833 {
836 }
837 else if (ran < 0.84)
838 {
841 }
842 else
843 {
846 }
847 }
848 }
849 else
850 {
852 if (ran < 0.67)
853 {
856 }
857 else if (ran < 0.78)
858 {
861 }
862 else if (ran < 0.89)
863 {
866 }
867 else
868 {
871 }
872 }
873 }
874
875 nt = npos + nneg + nzero;
876 while ( nt > 0) {
879 if( npos > 0 ) {
881 npos--;
882 }
883 }
else if (ran < (
G4double)(npos+nneg)/nt) {
884 if( nneg > 0 ) {
886 nneg--;
887 }
888 } else {
889 if( nzero > 0 ) {
891 nzero--;
892 }
893 }
894 nt = npos + nneg + nzero;
895 }
896
898 G4cout <<
"Particles produced: " ;
901 for (i=2; i < vecLen; i++)
G4cout << pv[i].getName() <<
" " ;
903 }
904
905 return;
906}
G4double pmltpc(G4int np, G4int nm, G4int nz, G4int n, G4double b, G4double c)
G4double getTotalMomentum() const