60 for (
G4int i=0; i<aVecLength; i++)
155 G4double ala = std::log(atomicWeight);
156 G4double ale = std::log(incidentKineticEnergy);
161 G4double sig = (ale > em) ? sig2 : sig1;
163 G4double dum1 = -(incidentKineticEnergy)*cinem;
167 if (dum2 >= 1.) cinema = dum1*dum3;
168 else if (dum3 > 1.
e-10) cinema = dum1*dum3;
169 cinema = -
Amax(-incidentKineticEnergy, cinema);
171 G4cout <<
" NuclearInelasticity: " << ala <<
" " << ale <<
" "
172 << em <<
" " << corr <<
" " << dum1 <<
" " << dum2 <<
" "
173 << dum3 <<
" " << cinema <<
G4endl;
188 excitationEnergyGPN = 0.;
189 excitationEnergyDTA = 0.;
191 if (atomicWeight > (neutronMass + 2.*electronMass))
193 G4int magic = ((
G4int)(atomicNumber+0.1) == 82) ? 1 : 0;
195 G4double cfa =
Amax(0.35 +((0.35 - 0.05)/2.3)*std::log(ekin), 0.15);
196 exnu = 7.716*cfa*std::exp(-cfa);
198 cfa = ((atno - 1.)/120.) * std::exp(-(atno-1.)/120.);
201 G4double gfa = 2.*((atomicWeight-1.)/70.)
202 * std::exp(-(atomicWeight-1.)/70.);
204 excitationEnergyGPN = exnu * fpdiv;
205 excitationEnergyDTA = exnu - excitationEnergyGPN;
212 excitationEnergyGPN =
Amax(excitationEnergyGPN*(1.+ran1*gfa),0.);
213 excitationEnergyDTA =
Amax(excitationEnergyDTA*(1.+ran2*gfa),0.);
214 exnu = excitationEnergyGPN + excitationEnergyDTA;
216 G4cout <<
" NuclearExcitation: " << magic <<
" " << ekin
217 <<
" " << cfa <<
" " << atno <<
" " << fpdiv <<
" "
218 << gfa <<
" " << excitationEnergyGPN
219 <<
" " << excitationEnergyDTA <<
G4endl;
222 while (exnu >= incidentKineticEnergy)
224 excitationEnergyGPN *= (1. - 0.5*
normal());
225 excitationEnergyDTA *= (1. - 0.5*
normal());
226 exnu = excitationEnergyGPN + excitationEnergyDTA;
239 G4double npf = 0.0, nmf = 0.0, nzf = 0.0;
240 for(i=2;i<=npos;i++) npf += std::log((
G4double)i);
241 for(i=2;i<=nneg;i++) nmf += std::log((
G4double)i);
242 for(i=2;i<=nzero;i++) nzf += std::log((
G4double)i);
244 -(npos-nneg+nzero+b)*(npos-nneg+nzero+b)/(2*c*c*n*n)-npf-nmf-nzf));
252 if (n < 0)
G4Exception(
"G4HEInelastic::Factorial()",
"HEP000",
254 while (n > 1) result *= n--;
280 if (ran < p3) iran = 3;
281 else if ( ran < p2 ) iran = 2;
282 else if ( ran < p1 ) iran = 1;
289 for (i = 1; i <= fivex; i++) {
291 if (i > 5) rrr = std::exp(i*std::log(x)-(i+0.5)*std::log((
G4double)i)+i-0.9189385);
294 if (ran <= rr)
break;
307 G4double la = std::sqrt(2.*avalue - 1.);
308 G4double ep = 1.570796327 + std::atan(ga/la);
314 if(xtrial == 0.)
goto repeat;
315 y = std::log(1.+
sqr((xtrial-ga)/la))+ga*std::log(xtrial/ga)-xtrial+ga;
323 G4double xtrial = 0.62666*std::log((1.+ran)/(1.-ran));
325 return mvalue+xtrial*std::sqrt(
G4double(mvalue));
346 static G4double avrs[] = {3.,4.,5.,6.,7.,8.,9.,10.,20.,30.,40.,50.};
347 static G4double avkkb[] = {0.0015,0.0050,0.0120,0.0285,0.0525,0.0750,0.0975,
348 0.1230,0.2800,0.3980,0.4950,0.5730};
349 static G4double kkb[] = {0.2500,0.3750,0.5000,0.5625,0.6250,0.6875,0.7500,
351 static G4double ky[] = {0.2000,0.3000,0.4000,0.5500,0.6250,0.7000,0.8000,
352 0.8500,0.9000,0.9500,0.9750,1.0000};
353 static G4int ipakkb[] = {10,13,10,11,10,12,11,11,11,12,12,11,12,12,
355 static G4int ipaky[] = {18,10,18,11,18,12,20,10,20,11,20,12,21,10,
356 21,11,21,12,22,10,22,11,22,12};
357 static G4int ipakyb[] = {19,13,19,12,19,11,23,13,23,12,23,11,24,13,
358 24,12,24,11,25,13,25,12,25,11};
359 static G4double avky[] = {0.0050,0.0300,0.0640,0.0950,0.1150,0.1300,0.1450,
360 0.1550,0.2000,0.2050,0.2100,0.2120};
361 static G4double avnnb[] ={0.00001,0.0001,0.0006,0.0025,0.0100,0.0200,0.0400,
362 0.0500,0.1200,0.1500,0.1800,0.2000};
364 G4int i, ibin, i3, i4;
380 if (vecLen <= 2)
return;
385 while ( (i<12) && (centerOfMassEnergy > avrs[i]) )i++;
386 if ( i == 12 ) ibin = 11;
404 avk = (std::log(avkkb[ibin])-std::log(avkkb[ibin-1]))*(centerOfMassEnergy-avrs[ibin-1])
405 /(avrs[ibin]-avrs[ibin-1]) + std::log(avkkb[ibin-1]);
408 avy = (std::log(avky[ibin])-std::log(avky[ibin-1]))*(centerOfMassEnergy-avrs[ibin-1])
409 /(avrs[ibin]-avrs[ibin-1]) + std::log(avky[ibin-1]);
412 avn = (std::log(avnnb[ibin])-std::log(avnnb[ibin-1]))*(centerOfMassEnergy-avrs[ibin-1])
413 /(avrs[ibin]-avrs[ibin-1]) + std::log(avnnb[ibin-1]);
416 if ( avk+avy+avn <= 0.0 )
return;
418 if ( incidentMass < protonMass ) avy /= 2.0;
425 if ( availableEnergy < 2.0)
return;
453 else if ( ran < avk )
455 if ( availableEnergy < 1.0)
return;
458 while( (i<9) && (ran1>kkb[i]) )i++;
459 if ( i == 9 )
return;
464 switch( ipakkb[i*2] )
474 switch( ipakkb[i*2+1] )
476 case 10: pv[vecLen++] =
KaonPlus;
break;
479 case 13: pv[vecLen++] =
KaonMinus;
break;
484 switch( ipakkb[i*2+1] )
493 else if ( ran < avy )
495 if( availableEnergy < 1.6)
return;
498 while( (i<12) && (ran1>ky[i]) )i++;
499 if ( i == 12 )
return;
511 case 18: pv[1] =
Lambda;
break;
516 switch( ipaky[i*2+1] )
531 if( (incidentCode==antiprotonCode) || (incidentCode==antineutronCode) ||
532 (incidentCode==antilambdaCode) || (incidentMass>sigmaMinusMass) )
534 switch( ipakyb[i*2] )
541 switch( ipakyb[i*2+1] )
552 case 18:pv[0] =
Lambda;
break;
557 switch( ipaky[i*2+1] )
577 incidentMass = incidentParticle.
getMass();
578 targetMass = targetParticle.
getMass();
580 G4double energyCheck = centerOfMassEnergy-(incidentMass+targetMass);
583 for ( i=0; i < vecLen; i++ )
585 energyCheck -= pv[i].
getMass();
587 if( energyCheck < 0.0 )
589 if( i > 0 ) vecLen = --i;
656 if (incidentTotalMomentum < 25. +
G4UniformRand()*25.)
return;
660 G4bool annihilation =
false;
661 if (incidentCode < 0 && incidentType == antiBaryonType &&
662 pv[0].getType() != antiBaryonType &&
663 pv[1].getType() != antiBaryonType) {
667 G4double twsup[] = { 1., 1., 0.7, 0.5, 0.3, 0.2, 0.1, 0.0 };
669 if (annihilation)
goto start;
670 if (vecLen >= 8)
goto start;
671 if( incidentKineticEnergy < 1.)
return;
672 if( ( incidentCode == kaonPlusCode || incidentCode == kaonMinusCode
673 || incidentCode == kaonZeroCode || incidentCode == antiKaonZeroCode
674 || incidentCode == kaonZeroSCode || incidentCode == kaonZeroLCode )
677 if( incidentKineticEnergy > (
G4UniformRand()*200 + 50.) )
goto start;
685 incidentKineticEnergy = 2*targetMass + incidentKineticEnergy*(1.+ekcor/atomicWeight);
690 excitationEnergyDTA);
691 incidentKineticEnergy -= excitation;
692 if (incidentKineticEnergy < excitationEnergyDTA) incidentKineticEnergy = 0.;
693 incidentEnergy = incidentKineticEnergy + incidentMass;
694 incidentTotalMomentum =
695 std::sqrt(
Amax(0., incidentEnergy*incidentEnergy - incidentMass*incidentMass));
699 for (i = 2; i < vecLen; i++) {
709 if ((incidentCode==kaonPlusCode || incidentCode==kaonMinusCode ||
710 incidentCode==kaonZeroCode || incidentCode==antiKaonZeroCode ||
711 incidentCode==kaonZeroSCode || incidentCode==kaonZeroLCode)
726 if ((incidentMass >= kaonPlusMass-0.05) &&
727 (incidentCode != protonCode) && (incidentCode != neutronCode) ) {
730 if ((pMass >= kaonPlusMass-0.05) && (pCode != protonCode)
731 && (pCode != neutronCode) ) {
733 leadParticle = pv[0];
737 if ((pMass >= kaonPlusMass-0.05) && (pCode != protonCode)
738 && (pCode != neutronCode) ) {
740 leadParticle = pv[1];
756 G4double centerOfMassEnergy = std::sqrt(
sqr(incidentMass)+
sqr(targetMass)
757 +2.0*targetMass*incidentEnergy );
759 G4double tavai1 = centerOfMassEnergy/2.0 - incidentMass;
760 G4double tavai2 = centerOfMassEnergy/2.0 - targetMass;
766 for (i = 0; i < vecLen; i++) {
768 else if (i == 1) pv[i].
setSide(-1);
777 pv[i].
setTOF(incidentTOF);
782 tb = (2. * ntb + vecLen)/2.;
785 G4cout <<
" pv Vector after Randomization " << vecLen <<
G4endl;
788 for (i = 0; i < vecLen; i++) pv[i].
Print(i);
797 ss = centerOfMassEnergy*centerOfMassEnergy;
799 afc =
Amin(0.5, 0.312 + 0.200 * std::log(std::log(ss))+ std::pow(ss,1.5)/6000.0);
800 xtarg =
Amax(0.01, afc * (std::pow(atomicWeight, 0.33) - 1.0) * tb);
802 G4int momentumBin = 0;
803 G4double nucsup[] = { 1.00, 0.7, 0.5, 0.4, 0.5, 0.5 };
804 G4double psup[] = { 3., 6., 20., 50., 100., 1000. };
805 while( (momentumBin < 6) && (incidentTotalMomentum > psup[momentumBin])) momentumBin++;
806 momentumBin =
Imin(5, momentumBin);
813 G4cout <<
"xtarg= " << xtarg <<
" xpnhmf = " << xpnhmf <<
G4endl;
815 G4int nshhmf, npnhmf;
817 rshhmf = xshhmf/(rshhmf-1.);
822 xshhmf *= xhmf/rshhmf;
826 G4cout <<
"xshhmf = " << xshhmf <<
" xhmf = " << xhmf
827 <<
" rshhmf = " << rshhmf <<
G4endl;
831 rpnhmf = xpnhmf/(rpnhmf -1.);
836 xpnhmf *= xhmf/rpnhmf;
840 G4cout <<
"nshhmf = " << nshhmf <<
" npnhmf = " << npnhmf
841 <<
" nstran = " << nstran <<
G4endl;
856 pv[vecLen].
setTOF( incidentTOF );
863 if (ran < 0.14) pv[vecLen] =
Lambda;
864 else if (ran < 0.20) pv[vecLen] =
SigmaZero;
865 else if (ran < 0.43) pv[vecLen] =
KaonPlus;
866 else if (ran < 0.66) pv[vecLen] =
KaonZero;
880 pv[vecLen].
setTOF( incidentTOF );
889 else if( ran < 0.66667 )
904 pv[vecLen].
setTOF( incidentTOF );
912 G4int is, iskip, iavai1;
913 if (vecLen <= 1)
return;
915 tavai1 = centerOfMassEnergy/2.;
918 for (i = 0; i < vecLen; i++)
920 if (pv[i].getSide() > 0)
926 if ( iavai1 == 0)
return;
928 while (tavai1 <= 0.0) {
932 for (i = vecLen-1; i >= 0; i--) {
933 if (pv[i].getSide() > 0) {
938 for (j = i; j < vecLen; j++) pv[j] = pv[j+1];
940 if (--vecLen == 0)
return;
947 tavai2 = (targ+1)*centerOfMassEnergy/2.;
950 for (i = 0; i < vecLen; i++)
952 if (pv[i].getSide() < 0)
958 if (iavai2 == 0)
return;
960 while( tavai2 <= 0.0 )
964 for( i = vecLen-1; i >= 0; i-- )
966 if( pv[i].getSide() < 0 )
972 if (pv[i].getSide() == -2) ntarg--;
975 for( j=i; j<vecLen; j++)
980 if (--vecLen == 0)
return;
988 G4cout <<
" pv Vector after Energy checks "
989 << vecLen <<
" " << tavai1 <<
" " << iavai1 <<
" " << tavai2
990 <<
" " << iavai2 <<
" " << ntarg <<
G4endl;
993 for (i=0; i < vecLen ; i++) pv[i].
Print(i);
1000 pvmx[0].
setMass( incidentMass );
1004 pvmx[3].
setMass( protonMass*(1+targ));
1011 pvmx[2].
Add( pvmx[0], pvmx[1] );
1012 pvmx[3].
Add( pvmx[3], pvmx[0] );
1013 pvmx[0].
Lor( pvmx[0], pvmx[2] );
1014 pvmx[1].
Lor( pvmx[1], pvmx[2] );
1017 G4cout <<
" General Vectors after Definition " <<
G4endl;
1018 for (i=0; i<10; i++) pvmx[i].
Print(i);
1038 for (i = vecLen-1; i >= 0; i--) {
1042 if ( (pv[i].getMass() > neutronMass + 0.05) && (
G4UniformRand() < 0.2))
1052 else if ( pv[i].getMass() > protonMass - 0.05)
1063 if( pv[i].getSide() == -2)
1065 if ( pv[i].getName() ==
"Proton" || pv[i].getName() ==
"Neutron")
1080 G4double maspar[] = { 0.75, 0.70, 0.65, 0.60, 0.50, 0.40, 0.20, 0.10};
1081 G4double bp[] = { 4.00, 2.50, 2.20, 3.00, 3.00, 1.70, 3.50, 3.50};
1082 G4double ptex[] = { 1.70, 1.70, 1.50, 1.70, 1.40, 1.20, 1.70, 1.20};
1090 if (pv[i].getType() == mesonType ) j = 1;
1091 if ( pv[i].getMass() < 0.4 ) j = 0;
1092 if ( i <= 1 ) j += 3;
1093 if (pv[i].getSide() <= -2) j = 6;
1094 if (j == 6 && (pv[i].getType() == baryonType || pv[i].getType() == antiBaryonType)) j = 7;
1095 pt = std::sqrt(std::pow(-std::log(1.-
G4UniformRand())/bp[j],ptex[j]));
1099 pv[i].
setMomentum( pt*std::cos(phi), pt*std::sin(phi) );
1101 for( j=0; j<20; j++ ) binl[j] = j/(19.*pt);
1103 if( pv[i].getSide() > 0 )
1112 G4int outerCounter = 0, innerCounter = 0;
1113 G4bool eliminateThisParticle =
true;
1114 G4bool resetEnergies =
true;
1115 while( ++outerCounter < 3 )
1117 for( l=1; l<20; l++ )
1119 xval = (binl[l]+binl[l-1])/2.;
1121 dndl[l] = dndl[l-1];
1123 dndl[l] = dndl[l-1] +
1124 aspar/std::sqrt( std::pow((1.+aspar*xval*aspar*xval),3) ) *
1125 (binl[l]-binl[l-1]) * et /
1126 std::sqrt( pt*xval*et*pt*xval*et + pt*pt + pvMass*pvMass );
1132 while( ++innerCounter < 7 )
1136 while( ( ran >= dndl[l] ) && ( l < 20 ) )l++;
1139 if( pv[i].getSide() < 0 ) xval *= -1.;
1142 if( pv[i].getSide() > 0 )
1146 ekin = tavai1 - ekin1;
1147 if (ekin < 0.) ekin = 0.04*std::fabs(
normal());
1151 G4double pp = std::sqrt(ekin*(ekin+2*pvMass));
1152 pp =
Amax(0., pp*pp - pt*pt);
1153 pp = std::sqrt(pp)*pv[i].
getSide()/std::fabs(
G4double(pv[i].getSide()));
1161 pvmx[4].
Add( pvmx[4], pv[i]);
1163 resetEnergies =
false;
1164 eliminateThisParticle =
false;
1167 else if( (ekin1+pvEnergy-pvMass) < 0.95*tavai1 )
1169 pvmx[4].
Add( pvmx[4], pv[i] );
1170 ekin1 += pvEnergy - pvMass;
1171 pvmx[6].
Add( pvmx[4], pvmx[5] );
1174 eliminateThisParticle =
false;
1175 resetEnergies =
false;
1178 if( innerCounter > 5 )
break;
1180 if( tavai2 >= pvMass )
1190 xval =
Amin(0.999,0.95+0.05*targ/20.0);
1191 if( (ekin2+pvEnergy-pvMass) < xval*tavai2 )
1193 pvmx[5].
Add( pvmx[5], pv[i] );
1194 ekin2 += pvEnergy - pvMass;
1195 pvmx[6].
Add( pvmx[4], pvmx[5] );
1198 eliminateThisParticle =
false;
1199 resetEnergies =
false;
1202 if( innerCounter > 5 )
break;
1204 if( tavai1 >= pvMass )
1213 pv[i].getMomentum().
y() * 0.9);
1221 G4cout <<
" Reset energies for index " << i <<
" "
1222 << ekin1 <<
" " << tavai1 <<
G4endl;
1230 for( l=i+1; l < vecLen; l++ )
1232 if( (pv[l].getMass() < protonMass) || (pv[l].getSide() > 0) )
1236 if( pv[l].getSide() > 0)
1239 pvmx[4].
Add( pvmx[4], pv[l] );
1244 pvmx[5].
Add( pvmx[5], pv[l] );
1251 if (eliminateThisParticle) {
1257 if (i != vecLen-1) {
1259 for (j = i; j < vecLen-1; j++) pv[j] = pv[j+1];
1268 pvmx[6].
Add( pvmx[4], pvmx[5] );
1274 G4cout <<
" pv Vector after lambda fragmentation " << vecLen <<
G4endl;
1277 for (i=0; i < vecLen ; i++) pv[i].
Print(i);
1278 for (i=0; i < 10; i++) pvmx[i].
Print(i);
1283 G4double gpar[] = {2.6, 2.6, 1.80, 1.30, 1.20};
1284 G4double cpar[] = {0.6, 0.6, 0.35, 0.15, 0.10};
1290 if (npg1 >4) npg1 = 4;
1291 rmg += std::pow( -std::log(1.-
G4UniformRand()), cpar[npg1])/gpar[npg1];
1294 G4double ekit1 = 0.04, ekit2 = 0.6;
1295 if (incidentKineticEnergy < 5.) {
1296 ekit1 *=
sqr(incidentKineticEnergy)/25.;
1297 ekit2 *=
sqr(incidentKineticEnergy)/25.;
1299 G4double avalue = (1.-ga)/(std::pow(ekit2,1.-ga)-std::pow(ekit1,1.-ga));
1300 for (i = 0; i < vecLen; i++) {
1301 if (pv[i].getSide() == -3) {
1304 G4double sint = std::sqrt(1. - cost*cost);
1306 G4double pp = std::sqrt(ekit*(ekit+2*pv[i].getMass()));
1308 pp*sint*std::cos(pphi),
1310 pv[i].
Lor( pv[i], pvmx[2] );
1311 pvmx[5].
Add( pvmx[5], pv[i] );
1325 for( i=0; i < vecLen; i++ )
1327 if( pv[i].getType() == baryonType )targ++;
1328 if( pv[i].getType() == antiBaryonType )targ--;
1330 pv[i].
Lor( pv[i], pvmx[1] );
1333 if ( targ <1) targ = 1;
1338 for( i=0; i<vecLen; i++ )
1340 if( pv[i].getCode() == lead )
1350 if( ( (leadParticle.
getType() == baryonType ||
1351 leadParticle.
getType() == antiBaryonType)
1352 && (pv[1].getType() == baryonType ||
1353 pv[1].
getType() == antiBaryonType))
1354 || ( (leadParticle.
getType() == mesonType)
1355 && (pv[1].getType() == mesonType)))
1360 pv[i] = leadParticle;
1361 if( pv[i].getFlag() )
1369 pvmx[3].
setMass( incidentMass);
1374 pvmx[4].
setMass( protonMass * targ);
1380 pvmx[5].
Add( pvmx[3], pvmx[4] );
1381 pvmx[3].
Lor( pvmx[3], pvmx[5] );
1382 pvmx[4].
Lor( pvmx[4], pvmx[5] );
1391 for( i=0; i < vecLen; i++ )
1393 pvmx[7].
Add( pvmx[7], pv[i] );
1398 if( vecLen > 1 && vecLen < 19 )
1400 G4bool constantCrossSection =
true;
1402 for(i=0; i<vecLen; i++) pw[i] = pv[i];
1405 for( i=0; i < vecLen; i++ )
1407 pvmx[6].
setMass( pw[i].getMass());
1410 pvmx[6].
Lor( pvmx[6], pvmx[4] );
1413 teta = pvmx[7].
Ang( pvmx[3] );
1415 G4cout <<
" vecLen > 1 && vecLen < 19 " << teta <<
" " << ekin0
1416 <<
" " << ekin1 <<
" " << ekin <<
G4endl;
1424 for( i=0; i < vecLen; i++ )
1430 pvmx[6].
Add( pvmx[6], pv[i] );
1432 teta = pvmx[6].
Ang( pvmx[3] );
1434 G4cout <<
" ekin1 != 0 " << teta <<
" " << ekin0 <<
" "
1436 incidentParticle.
Print(0);
1437 targetParticle.
Print(1);
1438 for(i=0;i<vecLen;i++) pv[i].
Print(i);
1447 G4double a1 = std::sqrt(-2.0*std::log(ry));
1451 for (i = 0; i < vecLen; i++)
1452 pv[i].setMomentum( pv[i].getMomentum().
x()+rantarg1,
1453 pv[i].getMomentum().
y()+rantarg2 );
1457 for (i = 0; i < vecLen; i++) pvmx[6].Add( pvmx[6], pv[i] );
1458 teta = pvmx[6].
Ang( pvmx[3] );
1473 G4double cfa = 0.025*((atomicWeight-1.)/120.)*std::exp(-(atomicWeight-1.)/120.);
1474 G4double alem[] = {1.40, 2.30, 2.70, 3.00, 3.40, 4.60, 7.00, 10.00};
1475 G4double val0[] = {0.00, 0.40, 0.48, 0.51, 0.54, 0.60, 0.65, 0.70};
1478 G4cout <<
" Rotation in Direction of primary particle (Defs1)" <<
G4endl;
1480 for (i = 0; i < vecLen; i++) {
1482 pv[i].
Defs1( pv[i], pvI );
1484 if (atomicWeight > 1.5) {
1485 ekin =
Amax( 1.
e-6,pv[i].getKineticEnergy() - cfa*( 1. + 0.5*
normal()));
1486 alekw = std::log( incidentKineticEnergy );
1488 if (incidentCode == pionPlusCode || incidentCode == pionMinusCode) {
1489 if (pv[i].getCode() == pionZeroCode) {
1491 if (alekw > alem[0]) {
1493 for (j = 1; j < 8; j++) {
1494 if (alekw < alem[j]) {
1499 xxh = (val0[
jmax]-val0[jmax-1])/(alem[jmax]-alem[jmax-1])*alekw
1500 + val0[jmax-1] - (val0[
jmax]-val0[jmax-1])/(alem[jmax]-alem[jmax-1])*alem[jmax-1];
1506 dekin += ekin*(1.-xxh);
1510 if ((pvCode == pionPlusCode) ||
1511 (pvCode == pionMinusCode) ||
1512 (pvCode == pionZeroCode)) {
1519 if ( (ek1 > 0.0) && (npions > 0) ) {
1520 dekin = 1.+dekin/ek1;
1521 for (i = 0; i < vecLen; i++) {
1523 if ((pvCode == pionPlusCode) ||
1524 (pvCode == pionMinusCode) ||
1525 (pvCode == pionZeroCode)) {
1526 ekin =
Amax(1.0
e-6, pv[i].getKineticEnergy() * dekin);
1533 G4cout <<
" Lab-System " << ek1 <<
" " << npions <<
G4endl;
1534 incidentParticle.
Print(0);
1535 targetParticle.
Print(1);
1536 for (i = 0; i < vecLen; i++) pv[i].
Print(i);
1544 G4cout <<
" Evaporation : " << atomicWeight <<
" "
1545 << excitationEnergyGNP <<
" " << excitationEnergyDTA <<
G4endl;
1548 if (incidentKineticEnergy > 5.)
1550 sprob =
Amin(1., 0.000314*atomicWeight*std::log(incidentKineticEnergy-4.));
1555 G4int spall(0), nbl(0);
1559 if( excitationEnergyGNP >= 0.001 )
1564 nbl =
Poisson( (1.5+1.25*targ)*excitationEnergyGNP/
1565 (excitationEnergyGNP+excitationEnergyDTA));
1566 if( targ+nbl > atomicWeight ) nbl = (
int)(atomicWeight - targ);
1568 G4cout <<
" evaporation " << targ <<
" " << nbl <<
" "
1573 ekin = (excitationEnergyGNP)/nbl;
1575 for( i=0; i<nbl; i++ )
1582 if( ekin2 > excitationEnergyGNP)
break;
1584 ekin1 = -ekin*std::log(ran) - cfa*(1.0+0.5*
normal());
1585 if (ekin1 < 0) ekin1 = -0.010*std::log(ran);
1587 if( ekin2 > excitationEnergyGNP)
1588 ekin1 =
Amax( 1.0
e-6, excitationEnergyGNP-(ekin2-ekin1) );
1595 sint = std::sqrt(std::fabs(1.0-cost*cost));
1599 pv[vecLen].
setTOF( 1.0 );
1600 pvMass = pv[vecLen].
getMass();
1601 pvEnergy = ekin1 + pvMass;
1602 pp = std::sqrt( std::fabs( pvEnergy*pvEnergy - pvMass*pvMass ) );
1604 pp*sint*std::cos(phi),
1609 if( (atomicWeight >= 10.0 ) && (incidentKineticEnergy <= 2.0) )
1612 eka = incidentKineticEnergy;
1613 if( eka > 1.0 )eka *= eka;
1614 eka =
Amax( 0.1, eka );
1615 ika =
G4int(3.6*std::exp((atomicNumber*atomicNumber
1616 /atomicWeight-35.56)/6.45)/eka);
1619 for( i=(vecLen-1); i>=0; i-- )
1621 if( (pv[i].getCode() == protonCode) && pv[i].getFlag() )
1627 if( ++kk > ika )
break;
1638 if( excitationEnergyDTA >= 0.001 )
1640 nbl =
Poisson( (1.5+1.25*targ)*excitationEnergyDTA
1641 /(excitationEnergyGNP+excitationEnergyDTA));
1646 G4cout <<
" evaporation " << targ <<
" " << nbl <<
" "
1650 ekin = excitationEnergyDTA/nbl;
1652 for( i=0; i<nbl; i++ )
1659 if( ekin2 > excitationEnergyDTA)
break;
1661 ekin1 = -ekin*std::log(ran)-cfa*(1.+0.5*
normal());
1662 if( ekin1 < 0.0 ) ekin1 = -0.010*std::log(ran);
1664 if( ekin2 > excitationEnergyDTA)
1665 ekin1 =
Amax( 1.0
e-6, excitationEnergyDTA-(ekin2-ekin1));
1667 sint = std::sqrt(std::fabs(1.0-cost*cost));
1672 else if (ran <= 0.90)
1676 spall += (
int)(pv[vecLen].getMass() * 1.066);
1677 if( spall > atomicWeight )
break;
1680 pvMass = pv[vecLen].
getMass();
1681 pv[vecLen].
setTOF( 1.0 );
1682 pvEnergy = pvMass + ekin1;
1683 pp = std::sqrt( std::fabs( pvEnergy*pvEnergy - pvMass*pvMass ) );
1685 pp*sint*std::cos(phi),
1695 for( i=0; i<vecLen; i++ )
1698 if( etb >= incidentKineticEnergy )
1704 {
G4cout <<
"Call TuningOfHighEnergyCacsading vecLen = " << vecLen <<
G4endl;
1705 incidentParticle.
Print(0);
1706 targetParticle.
Print(1);
1707 for (i=0; i<vecLen; i++) pv[i].
Print(i);
1711 incidentParticle, targetParticle,
1712 atomicWeight, atomicNumber);
1716 for(i=0; i<vecLen; i++) pv[i].
Print(i);
1722 if( (atomicWeight >= 1.5) && (atomicWeight <= 230.0)
1723 && (incidentKineticEnergy <= 0.2) )
1724 tof -= 500.0 * std::exp(-incidentKineticEnergy /0.04) * std::log(
G4UniformRand() );
1726 for(i=0; i<vecLen; i++)
1728 if(pv[i].getName() ==
"KaonZero" || pv[i].getName() ==
"AntiKaonZero")
1741 for(testCurr=0; testCurr<vecLen; testCurr++)
1744 if(totKin>incidentKineticEnergy*1.05)
1777 G4double reden = -0.7 + 0.29*std::log10(incidentKineticEnergy);
1780 G4double redat = 0.722 - 0.278*std::log10(atomicWeight);
1791 && (std::fabs(incidentCharge) > 0.) )
1793 for (i=0; i < vecLen; i++)
1799 pmax = ppp; ipmax = i;
1801 if (iphmf == pionPlusCode && ppp > pmapip )
1803 pmapip = ppp; maxpip = i;
1805 else if (iphmf == pionZeroCode && ppp > pmapi0)
1807 pmapi0 = ppp; maxpi0 = i;
1809 else if (iphmf == pionMinusCode && ppp > pmapim)
1811 pmapim = ppp; maxpim = i;
1817 G4cout <<
"ipmax, pmax " << ipmax <<
" " << pmax <<
G4endl;
1818 G4cout <<
"maxpip,pmapip " << maxpip <<
" " << pmapip <<
G4endl;
1819 G4cout <<
"maxpi0,pmapi0 " << maxpi0 <<
" " << pmapi0 <<
G4endl;
1820 G4cout <<
"maxpim,pmapim " << maxpim <<
" " << pmapim <<
G4endl;
1825 for (i=2; i<vecLen; i++)
1828 if ( ((iphmf==protonCode)||(iphmf==neutronCode)||(pv[i].getType()==
"Nucleus"))
1829 && (pv[i].Length()<1.5)
1841 if (maxpi0 == ipmax)
1845 if ((incidentCharge > 0.5) && (maxpip != 0))
1852 G4cout <<
" exchange Momentum for " << maxpi0 <<
" and " << maxpip <<
G4endl;
1855 else if ((incidentCharge < -0.5) && (maxpim != 0))
1862 G4cout <<
" exchange Momentum for " << maxpi0 <<
" and " << maxpip <<
G4endl;
1868 for (i=0; i<vecLen; i++) bntot += pv[i].getBaryonNumber();
1869 if(atomicWeight < 1.5) { bntot = 0.; }
1870 else { bntot = 1. + bntot/atomicWeight; }
1874 G4cout <<
" Calculated Baryon- Number " << bntot <<
G4endl;
1878 for (i=0; i<vecLen; i++)
1885 && ((iphmf == protonCode) || (iphmf == neutronCode)
1886 || (pv[i].getType() ==
"Nucleus") )
1908 pvmx[0] = incidentParticle;
1909 pvmx[1] = targetParticle;
1911 pvmx[2].
Add(pvmx[0], pvmx[1]);
1912 pvmx[3].
Lor(pvmx[0], pvmx[2]);
1913 pvmx[4].
Lor(pvmx[1], pvmx[2]);
1917 incidentParticle.
Print(0);
1919 targetParticle.
Print(1);
1934 if (incidentParticle.
getName() ==
"KaonZeroShort" ||
1935 incidentParticle.
getName() ==
"KaonZeroLong") {
1945 for (i=0; i<vecLen; i++) {
1950 pvmx[5].
Lor( pv[i], pvmx[2] );
1959 if (pv[i].getName() ==
"KaonZeroShort" ||
1960 pv[i].getName() ==
"KaonZeroLong") {
1970 reddec[0] = std::fabs( incidentMass - pv[i].getMass() );
1971 reddec[1] = std::fabs( incidentCharge - pv[i].getCharge());
1972 reddec[2] = std::fabs(
G4double(incidentS - particleS) );
1973 reddec[3] = std::fabs(
G4double(incidentB - particleB) );
1974 hfmass = incidentMass;
1977 reddec[0] = std::fabs( targetMass - pv[i].getMass() );
1978 reddec[1] = std::fabs( atomicNumber/atomicWeight - pv[i].getCharge());
1979 reddec[2] = std::fabs(
G4double(particleS) );
1980 reddec[3] = std::fabs( 1. - particleB );
1981 hfmass = targetMass;
1984 reddec[5] = reddec[0]+reddec[1]+reddec[2]+reddec[3];
1987 sbqwgt = (sbqwgt-2.5)*0.10;
1988 if(pv[i].getCode() == pionZeroCode) sbqwgt = 0.15;
1989 }
else if (hfmass < 0.6) {
1990 sbqwgt = (sbqwgt-3.0)*0.10;
1992 sbqwgt = (sbqwgt-2.0)*0.10;
1993 if(pv[i].getCode() == pionZeroCode) sbqwgt = 0.15;
2001 if (sbqwgt > 0. && ppp > 1.
e-6) {
2002 G4double pthmf = ppp*std::sqrt(1.-cost*cost);
2003 G4double plhmf = ppp*cost*(1.-sbqwgt);
2004 pvmx[7].
Cross( pvmx[3], pvmx[5] );
2005 pvmx[7].
Cross( pvmx[7], pvmx[3] );
2007 if (pvmx[3].Length() > 0.)
2010 G4cout <<
"NaNQ in Tuning of High Energy Hadronic Interactions" <<
G4endl;
2012 if (pvmx[7].Length() > 0.)
2015 G4cout <<
"NaNQ in Tuning of High Energy Hadronic Interactions" <<
G4endl;
2017 pvmx[5].
Add3(pvmx[6], pvmx[7] );
2018 pvmx[5].
setEnergy( std::sqrt(
sqr(pvmx[5].Length()) +
sqr(pv[i].getMass())));
2019 pv[i].
Lor( pvmx[5], pvmx[4] );
2031 if (incidentS != 0) ss = 0;
2032 if (iphmf != pionZeroCode && pv[i].getSide() > ss) {
2033 pvmx[7].
Sub3( incidentParticle, pv[i] );
2034 reddec[4] = pvmx[7].
Length()/incidentTotalMomentum;
2035 reddec[6] = reddec[4]*2./3. + reddec[5]/12.;
2036 reddec[6] =
Amax(0., 1. - reddec[6]);
2037 if ( (reddec[5] <= 3.75) && (reddec[6] > redpar) ) {
2043 pvmx[8].
Add3(pvmx[8], pv[i] );
2046 if(
false)
if (ledpar >= 0)
2050 G4cout <<
" Leading Particle found : " << ledpar <<
G4endl;
2051 pv[ledpar].
Print(ledpar);
2053 incidentParticle.
Print(-1);
2055 pvmx[4].
Sub3(incidentParticle,pvmx[8]);
2056 pvmx[5].
Smul(incidentParticle, incidentParticle.
CosAng(pvmx[4])
2058 pv[ledpar].
Add3(pv[ledpar],pvmx[5]);
2063 pv[ledpar].
Print(ledpar);
2069 for (i=0; i<vecLen; i++) {
2071 if(pv[i].getMass() < 0.7) ekinhf += pv[i].
getMass();
2073 if(incidentParticle.
getMass() < 0.7) ekinhf -= incidentParticle.
getMass();
2077 for (i=0; i<vecLen; i++)
2078 pv[i].setKineticEnergyAndUpdate(ekinhf*pv[i].getKineticEnergy());
2085 if(ekinhf < 0.) ekinhf = 0.;
2140 G4cout <<
" G4HEInelastic::HighEnergyClusterProduction " <<
G4endl;
2143 if (incidentTotalMomentum < 25. +
G4UniformRand()*25.)
return;
2145 G4double centerOfMassEnergy = std::sqrt(
sqr(incidentMass) +
sqr(targetMass)
2146 +2.*targetMass*incidentEnergy);
2167 for (i = 0; i < vecLen; i++) {
2188 if ( ( (incidentCode == protonCode) || (incidentCode == neutronCode)
2189 || (incidentType == mesonType) )
2190 && ( (pvCode == pionPlusCode) || (pvCode == pionMinusCode) )
2199 pv[i].
setTOF( incidentTOF );
2203 if (centerOfMassEnergy < (2+
G4UniformRand())) tb = (2.*iback + vecLen)/2.;
2205 G4double nucsup[] = {1.0, 0.7, 0.5, 0.4, 0.35, 0.3};
2206 G4double psup[] = {3. , 6. , 20., 50., 100.,1000.};
2207 G4double ss = centerOfMassEnergy*centerOfMassEnergy;
2209 G4double xtarg =
Amax(0.01,
Amin(0.50, 0.312+0.2*std::log(std::log(ss))+std::pow(ss,1.5)/6000.)
2210 * (std::pow(atomicWeight,0.33)-1.) * tb);
2211 G4int momentumBin = 0;
2212 while( (momentumBin < 6) && (incidentTotalMomentum > psup[momentumBin])) momentumBin++;
2213 momentumBin =
Imin(5, momentumBin);
2214 G4double xpnhmf =
Amax(0.01,xtarg*nucsup[momentumBin]);
2219 G4int nshhmf, npnhmf;
2222 rshhmf = xshhmf/(rshhmf-1.);
2227 xshhmf *= xhmf/rshhmf;
2232 rpnhmf = xpnhmf/(rpnhmf -1.);
2237 xpnhmf *= xhmf/rpnhmf;
2250 pv[vecLen].
setTOF( incidentTOF );
2257 if (ran < 0.333333 )
2259 else if (ran < 0.6667)
2265 pv[vecLen].
setTOF( incidentTOF );
2277 if( (incidentMass >= kaonPlusMass-0.05) && (incidentCode != protonCode)
2278 && (incidentCode != neutronCode) )
2282 if( (pMass >= kaonPlusMass-0.05) && (pCode != protonCode)
2283 && (pCode != neutronCode) )
2286 leadParticle = pv[0];
2292 if( (pMass >= kaonPlusMass-0.05) && (pCode != protonCode)
2293 && (pCode != neutronCode) )
2296 leadParticle = pv[1];
2302 {
G4cout <<
" pv Vector after initialization " << vecLen <<
G4endl;
2305 for (i=0; i < vecLen ; i++) pv[i].
Print(i);
2309 for(i=0;i<vecLen;i++)
if(pv[i].getSide() != -2) tavai += pv[i].
getMass();
2311 while (tavai > centerOfMassEnergy)
2313 for (i=vecLen-1; i >= 0; i--)
2315 if (pv[i].getSide() != -2)
2320 for (j=i; j < vecLen; j++)
2340 G4double rmc0 = 0., rmd0 = 0., rme0 = 0.;
2341 G4int ntc = 0, ntd = 0, nte = 0;
2343 for (i=0; i < vecLen; i++)
2345 if(pv[i].getSide() > 0)
2368 else if (pv[i].getSide() == -1)
2389 G4double cpar[] = {0.6, 0.6, 0.35, 0.15, 0.10};
2390 G4double gpar[] = {2.6, 2.6, 1.80, 1.30, 1.20};
2392 G4double rmc = rmc0, rmd = rmd0, rme = rme0;
2396 if (ntc > 1) rmc = rmc0 + std::pow(-std::log(1.-
G4UniformRand()),cpar[ntc1])/gpar[ntc1];
2397 if (ntd > 1) rmd = rmd0 + std::pow(-std::log(1.-
G4UniformRand()),cpar[ntd1])/gpar[ntd1];
2398 if (nte > 1) rme = rme0 + std::pow(-std::log(1.-
G4UniformRand()),cpar[nte1])/gpar[nte1];
2399 while( (rmc+rmd) > centerOfMassEnergy)
2401 if ((rmc == rmc0) && (rmd == rmd0))
2403 rmd *= 0.999*centerOfMassEnergy/(rmc+rmd);
2404 rmc *= 0.999*centerOfMassEnergy/(rmc+rmd);
2408 rmc = 0.1*rmc0 + 0.9*rmc;
2409 rmd = 0.1*rmd0 + 0.9*rmd;
2413 G4cout <<
" Cluster Masses: " << ntc <<
" " << rmc <<
" " << ntd
2414 <<
" " << rmd <<
" " << nte <<
" " << rme <<
G4endl;
2418 pvmx[1].
setMass( incidentMass);
2422 pvmx[0].
Add( pvmx[1], pvmx[2] );
2423 pvmx[1].
Lor( pvmx[1], pvmx[0] );
2424 pvmx[2].
Lor( pvmx[2], pvmx[0] );
2427 - 4*
sqr(centerOfMassEnergy)*rmd*rmd))/(2.*centerOfMassEnergy);
2430 pvmx[3].
setEnergy( std::sqrt(pf*pf + rmc*rmc) );
2431 pvmx[4].
setEnergy( std::sqrt(pf*pf + rmd*rmd) );
2434 G4double bvalue =
Amax(0.01, 4.0 + 1.6*std::log(incidentTotalMomentum));
2435 if (bvalue != 0.0) tvalue = std::log(
G4UniformRand())/bvalue;
2437 G4double tacmin =
sqr( pvmx[1].getEnergy() - pvmx[3].getEnergy()) -
sqr( pin - pf);
2442 pf * stet * std::cos(phi),
2444 pvmx[4].
Smul( pvmx[3], -1.);
2451 if (incidentKineticEnergy <= 5.)
2453 ekit1 *=
sqr(incidentKineticEnergy)/25.;
2454 ekit2 *=
sqr(incidentKineticEnergy)/25.;
2456 G4double avalue = (1.-gaval)/(std::pow(ekit2, 1.-gaval)-std::pow(ekit1, 1.-gaval));
2457 for (i=0; i < vecLen; i++)
2459 if (pv[i].getSide() == -2)
2465 stet = std::sqrt(
Amax( 0.0, 1. - ctet*ctet ));
2469 pp * stet * std::cos(phi),
2471 pv[i].
Lor( pv[i], pvmx[0] );
2481 G4cout <<
" General vectors before Phase space Generation " <<
G4endl;
2482 for (i=0; i<7; i++) pvmx[i].
Print(i);
2486 G4bool constantCrossSection =
true;
2493 for (i=0; i < vecLen; i++)
2495 if (pv[i].getSide() > 0)
2497 tempV[npg++] = pv[i];
2500 wgt =
NBodyPhaseSpace( pvmx[3].getMass(), constantCrossSection, tempV, npg);
2503 for (i=0; i < vecLen; i++)
2505 if (pv[i].getSide() > 0)
2509 pv[i].
Lor( pv[i], pvmx[5] );
2515 for(i=0; i<vecLen; i++)
2527 for (i=0; i < vecLen; i++)
2529 if (pv[i].getSide() == -1)
2531 tempV[npg++] = pv[i];
2534 wgt =
NBodyPhaseSpace( pvmx[4].getMass(), constantCrossSection, tempV, npg);
2537 for (i=0; i < vecLen; i++)
2539 if (pv[i].getSide() == -1)
2543 pv[i].
Lor( pv[i], pvmx[6] );
2549 for(i=0; i<vecLen; i++)
2560 G4cout <<
" Vectors after PhaseSpace generation " <<
G4endl;
2561 for(i=0; i<vecLen; i++) pv[i].
Print(i);
2567 for( i=0; i < vecLen; i++ )
2569 if( pv[i].getType() == baryonType )targ++;
2570 if( pv[i].getType() == antiBaryonType )targ--;
2571 pv[i].
Lor( pv[i], pvmx[2] );
2573 if (targ<1) targ = 1;
2577 for(i=0; i<vecLen; i++) pv[i].
Print(i);
2585 for( i=0; i<vecLen; i++ )
2587 if( pv[i].getCode() == lead )
2597 if( ( (leadParticle.
getType() == baryonType ||
2598 leadParticle.
getType() == antiBaryonType)
2599 && (pv[1].getType() == baryonType ||
2600 pv[1].
getType() == antiBaryonType))
2601 || ( (leadParticle.
getType() == mesonType)
2602 && (pv[1].getType() == mesonType)))
2608 pv[i] = leadParticle;
2609 if( pv[i].getFlag() )
2617 pvmx[4].
setMass( incidentMass);
2622 pvmx[5].
setMass ( protonMass * targ);
2629 pvmx[6].
Add( pvmx[4], pvmx[5] );
2630 pvmx[4].
Lor( pvmx[4], pvmx[6] );
2631 pvmx[5].
Lor( pvmx[5], pvmx[6] );
2639 for( i=0; i < vecLen; i++ )
2641 pvmx[8].
Add( pvmx[8], pv[i] );
2646 if( vecLen > 1 && vecLen < 19 )
2648 constantCrossSection =
true;
2650 for(i=0;i<vecLen;i++) pw[i] = pv[i];
2653 for( i=0; i < vecLen; i++ )
2655 pvmx[7].
setMass( pw[i].getMass());
2658 pvmx[7].
Lor( pvmx[7], pvmx[5] );
2661 teta = pvmx[8].
Ang( pvmx[4] );
2663 G4cout <<
" vecLen > 1 && vecLen < 19 " << teta <<
" "
2664 << ekin0 <<
" " << ekin1 <<
" " << ekin <<
G4endl;
2672 for( i=0; i < vecLen; i++ )
2678 pvmx[7].
Add( pvmx[7], pv[i] );
2680 teta = pvmx[7].
Ang( pvmx[4] );
2682 G4cout <<
" ekin1 != 0 " << teta <<
" " << ekin0 <<
" "
2689 for(i=0; i<vecLen; i++) pv[i].
Print(i);
2697 G4double a1 = std::sqrt(-2.0*std::log(ry));
2701 for (i = 0; i < vecLen; i++)
2702 pv[i].setMomentum(pv[i].getMomentum().
x()+rantarg1,
2703 pv[i].getMomentum().
y()+rantarg2);
2707 for (i = 0; i < vecLen; i++) pvmx[7].Add( pvmx[7], pv[i] );
2708 teta = pvmx[7].
Ang( pvmx[4] );
2723 G4double cfa = 0.025*((atomicWeight-1.)/120.)*std::exp(-(atomicWeight-1.)/120.);
2724 G4double alem[] = {1.40, 2.30, 2.70, 3.00, 3.40, 4.60, 7.00, 10.0};
2725 G4double val0[] = {0.00, 0.40, 0.48, 0.51, 0.54, 0.60, 0.65, 0.70};
2727 for (i = 0; i < vecLen; i++) {
2728 pv[i].
Defs1( pv[i], pvI );
2729 if (atomicWeight > 1.5) {
2730 ekin =
Amax( 1.
e-6,pv[i].getKineticEnergy() - cfa*( 1. + 0.5*
normal()));
2731 alekw = std::log( incidentKineticEnergy );
2733 if (incidentCode == pionPlusCode || incidentCode == pionMinusCode) {
2734 if (pv[i].getCode() == pionZeroCode) {
2736 if (alekw > alem[0]) {
2738 for (j = 1; j < 8; j++) {
2739 if (alekw < alem[j]) {
2744 xxh = (val0[
jmax]-val0[jmax-1])/(alem[jmax]-alem[jmax-1])*alekw
2745 + val0[jmax-1] - (val0[
jmax]-val0[jmax-1])/(alem[jmax]-alem[jmax-1])*alem[jmax-1];
2751 dekin += ekin*(1.-xxh);
2755 if ((pvCode == pionPlusCode) ||
2756 (pvCode == pionMinusCode) ||
2757 (pvCode == pionZeroCode)) {
2764 if( (ek1 > 0.0) && (npions > 0) )
2766 dekin = 1.+dekin/ek1;
2767 for (i = 0; i < vecLen; i++)
2770 if((pvCode == pionPlusCode) || (pvCode == pionMinusCode) || (pvCode == pionZeroCode))
2772 ekin =
Amax( 1.0
e-6, pv[i].getKineticEnergy() * dekin );
2778 {
G4cout <<
" Lab-System " << ek1 <<
" " << npions <<
G4endl;
2779 for (i=0; i<vecLen; i++) pv[i].
Print(i);
2787 G4cout <<
" Evaporation " << atomicWeight <<
" " << excitationEnergyGNP
2788 <<
" " << excitationEnergyDTA <<
G4endl;
2791 if (incidentKineticEnergy > 5. )
2793 sprob =
Amin(1., 0.000314*atomicWeight*std::log(incidentKineticEnergy-4.));
2798 G4int spall(0), nbl(0);
2802 if( excitationEnergyGNP >= 0.001 )
2807 nbl =
Poisson( (1.5+1.25*targ)*excitationEnergyGNP/
2808 (excitationEnergyGNP+excitationEnergyDTA));
2809 if( targ+nbl > atomicWeight ) nbl = (
int)(atomicWeight - targ);
2811 G4cout <<
" evaporation " << targ <<
" " << nbl <<
" "
2816 ekin = excitationEnergyGNP/nbl;
2818 for( i=0; i<nbl; i++ )
2821 if( ekin2 > excitationEnergyGNP)
break;
2823 ekin1 = -ekin*std::log(ran) - cfa*(1.0+0.5*
normal());
2824 if (ekin1 < 0) ekin1 = -0.010*std::log(ran);
2826 if( ekin2 > excitationEnergyGNP)
2827 ekin1 =
Amax( 1.0
e-6, excitationEnergyGNP-(ekin2-ekin1) );
2834 sint = std::sqrt(std::fabs(1.0-cost*cost));
2838 pvMass = pv[vecLen].
getMass();
2839 pv[vecLen].
setTOF( 1.0 );
2840 pvEnergy = ekin1 + pvMass;
2841 pp = std::sqrt( std::fabs( pvEnergy*pvEnergy - pvMass*pvMass ) );
2843 pp*sint*std::cos(phi),
2848 if( (atomicWeight >= 10.0 ) && (incidentKineticEnergy <= 2.0) )
2851 eka = incidentKineticEnergy;
2852 if( eka > 1.0 )eka *= eka;
2853 eka =
Amax( 0.1, eka );
2854 ika =
G4int(3.6*std::exp((atomicNumber*atomicNumber
2855 /atomicWeight-35.56)/6.45)/eka);
2858 for( i=(vecLen-1); i>=0; i-- )
2860 if( (pv[i].getCode() == protonCode) && pv[i].getFlag() )
2866 if( ++kk > ika )
break;
2877 if( excitationEnergyDTA >= 0.001 )
2879 nbl =
Poisson( (1.5+1.25*targ)*excitationEnergyDTA
2880 /(excitationEnergyGNP+excitationEnergyDTA));
2886 ekin = excitationEnergyDTA/nbl;
2888 for( i=0; i<nbl; i++ )
2891 if( ekin2 > excitationEnergyDTA)
break;
2893 ekin1 = -ekin*std::log(ran)-cfa*(1.+0.5*
normal());
2894 if( ekin1 < 0.0 ) ekin1 = -0.010*std::log(ran);
2896 if( ekin2 > excitationEnergyDTA )
2897 ekin1 =
Amax( 1.0
e-6, excitationEnergyDTA-(ekin2-ekin1));
2899 sint = std::sqrt(std::fabs(1.0-cost*cost));
2904 else if (ran <= 0.90)
2908 spall += (
int)(pv[vecLen].getMass() * 1.066);
2909 if( spall > atomicWeight )
break;
2912 pvMass = pv[vecLen].
getMass();
2913 pv[vecLen].
setTOF( 1.0 );
2914 pvEnergy = pvMass + ekin1;
2915 pp = std::sqrt( std::fabs( pvEnergy*pvEnergy - pvMass*pvMass ) );
2917 pp*sint*std::cos(phi),
2927 for( i=0; i<vecLen; i++ )
2930 if( etb >= incidentKineticEnergy )
2936 incidentParticle, targetParticle,
2937 atomicWeight, atomicNumber);
2942 if( (atomicWeight >= 1.5) && (atomicWeight <= 230.0)
2943 && (incidentKineticEnergy <= 0.2) )
2944 tof -= 500.0 * std::exp(-incidentKineticEnergy /0.04) * std::log(
G4UniformRand() );
2945 for ( i=0; i < vecLen; i++)
2952 for(i=0; i<vecLen; i++)
2954 if(pv[i].getName() ==
"KaonZero" || pv[i].getName() ==
"AntiKaonZero")
3023 G4cout <<
" G4HEInelastic::MediumEnergyCascading " <<
G4endl;
3027 G4bool annihilation =
false;
3028 if (incidentCode < 0 && incidentType == antiBaryonType &&
3029 pv[0].getType() != antiBaryonType &&
3030 pv[1].getType() != antiBaryonType) {
3031 annihilation =
true;
3036 G4double twsup[] = { 1., 1., 0.7, 0.5, 0.3, 0.2, 0.1, 0.0 };
3038 if(annihilation)
goto start;
3039 if(vecLen >= 8)
goto start;
3040 if(incidentKineticEnergy < 1.)
return;
3041 if( ( incidentCode == kaonPlusCode || incidentCode == kaonMinusCode
3042 || incidentCode == kaonZeroCode || incidentCode == antiKaonZeroCode
3043 || incidentCode == kaonZeroSCode || incidentCode == kaonZeroLCode )
3053 incidentKineticEnergy = 2*targetMass + incidentKineticEnergy*(1.+ekcor/atomicWeight);
3057 excitationEnergyGNP,
3058 excitationEnergyDTA);
3059 incidentKineticEnergy -= excitation;
3060 if (incidentKineticEnergy < excitationEnergyDTA) incidentKineticEnergy = 0.;
3061 incidentEnergy = incidentKineticEnergy + incidentMass;
3062 incidentTotalMomentum =
3063 std::sqrt(
Amax(0., incidentEnergy*incidentEnergy - incidentMass*incidentMass));
3067 for(i = 2; i<vecLen; i++)
3079 if ((incidentCode==kaonPlusCode || incidentCode==kaonMinusCode ||
3080 incidentCode==kaonZeroCode || incidentCode==antiKaonZeroCode ||
3081 incidentCode==kaonZeroSCode || incidentCode==kaonZeroLCode)
3096 if ((incidentMass >= kaonPlusMass-0.05) && (incidentCode != protonCode)
3097 && (incidentCode != neutronCode) ) {
3100 if ((pMass >= kaonPlusMass-0.05) && (pCode != protonCode)
3101 && (pCode != neutronCode) ) {
3103 leadParticle = pv[0];
3107 if ((pMass >= kaonPlusMass-0.05) && (pCode != protonCode)
3108 && (pCode != neutronCode) ) {
3110 leadParticle = pv[1];
3126 G4double centerOfMassEnergy = std::sqrt(
sqr(incidentMass)+
sqr(targetMass)
3127 +2.0*targetMass*incidentEnergy );
3129 G4double tavai1 = centerOfMassEnergy/2.0 - incidentMass;
3130 G4double tavai2 = centerOfMassEnergy/2.0 - targetMass;
3133 for (i = 0; i < vecLen; i++) {
3136 }
else if (i == 1) {
3144 pv[i].
setTOF(incidentTOF);
3149 tb = (2. * ntb + vecLen)/2.;
3152 G4cout <<
" pv Vector after Randomization " << vecLen <<
G4endl;
3155 for (i=0; i < vecLen ; i++) pv[i].
Print(i);
3164 ss = centerOfMassEnergy*centerOfMassEnergy;
3165 xtarg =
Amax( 0.01,
Amin( 0.75, 0.312 + 0.200 * std::log(std::log(ss))
3166 + std::pow(ss,1.5)/6000.0 )
3167 *(std::pow(atomicWeight, 0.33) - 1.0) * tb);
3173 G4double nucsup[] = { 1.00, 0.7, 0.5, 0.4, 0.35, 0.3 };
3174 G4double psup[] = { 3., 6., 20., 50., 100., 1000. };
3175 G4int momentumBin = 0;
3176 while( (momentumBin < 6) && (incidentTotalMomentum > psup[momentumBin]) )
3178 momentumBin =
Imin( 5, momentumBin );
3183 for( i=0; i<
ntarg; i++ )
3198 else if( ran < 0.66667 )
3205 pv[vecLen].
setTOF( incidentTOF );
3214 tavai1 = centerOfMassEnergy/2.;
3217 for (i = 0; i < vecLen; i++)
3219 if (pv[i].getSide() > 0)
3225 if ( iavai1 == 0)
return;
3227 while( tavai1 <= 0.0 )
3231 for( i=vecLen-1; i>=0; i-- )
3233 if( pv[i].getSide() > 0 )
3241 for( j=i; j<vecLen; j++ )
3246 if( --vecLen == 0 )
return;
3254 tavai2 = (targ+1)*centerOfMassEnergy/2.;
3257 for (i = 0; i < vecLen; i++)
3259 if (pv[i].getSide() < 0)
3265 if (iavai2 == 0)
return;
3267 while( tavai2 <= 0.0 )
3271 for( i = vecLen-1; i >= 0; i-- )
3273 if( pv[i].getSide() < 0 )
3279 if (pv[i].getSide() == -2) ntarg--;
3282 for( j=i; j<vecLen; j++)
3287 if (--vecLen == 0)
return;
3295 G4cout <<
" pv Vector after Energy checks " << vecLen <<
" "
3296 << tavai1 <<
" " << iavai1 <<
" " << tavai2 <<
" "
3297 << iavai2 <<
" " << ntarg <<
G4endl;
3300 for (i=0; i < vecLen ; i++) pv[i].
Print(i);
3307 pvmx[0].
setMass( incidentMass );
3311 pvmx[3].
setMass( protonMass*(1+targ));
3318 pvmx[2].
Add( pvmx[0], pvmx[1] );
3319 pvmx[3].
Add( pvmx[3], pvmx[0] );
3320 pvmx[0].
Lor( pvmx[0], pvmx[2] );
3321 pvmx[1].
Lor( pvmx[1], pvmx[2] );
3324 G4cout <<
" General Vectors after Definition " <<
G4endl;
3325 for (i=0; i<10; i++) pvmx[i].
Print(i);
3343 for( i=vecLen-1; i>=0; i-- )
3345 if( (pv[i].getSide() == -2) || (i == 1) )
3347 if ( pv[i].getType() == baryonType ||
3348 pv[i].getType() == antiBaryonType)
3363 G4double maspar[] = { 0.75, 0.70, 0.65, 0.60, 0.50, 0.40, 0.75, 0.20};
3364 G4double bp[] = { 3.50, 3.50, 3.50, 6.00, 5.00, 4.00, 3.50, 3.50};
3365 G4double ptex[] = { 1.70, 1.70, 1.50, 1.70, 1.40, 1.20, 1.70, 1.20};
3372 if ( pv[i].getType() == mesonType ) j = 1;
3373 if ( pv[i].getMass() < 0.4 ) j = 0;
3374 if ( i <= 1 ) j += 3;
3375 if (pv[i].getSide() <= -2) j = 6;
3376 if (j == 6 && (pv[i].getType() == baryonType || pv[i].getType()==antiBaryonType) ) j = 7;
3377 pt =
Amax(0.001, std::sqrt(std::pow(-std::log(1.-
G4UniformRand())/bp[j],ptex[j])));
3380 pv[i].
setMomentum( pt*std::cos(phi), pt*std::sin(phi) );
3382 for( j=0; j<20; j++ ) binl[j] = j/(19.*pt);
3384 if( pv[i].getSide() > 0 )
3393 G4int outerCounter = 0, innerCounter = 0;
3394 G4bool eliminateThisParticle =
true;
3395 G4bool resetEnergies =
true;
3396 while( ++outerCounter < 3 )
3398 for( l=1; l<20; l++ )
3400 xval = (binl[l]+binl[l-1])/2.;
3402 dndl[l] = dndl[l-1];
3404 dndl[l] = dndl[l-1] +
3405 aspar/std::sqrt( std::pow((1.+aspar*xval*aspar*xval),3) ) *
3406 (binl[l]-binl[l-1]) * et /
3407 std::sqrt( pt*xval*et*pt*xval*et + pt*pt + pvMass*pvMass );
3413 while( ++innerCounter < 7 )
3417 while( ( ran >= dndl[l] ) && ( l < 20 ) )l++;
3420 if( pv[i].getSide() < 0 ) xval *= -1.;
3423 if( pv[i].getSide() > 0 )
3427 ekin = tavai1 - ekin1;
3428 if (ekin < 0.) ekin = 0.04*std::fabs(
normal());
3432 G4double pp = std::sqrt(ekin*(ekin+2*pvMass));
3433 pp =
Amax(0.,pp*pp-pt*pt);
3434 pp = std::sqrt(pp)*pv[i].
getSide()/std::fabs(
G4double(pv[i].getSide()));
3442 pvmx[4].
Add( pvmx[4], pv[i]);
3444 resetEnergies =
false;
3445 eliminateThisParticle =
false;
3448 else if( (ekin1+pvEnergy-pvMass) < 0.95*tavai1 )
3450 pvmx[4].
Add( pvmx[4], pv[i] );
3451 ekin1 += pvEnergy - pvMass;
3452 pvmx[6].
Add( pvmx[4], pvmx[5] );
3455 eliminateThisParticle =
false;
3456 resetEnergies =
false;
3459 if( innerCounter > 5 )
break;
3461 if( tavai2 >= pvMass )
3471 xval =
Amin(0.999,0.95+0.05*targ/20.0);
3472 if( (ekin2+pvEnergy-pvMass) < xval*tavai2 )
3474 pvmx[5].
Add( pvmx[5], pv[i] );
3475 ekin2 += pvEnergy - pvMass;
3476 pvmx[6].
Add( pvmx[4], pvmx[5] );
3479 eliminateThisParticle =
false;
3480 resetEnergies =
false;
3483 if( innerCounter > 5 )
break;
3485 if( tavai1 >= pvMass )
3494 pv[i].getMomentum().
y() * 0.9);
3507 for( l=i+1; l < vecLen; l++ )
3509 if( (pv[l].getMass() < protonMass) || (pv[l].getSide() > 0) )
3511 pvEnergy =
Amax( pv[l].getMass(), 0.95*pv[l].getEnergy()
3512 + 0.05*pv[l].getMass() );
3514 if( pv[l].getSide() > 0)
3517 pvmx[4].
Add( pvmx[4], pv[l] );
3522 pvmx[5].
Add( pvmx[5], pv[l] );
3529 if( eliminateThisParticle )
3533 G4cout <<
" Eliminate particle with index " << i <<
G4endl;
3536 for( j=i; j < vecLen; j++ )
3546 pvmx[6].
Add( pvmx[4], pvmx[5] );
3551 {
G4cout <<
" pv Vector after lambda fragmentation " << vecLen <<
G4endl;
3554 for (i=0; i < vecLen ; i++) pv[i].
Print(i);
3555 for (i=0; i < 10; i++) pvmx[i].
Print(i);
3560 pvmx[6].
Lor( pvmx[3], pvmx[2] );
3561 pvmx[6].
Sub( pvmx[6], pvmx[4] );
3562 pvmx[6].
Sub( pvmx[6], pvmx[5] );
3569 G4bool constantCrossSection =
true;
3570 for (i = 0; i < vecLen; i++)
3572 if(pv[i].getSide() == -3)
3578 if( targ1 == 1 || npg < 2)
3580 ekin =
Amin( tavai2-ekin2, centerOfMassEnergy/2.0-protonMass );
3581 if( ekin < 0.04 ) ekin = 0.04 * std::fabs(
normal() );
3582 G4double pp = std::sqrt(ekin*(ekin+2*pv[1].getMass()));
3593 pvmx[5].
Add( pvmx[5], pv[1] );
3597 G4double cpar[] = { 0.6, 0.6, 0.35, 0.15, 0.10 };
3598 G4double gpar[] = { 2.6, 2.6, 1.80, 1.30, 1.20 };
3602 rmb = rmb0 + std::pow(-std::log(1.0-
G4UniformRand()), cpar[tempCount])/gpar[tempCount];
3604 if ( rmb > pvEnergy ) rmb = pvEnergy;
3607 pvmx[6].
Smul( pvmx[6], -1. );
3609 G4cout <<
" General Vectors before input to NBodyPhaseSpace "
3610 << targ1 <<
" " << tempCount <<
" " << rmb0 <<
" "
3611 << rmb <<
" " << pvEnergy <<
G4endl;
3612 for (i=0; i<10; i++) pvmx[i].
Print(i);
3619 for( i=0; i < vecLen; i++ )
3621 if( pv[i].getSide() == -3 ) tempV[npg++] = pv[i];
3624 wgt =
NBodyPhaseSpace( pvmx[6].getMass(), constantCrossSection, tempV, npg );
3627 for( i=0; i < vecLen; i++ )
3629 if( pv[i].getSide() == -3 )
3633 pv[i].
Lor( pv[i], pvmx[6] );
3634 pvmx[5].
Add( pvmx[5], pv[i] );
3648 for( i=0; i < vecLen; i++ )
3650 if( pv[i].getType() == baryonType )targ++;
3651 if( pv[i].getType() == antiBaryonType )targ++;
3652 pv[i].
Lor( pv[i], pvmx[1] );
3654 targ =
Imax( 1, targ );
3659 for( i=0; i<vecLen; i++ )
3661 if( pv[i].getCode() == lead )
3671 if( ( (leadParticle.
getType() == baryonType ||
3672 leadParticle.
getType() == antiBaryonType)
3673 && (pv[1].getType() == baryonType ||
3674 pv[1].
getType() == antiBaryonType))
3675 || ( (leadParticle.
getType() == mesonType)
3676 && (pv[1].getType() == mesonType)))
3681 pv[i] = leadParticle;
3682 if( pv[i].getFlag() )
3690 pvmx[3].
setMass( incidentMass);
3695 pvmx[4].
setMass ( protonMass * targ);
3702 pvmx[5].
Add( pvmx[3], pvmx[4] );
3703 pvmx[3].
Lor( pvmx[3], pvmx[5] );
3704 pvmx[4].
Lor( pvmx[4], pvmx[5] );
3713 for( i=0; i < vecLen; i++ )
3715 pvmx[7].
Add( pvmx[7], pv[i] );
3720 if( vecLen > 1 && vecLen < 19 )
3722 constantCrossSection =
true;
3724 for(i=0;i<vecLen;i++) pw[i] = pv[i];
3727 for( i=0; i < vecLen; i++ )
3729 pvmx[6].
setMass( pw[i].getMass());
3732 pvmx[6].
Lor( pvmx[6], pvmx[4] );
3735 teta = pvmx[7].
Ang( pvmx[3] );
3737 G4cout <<
" vecLen > 1 && vecLen < 19 " << teta <<
" " << ekin0
3738 <<
" " << ekin1 <<
" " << ekin <<
G4endl;
3746 for( i=0; i < vecLen; i++ )
3752 pvmx[6].
Add( pvmx[6], pv[i] );
3754 teta = pvmx[6].
Ang( pvmx[3] );
3756 G4cout <<
" ekin1 != 0 " << teta <<
" " << ekin0 <<
" "
3765 G4double a1 = std::sqrt(-2.0*std::log(ry));
3769 for (i = 0; i < vecLen; i++)
3770 pv[i].setMomentum( pv[i].getMomentum().
x()+rantarg1,
3771 pv[i].getMomentum().
y()+rantarg2 );
3775 for (i = 0; i < vecLen; i++) pvmx[6].Add( pvmx[6], pv[i] );
3776 teta = pvmx[6].
Ang( pvmx[3] );
3791 G4double cfa = 0.025*((atomicWeight-1.)/120.)*std::exp(-(atomicWeight-1.)/120.);
3792 G4double alem[] = {1.40, 2.30, 2.70, 3.00, 3.40, 4.60, 7.00, 10.00};
3793 G4double val0[] = {0.00, 0.40, 0.48, 0.51, 0.54, 0.60, 0.65, 0.70};
3795 for (i = 0; i < vecLen; i++) {
3796 pv[i].
Defs1( pv[i], pvI );
3797 if (atomicWeight > 1.5) {
3798 ekin =
Amax( 1.
e-6,pv[i].getKineticEnergy() - cfa*( 1. + 0.5*
normal()));
3799 alekw = std::log( incidentKineticEnergy );
3801 if (incidentCode == pionPlusCode || incidentCode == pionMinusCode) {
3802 if (pv[i].getCode() == pionZeroCode) {
3804 if (alekw > alem[0]) {
3806 for (j = 1; j < 8; j++) {
3807 if (alekw < alem[j]) {
3812 xxh = (val0[
jmax] - val0[jmax-1])/(alem[jmax]-alem[jmax-1])*alekw
3813 + val0[jmax-1] - (val0[
jmax]-val0[jmax-1])/(alem[jmax]-alem[jmax-1])*alem[jmax-1];
3819 dekin += ekin*(1.-xxh);
3823 if ((pvCode == pionPlusCode) ||
3824 (pvCode == pionMinusCode) ||
3825 (pvCode == pionZeroCode)) {
3832 if( (ek1 > 0.0) && (npions > 0) )
3834 dekin = 1.+dekin/ek1;
3835 for (i = 0; i < vecLen; i++)
3838 if((pvCode == pionPlusCode) || (pvCode == pionMinusCode) || (pvCode == pionZeroCode))
3840 ekin =
Amax( 1.0
e-6, pv[i].getKineticEnergy() * dekin );
3846 {
G4cout <<
" Lab-System " << ek1 <<
" " << npions <<
G4endl;
3847 for (i=0; i<vecLen; i++) pv[i].
Print(i);
3855 excitationEnergyGNP <<
" " << excitationEnergyDTA <<
G4endl;
3857 if( atomicWeight > 1.5 )
3861 G4int spall(0), nbl(0);
3864 if( incidentKineticEnergy < 5.0 )
3868 sprob =
Amin(1., 0.000314*atomicWeight*std::log(incidentKineticEnergy-4.));
3872 if( excitationEnergyGNP >= 0.001 )
3877 nbl =
Poisson( (1.5+1.25*targ)*excitationEnergyGNP/
3878 (excitationEnergyGNP+excitationEnergyDTA));
3879 if( targ+nbl > atomicWeight ) nbl = (
int)(atomicWeight - targ);
3881 G4cout <<
" evaporation " << targ <<
" " << nbl <<
" "
3886 ekin = excitationEnergyGNP/nbl;
3888 for( i=0; i<nbl; i++ )
3891 if( ekin2 > excitationEnergyGNP)
break;
3893 ekin1 = -ekin*std::log(ran) - cfa*(1.0+0.5*
normal());
3894 if (ekin1 < 0) ekin1 = -0.010*std::log(ran);
3896 if( ekin2 > excitationEnergyGNP)
3897 ekin1 =
Amax( 1.0
e-6, excitationEnergyGNP-(ekin2-ekin1) );
3904 sint = std::sqrt(std::fabs(1.0-cost*cost));
3908 pvMass = pv[vecLen].
getMass();
3909 pv[vecLen].
setTOF( 1.0 );
3910 pvEnergy = ekin1 + pvMass;
3911 pp = std::sqrt( std::fabs( pvEnergy*pvEnergy - pvMass*pvMass ) );
3913 pp*sint*std::cos(phi),
3918 if( (atomicWeight >= 10.0 ) && (incidentKineticEnergy <= 2.0) )
3921 eka = incidentKineticEnergy;
3922 if( eka > 1.0 )eka *= eka;
3923 eka =
Amax( 0.1, eka );
3924 ika =
G4int(3.6*std::exp((atomicNumber*atomicNumber
3925 /atomicWeight-35.56)/6.45)/eka);
3928 for( i=(vecLen-1); i>=0; i-- )
3930 if( (pv[i].getCode() == protonCode) && pv[i].getFlag() )
3936 if( ++kk > ika )
break;
3947 if( excitationEnergyDTA >= 0.001 )
3949 nbl =
Poisson( (1.5+1.25*targ)*excitationEnergyDTA
3950 /(excitationEnergyGNP+excitationEnergyDTA));
3956 ekin = excitationEnergyDTA/nbl;
3958 for( i=0; i<nbl; i++ )
3961 if( ekin2 > excitationEnergyDTA)
break;
3963 ekin1 = -ekin*std::log(ran)-cfa*(1.+0.5*
normal());
3964 if( ekin1 < 0.0 ) ekin1 = -0.010*std::log(ran);
3966 if( ekin2 > excitationEnergyDTA)
3967 ekin1 =
Amax( 1.0
e-6, excitationEnergyDTA-(ekin2-ekin1));
3969 sint = std::sqrt(std::fabs(1.0-cost*cost));
3974 else if (ran <= 0.90)
3978 spall += (
int)(pv[vecLen].getMass() * 1.066);
3979 if( spall > atomicWeight )
break;
3982 pvMass = pv[vecLen].
getMass();
3983 pv[vecLen].
setSide( pv[vecLen].getCode());
3984 pv[vecLen].
setTOF( 1.0 );
3985 pvEnergy = pvMass + ekin1;
3986 pp = std::sqrt( std::fabs( pvEnergy*pvEnergy - pvMass*pvMass ) );
3988 pp*sint*std::cos(phi),
3998 for( i=0; i<vecLen; i++ )
4001 if( etb >= incidentKineticEnergy )
4009 if( (atomicWeight >= 1.5) && (atomicWeight <= 230.0)
4010 && (incidentKineticEnergy <= 0.2) )
4011 tof -= 500.0 * std::exp(-incidentKineticEnergy /0.04) * std::log(
G4UniformRand() );
4012 for ( i=0; i < vecLen; i++)
4019 for(i=0; i<vecLen; i++)
4021 if(pv[i].getName() ==
"KaonZero" || pv[i].getName() ==
"AntiKaonZero")
4080 G4cout <<
" G4HEInelastic::MediumEnergyClusterProduction " <<
G4endl;
4082 if (incidentTotalMomentum < 0.01) {
4086 G4double centerOfMassEnergy = std::sqrt(
sqr(incidentMass) +
sqr(targetMass)
4087 +2.*targetMass*incidentEnergy);
4109 for(i = 0; i < vecLen; i++)
4137 if ( ( (incidentCode == protonCode) || (incidentCode == neutronCode)
4138 || (incidentType == mesonType) )
4139 && ( (pvCode == pionPlusCode) || (pvCode == pionMinusCode) )
4149 pv[i].
setTOF( incidentTOF );
4152 if (centerOfMassEnergy < (2+
G4UniformRand())) tb = (2.*iback + vecLen)/2.;
4154 G4double nucsup[] = { 1.0, 0.8, 0.6, 0.5, 0.4};
4156 G4double xtarg =
Amax(0.01, (0.312+0.2*std::log(std::log(centerOfMassEnergy*centerOfMassEnergy)))
4157 * (std::pow(atomicWeight,0.33)-1.) * tb);
4162 for (i=0; i <
ntarg; i++)
4177 else if (ran < 0.6666)
4184 pv[vecLen].
setTOF( incidentTOF );
4196 if( (incidentMass >= kaonPlusMass-0.05) && (incidentCode != protonCode)
4197 && (incidentCode != neutronCode) )
4201 if( (pMass >= kaonPlusMass-0.05) && (pCode != protonCode)
4202 && (pCode != neutronCode) )
4205 leadParticle = pv[0];
4211 if( (pMass >= kaonPlusMass-0.05) && (pCode != protonCode)
4212 && (pCode != neutronCode) )
4215 leadParticle = pv[1];
4221 G4cout <<
" pv Vector after initialization " << vecLen <<
G4endl;
4224 for (i=0; i < vecLen ; i++) pv[i].
Print(i);
4228 for(i=0;i<vecLen;i++)
if(pv[i].getSide() != -2) tavai += pv[i].
getMass();
4230 while (tavai > centerOfMassEnergy)
4232 for (i=vecLen-1; i >= 0; i--)
4234 if (pv[i].getSide() != -2)
4239 for (j=i; j < vecLen; j++)
4259 G4double rmc0 = 0., rmd0 = 0., rme0 = 0.;
4260 G4int ntc = 0, ntd = 0, nte = 0;
4262 for (i=0; i < vecLen; i++)
4264 if(pv[i].getSide() > 0)
4287 else if (pv[i].getSide() == -1)
4308 G4double cpar[] = {0.6, 0.6, 0.35, 0.15, 0.10};
4309 G4double gpar[] = {2.6, 2.6, 1.80, 1.30, 1.20};
4311 G4double rmc = rmc0, rmd = rmd0, rme = rme0;
4315 if (ntc > 1) rmc = rmc0 + std::pow(-std::log(1.-
G4UniformRand()),cpar[ntc1])/gpar[ntc1];
4316 if (ntd > 1) rmd = rmd0 + std::pow(-std::log(1.-
G4UniformRand()),cpar[ntd1])/gpar[ntd1];
4317 if (nte > 1) rme = rme0 + std::pow(-std::log(1.-
G4UniformRand()),cpar[nte1])/gpar[nte1];
4318 while( (rmc+rmd) > centerOfMassEnergy)
4320 if ((rmc == rmc0) && (rmd == rmd0))
4322 rmd *= 0.999*centerOfMassEnergy/(rmc+rmd);
4323 rmc *= 0.999*centerOfMassEnergy/(rmc+rmd);
4327 rmc = 0.1*rmc0 + 0.9*rmc;
4328 rmd = 0.1*rmd0 + 0.9*rmd;
4332 G4cout <<
" Cluster Masses: " << ntc <<
" " << rmc <<
" " << ntd <<
" "
4333 << rmd <<
" " << nte <<
" " << rme <<
G4endl;
4338 pvmx[1].
setMass( incidentMass);
4342 pvmx[0].
Add( pvmx[1], pvmx[2] );
4343 pvmx[1].
Lor( pvmx[1], pvmx[0] );
4344 pvmx[2].
Lor( pvmx[2], pvmx[0] );
4347 - 4*
sqr(centerOfMassEnergy)*rmd*rmd))/(2.*centerOfMassEnergy);
4350 pvmx[3].
setEnergy( std::sqrt(pf*pf + rmc*rmc) );
4351 pvmx[4].
setEnergy( std::sqrt(pf*pf + rmd*rmd) );
4354 G4double bvalue =
Amax(0.01, 4.0 + 1.6*std::log(incidentTotalMomentum));
4355 if (bvalue != 0.0) tvalue = std::log(
G4UniformRand())/bvalue;
4357 G4double tacmin =
sqr( pvmx[1].getEnergy() - pvmx[3].getEnergy()) -
sqr( pin - pf);
4362 pf * stet * std::cos(phi),
4364 pvmx[4].
Smul( pvmx[3], -1.);
4371 if (incidentKineticEnergy <= 5.)
4373 ekit1 *=
sqr(incidentKineticEnergy)/25.;
4374 ekit2 *=
sqr(incidentKineticEnergy)/25.;
4376 G4double avalue = (1.-gaval)/(std::pow(ekit2, 1.-gaval)-std::pow(ekit1, 1.-gaval));
4377 for (i=0; i < vecLen; i++)
4379 if (pv[i].getSide() == -2)
4385 stet = std::sqrt(
Amax( 0.0, 1. - ctet*ctet ));
4389 pp * stet * std::cos(phi),
4391 pv[i].
Lor( pv[i], pvmx[0] );
4401 G4cout <<
" General vectors before Phase space Generation " <<
G4endl;
4402 for (i=0; i<7; i++) pvmx[i].
Print(i);
4407 G4bool constantCrossSection =
true;
4414 for (i=0; i < vecLen; i++)
4416 if (pv[i].getSide() > 0)
4418 tempV[npg++] = pv[i];
4422 wgt =
NBodyPhaseSpace( pvmx[3].getMass(), constantCrossSection, tempV, npg);
4425 for (i=0; i < vecLen; i++)
4427 if (pv[i].getSide() > 0)
4431 pv[i].
Lor( pv[i], pvmx[5] );
4438 for(i=0; i<vecLen; i++)
4451 for (i=0; i < vecLen; i++)
4453 if (pv[i].getSide() == -1)
4455 tempV[npg++] = pv[i];
4459 wgt =
NBodyPhaseSpace( pvmx[4].getMass(), constantCrossSection, tempV, npg);
4462 for (i=0; i < vecLen; i++)
4464 if (pv[i].getSide() == -1)
4468 pv[i].
Lor( pv[i], pvmx[6] );
4475 for(i=0; i<vecLen; i++)
4487 G4cout <<
" Vectors after PhaseSpace generation " <<
G4endl;
4488 for(i=0;i<vecLen; i++) pv[i].
Print(i);
4494 for( i=0; i < vecLen; i++ )
4496 if( pv[i].getType() == baryonType )targ++;
4497 if( pv[i].getType() == antiBaryonType )targ++;
4498 pv[i].
Lor( pv[i], pvmx[2] );
4500 if (targ <1) targ =1;
4504 for(i=0; i<vecLen; i++) pv[i].
Print(i);
4513 for (i = 0; i < vecLen; i++) {
4514 if (pv[i].getCode() == lead) {
4548 pvmx[4].
setMass( incidentMass);
4553 pvmx[5].
setMass ( protonMass * targ);
4558 pvmx[6].
Add( pvmx[4], pvmx[5] );
4559 pvmx[4].
Lor( pvmx[4], pvmx[6] );
4560 pvmx[5].
Lor( pvmx[5], pvmx[6] );
4568 for( i=0; i < vecLen; i++ )
4570 pvmx[8].
Add( pvmx[8], pv[i] );
4575 if( vecLen > 1 && vecLen < 19 )
4577 constantCrossSection =
true;
4579 for(i=0;i<vecLen;i++) pw[i] = pv[i];
4582 for( i=0; i < vecLen; i++ )
4584 pvmx[7].
setMass( pw[i].getMass());
4587 pvmx[7].
Lor( pvmx[7], pvmx[5] );
4590 teta = pvmx[8].
Ang( pvmx[4] );
4592 G4cout <<
" vecLen > 1 && vecLen < 19 " << teta <<
" " << ekin0
4593 <<
" " << ekin1 <<
" " << ekin <<
G4endl;
4601 for( i=0; i < vecLen; i++ )
4607 pvmx[7].
Add( pvmx[7], pv[i] );
4609 teta = pvmx[7].
Ang( pvmx[4] );
4611 G4cout <<
" ekin1 != 0 " << teta <<
" " << ekin0 <<
" "
4620 G4double a1 = std::sqrt(-2.0*std::log(ry));
4624 for (i = 0; i < vecLen; i++)
4625 pv[i].setMomentum( pv[i].getMomentum().
x()+rantarg1,
4626 pv[i].getMomentum().
y()+rantarg2 );
4630 for (i = 0; i < vecLen; i++) pvmx[7].Add( pvmx[7], pv[i] );
4631 teta = pvmx[7].
Ang( pvmx[4] );
4646 G4double cfa = 0.025*((atomicWeight-1.)/120.)*std::exp(-(atomicWeight-1.)/120.);
4647 G4double alem[] = {1.40, 2.30, 2.70, 3.00, 3.40, 4.60, 7.00};
4648 G4double val0[] = {0.00, 0.40, 0.48, 0.51, 0.54, 0.60, 0.65};
4650 for (i = 0; i < vecLen; i++) {
4651 pv[i].
Defs1( pv[i], pvI );
4652 if (atomicWeight > 1.5) {
4653 ekin =
Amax( 1.
e-6,pv[i].getKineticEnergy() - cfa*( 1. + 0.5*
normal()));
4654 alekw = std::log( incidentKineticEnergy );
4657 if (incidentCode == pionPlusCode || incidentCode == pionMinusCode) {
4658 if (pv[i].getCode() == pionZeroCode) {
4660 if (alekw > alem[0]) {
4662 for (j = 1; j < 8; j++) {
4663 if (alekw < alem[j]) {
4668 xxh = (val0[
jmax]-val0[jmax-1])/(alem[jmax]-alem[jmax-1])*alekw
4669 + val0[jmax-1] - (val0[
jmax]-val0[jmax-1])/(alem[jmax]-alem[jmax-1])*alem[jmax-1];
4675 dekin += ekin*(1.-xxh);
4679 if ((pvCode == pionPlusCode) ||
4680 (pvCode == pionMinusCode) ||
4681 (pvCode == pionZeroCode)) {
4688 if( (ek1 > 0.0) && (npions > 0) )
4690 dekin = 1.+dekin/ek1;
4691 for (i = 0; i < vecLen; i++)
4694 if((pvCode == pionPlusCode) || (pvCode == pionMinusCode) || (pvCode == pionZeroCode))
4696 ekin =
Amax( 1.0
e-6, pv[i].getKineticEnergy() * dekin );
4702 {
G4cout <<
" Lab-System " << ek1 <<
" " << npions <<
G4endl;
4703 for (i=0; i<vecLen; i++) pv[i].
Print(i);
4711 G4cout <<
" Evaporation " << atomicWeight <<
" "
4712 << excitationEnergyGNP <<
" " << excitationEnergyDTA <<
G4endl;
4714 if( atomicWeight > 1.5 )
4717 G4double sprob, cost, sint, ekin2, ran,
pp, eka;
4718 G4int spall(0), nbl(0);
4721 if( incidentKineticEnergy < 5.0 )
4725 sprob =
Amin(1., 0.000314*atomicWeight*std::log(incidentKineticEnergy-4.));
4728 if( excitationEnergyGNP >= 0.001 )
4733 nbl =
Poisson( (1.5+1.25*targ)*excitationEnergyGNP/
4734 (excitationEnergyGNP+excitationEnergyDTA));
4735 if( targ+nbl > atomicWeight ) nbl = (
int)(atomicWeight - targ);
4737 G4cout <<
" evaporation " << targ <<
" " << nbl <<
" "
4742 ekin = excitationEnergyGNP/nbl;
4744 for( i=0; i<nbl; i++ )
4747 if( ekin2 > excitationEnergyGNP)
break;
4749 ekin1 = -ekin*std::log(ran) - cfa*(1.0+0.5*
normal());
4750 if (ekin1 < 0) ekin1 = -0.010*std::log(ran);
4752 if( ekin2 > excitationEnergyGNP )
4753 ekin1 =
Amax( 1.0
e-6, excitationEnergyGNP-(ekin2-ekin1) );
4760 sint = std::sqrt(std::fabs(1.0-cost*cost));
4764 pvMass = pv[vecLen].
getMass();
4765 pv[vecLen].
setTOF( 1.0 );
4766 pvEnergy = ekin1 + pvMass;
4767 pp = std::sqrt( std::fabs( pvEnergy*pvEnergy - pvMass*pvMass ) );
4769 pp*sint*std::cos(phi),
4774 if( (atomicWeight >= 10.0 ) && (incidentKineticEnergy <= 2.0) )
4777 eka = incidentKineticEnergy;
4778 if( eka > 1.0 )eka *= eka;
4779 eka =
Amax( 0.1, eka );
4780 ika =
G4int(3.6*std::exp((atomicNumber*atomicNumber
4781 /atomicWeight-35.56)/6.45)/eka);
4784 for( i=(vecLen-1); i>=0; i-- )
4786 if( (pv[i].getCode() == protonCode) && pv[i].getFlag() )
4792 if( ++kk > ika )
break;
4803 if( excitationEnergyDTA >= 0.001 )
4805 nbl =
Poisson( (1.5+1.25*targ)*excitationEnergyDTA
4806 /(excitationEnergyGNP+excitationEnergyDTA));
4812 ekin = excitationEnergyDTA/nbl;
4814 for( i=0; i<nbl; i++ )
4817 if( ekin2 > excitationEnergyDTA)
break;
4819 ekin1 = -ekin*std::log(ran)-cfa*(1.+0.5*
normal());
4820 if( ekin1 < 0.0 ) ekin1 = -0.010*std::log(ran);
4822 if( ekin2 > excitationEnergyDTA)
4823 ekin1 =
Amax( 1.0
e-6, excitationEnergyDTA-(ekin2-ekin1));
4825 sint = std::sqrt(std::fabs(1.0-cost*cost));
4830 else if (ran <= 0.90)
4834 spall += (
int)(pv[vecLen].getMass() * 1.066);
4835 if( spall > atomicWeight )
break;
4838 pvMass = pv[vecLen].
getMass();
4839 pv[vecLen].
setTOF( 1.0 );
4840 pvEnergy = pvMass + ekin1;
4841 pp = std::sqrt( std::fabs( pvEnergy*pvEnergy - pvMass*pvMass ) );
4843 pp*sint*std::cos(phi),
4853 for( i=0; i<vecLen; i++ )
4856 if( etb >= incidentKineticEnergy )
4864 if( (atomicWeight >= 1.5) && (atomicWeight <= 230.0)
4865 && (incidentKineticEnergy <= 0.2) )
4866 tof -= 500.0 * std::exp(-incidentKineticEnergy /0.04) * std::log(
G4UniformRand() );
4867 for ( i=0; i < vecLen; i++)
4874 for(i=0; i<vecLen; i++)
4876 if(pv[i].getName() ==
"KaonZero" || pv[i].getName() ==
"AntiKaonZero")
4925 G4cout <<
" G4HEInelastic::QuasiElasticScattering " <<
G4endl;
4927 if (incidentTotalMomentum < 0.01 || vecLen < 2) {
4932 G4double centerOfMassEnergy = std::sqrt(
sqr(incidentMass) +
sqr(targetMass)
4933 +2.*targetMass*incidentEnergy);
4945 if (atomicWeight > 1.5) {
4949 && (excitationEnergyGNP < 0.001)
4950 && (excitationEnergyDTA < 0.001) ) {
4959 pv[0].
setTOF( incidentTOF);
4963 pv[1].
setTOF( incidentTOF);
4966 if ((incidentTotalMomentum > 0.1) && (centerOfMassEnergy > 0.01) ) {
4967 if (pv[1].getType() == mesonType) {
4973 pvmx[0].
Add( pvI, pvT );
4974 pvmx[1].
Lor( pvI, pvmx[0] );
4975 pvmx[2].
Lor( pvT, pvmx[0] );
4977 G4double bvalue =
Amax(0.01 , 4.225+1.795*std::log(incidentTotalMomentum));
4979 - 4 *
sqr(centerOfMassEnergy) *
sqr(pv[1].getMass());
4986 pf = std::sqrt(pf)/(2.*centerOfMassEnergy);
4987 G4double btrang = 4. * bvalue * pin * pf;
4989 if (btrang < 46.) exindt += std::exp(-btrang);
4992 G4double stet = std::sqrt((1.-ctet)*(1.+ctet));
4995 pf*stet*std::cos(phi),
4998 for (i = 0; i < 2; i++) {
5001 pv[i].
Lor(pv[i], pvmx[0]);
5002 pv[i].
Defs1(pv[i], pvI);
5003 if (atomicWeight > 1.5) {
5005 - 0.025*((atomicWeight-1.)/120.)*std::exp(-(atomicWeight-1.)/120.)
5007 ekin =
Amax(0.0001, ekin);
5019 G4cout <<
" Evaporation " << atomicWeight <<
" "
5020 << excitationEnergyGNP <<
" " << excitationEnergyDTA <<
G4endl;
5022 if( atomicWeight > 1.5 )
5025 G4double sprob, cost, sint, ekin2, ran,
pp, eka;
5026 G4double ekin, cfa, ekin1, phi, pvMass, pvEnergy;
5027 G4int spall(0), nbl(0);
5031 cfa = 0.025*((atomicWeight-1.)/120.)*std::exp(-(atomicWeight-1.)/120.);
5034 if( excitationEnergyGNP >= 0.001 )
5039 nbl =
Poisson( excitationEnergyGNP/0.02);
5040 if( nbl > atomicWeight ) nbl = (
int)(atomicWeight);
5042 G4cout <<
" evaporation " << nbl <<
" " << sprob <<
G4endl;
5046 ekin = excitationEnergyGNP/nbl;
5048 for( i=0; i<nbl; i++ )
5051 if( ekin2 > excitationEnergyGNP)
break;
5053 ekin1 = -ekin*std::log(ran) - cfa*(1.0+0.5*
normal());
5054 if (ekin1 < 0) ekin1 = -0.010*std::log(ran);
5056 if( ekin2 > excitationEnergyGNP)
5057 ekin1 =
Amax( 1.0
e-6, excitationEnergyGNP-(ekin2-ekin1) );
5064 sint = std::sqrt(std::fabs(1.0-cost*cost));
5068 pvMass = pv[vecLen].
getMass();
5069 pv[vecLen].
setTOF( 1.0 );
5070 pvEnergy = ekin1 + pvMass;
5071 pp = std::sqrt( std::fabs( pvEnergy*pvEnergy - pvMass*pvMass ) );
5073 pp*sint*std::cos(phi),
5078 if( (atomicWeight >= 10.0 ) && (incidentKineticEnergy <= 2.0) )
5081 eka = incidentKineticEnergy;
5082 if( eka > 1.0 )eka *= eka;
5083 eka =
Amax( 0.1, eka );
5084 ika =
G4int(3.6*std::exp((atomicNumber*atomicNumber
5085 /atomicWeight-35.56)/6.45)/eka);
5088 for( i=(vecLen-1); i>=0; i-- )
5090 if( (pv[i].getCode() == protonCode) && pv[i].getFlag() )
5094 if( ++kk > ika )
break;
5105 if( excitationEnergyDTA >= 0.001 )
5107 nbl = (
G4int)(2.*std::log(atomicWeight));
5113 ekin = excitationEnergyDTA/nbl;
5115 for( i=0; i<nbl; i++ )
5118 if( ekin2 > excitationEnergyDTA)
break;
5120 ekin1 = -ekin*std::log(ran)-cfa*(1.+0.5*
normal());
5121 if( ekin1 < 0.0 ) ekin1 = -0.010*std::log(ran);
5123 if( ekin2 > excitationEnergyDTA)
5124 ekin1 =
Amax( 1.0
e-6, excitationEnergyDTA-(ekin2-ekin1));
5126 sint = std::sqrt(std::fabs(1.0-cost*cost));
5131 else if (ran <= 0.90)
5135 spall += (
int)(pv[vecLen].getMass() * 1.066);
5136 if( spall > atomicWeight )
break;
5139 pvMass = pv[vecLen].
getMass();
5140 pv[vecLen].
setTOF( 1.0 );
5141 pvEnergy = pvMass + ekin1;
5142 pp = std::sqrt( std::fabs( pvEnergy*pvEnergy - pvMass*pvMass ) );
5144 pp*sint*std::cos(phi),
5156 if( (atomicWeight >= 1.5) && (atomicWeight <= 230.0)
5157 && (incidentKineticEnergy <= 0.2) )
5158 tof -= 500.0 * std::exp(-incidentKineticEnergy /0.04) * std::log(
G4UniformRand() );
5159 for ( i=0; i < vecLen; i++)
5166 for(i=0; i<vecLen; i++)
5168 if(pv[i].getName() ==
"KaonZero" || pv[i].getName() ==
"AntiKaonZero")
5191 G4cout <<
" G4HEInelastic::ElasticScattering " <<
G4endl;
5195 G4cout <<
"DoIt: Incident particle momentum="
5196 << incidentTotalMomentum <<
" GeV" <<
G4endl;
5197 if (incidentTotalMomentum < 0.01) {
5202 if (atomicWeight < 0.5)
5207 pv[0] = incidentParticle;
5211 if (atomicWeight <= 62.)
5213 aa = std::pow(atomicWeight, 1.63);
5214 bb = 14.5*std::pow(atomicWeight, 0.66);
5215 cc = 1.4*std::pow(atomicWeight, 0.33);
5220 aa = std::pow(atomicWeight, 1.33);
5221 bb = 60.*std::pow(atomicWeight, 0.33);
5222 cc = 0.4*std::pow(atomicWeight, 0.40);
5231 G4cout <<
"ElasticScattering: aa,bb,cc,dd,rr" <<
G4endl;
5232 G4cout << aa <<
" " << bb <<
" " << cc <<
" " << dd <<
" "
5238 G4cout <<
"t1,fctcos " << t1 <<
" " <<
fctcos(t1, aa, bb, cc, dd, rr)
5240 G4cout <<
"t2,fctcos " << t2 <<
" " <<
fctcos(t2, aa, bb, cc, dd, rr)
5247 ier1 =
rtmi(&t, t1, t2, eps, ind1, aa, bb, cc, dd, rr);
5250 G4cout <<
"t, fctcos " << t <<
" " <<
fctcos(t, aa, bb, cc, dd, rr)
5253 if (ier1 != 0) t = 0.25*(3.*t1 +
t2);
5255 G4cout <<
"t, fctcos " << t <<
" " <<
fctcos(t, aa, bb, cc, dd, rr)
5259 rr = 0.5*t/
sqr(incidentTotalMomentum);
5260 if (rr > 1.) rr = 0.;
5266 G4cout <<
"cos(t)=" << cost <<
" std::sin(t)=" << sint <<
G4endl;
5276 incidentTotalMomentum * sint * std::cos(phi),
5277 incidentTotalMomentum * cost );
5278 pv0.
Defs1( pv0, pvI );
5297 if (f == 0.)
return ier;
5302 f =
fctcos(tol, aa, bb, cc, dd, rr);
5303 if (f == 0.)
return ier;
5325 for (
G4int k = 1; k <= iend; k++)
5329 f =
fctcos(tol, aa, bb, cc, dd, rr);
5330 if (f == 0.)
return 0;
5343 if (a < fr*(fr - fl) && i <= iend)
goto label17;
5350 if (a > 1.) tol = tol*
a;
5351 if (std::fabs(xr - xl) <= tol && std::fabs(fr - fl) <= tolf)
goto label14;
5361 if (std::fabs(fr) > std::fabs(fl))
5371 G4double dx = (*x - xl)*fl*(1. + f*(a - tol)/(a*(fr - fl)))/tol;
5376 f =
fctcos(tol, aa, bb, cc, dd, rr);
5377 if (f == 0.)
return ier;
5382 if (a > 1) tol = tol*
a;
5383 if (std::fabs(dx) <= tol && std::fabs(f) <= tolf)
return ier;
5412 if (test1 > expxu) test1 = expxu;
5413 if (test1 < expxl) test1 = expxl;
5416 if (test2 > expxu) test2 = expxu;
5417 if (test2 < expxl) test2 = expxl;
5419 return aa*std::exp(test1) + cc*std::exp(test2) - rr;
5424 const G4bool constantCrossSection,
5436 G4cerr <<
"*** Error in G4HEInelastic::GenerateNBodyEvent" <<
G4endl;
5438 G4cerr <<
"totalEnergy = " << totalEnergy <<
", vecLen = "
5447 for( i=0; i<3; ++i )pcm[i] =
new G4double [vecLen];
5452 for( i=0; i<vecLen; ++i ) {
5458 energy[i] = mass[i];
5459 totalMass += mass[i];
5463 if (totalMass >= totalEnergy ) {
5465 G4cout <<
"*** Error in G4HEInelastic::GenerateNBodyEvent" <<
G4endl;
5466 G4cout <<
" total mass (" << totalMass <<
") >= total energy ("
5467 << totalEnergy <<
")" <<
G4endl;
5471 for( i=0; i<3; ++i )
delete [] pcm[i];
5477 G4double kineticEnergy = totalEnergy - totalMass;
5483 for( i=0; i<vecLen-1; ++i ) {
5484 for(
G4int j=vecLen-1; j > i; --j ) {
5485 if( ran[i] > ran[j] ) {
5492 for( i=1; i<vecLen; ++i )emm[i] = ran[i-1]*kineticEnergy + sm[i];
5498 emm[vecLen-1] = totalEnergy;
5504 if (constantCrossSection) {
5505 G4double emmax = kineticEnergy + mass[0];
5507 for( i=1; i<vecLen; ++i ) {
5511 if( emmax*emmax > 0.0 ) {
5513 + (emmin*emmin-mass[i]*mass[i])*(emmin*emmin-mass[i]*mass[i])/(emmax*emmax)
5514 - 2.0*(emmin*emmin+mass[i]*mass[i]);
5515 if( arg > 0.0 )wtfc = 0.5*std::sqrt( arg );
5521 wtmax += std::log( wtfc );
5528 wtmax = std::log( std::pow( kineticEnergy, vecLen-2 ) *
5533 for( i=0; i<vecLen-1; ++i ) {
5535 if( emm[i+1]*emm[i+1] > 0.0 ) {
5537 + (emm[i]*emm[i]-mass[i+1]*mass[i+1])*(emm[i]*emm[i]-mass[i+1]*mass[i+1])
5538 /(emm[i+1]*emm[i+1])
5539 - 2.0*(emm[i]*emm[i]+mass[i+1]*mass[i+1]);
5540 if( arg > 0.0 )pd[i] = 0.5*std::sqrt( arg );
5545 wtmax += std::log( pd[i] );
5548 if( lzero )weight = std::exp(
Amax(
Amin(wtmax,expxu),expxl) );
5550 G4double bang, cb, sb,
s0, s1, s2,
c, esys,
a,
b, gama, beta;
5555 for( i=1; i<vecLen; ++i ) {
5557 pcm[1][i] = -pd[i-1];
5560 cb = std::cos(bang);
5561 sb = std::sin(bang);
5563 ss = std::sqrt( std::fabs( 1.0-c*c ) );
5564 if( i < vecLen-1 ) {
5565 esys = std::sqrt(pd[i]*pd[i] + emm[i]*emm[i]);
5568 for(
G4int j=0; j<=i; ++j ) {
5572 energy[j] = std::sqrt( s0*s0 + s1*s1 + s2*s2 + mass[j]*mass[j] );
5574 pcm[1][j] = s0*ss + s1*
c;
5576 pcm[0][j] = a*cb - b*sb;
5577 pcm[2][j] = a*sb + b*cb;
5578 pcm[1][j] = gama*(pcm[1][j] + beta*energy[j]);
5581 for(
G4int j=0; j<=i; ++j ) {
5585 energy[j] = std::sqrt( s0*s0 + s1*s1 + s2*s2 + mass[j]*mass[j] );
5587 pcm[1][j] = s0*ss + s1*
c;
5589 pcm[0][j] = a*cb - b*sb;
5590 pcm[2][j] = a*sb + b*cb;
5596 for (i = 0; i < vecLen; ++i) {
5597 kineticEnergy = energy[i] - mass[i];
5598 pModule = std::sqrt(
sqr(kineticEnergy) + 2*kineticEnergy*mass[i] );
5607 for( i=0; i<3; ++i )
delete [] pcm[i];
5625 G4double arg = a*a+(b*b-c*
c)*(b*b-c*c)/(a*
a)-2.0*(b*b+c*c);
5632 return 0.5*std::sqrt(std::fabs(arg));
5644 while ( ntrial < maxtrial)
5647 G4int nrn = 3*(npart-2)-4;
5650 G4int nrnp = npart-4;
5651 if(nrnp > 1)
QuickSort( ranarr, 0 , nrnp-1 );
5653 pvcms.
Add(pv[0],pv[1]);
5654 pvcms.
Smul( pvcms, -1.);
5656 for (i=2;i<
npart;i++) rm += pv[i].getMass();
5660 for (i=3; (i=npart-1);i++) wps /= i-2;
5662 for (i=1; (i=npart-4); i++) wps /= xxx/i;
5669 if(j == npart-2)
break;
5670 G4double rmass = rm + rm1*ranarr[npart-j-1];
5673 cost = 1. - 2.*ranarr[npart+2*j-9];
5674 sint = std::sqrt(1.-cost*cost);
5675 phi =
twopi*ranarr[npart+2*j-8];
5676 p2 = std::sqrt(
Amax(0., p2));
5679 pv[j].
Lor(pv[j], pvcms);
5680 pvcms.
Add3( pvcms, pv[j] );
5686 cost = 1. - 2.*ranarr[npart+2*j-9];
5687 sint = std::sqrt(1.-cost*cost);
5688 phi =
twopi*ranarr[npart+2*j-8];
5689 p2 = std::sqrt(
Amax(0. , p2));
5693 pv[j].
Lor( pv[j], pvcms );
5694 pv[j+1].
Lor( pv[j+1], pvcms );
5699 G4cout <<
"maximum weight changed to " << wmax <<
G4endl;
5713 if(lidx>=ridx)
return;
5714 mid = (
int)((lidx+ridx)/2.);
5716 arr[lidx]= arr[mid];
5719 for (k=lidx+1;k<=ridx;k++)
5720 if (arr[k] < arr[lidx])
5736 {
return a*a + b*b + c*c - 2.*a*b - 2.*a*c -2.*b*
c;
5748 return std::pair<G4double, G4double>(5*
perCent,250*
GeV);