44   outFile << 
"G4HEProtonInelastic is one of the High Energy\n" 
   45           << 
"Parameterized (HEP) models used to implement inelastic\n" 
   46           << 
"proton scattering from nuclei.  It is a re-engineered\n" 
   47           << 
"version of the GHEISHA code of H. Fesefeldt.  It divides the\n" 
   48           << 
"initial collision products into backward- and forward-going\n" 
   49           << 
"clusters which are then decayed into final state hadrons.\n" 
   50           << 
"The model does not conserve energy on an event-by-event\n" 
   51           << 
"basis.  It may be applied to protons with initial energies\n" 
   70     G4cout << 
"Z , A = " << atomicNumber << 
"  " << atomicWeight << 
G4endl;
 
   81   if (incidentKineticEnergy < 1.)
 
   82     G4cout << 
"GHEProtonInelastic: incident energy < 1 GeV" << 
G4endl;
 
   85     G4cout << 
"G4HEProtonInelastic::ApplyYourself" << 
G4endl;
 
   86     G4cout << 
"incident particle " << incidentParticle.
getName() << 
" "  
   87            << 
"mass "              << incidentMass << 
" "  
   88            << 
"kinetic energy "    << incidentKineticEnergy
 
   90     G4cout << 
"target material with (A,Z) = ("  
   91            << atomicWeight << 
"," << atomicNumber << 
")" << 
G4endl;
 
   95                                               atomicWeight, atomicNumber);
 
   97     G4cout << 
"nuclear inelasticity = " << inelasticity << 
G4endl;
 
   99   incidentKineticEnergy -= inelasticity;
 
  105                                           atomicWeight, atomicNumber,
 
  107                                           excitationEnergyDTA);
 
  110     G4cout << 
"nuclear excitation = " << excitation << 
" " 
  111            << excitationEnergyGNP << 
" " << excitationEnergyDTA << 
G4endl;             
 
  113   incidentKineticEnergy -= excitation;
 
  114   incidentTotalEnergy = incidentKineticEnergy + incidentMass;
 
  127   G4double centerOfMassEnergy = std::sqrt(incidentMass*incidentMass
 
  128                                         + targetMass*targetMass
 
  129                                         + 2.0*targetMass*incidentTotalEnergy);
 
  130   G4double availableEnergy = centerOfMassEnergy - targetMass - incidentMass;
 
  143     G4cout << 
"ApplyYourself: CallFirstIntInCascade for particle " 
  144            << incidentCode << 
G4endl;
 
  146   G4bool successful = 
false; 
 
  149                       incidentParticle, targetParticle, atomicWeight);
 
  152     G4cout << 
"ApplyYourself::StrangeParticlePairProduction" << 
G4endl;
 
  154   if ((
vecLength > 0) && (availableEnergy > 1.)) 
 
  157                                   incidentParticle, targetParticle);
 
  160                       excitationEnergyGNP, excitationEnergyDTA,
 
  161                       incidentParticle, targetParticle,
 
  162                       atomicWeight, atomicNumber);
 
  165                                 excitationEnergyGNP, excitationEnergyDTA,
 
  166                                 incidentParticle, targetParticle,
 
  167                                 atomicWeight, atomicNumber);
 
  170                           excitationEnergyGNP, excitationEnergyDTA, 
 
  171                           incidentParticle, targetParticle,
 
  172                           atomicWeight, atomicNumber);
 
  176                                   excitationEnergyGNP, excitationEnergyDTA,       
 
  177                                   incidentParticle, targetParticle,
 
  178                                   atomicWeight, atomicNumber);
 
  181                            excitationEnergyGNP, excitationEnergyDTA,
 
  182                            incidentParticle, targetParticle, 
 
  183                            atomicWeight, atomicNumber);
 
  187                       atomicWeight, atomicNumber);
 
  190     G4cout << 
"GHEInelasticInteraction::ApplyYourself fails to produce final state particles"  
  218   static const G4double expxl = -expxu;  
 
  224   static const G4int numMul = 1200;
 
  225   static const G4int numSec = 60;
 
  234   static G4bool first = 
true;
 
  235   static G4double protmul[numMul], protnorm[numSec];  
 
  236   static G4double neutmul[numMul], neutnorm[numSec];  
 
  241   G4int i, counter, 
