45   outFile << 
"G4HEAntiProtonInelastic is one of the High Energy\n" 
   46           << 
"Parameterized (HEP) models used to implement inelastic\n" 
   47           << 
"anti-proton scattering from nuclei.  It is a re-engineered\n" 
   48           << 
"version of the GHEISHA code of H. Fesefeldt.  It divides the\n" 
   49           << 
"initial collision products into backward- and forward-going\n" 
   50           << 
"clusters which are then decayed into final state hadrons.\n" 
   51           << 
"The model does not conserve energy on an event-by-event\n" 
   52           << 
"basis.  It may be applied to anti-protons with initial\n" 
   53           << 
"energies above 20 GeV.\n";
 
   74   G4double incidentKineticEnergy = incidentTotalEnergy - incidentMass;
 
   76   if (incidentKineticEnergy < 1.)
 
   77     G4cout << 
"GHEAntiProtonInelastic: incident energy < 1 GeV" << 
G4endl;
 
   80     G4cout << 
"G4HEAntiProtonInelastic::ApplyYourself" << 
G4endl;
 
   82            << 
"mass "              << incidentMass
 
   83            << 
"kinetic energy "    << incidentKineticEnergy
 
   85     G4cout << 
"target material with (A,Z) = ("  
   86            << atomicWeight << 
"," << atomicNumber << 
")" << 
G4endl;
 
   90                                               atomicWeight, atomicNumber);
 
   92     G4cout << 
"nuclear inelasticity = " << inelasticity << 
G4endl;
 
   94   incidentKineticEnergy -= inelasticity;
 
  100                                           atomicWeight, atomicNumber,
 
  102                                           excitationEnergyDTA);
 
  104     G4cout << 
"nuclear excitation = " << excitation << excitationEnergyGNP 
 
  105            << excitationEnergyDTA << 
G4endl;             
 
  108   incidentKineticEnergy -= excitation;
 
  109   incidentTotalEnergy = incidentKineticEnergy + incidentMass;
 
  122   G4double centerOfMassEnergy = std::sqrt(incidentMass*incidentMass
 
  123                                         + targetMass*targetMass
 
  124                                         + 2.0*targetMass*incidentTotalEnergy);
 
  125   G4double availableEnergy = centerOfMassEnergy - targetMass - incidentMass;
 
  131     G4cout << 
"ApplyYourself: CallFirstIntInCascade for particle " 
  132            << incidentCode << 
G4endl;
 
  134   G4bool successful = 
false; 
 
  137                           incidentParticle, targetParticle, atomicWeight);
 
  140     G4cout << 
"ApplyYourself::StrangeParticlePairProduction" << 
G4endl;  
 
  142   if ((
vecLength > 0) && (availableEnergy > 1.)) 
 
  145                                   incidentParticle, targetParticle);
 
  147                       excitationEnergyGNP, excitationEnergyDTA,
 
  148                       incidentParticle, targetParticle,
 
  149                       atomicWeight, atomicNumber);
 
  152                                 excitationEnergyGNP, excitationEnergyDTA,
 
  153                                 incidentParticle, targetParticle,
 
  154                                 atomicWeight, atomicNumber);
 
  157                           excitationEnergyGNP, excitationEnergyDTA, 
 
  158                           incidentParticle, targetParticle,
 
  159                           atomicWeight, atomicNumber);
 
  163                                   excitationEnergyGNP, excitationEnergyDTA,       
 
  164                                   incidentParticle, targetParticle,
 
  165                                   atomicWeight, atomicNumber);
 
  168                            excitationEnergyGNP, excitationEnergyDTA,
 
  169                            incidentParticle, targetParticle, 
 
  170                            atomicWeight, atomicNumber);
 
  174                       atomicWeight, atomicNumber);
 
  177     G4cout << 
"GHEInelasticInteraction::ApplyYourself fails to produce final state particles"  
  205   static const G4double expxl = -expxu;  
 
  211   static const G4int numMul   = 1200;
 
  212   static const G4int numMulAn = 400;
 
  213   static const G4int numSec   = 60;
 
  221   static G4bool first = 
true;
 
  222   static G4double protmul[numMul],  protnorm[numSec];   
 
  223   static G4double protmulAn[numMulAn],protnormAn[numSec]; 
 
  224   static G4double neutmul[numMul],  neutnorm[numSec];   
 
  225   static G4double neutmulAn[numMulAn],neutnormAn[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=
Imax(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) ) 
 
  249                               protmul[counter] = 
pmltpc(npos,nneg,nzero,nt,protb,c);
 
  250                               protnorm[nt-1] += protmul[counter];
 
  256        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) ) 
 
  271                                neutmul[counter] = 
