44   outFile << 
"G4HEKaonZeroInelastic is one of the High Energy\n" 
   45           << 
"Parameterized (HEP) models used to implement inelastic\n" 
   46           << 
"K0 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 K0 with initial energies\n" 
   76   G4double incidentKineticEnergy = incidentTotalEnergy - incidentMass;
 
   78   if (incidentKineticEnergy < 1.)
 
   79     G4cout << 
"GHEKaonZeroInelastic: incident energy < 1 GeV" << 
G4endl;;
 
   82     G4cout << 
"G4HEKaonZeroInelastic::ApplyYourself" << 
G4endl;
 
   84            << 
"mass "              << incidentMass
 
   85            << 
"kinetic energy "    << incidentKineticEnergy
 
   87     G4cout << 
"target material with (A,Z) = ("  
   88            << atomicWeight << 
"," << atomicNumber << 
")" << 
G4endl;
 
   92                                               atomicWeight, atomicNumber);
 
   94     G4cout << 
"nuclear inelasticity = " << inelasticity << 
G4endl;
 
   96   incidentKineticEnergy -= inelasticity;
 
  102                                           atomicWeight, atomicNumber,
 
  104                                           excitationEnergyDTA);
 
  106     G4cout << 
"nuclear excitation = " << excitation << excitationEnergyGNP 
 
  107            << excitationEnergyDTA << 
G4endl;             
 
  109   incidentKineticEnergy -= excitation;
 
  110   incidentTotalEnergy = incidentKineticEnergy + incidentMass;
 
  123   G4double centerOfMassEnergy = std::sqrt(incidentMass*incidentMass
 
  124                                         + targetMass*targetMass
 
  125                                         + 2.0*targetMass*incidentTotalEnergy);
 
  126   G4double availableEnergy = centerOfMassEnergy - targetMass - incidentMass;
 
  132     G4cout << 
"ApplyYourself: CallFirstIntInCascade for particle " 
  133            << incidentCode << 
G4endl;
 
  135   G4bool successful = 
false; 
 
  138                         incidentParticle, targetParticle, atomicWeight);
 
  141     G4cout << 
"ApplyYourself::StrangeParticlePairProduction" << 
G4endl;
 
  143   if ((
vecLength > 0) && (availableEnergy > 1.)) 
 
  146                                   incidentParticle, targetParticle);
 
  149                       excitationEnergyGNP, excitationEnergyDTA,
 
  150                       incidentParticle, targetParticle,
 
  151                       atomicWeight, atomicNumber);
 
  154                                 excitationEnergyGNP, excitationEnergyDTA,
 
  155                                 incidentParticle, targetParticle,
 
  156                                 atomicWeight, atomicNumber);
 
  159                           excitationEnergyGNP, excitationEnergyDTA, 
 
  160                           incidentParticle, targetParticle,
 
  161                           atomicWeight, atomicNumber);
 
  165                                   excitationEnergyGNP, excitationEnergyDTA,       
 
  166                                   incidentParticle, targetParticle,
 
  167                                   atomicWeight, atomicNumber);
 
  170                            excitationEnergyGNP, excitationEnergyDTA,
 
  171                            incidentParticle, targetParticle, 
 
  172                            atomicWeight, atomicNumber);
 
  176                       atomicWeight, atomicNumber);
 
  179     G4cout << 
"GHEInelasticInteraction::ApplyYourself fails to produce final state particles" 
  208   static const G4double expxl = -expxu;  
 
  214   static const G4int numMul = 1200;
 
  215   static const G4int numSec = 60;
 
  223   static G4bool first = 
true;
 
  224   static G4double protmul[numMul], protnorm[numSec];  
 
  225   static G4double neutmul[numMul], neutnorm[numSec];  
 
  230   G4int i, counter, 
nt, npos, nneg, nzero;
 
  235        for( i=0; i<numMul; i++ )protmul[i]  = 0.0;
 
  236        for( i=0; i<numSec; i++ )protnorm[i] = 0.0;
 
  238        for( npos=0; npos<(numSec/3); npos++ ) 
 
  240             for( nneg=std::max(0,npos-1); nneg<=(npos+1); nneg++ ) 
 
  242                  for( nzero=0; nzero<numSec/3; nzero++ ) 
 
  244                       if( ++counter < numMul ) 
 
  246                           nt = npos+nneg+nzero;
 
  247                           if( (nt>0) && (nt<=numSec) ) 
 
  250                                     pmltpc(npos,nneg,nzero,nt,protb,c) ;
 
  251                               protnorm[nt-1] += protmul[counter];
 
  257        for( i=0; i<numMul; i++ )neutmul[i]  = 0.0;
 
  258        for( i=0; i<numSec; i++ )neutnorm[i] = 0.0;
 
  260        for( npos=0; npos<numSec/3; npos++ ) 
 
  262             for( nneg=npos; nneg<=(npos+2); nneg++ ) 
 
  264                  for( nzero=0; nzero<numSec/3; nzero++ ) 
 
  266                       if( ++counter < numMul ) 
 
  268                           nt = npos+nneg+nzero;
 
  269                           if( (nt>0) && (nt<=numSec) ) 
 
  272                                       pmltpc(npos,nneg,nzero,nt,neutb,c);
 
  273                                neutnorm[nt-1] += neutmul[counter];
 
  279        for( i=0; i<numSec; i++ ) 
 
  281             if( protnorm[i] > 0.0 )protnorm[i] = 1.0/protnorm[i];
 
  282             if( neutnorm[i] > 0.0 )neutnorm[i] = 1.0/neutnorm[i];
 
  289    pv[0] = incidentParticle;
 
  290    pv[1] = targetParticle;
 
  295        if( targetCode == protonCode ) 
 
  297            G4double cech[] = {0.33,0.27,0.29,0.31,0.27,0.18,0.13,0.10,0.09,0.07};
 
  298            G4int iplab = 