nt, npos, nneg, nzero;
 
  246     for (i=0; i<numMul; i++) protmul[i] = 0.0;
 
  247     for (i=0; i<numSec; i++) protnorm[i] = 0.0;
 
  249     for (npos=0; npos<(numSec/3); npos++) {
 
  250       for (nneg=
Imax(0,npos-2); nneg<=npos; nneg++) {
 
  251         for (nzero=0; nzero<numSec/3; nzero++) {
 
  252           if (++counter < numMul) {
 
  253             nt = npos+nneg+nzero;
 
  254             if ( (nt>0) && (nt<=numSec) ) {
 
  255               protmul[counter] = 
pmltpc(npos,nneg,nzero,nt,protb,c)
 
  257               protnorm[nt-1] += protmul[counter];
 
  264     for( i=0; i<numMul; i++ )neutmul[i]  = 0.0;
 
  265     for( i=0; i<numSec; i++ )neutnorm[i] = 0.0;
 
  267     for (npos=0; npos<numSec/3; npos++) {
 
  268       for (nneg=
Imax(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)
 
  275               neutnorm[nt-1] += neutmul[counter];
 
  281     for (i=0; i<numSec; i++) {
 
  282       if( protnorm[i] > 0.0 )protnorm[i] = 1.0/protnorm[i];
 
  283       if( neutnorm[i] > 0.0 )neutnorm[i] = 1.0/neutnorm[i];
 
  290   pv[0] = incidentParticle;
 
  291   pv[1] = targetParticle;
 
  295     if (targetCode == neutronCode) {
 
  296       G4double cech[] = {0.50, 0.45, 0.40, 0.35, 0.30, 0.25, 0.06, 0.04, 0.005, 0.};
 
  298       if (
G4UniformRand() < cech[iplab]/std::pow(atomicWeight,0.42) ) {
 
  305   } 
else if (availableEnergy <= pionMass) 
return;
 
  308   npos = 0, nneg = 0, nzero = 0;
 
  312   G4double supp[] = {0., 0.4, 0.55, 0.65, 0.75, 0.82, 0.86, 0.90, 0.94, 0.98};
 
  317     if (targetCode == protonCode) {    
 
  318       w0 = - 
sqr(1.+protb)/(2.*c*
c);
 
  319       wp = w0 = std::exp(w0);
 
  329         w0 = -
sqr(1.+neutb)/(2.*c*
c);
 
  332         wm = -
sqr(-1.+neutb)/(2.*c*
c);
 
  333            wm = std::exp(wm)/2.;
 
  338              { npos = 0; nneg = 0; nzero = 1; }       
 
  339            else if( ran < wp/wt)
 
  340              { npos = 1; nneg = 0; nzero = 0; }       
 
  342              { npos = 0; nneg = 1; nzero = 0; }       
 
  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;
 
  355        for (nt=1; nt<=numSec; nt++) {
 
  356          test = std::exp( 
Amin( expxu, 
Amax( 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.0
e-10 )anpn += dum*
test;
 
  367        if( targetCode == protonCode ) 
 
  370            for (npos=0; npos<numSec/3; npos++) {
 
  371              for (nneg=
Imax(0,npos-2); nneg<=npos; nneg++) {
 
  372                for (nzero=0; nzero<numSec/3; nzero++) {
 
  373                  if (++counter < numMul) {
 
  374                    nt = npos+nneg+nzero;
 
  375                    if ( (nt>0) && (nt<=numSec) ) {
 
  376                      test = std::exp( 
Amin( expxu, 
Amax( expxl, -(
pi/4.0)*(nt*nt)/(n*n) ) ) );
 
  377                      dum = (
pi/anpn)*nt*protmul[counter]*protnorm[nt-1]/(2.0*n*n);
 
  378                      if (std::fabs(dum) < 1.0) { 
 
  379                        if( test >= 1.0
e-10 )excs += dum*
test;
 
  383                      if (ran < excs) 
goto outOfLoop;      
 
  397            for (npos=0; npos<numSec/3; npos++) {
 
  398              for (nneg=
Imax(0,npos-1); nneg<=(npos+1); nneg++) {
 
  399                for (nzero=0; nzero<numSec/3; nzero++) {
 
  400                  if (++counter < numMul) {
 
  401                    nt = npos+nneg+nzero;
 
  402                    if ( (nt>=1) && (nt<=numSec) ) {
 
  403                      test = std::exp( 
Amin( expxu, 
Amax( expxl, -(
pi/4.0)*(nt*nt)/(n*n) ) ) );
 
  404                      dum = (
pi/anpn)*nt*neutmul[counter]*neutnorm[nt-1]/(2.0*n*n);
 
  405                      if (std::fabs(dum) < 1.0) { 
 
  406                        if( test >= 1.0
e-10 )excs += dum*
test;
 
  410                      if (ran < excs) 
goto outOfLoop;       
 
  423    if( targetCode == protonCode)
 
  428        else if (npos == (1+nneg))
 
  458        else if ( npos == (1+nneg))
 
  469    nt = npos + nneg + nzero;
 
  480          else if ( ran < (
G4double)(npos+nneg)/nt)
 
  496          nt = npos + nneg + nzero;
 
  500         G4cout << 
"Particles produced: " ;
 
  503         for (i=2; i < vecLen; i++)