Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/hadronic/models/coherent_elastic/src/G4HadronElastic.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/coherent_elastic/src/G4HadronElastic.cc (Version 11.3.0) and /processes/hadronic/models/coherent_elastic/src/G4HadronElastic.cc (Version 9.2.p3)


  1 //                                             <<   1 //
  2 // ******************************************* <<   2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * License and Disclaimer                                           *
  4 // *                                           <<   4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License <<   7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.      <<   9 // * include a list of copyright holders.                             *
 10 // *                                           <<  10 // *                                                                  *
 11 // * Neither the authors of this software syst <<  11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin <<  12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran <<  13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum <<  14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio <<  16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                           <<  17 // *                                                                  *
 18 // * This  code  implementation is the result  <<  18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio <<  19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri <<  20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag <<  21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati <<  22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof <<  23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ******************************************* <<  24 // ********************************************************************
 25 //                                             <<  25 //
 26 //                                             <<  26 // $Id: G4HadronElastic.cc,v 1.61.2.1 2010/01/26 15:03:49 gcosmo Exp $
 27 // Geant4 Header : G4HadronElastic             <<  27 // GEANT4 tag $Name: geant4-09-02-patch-03 $
 28 //                                             <<  28 //
 29 // Author : V.Ivanchenko 29 June 2009 (redesig <<  29 //
 30 //                                             <<  30 // Physics model class G4HadronElastic (derived from G4LElastic)
 31                                                <<  31 //
 32 #include "G4HadronElastic.hh"                  <<  32 //
 33 #include "G4SystemOfUnits.hh"                  <<  33 // G4 Model: Low-energy Elastic scattering with 4-momentum balance
 34 #include "G4ParticleTable.hh"                  <<  34 // F.W. Jones, TRIUMF, 04-JUN-96
 35 #include "G4ParticleDefinition.hh"             <<  35 // Uses  G4ElasticHadrNucleusHE and G4VQCrossSection
 36 #include "G4IonTable.hh"                       <<  36 //
 37 #include "Randomize.hh"                        <<  37 //
 38 #include "G4Proton.hh"                         <<  38 // 25-JUN-98 FWJ: replaced missing Initialize for ParticleChange.
 39 #include "G4Neutron.hh"                        <<  39 // 09-Set-05 V.Ivanchenko HARP version of the model: fix scattering
 40 #include "G4Deuteron.hh"                       <<  40 //           on hydrogen, use relativistic Lorentz transformation
 41 #include "G4Alpha.hh"                          <<  41 // 24-Nov-05 V.Ivanchenko sample cost in center of mass reference system
 42 #include "G4Pow.hh"                            <<  42 // 03-Dec-05 V.Ivanchenko add protection to initial momentum 20 MeV/c in
 43 #include "G4Exp.hh"                            <<  43 //           center of mass system (before it was in lab system)
 44 #include "G4Log.hh"                            <<  44 //           below model is not valid
 45 #include "G4HadronicParameters.hh"             <<  45 // 14-Dec-05 V.Ivanchenko change protection to cos(theta) < -1 and
 46 #include "G4PhysicsModelCatalog.hh"            <<  46 //           rename the class
 47                                                <<  47 // 13-Apr-06 V.Ivanchenko move to coherent_elastic subdirectory; remove
 48                                                <<  48 //           charge exchange; remove limitation on incident momentum;
 49 G4HadronElastic::G4HadronElastic(const G4Strin <<  49 //           add s-wave regim below some momentum        
 50   : G4HadronicInteraction(name), secID(-1)     <<  50 // 24-Apr-06 V.Ivanchenko add neutron scattering on hydrogen from CHIPS
 51 {                                              <<  51 // 07-Jun-06 V.Ivanchenko fix problem of rotation
 52   SetMinEnergy( 0.0*GeV );                     <<  52 // 25-Jul-06 V.Ivanchenko add 19 MeV low energy, below which S-wave is sampled
 53   SetMaxEnergy( G4HadronicParameters::Instance <<  53 // 02-Aug-06 V.Ivanchenko introduce energy cut on the aria of S-wave for pions
 54   lowestEnergyLimit= 1.e-6*eV;                 <<  54 // 24-Aug-06 V.Ivanchenko switch on G4ElasticHadrNucleusHE
 55   pLocalTmax  = 0.0;                           <<  55 // 31-Aug-06 V.Ivanchenko do not sample sacttering for particles with kinetic 
 56   nwarn = 0;                                   <<  56 //                        energy below 10 keV
 57                                                <<  57 // 16-Nov-06 V.Ivanchenko Simplify logic of choosing of the model for sampling
 58   theProton   = G4Proton::Proton();            <<  58 // 30-Mar-07 V.Ivanchenko lowEnergyLimitQ=0, lowEnergyLimitHE = 1.0*GeV,
 59   theNeutron  = G4Neutron::Neutron();          <<  59 //                        lowestEnergyLimit= 0
 60   theDeuteron = G4Deuteron::Deuteron();        <<  60 // 04-May-07 V.Ivanchenko do not use HE model for hydrogen target to avoid NaN;
 61   theAlpha    = G4Alpha::Alpha();              <<  61 //                        use QElastic for p, n incident for any energy for 
 62                                                <<  62 //                        p and He targets only  
 63   secID = G4PhysicsModelCatalog::GetModelID( " <<  63 // 11-May-07 V.Ivanchenko remove unused method Defs1
 64 }                                              <<  64 //
 65                                                <<  65 
 66 G4HadronElastic::~G4HadronElastic()            <<  66 #include "G4HadronElastic.hh"
 67 {}                                             <<  67 #include "G4ParticleTable.hh"
 68                                                <<  68 #include "G4ParticleDefinition.hh"
 69                                                <<  69 #include "G4IonTable.hh"
 70 void G4HadronElastic::ModelDescription(std::os <<  70 #include "G4QElasticCrossSection.hh"
 71 {                                              <<  71 #include "G4VQCrossSection.hh"
 72   outFile << "G4HadronElastic is the base clas <<  72 #include "G4ElasticHadrNucleusHE.hh"
 73           << "elastic scattering models except <<  73 #include "Randomize.hh"
 74           << "By default it uses the Gheisha t <<  74 #include "G4Proton.hh"
 75     << "transfer parameterization.  The model  <<  75 #include "G4Neutron.hh"
 76     << "as opposed to the original Gheisha mod <<  76 #include "G4Deuteron.hh"
 77     << "This model may be used for all long-li <<  77 #include "G4Alpha.hh"
 78     << "incident energies but fit the data onl <<  78 #include "G4PionPlus.hh"
 79 }                                              <<  79 #include "G4PionMinus.hh"
 80                                                <<  80 
 81 G4HadFinalState* G4HadronElastic::ApplyYoursel <<  81 G4VQCrossSection* G4HadronElastic::qCManager = 0;
 82      const G4HadProjectile& aTrack, G4Nucleus& <<  82 
 83 {                                              <<  83 G4HadronElastic::G4HadronElastic(G4ElasticHadrNucleusHE* HModel) 
 84   theParticleChange.Clear();                   <<  84   : G4HadronicInteraction("G4HadronElastic"), hElastic(HModel)
 85                                                <<  85 {
 86   const G4HadProjectile* aParticle = &aTrack;  <<  86   SetMinEnergy( 0.0*GeV );
 87   G4double ekin = aParticle->GetKineticEnergy( <<  87   SetMaxEnergy( 100.*TeV );
 88                                                <<  88   verboseLevel= 0;
 89   // no scattering below the limit             <<  89   lowEnergyRecoilLimit = 100.*keV;  
 90   if(ekin <= lowestEnergyLimit) {              <<  90   lowEnergyLimitQ  = 0.0*GeV;  
 91     theParticleChange.SetEnergyChange(ekin);   <<  91   lowEnergyLimitHE = 1.0*GeV; 
 92     theParticleChange.SetMomentumChange(0.,0., <<  92   lowestEnergyLimit= 1.e-6*eV;  
 93     return &theParticleChange;                 <<  93   plabLowLimit     = 20.0*MeV;
 94   }                                            <<  94 
 95                                                <<  95   if(!qCManager) {qCManager = G4QElasticCrossSection::GetPointer();}
 96   G4int A = targetNucleus.GetA_asInt();        <<  96   if(!hElastic) hElastic = new G4ElasticHadrNucleusHE();
 97   G4int Z = targetNucleus.GetZ_asInt();        <<  97 
 98                                                <<  98   theProton   = G4Proton::Proton();
 99   // Scattered particle referred to axis of in <<  99   theNeutron  = G4Neutron::Neutron();
100   const G4ParticleDefinition* theParticle = aP << 100   theDeuteron = G4Deuteron::Deuteron();
101   G4double m1 = theParticle->GetPDGMass();     << 101   theAlpha    = G4Alpha::Alpha();
102   G4double plab = std::sqrt(ekin*(ekin + 2.0*m << 102   thePionPlus = G4PionPlus::PionPlus();
103                                                << 103   thePionMinus= G4PionMinus::PionMinus();
104   if (verboseLevel>1) {                        << 104 
105     G4cout << "G4HadronElastic: "              << 105 }
106      << aParticle->GetDefinition()->GetParticl << 106 
107      << " Plab(GeV/c)= " << plab/GeV           << 107 G4HadronElastic::~G4HadronElastic()
108      << " Ekin(MeV) = " << ekin/MeV            << 108 {
109      << " scattered off Z= " << Z              << 109   delete hElastic;
110      << " A= " << A                            << 110 }
111      << G4endl;                                << 111 
112   }                                            << 112 G4VQCrossSection* G4HadronElastic::GetCS()
113                                                << 113 {
114   G4double mass2 = G4NucleiProperties::GetNucl << 114   return qCManager;
115   G4double e1 = m1 + ekin;                     << 115 }
116   G4LorentzVector lv(0.0,0.0,plab,e1+mass2);   << 116 
117   G4ThreeVector bst = lv.boostVector();        << 117 G4ElasticHadrNucleusHE* G4HadronElastic::GetHElastic()
118   G4double momentumCMS = plab*mass2/std::sqrt( << 118 {
119                                                << 119   return hElastic;
120   pLocalTmax = 4.0*momentumCMS*momentumCMS;    << 120 }
121                                                << 121 
122   // Sampling in CM system                     << 122 G4HadFinalState* G4HadronElastic::ApplyYourself(
123   G4double t = SampleInvariantT(theParticle, p << 123      const G4HadProjectile& aTrack, G4Nucleus& targetNucleus)
124                                                << 124 {
125   if(t < 0.0 || t > pLocalTmax) {              << 125   theParticleChange.Clear();
126     // For the very rare cases where cos(theta << 126 
127     // print some debugging information via a  << 127   const G4HadProjectile* aParticle = &aTrack;
128     // using the default algorithm             << 128   G4double ekin = aParticle->GetKineticEnergy();
129 #ifdef G4VERBOSE                               << 129   if(ekin <= lowestEnergyLimit) {
130     if(nwarn < 2) {                            << 130     theParticleChange.SetEnergyChange(ekin);
131       G4ExceptionDescription ed;               << 131     theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
132       ed << GetModelName() << " wrong sampling << 132     return &theParticleChange;
133    << " for " << aParticle->GetDefinition()->G << 133   }
134    << " ekin=" << ekin << " MeV"               << 134 
135    << " off (Z,A)=(" << Z << "," << A << ") -  << 135   G4double aTarget = targetNucleus.GetN();
136       G4Exception( "G4HadronElastic::ApplyYour << 136   G4double zTarget = targetNucleus.GetZ();
137       ++nwarn;                                 << 137 
138     }                                          << 138   G4double plab = aParticle->GetTotalMomentum();
139 #endif                                         << 139   if (verboseLevel >1) {
140     t = G4HadronElastic::SampleInvariantT(theP << 140     G4cout << "G4HadronElastic::DoIt: Incident particle plab=" 
141   }                                            << 141      << plab/GeV << " GeV/c " 
142                                                << 142      << " ekin(MeV) = " << ekin/MeV << "  " 
143   G4double phi  = G4UniformRand()*CLHEP::twopi << 143      << aParticle->GetDefinition()->GetParticleName() << G4endl;
144   G4double cost = 1. - 2.0*t/pLocalTmax;       << 144   }
145                                                << 145   // Scattered particle referred to axis of incident particle
146   if (cost > 1.0) { cost = 1.0; }              << 146   const G4ParticleDefinition* theParticle = aParticle->GetDefinition();
147   else if(cost < -1.0) { cost = -1.0; }        << 147   G4double m1 = theParticle->GetPDGMass();
148                                                << 148 
149   G4double sint = std::sqrt((1.0-cost)*(1.0+co << 149   G4int Z = static_cast<G4int>(zTarget+0.5);
150                                                << 150   G4int A = static_cast<G4int>(aTarget+0.5);
151   if (verboseLevel>1) {                        << 151   G4int N = A - Z;
152     G4cout << " t= " << t << " tmax(GeV^2)= "  << 152   G4int projPDG = theParticle->GetPDGEncoding();
153      << " Pcms(GeV)= " << momentumCMS/GeV << " << 153   if (verboseLevel>1) {
154      << " sin(t)=" << sint << G4endl;          << 154     G4cout << "G4HadronElastic for " << theParticle->GetParticleName()
155   }                                            << 155      << " PDGcode= " << projPDG << " on nucleus Z= " << Z 
156   G4LorentzVector nlv1(momentumCMS*sint*std::c << 156      << " A= " << A << " N= " << N 
157            momentumCMS*sint*std::sin(phi),     << 157      << G4endl;
158                        momentumCMS*cost,       << 158   }
159            std::sqrt(momentumCMS*momentumCMS + << 159   G4ParticleDefinition * theDef = 0;
160                                                << 160 
161   nlv1.boost(bst);                             << 161   if(Z == 1 && A == 1)       theDef = theProton;
162                                                << 162   else if (Z == 1 && A == 2) theDef = theDeuteron;
163   G4double eFinal = nlv1.e() - m1;             << 163   else if (Z == 1 && A == 3) theDef = G4Triton::Triton();
164   if (verboseLevel > 1) {                      << 164   else if (Z == 2 && A == 3) theDef = G4He3::He3();
165     G4cout <<"G4HadronElastic: m= " << m1 << " << 165   else if (Z == 2 && A == 4) theDef = theAlpha;
166      << " 4-M Final: " << nlv1                 << 166   else theDef = G4ParticleTable::GetParticleTable()->FindIon(Z,A,0,Z);
167      << G4endl;                                << 167  
168   }                                            << 168   G4double m2 = theDef->GetPDGMass();
169                                                << 169   G4LorentzVector lv1 = aParticle->Get4Momentum();
170   if(eFinal <= 0.0) {                          << 170   G4LorentzVector lv(0.0,0.0,0.0,m2);   
171     theParticleChange.SetMomentumChange(0.0,0. << 171   lv += lv1;
172     theParticleChange.SetEnergyChange(0.0);    << 172 
173   } else {                                     << 173   G4ThreeVector bst = lv.boostVector();
174     theParticleChange.SetMomentumChange(nlv1.v << 174   lv1.boost(-bst);
175     theParticleChange.SetEnergyChange(eFinal); << 175 
176   }                                            << 176   G4ThreeVector p1 = lv1.vect();
177   lv -= nlv1;                                  << 177   G4double ptot = p1.mag();
178   G4double erec =  std::max(lv.e() - mass2, 0. << 178   G4double tmax = 4.0*ptot*ptot;
179   if (verboseLevel > 1) {                      << 179   G4double t = 0.0;
180     G4cout << "Recoil: " <<" m= " << mass2 <<  << 180 
181      << " 4-mom: " << lv                       << 181   // Choose generator
182      << G4endl;                                << 182   G4ElasticGenerator gtype = fLElastic;
183   }                                            << 183 
184                                                << 184   // Q-elastic for p,n scattering on H and He
185   // the recoil is created if kinetic energy a << 185   if (theParticle == theProton || theParticle == theNeutron) {
186   if(erec > GetRecoilEnergyThreshold()) {      << 186     //     && Z <= 2 && ekin >= lowEnergyLimitQ)  
187     G4ParticleDefinition * theDef = nullptr;   << 187     gtype = fQElastic;
188     if(Z == 1 && A == 1)       { theDef = theP << 188 
189     else if (Z == 1 && A == 2) { theDef = theD << 189   } else {
190     else if (Z == 1 && A == 3) { theDef = G4Tr << 190     // S-wave for very low energy
191     else if (Z == 2 && A == 3) { theDef = G4He << 191     if(plab < plabLowLimit) gtype = fSWave;
192     else if (Z == 2 && A == 4) { theDef = theA << 192     // HE-elastic for energetic projectile mesons
193     else {                                     << 193     else if(ekin >= lowEnergyLimitHE && theParticle->GetBaryonNumber() == 0) 
194       theDef =                                 << 194       { gtype = fHElastic; }
195   G4ParticleTable::GetParticleTable()->GetIonT << 195   }
196     }                                          << 196 
197     G4DynamicParticle * aSec = new G4DynamicPa << 197   //
198     theParticleChange.AddSecondary(aSec, secID << 198   // Sample t
199   } else {                                     << 199   //
200     theParticleChange.SetLocalEnergyDeposit(er << 200   if(gtype == fQElastic) {
201   }                                            << 201     if (verboseLevel >1) {
202                                                << 202       G4cout << "G4HadronElastic: Z= " << Z << " N= " 
203   return &theParticleChange;                   << 203        << N << " pdg= " <<  projPDG
204 }                                              << 204        << " mom(GeV)= " << plab/GeV << "  " << qCManager << G4endl; 
205                                                << 205     }
206 // sample momentum transfer in the CMS system  << 206     if(Z == 1 && N == 2) N = 1;
207 G4double                                       << 207     else if(Z == 2 && N == 1) N = 2;
208 G4HadronElastic::SampleInvariantT(const G4Part << 208     G4double cs = qCManager->GetCrossSection(false,plab,Z,N,projPDG);
209           G4double mom, G4int, G4int A)        << 209 
210 {                                              << 210     // check if cross section is reasonable
211   const G4double plabLowLimit = 400.0*CLHEP::M << 211     if(cs > 0.0) t = qCManager->GetExchangeT(Z,N,projPDG);
212   const G4double GeV2 = GeV*GeV;               << 212     else if(plab > plabLowLimit) gtype = fLElastic;
213   const G4double z07in13 = std::pow(0.7, 0.333 << 213     else gtype = fSWave;
214   const G4double numLimit = 18.;               << 214   }
215                                                << 215 
216   G4int pdg = std::abs(part->GetPDGEncoding()) << 216   if(gtype == fLElastic) {
217   G4double tmax = pLocalTmax/GeV2;             << 217     G4double g2 = GeV*GeV; 
218                                                << 218     t = g2*SampleT(tmax/g2,m1,m2,aTarget);
219   G4double aa, bb, cc, dd;                     << 219   }
220   G4Pow* g4pow = G4Pow::GetInstance();         << 220 
221   if (A <= 62) {                               << 221   // use mean atomic number
222     if (pdg == 211){ //Pions                   << 222   if(gtype == fHElastic) {
223       if(mom >= plabLowLimit){     //High ener << 223     t = hElastic->SampleT(theParticle,plab,Z,A);
224   bb = 14.5*g4pow->Z23(A);/*14.5*/             << 224   }
225   dd = 10.;                                    << 225 
226   cc = 0.075*g4pow->Z13(A)/dd;//1.4            << 226   if(gtype == fSWave) t = G4UniformRand()*tmax;
227   //aa = g4pow->powZ(A, 1.93)/bb;//1.63        << 227 
228   aa = (A*A)/bb;//1.63                         << 228   if(verboseLevel>1) {
229       } else {                       //Low ene << 229     G4cout <<"type= " << gtype <<" t= " << t << " tmax= " << tmax 
230   bb = 29.*z07in13*z07in13*g4pow->Z23(A);      << 230      << " ptot= " << ptot << G4endl;
231   dd = 15.;                                    << 231   }
232   cc = 0.04*g4pow->Z13(A)/dd;//1.4             << 232   // Sampling in CM system
233   aa = g4pow->powZ(A, 1.63)/bb;//1.63          << 233   G4double phi  = G4UniformRand()*twopi;
234       }                                        << 234   G4double cost = 1. - 2.0*t/tmax;
235     } else { //Other particles                 << 235   G4double sint;
236       bb = 14.5*g4pow->Z23(A);                 << 236 
237       dd = 20.;                                << 237   // problem in sampling
238       aa = (A*A)/bb;//1.63                     << 238   if(cost > 1.0 || cost < -1.0) {
239       cc = 1.4*g4pow->Z13(A)/dd;               << 239     if(verboseLevel > 0) {
240     }                                          << 240       G4cout << "G4HadronElastic:WARNING: Z= " << Z << " N= " 
241       //===========================            << 241        << N << " " << aParticle->GetDefinition()->GetParticleName()
242   } else { //(A>62)                            << 242        << " mom(GeV)= " << plab/GeV 
243     if (pdg == 211) {                          << 243        << " the model type " << gtype;
244       if(mom >= plabLowLimit){ //high          << 244       if(gtype ==  fQElastic) G4cout << " CHIPS ";
245   bb = 60.*z07in13*g4pow->Z13(A);//60          << 245       else if(gtype ==  fLElastic) G4cout << " LElastic ";
246   dd = 30.;                                    << 246       else if(gtype ==  fHElastic) G4cout << " HElastic ";
247   aa = 0.5*(A*A)/bb;//1.33                     << 247       G4cout << " cost= " << cost 
248   cc = 4.*g4pow->powZ(A,0.4)/dd;//1:0.4     -- << 248        << G4endl; 
249       } else { //low                           << 249     }
250   bb = 120.*z07in13*g4pow->Z13(A);//60         << 250     cost = 1.0;
251   dd = 30.;                                    << 251     sint = 0.0;
252   aa = 2.*g4pow->powZ(A,1.33)/bb;              << 252 
253   cc = 4.*g4pow->powZ(A,0.4)/dd;//1:0.4     -- << 253     // normal situation
254       }                                        << 254   } else  {
255     } else {                                   << 255     sint = std::sqrt((1.0-cost)*(1.0+cost));
256       bb = 60.*g4pow->Z13(A);                  << 256   }    
257       dd = 25.;                                << 257   if (verboseLevel>1) {
258       aa = g4pow->powZ(A,1.33)/bb;//1.33       << 258     G4cout << "cos(t)=" << cost << " std::sin(t)=" << sint << G4endl;
259       cc = 0.2*g4pow->powZ(A,0.4)/dd;//1:0.4   << 259   }
260     }                                          << 260   G4ThreeVector v1(sint*std::cos(phi),sint*std::sin(phi),cost);
261   }                                            << 261   v1 *= ptot;
262   G4double q1 = 1.0 - G4Exp(-std::min(bb*tmax, << 262   G4LorentzVector nlv1(v1.x(),v1.y(),v1.z(),std::sqrt(ptot*ptot + m1*m1));
263   G4double q2 = 1.0 - G4Exp(-std::min(dd*tmax, << 263 
264   G4double s1 = q1*aa;                         << 264   nlv1.boost(bst); 
265   G4double s2 = q2*cc;                         << 265 
266   if((s1 + s2)*G4UniformRand() < s2) {         << 266   G4double eFinal = nlv1.e() - m1;
267     q1 = q2;                                   << 267   if (verboseLevel > 1) {
268     bb = dd;                                   << 268     G4cout << "Scattered: "
269   }                                            << 269      << nlv1<<" m= " << m1 << " ekin(MeV)= " << eFinal 
270   return -GeV2*G4Log(1.0 - G4UniformRand()*q1) << 270      << " Proj: 4-mom " << lv1 
271 }                                              << 271      <<G4endl;
272                                                << 272   }
273 ////////////////////////////////////////////// << 273   if(eFinal <= lowestEnergyLimit) {
274 //                                             << 274     if(eFinal < 0.0 && verboseLevel > 0) {
275 // Cofs for s-,c-,b-particles ds/dt slopes     << 275       G4cout << "G4HadronElastic WARNING ekin= " << eFinal
276                                                << 276        << " after scattering of " 
277 G4double G4HadronElastic::GetSlopeCof(const G4 << 277        << aParticle->GetDefinition()->GetParticleName()
278 {                                              << 278        << " p(GeV/c)= " << plab
279   // The input parameter "pdg" should be the a << 279        << " on " << theDef->GetParticleName()
280   // (i.e. the same value for a particle and i << 280        << G4endl;
281                                                << 281     }
282   G4double coeff = 1.0;                        << 282     theParticleChange.SetEnergyChange(0.0);
283                                                << 283     nlv1 = G4LorentzVector(0.0,0.0,0.0,m1);
284   // heavy barions                             << 284 
285                                                << 285   } else {
286   static const G4double  lBarCof1S  = 0.88;    << 286     theParticleChange.SetMomentumChange(nlv1.vect().unit());
287   static const G4double  lBarCof2S  = 0.76;    << 287     theParticleChange.SetEnergyChange(eFinal);
288   static const G4double  lBarCof3S  = 0.64;    << 288   }  
289   static const G4double  lBarCof1C  = 0.784378 << 289 
290   static const G4double  lBarCofSC  = 0.664378 << 290   G4LorentzVector nlv0 = lv - nlv1;
291   static const G4double  lBarCof2SC = 0.544378 << 291   G4double erec =  nlv0.e() - m2;
292   static const G4double  lBarCof1B  = 0.740659 << 292   if (verboseLevel > 1) {
293   static const G4double  lBarCofSB  = 0.620659 << 293     G4cout << "Recoil: "
294   static const G4double  lBarCof2SB = 0.500659 << 294      << nlv0<<" m= " << m2 << " ekin(MeV)= " << erec 
295                                                << 295      <<G4endl;
296   if( pdg == 3122 || pdg == 3222 ||  pdg == 31 << 296   }
297   {                                            << 297   if(erec > lowEnergyRecoilLimit) {
298     coeff = lBarCof1S; // Lambda, Sigma+, Sigm << 298     G4DynamicParticle * aSec = new G4DynamicParticle(theDef, nlv0);
299                                                << 299     theParticleChange.AddSecondary(aSec);
300   } else if( pdg == 3322 || pdg == 3312   )    << 300   } else {
301   {                                            << 301     if(erec < 0.0) erec = 0.0;
302     coeff = lBarCof2S; // Xi-, Xi0             << 302     theParticleChange.SetLocalEnergyDeposit(erec);
303   }                                            << 303   }
304   else if( pdg == 3324)                        << 304 
305   {                                            << 305   return &theParticleChange;
306     coeff = lBarCof3S; // Omega                << 306 }
307   }                                            << 307 
308   else if( pdg == 4122 ||  pdg == 4212 ||   pd << 308 G4double 
309   {                                            << 309 G4HadronElastic::SampleT(G4double tmax, G4double, G4double, G4double atno2)
310     coeff = lBarCof1C; // LambdaC+, SigmaC+, S << 310 {
311   }                                            << 311   // G4cout << "Entering elastic scattering 2"<<G4endl;
312   else if( pdg == 4332 )                       << 312   // Compute the direction of elastic scattering.
313   {                                            << 313   // It is planned to replace this code with a method based on
314     coeff = lBarCof2SC; // OmegaC              << 314   // parameterized functions and a Monte Carlo method to invert the CDF.
315   }                                            << 315 
316   else if( pdg == 4232 || pdg == 4132 )        << 316   //  G4double ran = G4UniformRand();
317   {                                            << 317   G4double aa, bb, cc, dd, rr;
318     coeff = lBarCofSC; // XiC+, XiC0           << 318   if (atno2 <= 62.) {
319   }                                            << 319     aa = std::pow(atno2, 1.63);
320   else if( pdg == 5122 || pdg == 5222 || pdg = << 320     bb = 14.5*std::pow(atno2, 0.66);
321   {                                            << 321     cc = 1.4*std::pow(atno2, 0.33);
322     coeff = lBarCof1B; // LambdaB, SigmaB+, Si << 322     dd = 10.;
323   }                                            << 323   } else {
324   else if( pdg == 5332 )                       << 324     aa = std::pow(atno2, 1.33);
325   {                                            << 325     bb = 60.*std::pow(atno2, 0.33);
326     coeff = lBarCof2SB; // OmegaB-             << 326     cc = 0.4*std::pow(atno2, 0.40);
327   }                                            << 327     dd = 10.;
328   else if( pdg == 5132 || pdg == 5232 ) // XiB << 328   }
329   {                                            << 329   aa = aa/bb;
330     coeff = lBarCofSB;                         << 330   cc = cc/dd;
331   }                                            << 331   G4double ran, t1, t2;
332   // heavy mesons Kaons?                       << 332   do {
333   static const G4double lMesCof1S = 0.82; // K << 333     ran = G4UniformRand();
334   static const G4double llMesCof1C = 0.676568; << 334     t1 = -std::log(ran)/bb;
335   static const G4double llMesCof1B = 0.610989; << 335     t2 = -std::log(ran)/dd;
336   static const G4double llMesCof2C = 0.353135; << 336   } while(t1 > tmax || t2 > tmax);
337   static const G4double llMesCof2B = 0.221978; << 337 
338   static const G4double llMesCofSC = 0.496568; << 338   rr = (aa + cc)*ran;
339   static const G4double llMesCofSB = 0.430989; << 339 
340   static const G4double llMesCofCB = 0.287557; << 340   if (verboseLevel > 1) {
341   static const G4double llMesCofEtaP = 0.88;   << 341     G4cout << "DoIt: aa,bb,cc,dd,rr" << G4endl;
342   static const G4double llMesCofEta = 0.76;    << 342     G4cout << aa << " " << bb << " " << cc << " " << dd << " " << rr << G4endl;
343                                                << 343     G4cout << "t1,Fctcos " << t1 << " " << Fctcos(t1, aa, bb, cc, dd, rr) << G4endl;
344   if( pdg == 321 || pdg == 311 || pdg == 310 ) << 344     G4cout << "t2,Fctcos " << t2 << " " << Fctcos(t2, aa, bb, cc, dd, rr) << G4endl;
345   {                                            << 345   }
346     coeff = lMesCof1S; //K+-0                  << 346   G4double eps = 0.001;
347   }                                            << 347   G4int ind1 = 10;
348   else if( pdg == 511 ||  pdg == 521  )        << 348   G4double t = 0.0;
349   {                                            << 349   G4int ier1;
350     coeff = llMesCof1B; // BMeson0, BMeson+    << 350   ier1 = Rtmi(&t, t1, t2, eps, ind1,
351   }                                            << 351         aa, bb, cc, dd, rr);
352   else if(pdg == 421 ||  pdg == 411 )          << 352   if (verboseLevel > 1) {
353   {                                            << 353     G4cout << "From Rtmi, ier1=" << ier1 << " t= " << t << G4endl;
354     coeff = llMesCof1C; // DMeson+, DMeson0    << 354     G4cout << "t, Fctcos " << t << " " << Fctcos(t, aa, bb, cc, dd, rr) << G4endl;
355   }                                            << 355   }
356   else if( pdg == 531  )                       << 356   if (ier1 != 0) t = 0.25*(3.*t1 + t2);
357   {                                            << 357   if (verboseLevel > 1) {
358     coeff = llMesCofSB; // BSMeson0            << 358       G4cout << "t, Fctcos " << t << " " << Fctcos(t, aa, bb, cc, dd, rr) << 
359   }                                            << 359               G4endl;
360   else if( pdg == 541 )                        << 360   }
361   {                                            << 361   return t;
362     coeff = llMesCofCB; // BCMeson+-           << 362 }
363   }                                            << 363 
364   else if(pdg == 431 )                         << 364 // The following is a "translation" of a root-finding routine
365   {                                            << 365 // from GEANT3.21/GHEISHA.  Some of the labelled block structure has
366     coeff = llMesCofSC; // DSMeson+-           << 366 // been retained for clarity.  This routine will not be needed after
367   }                                            << 367 // the planned revisions to DoIt().
368   else if(pdg == 441 || pdg == 443 )           << 368 
369   {                                            << 369 G4int
370     coeff = llMesCof2C; // Etac, JPsi          << 370 G4HadronElastic::Rtmi(G4double* x, G4double xli, G4double xri, G4double eps, 
371   }                                            << 371           G4int iend, 
372   else if(pdg == 553 )                         << 372           G4double aa, G4double bb, G4double cc, G4double dd, 
373   {                                            << 373           G4double rr)
374     coeff = llMesCof2B; // Upsilon             << 374 {
375   }                                            << 375    G4int ier = 0;
376   else if(pdg == 221 )                         << 376    G4double xl = xli;
377   {                                            << 377    G4double xr = xri;
378     coeff = llMesCofEta; // Eta                << 378    *x = xl;
379   }                                            << 379    G4double tol = *x;
380   else if(pdg == 331 )                         << 380    G4double f = Fctcos(tol, aa, bb, cc, dd, rr);
381   {                                            << 381    if (f == 0.) return ier;
382     coeff = llMesCofEtaP; // Eta'              << 382    G4double fl, fr;
383   }                                            << 383    fl = f;
384   return coeff;                                << 384    *x = xr;
385 }                                              << 385    tol = *x;
386                                                << 386    f = Fctcos(tol, aa, bb, cc, dd, rr);
387                                                << 387    if (f == 0.) return ier;
                                                   >> 388    fr = f;
                                                   >> 389 
                                                   >> 390 // Error return in case of wrong input data
                                                   >> 391    if (fl*fr >= 0.) {
                                                   >> 392       ier = 2;
                                                   >> 393       return ier;
                                                   >> 394    }
                                                   >> 395 
                                                   >> 396 // Basic assumption fl*fr less than 0 is satisfied.
                                                   >> 397 // Generate tolerance for function values.
                                                   >> 398    G4int i = 0;
                                                   >> 399    G4double tolf = 100.*eps;
                                                   >> 400 
                                                   >> 401 // Start iteration loop
                                                   >> 402 label4:
                                                   >> 403    i++;
                                                   >> 404 
                                                   >> 405 // Start bisection loop
                                                   >> 406    for (G4int k = 1; k <= iend; k++) {
                                                   >> 407       *x = 0.5*(xl + xr);
                                                   >> 408       tol = *x;
                                                   >> 409       f = Fctcos(tol, aa, bb, cc, dd, rr);
                                                   >> 410       if (f == 0.) return 0;
                                                   >> 411       if (f*fr < 0.) {      // Interchange xl and xr in order to get the
                                                   >> 412          tol = xl;          // same Sign in f and fr
                                                   >> 413          xl = xr;
                                                   >> 414          xr = tol;
                                                   >> 415          tol = fl;
                                                   >> 416          fl = fr;
                                                   >> 417          fr = tol;
                                                   >> 418       }
                                                   >> 419       tol = f - fl;
                                                   >> 420       G4double a = f*tol;
                                                   >> 421       a = a + a;
                                                   >> 422       if (a < fr*(fr - fl) && i <= iend) goto label17;
                                                   >> 423       xr = *x;
                                                   >> 424       fr = f;
                                                   >> 425 
                                                   >> 426 // Test on satisfactory accuracy in bisection loop
                                                   >> 427       tol = eps;
                                                   >> 428       a = std::abs(xr);
                                                   >> 429       if (a > 1.) tol = tol*a;
                                                   >> 430       if (std::abs(xr - xl) <= tol && std::abs(fr - fl) <= tolf) goto label14;
                                                   >> 431    }
                                                   >> 432 // End of bisection loop
                                                   >> 433 
                                                   >> 434 // No convergence after iend iteration steps followed by iend
                                                   >> 435 // successive steps of bisection or steadily increasing function
                                                   >> 436 // values at right bounds.  Error return.
                                                   >> 437    ier = 1;
                                                   >> 438 
                                                   >> 439 label14:
                                                   >> 440    if (std::abs(fr) > std::abs(fl)) {
                                                   >> 441       *x = xl;
                                                   >> 442       f = fl;
                                                   >> 443    }
                                                   >> 444    return ier;
                                                   >> 445 
                                                   >> 446 // Computation of iterated x-value by inverse parabolic interp
                                                   >> 447 label17:
                                                   >> 448    G4double a = fr - f;
                                                   >> 449    G4double dx = (*x - xl)*fl*(1. + f*(a - tol)/(a*(fr - fl)))/tol;
                                                   >> 450    G4double xm = *x;
                                                   >> 451    G4double fm = f;
                                                   >> 452    *x = xl - dx;
                                                   >> 453    tol = *x;
                                                   >> 454    f = Fctcos(tol, aa, bb, cc, dd, rr);
                                                   >> 455    if (f == 0.) return ier;
                                                   >> 456 
                                                   >> 457 // Test on satisfactory accuracy in iteration loop
                                                   >> 458    tol = eps;
                                                   >> 459    a = std::abs(*x);
                                                   >> 460    if (a > 1) tol = tol*a;
                                                   >> 461    if (std::abs(dx) <= tol && std::abs(f) <= tolf) return ier;
                                                   >> 462 
                                                   >> 463 // Preparation of next bisection loop
                                                   >> 464    if (f*fl < 0.) {
                                                   >> 465       xr = *x;
                                                   >> 466       fr = f;
                                                   >> 467    }
                                                   >> 468    else {
                                                   >> 469       xl = *x;
                                                   >> 470       fl = f;
                                                   >> 471       xr = xm;
                                                   >> 472       fr = fm;
                                                   >> 473    }
                                                   >> 474    goto label4;
                                                   >> 475 }
                                                   >> 476 
                                                   >> 477 // Test function for root-finder
                                                   >> 478 G4double
                                                   >> 479 G4HadronElastic::Fctcos(G4double t, 
                                                   >> 480       G4double aa, G4double bb, G4double cc, G4double dd, 
                                                   >> 481       G4double rr)
                                                   >> 482 {
                                                   >> 483    const G4double expxl = -82.;
                                                   >> 484    const G4double expxu = 82.;
                                                   >> 485 
                                                   >> 486    G4double test1 = -bb*t;
                                                   >> 487    if (test1 > expxu) test1 = expxu;
                                                   >> 488    if (test1 < expxl) test1 = expxl;
                                                   >> 489 
                                                   >> 490    G4double test2 = -dd*t;
                                                   >> 491    if (test2 > expxu) test2 = expxu;
                                                   >> 492    if (test2 < expxl) test2 = expxl;
                                                   >> 493 
                                                   >> 494    return aa*std::exp(test1) + cc*std::exp(test2) - rr;
                                                   >> 495 }
                                                   >> 496 
                                                   >> 497 
388                                                   498