G4int( std::min( 9.0, incidentTotalMomentum*5. ) );
 
  299            if( 
G4UniformRand() < cech[iplab]/std::pow(atomicWeight,0.42) ) 
 
  312    npos = 0, nneg = 0, nzero = 0;
 
  316    G4double supp[] = {0., 0.4, 0.55, 0.65, 0.75, 0.82, 0.86, 0.90, 0.94, 0.98};
 
  322        if( targetCode == neutronCode )                    
 
  324            w0 = - 
sqr(1.+protb)/(2.*c*
c);
 
  326            wm = - 
sqr(-1.+protb)/(2.*c*
c);
 
  330            if( 
G4UniformRand() < w0/(w0+wm) )              { npos = 0; nneg = 0; nzero = 1; }
 
  332              { npos = 0; nneg = 1; nzero = 0; }       
 
  336            w0 = -
sqr(1.+neutb)/(2.*c*
c);
 
  337            wp = w0 = std::exp(w0);
 
  338            wm = -
sqr(-1.+neutb)/(2.*c*
c);
 
  344              { npos = 0; nneg = 0; nzero = 1; }       
 
  345            else if( ran < wp/wt)
 
  346              { npos = 1; nneg = 0; nzero = 0; }       
 
  348              { npos = 0; nneg = 1; nzero = 0; }       
 
  355        G4double aleab = std::log(availableEnergy);
 
  356        G4double n     = 3.62567+aleab*(0.665843+aleab*(0.336514
 
  357                     + aleab*(0.117712+0.0136912*aleab))) - 2.0;
 
  363        for (nt=1; nt<=numSec; nt++) {
 
  364          test = std::exp( std::min( expxu, std::max( expxl, -(
pi/4.0)*(nt*nt)/(n*n) ) ) );
 
  365          dum = 
pi*nt/(2.0*n*
n);
 
  366          if (std::fabs(dum) < 1.0) { 
 
  367            if( test >= 1.0
e-10 )anpn += dum*
test;
 
  375        if( targetCode == protonCode ) 
 
  378            for( npos=0; npos<numSec/3; npos++ ) 
 
  380                 for( nneg=std::max(0,npos-1); nneg<=(npos+1); nneg++ ) 
 
  382                      for (nzero=0; nzero<numSec/3; nzero++) {
 
  383                        if (++counter < numMul) {
 
  384                          nt = npos+nneg+nzero;
 
  385                          if ( (nt>0) && (nt<=numSec) ) {
 
  386                            test = std::exp( std::min( expxu, std::max( expxl, -(
pi/4.0)*(nt*nt)/(n*n) ) ) );
 
  387                            dum = (
pi/anpn)*nt*protmul[counter]*protnorm[nt-1]/(2.0*n*n);
 
  388                            if (std::fabs(dum) < 1.0) { 
 
  389                              if( test >= 1.0
e-10 )excs += dum*
test;
 
  393                            if (ran < excs) 
goto outOfLoop;      
 
  407            for( npos=0; npos<numSec/3; npos++ ) 
 
  409                 for( nneg=npos; nneg<=(npos+2); nneg++ ) 
 
  411                      for (nzero=0; nzero<numSec/3; nzero++) {
 
  412                        if (++counter < numMul) {
 
  413                          nt = npos+nneg+nzero;
 
  414                          if ( (nt>=1) && (nt<=numSec) ) {
 
  415                            test = std::exp( std::min( expxu, std::max( expxl, -(
pi/4.0)*(nt*nt)/(n*n) ) ) );
 
  416                            dum = (
pi/anpn)*nt*neutmul[counter]*neutnorm[nt-1]/(2.0*n*n);
 
  417                            if (std::fabs(dum) < 1.0) { 
 
  418                              if( test >= 1.0
e-10 )excs += dum*
test;
 
  422                            if (ran < excs) 
goto outOfLoop;       
 
  435    if( targetCode == neutronCode)
 
  440        else if (npos == (nneg-1))
 
  470        else if ( npos == (nneg+1))
 
  481    nt = npos + nneg + nzero;
 
  492          else if ( ran < (
G4double)(npos+nneg)/nt)
 
  508          nt = npos + nneg + nzero;
 
  512         G4cout << 
"Particles produced: " ;
 
  515         for (i=2; i < vecLen; i++)