pmltpc(npos,nneg,nzero,nt,neutb,c);
 
  272                                neutnorm[nt-1] += neutmul[counter];
 
  278        for( i=0; i<numSec; i++ ) 
 
  280             if( protnorm[i] > 0.0 )protnorm[i] = 1.0/protnorm[i];
 
  281             if( neutnorm[i] > 0.0 )neutnorm[i] = 1.0/neutnorm[i];
 
  284        for( i=0; i<numMulAn  ; i++ ) protmulAn[i]  = 0.0;
 
  285        for( i=0; i<numSec    ; i++ ) protnormAn[i] = 0.0;
 
  287        for( npos=1; npos<(numSec/3); npos++ ) 
 
  290             for( nzero=0; nzero<numSec/3; nzero++ ) 
 
  292                  if( ++counter < numMulAn ) 
 
  294                      nt = npos+nneg+nzero;
 
  295                      if( (nt>0) && (nt<=numSec) ) 
 
  297                          protmulAn[counter] = 
pmltpc(npos,nneg,nzero,nt,protb,c);
 
  298                          protnormAn[nt-1] += protmulAn[counter];
 
  303        for( i=0; i<numMulAn; i++ ) neutmulAn[i]  = 0.0;
 
  304        for( i=0; i<numSec;   i++ ) neutnormAn[i] = 0.0;
 
  306        for( npos=1; npos<numSec/3; npos++ ) 
 
  309             for( nzero=0; nzero<numSec/3; nzero++ ) 
 
  311                  if( ++counter < numMulAn ) 
 
  313                      nt = npos+nneg+nzero;
 
  314                      if( (nt>0) && (nt<=numSec) ) 
 
  316                           neutmulAn[counter] = 
pmltpc(npos,nneg,nzero,nt,neutb,c);
 
  317                           neutnormAn[nt-1] += neutmulAn[counter];
 
  322        for( i=0; i<numSec; i++ ) 
 
  324             if( protnormAn[i] > 0.0 )protnormAn[i] = 1.0/protnormAn[i];
 
  325             if( neutnormAn[i] > 0.0 )neutnormAn[i] = 1.0/neutnormAn[i];
 
  332    pv[0] = incidentParticle;
 
  333    pv[1] = targetParticle;
 
  338        if( targetCode == protonCode ) 
 
  340            G4double cech[] = {0.14, 0.170, 0.180, 0.180, 0.180, 0.170, 0.170, 0.160, 0.155, 0.145,
 
  341                               0.11, 0.082, 0.065, 0.050, 0.041, 0.035, 0.028, 0.024, 0.010, 0.000};
 
  343            G4int iplab = 
G4int( incidentTotalMomentum*10.);
 
  344            if (iplab > 9) iplab = 
Imin(19, 
G4int( incidentTotalMomentum) + 9);
 
  345            if( 
G4UniformRand() < cech[iplab]/std::pow(atomicWeight,0.42) ) 
 
  358    npos = 0; nneg = 0; nzero = 0;
 
  359    G4double anhl[] = {1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 0.90,
 
  360                       0.60, 0.52, 0.47, 0.44, 0.41, 0.39, 0.37, 0.35, 0.34, 0.24,
 
  361                       0.19, 0.15, 0.12, 0.10, 0.09, 0.07, 0.06, 0.05, 0.00};
 
  362    G4int            iplab =      
G4int( incidentTotalMomentum*10.);
 
  363    if ( iplab >  9) iplab =  9 + 
G4int( incidentTotalMomentum);          
 
  364    if ( iplab > 18) iplab = 18 + 
G4int( incidentTotalMomentum*10.);
 
  365                     iplab = 
Imin(28, iplab);
 
  373        G4double supp[] = {0., 0.4, 0.55, 0.65, 0.75, 0.82, 0.86, 0.90, 0.94, 0.98};
 
  379            if( targetCode == neutronCode )                    
 
  381                w0 = - 
sqr(1.+neutb)/(2.*c*
c);
 
  383                wm = - 
sqr(-1.+neutb)/(2.*c*
c);  
 
  386                  { npos = 0; nneg = 0; nzero = 1; }
 
  388                  { npos = 0; nneg = 1; nzero = 0; }       
 
  392                w0 = -
sqr(1.+protb)/(2.*c*
c);
 
  395                wm = -
sqr(-1.+protb)/(2.*c*
c);
 
  401                  { npos = 0; nneg = 0; nzero = 1; }       
 
  402                else if( ran < wp/wt)
 
  403                  { npos = 1; nneg = 0; nzero = 0; }       
 
  405                  { npos = 0; nneg = 1; nzero = 0; }       
 
  412            G4double aleab = std::log(availableEnergy);
 
  413            G4double n     = 3.62567+aleab*(0.665843+aleab*(0.336514
 
  414                             + aleab*(0.117712+0.0136912*aleab))) - 2.0;
 
  420            for (nt=1; nt<=numSec; nt++) {
 
  421              test = std::exp( 
Amin( expxu, 
Amax( expxl, -(
pi/4.0)*(nt*nt)/(n*n) ) ) );
 
  422              dum = 
pi*nt/(2.0*n*
n);
 
  423              if (std::fabs(dum) < 1.0) { 
 
  424                if( test >= 1.0
e-10 )anpn += dum*
test;
 
  432            if( targetCode == protonCode ) 
 
  435                for( npos=0; npos<numSec/3; npos++ ) 
 
  437                     for( nneg=
Imax(0,npos-1); nneg<=(npos+1); nneg++ ) 
 
  439                          for( nzero=0; nzero<numSec/3; nzero++ ) 
 
  441                               if( ++counter < numMul ) 
 
  443                                   nt = npos+nneg+nzero;
 
  444                                   if ( (nt>0) && (nt<=numSec) ) {
 
  445                                     test = std::exp( 
Amin( expxu, 
Amax( expxl, -(
pi/4.0)*(nt*nt)/(n*n) ) ) );
 
  446                                     dum = (
pi/anpn)*nt*protmul[counter]*protnorm[nt-1]/(2.0*n*n);
 
  447                                     if (std::fabs(dum) < 1.0) { 
 
  448                                       if( test >= 1.0
e-10 )excs += dum*
test;
 
  453                                     if (ran < excs) 
goto outOfLoop;      
 
  467                for( npos=0; npos<numSec/3; npos++ ) 
 
  469                     for( nneg=npos; nneg<=(npos+2); nneg++ ) 
 
  471                          for( nzero=0; nzero<numSec/3; nzero++ ) 
 
  473                               if( ++counter < numMul ) 
 
  475                                   nt = npos+nneg+nzero;
 
  476                                   if ( (nt>=1) && (nt<=numSec) ) {
 
  477                                     test = std::exp( 
Amin( expxu, 
Amax( expxl, -(
pi/4.0)*(nt*nt)/(n*n) ) ) );
 
  478                                     dum = (
pi/anpn)*nt*neutmul[counter]*neutnorm[nt-1]/(2.0*n*n);
 
  479                                     if (std::fabs(dum) < 1.0) { 
 
  480                                       if( test >= 1.0
e-10 )excs += dum*
test;
 
  485                                     if (ran < excs) 
goto outOfLoop;       
 
  498        if( targetCode == neutronCode)
 
  503            else if (npos == (nneg-1))
 
  533            else if ( npos == (1+nneg))
 
  549            G4double aleab = std::log(availableEnergy);
 
  550            G4double n     = 3.62567+aleab*(0.665843+aleab*(0.336514
 
  551                             + aleab*(0.117712+0.0136912*aleab))) - 2.0;
 
  557            for (nt=2; nt<=numSec; nt++) {
 
  558              test = std::exp( 
Amin( expxu, 
Amax( expxl, -(
pi/4.0)*(nt*nt)/(n*n) ) ) );
 
  559              dum = 
pi*nt/(2.0*n*
n);
 
  560              if (std::fabs(dum) < 1.0) { 
 
  561                if( test >= 1.0
e-10 )anpn += dum*
test;
 
  569            if( targetCode == protonCode ) 
 
  572                for( npos=1; npos<numSec/3; npos++ ) 
 
  575                     for( nzero=0; nzero<numSec/3; nzero++ ) 
 
  577                         if( ++counter < numMulAn ) 
 
  579                             nt = npos+nneg+nzero;
 
  580                             if ( (nt>0) && (nt<=numSec) ) {
 
  581                               test = std::exp( 
Amin( expxu, 
Amax( expxl, -(
pi/4.0)*(nt*nt)/(n*n) ) ) );
 
  582                               dum = (
pi/anpn)*nt*protmulAn[counter]*protnormAn[nt-1]/(2.0*n*n);
 
  583                               if (std::fabs(dum) < 1.0) { 
 
  584                                 if( test >= 1.0
e-10 )excs += dum*
test;
 
  589                               if (ran < excs) 
goto outOfLoopAn;      
 
  601                for( npos=1; npos<numSec/3; npos++ ) 
 
  604                    for( nzero=0; nzero<numSec/3; nzero++ ) 
 
  606                         if( ++counter < numMulAn ) 
 
  608                             nt = npos+nneg+nzero;
 
  609                             if ( (nt>=1) && (nt<=numSec) ) {
 
  610                               test = std::exp( 
Amin( expxu, 
Amax( expxl, -(
pi/4.0)*(nt*nt)/(n*n) ) ) );
 
  611                               dum = (
pi/anpn)*nt*neutmulAn[counter]*neutnormAn[nt-1]/(2.0*n*n);
 
  612                               if (std::fabs(dum) < 1.0) { 
 
  613                                 if( test >= 1.0
e-10 )excs += dum*
test;
 
  618                               if (ran < excs) 
goto outOfLoopAn;       
 
  631    nt = npos + nneg + nzero;
 
  642          else if ( ran < (
G4double)(npos+nneg)/nt)
 
  658          nt = npos + nneg + nzero;
 
  662         G4cout << 
"Particles produced: " ;
 
  665         for (i=2; i < vecLen; i++)