Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/hadronic/util/src/G4Nucleus.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/util/src/G4Nucleus.cc (Version 11.3.0) and /processes/hadronic/util/src/G4Nucleus.cc (Version 6.0)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 //                                                 23 //
 27 //                                                 24 //
 28 // original by H.P. Wellisch                   <<  25  // original by H.P. Wellisch
 29 // modified by J.L. Chuma, TRIUMF, 19-Nov-1996 <<  26  // modified by J.L. Chuma, TRIUMF, 19-Nov-1996
 30 // last modified: 27-Mar-1997                  <<  27  // last modified: 27-Mar-1997
 31 // J.P.Wellisch: 23-Apr-97: minor simplificati <<  28  // J.P.Wellisch: 23-Apr-97: minor simplifications
 32 // modified by J.L.Chuma 24-Jul-97  to set the <<  29  // modified by J.L.Chuma 24-Jul-97  to set the total momentum in Cinema and
 33 //                                  Evaporatio <<  30  //                                  EvaporationEffects
 34 // modified by J.L.Chuma 21-Oct-97  put std::a <<  31  // modified by J.L.Chuma 21-Oct-97  put abs() around the totalE^2-mass^2
 35 //                                  in calcula <<  32  //                                  in calculation of total momentum in
 36 //                                  Cinema and <<  33  //                                  Cinema and EvaporationEffects
 37 // Chr. Volcker, 10-Nov-1997: new methods and  <<  34  // Chr. Volcker, 10-Nov-1997: new methods and class variables.
 38 // HPW added utilities for low energy neutron  <<  35  // HPW added utilities for low energy neutron transport. (12.04.1998)
 39 // M.G. Pia, 2 Oct 1998: modified GetFermiMome <<  36  // M.G. Pia, 2 Oct 1998: modified GetFermiMomentum to avoid memory leaks
 40 // G.Folger, spring 2010:  add integer A/Z int << 
 41 // A. Ribon, summer 2015:  migrated to G4Exp a << 
 42 // A. Ribon, autumn 2021:  extended to hypernu << 
 43                                                    37  
 44 #include "G4Nucleus.hh"                            38 #include "G4Nucleus.hh"
 45 #include "G4NucleiProperties.hh"               << 
 46 #include "G4PhysicalConstants.hh"              << 
 47 #include "G4SystemOfUnits.hh"                  << 
 48 #include "Randomize.hh"                            39 #include "Randomize.hh"
 49 #include "G4HadronicException.hh"                  40 #include "G4HadronicException.hh"
 50 #include "G4Exp.hh"                            <<  41  
 51 #include "G4Log.hh"                            << 
 52 #include "G4HyperNucleiProperties.hh"          << 
 53 #include "G4HadronicParameters.hh"             << 
 54                                                << 
 55                                                << 
 56 G4Nucleus::G4Nucleus()                             42 G4Nucleus::G4Nucleus()
 57   : theA(0), theZ(0), theL(0), aEff(0.0), zEff << 
 58 {                                              << 
 59   pnBlackTrackEnergy = 0.0;                    << 
 60   dtaBlackTrackEnergy = 0.0;                   << 
 61   pnBlackTrackEnergyfromAnnihilation = 0.0;    << 
 62   dtaBlackTrackEnergyfromAnnihilation = 0.0;   << 
 63   excitationEnergy = 0.0;                      << 
 64   momentum = G4ThreeVector(0.,0.,0.);          << 
 65   fermiMomentum = 1.52*hbarc/fermi;            << 
 66   theTemp = 293.16*kelvin;                     << 
 67   fIsotope = 0;                                << 
 68 }                                              << 
 69                                                << 
 70 G4Nucleus::G4Nucleus( const G4double A, const  << 
 71 {                                                  43 {
 72   SetParameters( A, Z, std::max(numberOfLambda <<  44   pnBlackTrackEnergy = dtaBlackTrackEnergy = 0.0;
 73   pnBlackTrackEnergy = 0.0;                    << 
 74   dtaBlackTrackEnergy = 0.0;                   << 
 75   pnBlackTrackEnergyfromAnnihilation = 0.0;    << 
 76   dtaBlackTrackEnergyfromAnnihilation = 0.0;   << 
 77   excitationEnergy = 0.0;                          45   excitationEnergy = 0.0;
 78   momentum = G4ThreeVector(0.,0.,0.);              46   momentum = G4ThreeVector(0.,0.,0.);
 79   fermiMomentum = 1.52*hbarc/fermi;                47   fermiMomentum = 1.52*hbarc/fermi;
 80   theTemp = 293.16*kelvin;                         48   theTemp = 293.16*kelvin;
 81   fIsotope = 0;                                << 
 82 }                                                  49 }
 83                                                    50 
 84 G4Nucleus::G4Nucleus( const G4int A, const G4i <<  51 G4Nucleus::G4Nucleus( const G4double A, const G4double Z )
 85 {                                                  52 {
 86   SetParameters( A, Z, std::max(numberOfLambda <<  53   SetParameters( A, Z );
 87   pnBlackTrackEnergy = 0.0;                    <<  54   pnBlackTrackEnergy = dtaBlackTrackEnergy = 0.0;
 88   dtaBlackTrackEnergy = 0.0;                   << 
 89   pnBlackTrackEnergyfromAnnihilation = 0.0;    << 
 90   dtaBlackTrackEnergyfromAnnihilation = 0.0;   << 
 91   excitationEnergy = 0.0;                          55   excitationEnergy = 0.0;
 92   momentum = G4ThreeVector(0.,0.,0.);              56   momentum = G4ThreeVector(0.,0.,0.);
 93   fermiMomentum = 1.52*hbarc/fermi;                57   fermiMomentum = 1.52*hbarc/fermi;
 94   theTemp = 293.16*kelvin;                         58   theTemp = 293.16*kelvin;
 95   fIsotope = 0;                                << 
 96 }                                                  59 }
 97                                                    60 
 98 G4Nucleus::G4Nucleus( const G4Material *aMater     61 G4Nucleus::G4Nucleus( const G4Material *aMaterial )
 99 {                                                  62 {
100   ChooseParameters( aMaterial );                   63   ChooseParameters( aMaterial );
101   pnBlackTrackEnergy = 0.0;                    <<  64   pnBlackTrackEnergy = dtaBlackTrackEnergy = 0.0;
102   dtaBlackTrackEnergy = 0.0;                   << 
103   pnBlackTrackEnergyfromAnnihilation = 0.0;    << 
104   dtaBlackTrackEnergyfromAnnihilation = 0.0;   << 
105   excitationEnergy = 0.0;                          65   excitationEnergy = 0.0;
106   momentum = G4ThreeVector(0.,0.,0.);              66   momentum = G4ThreeVector(0.,0.,0.);
107   fermiMomentum = 1.52*hbarc/fermi;                67   fermiMomentum = 1.52*hbarc/fermi;
108   theTemp = aMaterial->GetTemperature();           68   theTemp = aMaterial->GetTemperature();
109   fIsotope = 0;                                << 
110 }                                                  69 }
111                                                    70 
112 G4Nucleus::~G4Nucleus() {}                         71 G4Nucleus::~G4Nucleus() {}
113                                                    72 
114                                                <<  73 G4ReactionProduct G4Nucleus::
115 //-------------------------------------------- <<  74 GetBiasedThermalNucleus(G4double aMass, G4ThreeVector aVelocity, G4double temp) const
116 // SVT (Sampling of the Velocity of the Target << 
117 //-------------------------------------------- << 
118 G4ReactionProduct                              << 
119 G4Nucleus::GetBiasedThermalNucleus(G4double aM << 
120 {                                                  75 {
121   // If E_neutron <= E_threshold, Then apply t <<  76   G4double velMag = aVelocity.mag();
122   // Else consider the target nucleus being wi << 
123   G4double E_threshold = G4HadronicParameters: << 
124   if ( E_threshold == -1. ) {                  << 
125     E_threshold = 400.0*8.617333262E-11*temp;  << 
126   }                                            << 
127   G4double E_neutron = 0.5*aVelocity.mag2()*G4 << 
128                                                << 
129   G4ReactionProduct result;                        77   G4ReactionProduct result;
130   result.SetMass(aMass*G4Neutron::Neutron()->G <<  78   G4double value = 0;
131                                                <<  79   G4double random = 1;
132   if ( E_neutron <= E_threshold ) {            <<  80   G4double norm = 3.*sqrt(k_Boltzmann*temp*aMass*G4Neutron::Neutron()->GetPDGMass());
133                                                <<  81   norm /= G4Neutron::Neutron()->GetPDGMass();
134     // Beta = sqrt(m/2kT)                      <<  82   norm *= 5.;
135     G4double beta = std::sqrt(result.GetMass() <<  83   norm += velMag;
136                                                <<  84   norm /= velMag;
137     // Neutron speed vn                        <<  85   while(value/norm<random)
138     G4double vN_norm = aVelocity.mag();        <<  86   {
139     G4double vN_norm2 = vN_norm*vN_norm;       <<  87      result = GetThermalNucleus(aMass, temp);
140     G4double y = beta*vN_norm;                 <<  88      G4ThreeVector targetVelocity = 1./result.GetMass()*result.GetMomentum();
141                                                <<  89      value = (targetVelocity+aVelocity).mag()/velMag;
142     // Normalize neutron velocity              <<  90      random = G4UniformRand();
143     aVelocity = (1./vN_norm)*aVelocity;        << 
144                                                << 
145     // Sample target speed                     << 
146     G4double x2;                               << 
147     G4double randThreshold;                    << 
148     G4double vT_norm, vT_norm2, mu; //theta, v << 
149     G4double acceptThreshold;                  << 
150     G4double vRelativeSpeed;                   << 
151     G4double cdf0 = 2./(2.+std::sqrt(CLHEP::pi << 
152                                                << 
153     do {                                       << 
154       // Sample the target velocity vT in the  << 
155       if ( G4UniformRand() < cdf0 ) {          << 
156         // Sample in C45 from https://laws.lan << 
157         x2 = -std::log(G4UniformRand()*G4Unifo << 
158       } else {                                 << 
159         // Sample in C61 from https://laws.lan << 
160         G4double ampl = std::cos(CLHEP::pi/2.0 << 
161         x2 = -std::log(G4UniformRand()) - std: << 
162       }                                        << 
163                                                << 
164       vT_norm = std::sqrt(x2)/beta;            << 
165       vT_norm2 = vT_norm*vT_norm;              << 
166                                                << 
167       // Sample cosine between the incident ne << 
168       mu = 2*G4UniformRand() - 1;              << 
169                                                << 
170       // Define acceptance threshold           << 
171       vRelativeSpeed = std::sqrt(vN_norm2 + vT << 
172       acceptThreshold = vRelativeSpeed/(vN_nor << 
173       randThreshold = G4UniformRand();         << 
174     } while ( randThreshold >= acceptThreshold << 
175                                                << 
176     DoKinematicsOfThermalNucleus(mu, vT_norm,  << 
177                                                << 
178   } else { // target nucleus considered as bei << 
179                                                << 
180     result.SetMomentum(0., 0., 0.);            << 
181     result.SetKineticEnergy(0.);               << 
182                                                << 
183   }                                                91   }
184                                                << 
185   return result;                                   92   return result;
186 }                                                  93 }
187                                                    94 
188                                                <<  95 G4ReactionProduct G4Nucleus::GetThermalNucleus(G4double targetMass, G4double temp) const
189 void                                           <<  96   {
190 G4Nucleus::DoKinematicsOfThermalNucleus(const  <<  97     G4double currentTemp = temp;
191                                         G4Reac <<  98     if(currentTemp < 0) currentTemp = theTemp;
192                                                <<  99     G4ReactionProduct theTarget;    
193   // Get target nucleus direction from the neu << 100     theTarget.SetMass(targetMass*G4Neutron::Neutron()->GetPDGMass());
194   G4double cosTh = mu;                         << 101     G4double px, py, pz;
195   G4ThreeVector uNorm = aVelocity;             << 102     px = GetThermalPz(theTarget.GetMass(), currentTemp);
196                                                << 103     py = GetThermalPz(theTarget.GetMass(), currentTemp);
197   G4double sinTh = std::sqrt(1. - cosTh*cosTh) << 104     pz = GetThermalPz(theTarget.GetMass(), currentTemp);
198                                                << 105     theTarget.SetMomentum(px, py, pz);
199   // Sample randomly the phi angle between the << 106     G4double tMom = sqrt(px*px+py*py+pz*pz);
200   G4double phi = CLHEP::twopi*G4UniformRand(); << 107     G4double tEtot = sqrt((tMom+theTarget.GetMass())*
201   G4double sinPhi = std::sin(phi);             << 108                           (tMom+theTarget.GetMass())-
202   G4double cosPhi = std::cos(phi);             << 109                           2.*tMom*theTarget.GetMass());
203                                                << 110     if(1-tEtot/theTarget.GetMass()>0.001)
204   // Find orthogonal vector to aVelocity - sol << 111     {
205   G4ThreeVector ortho(1., 1., 1.);             << 112       theTarget.SetTotalEnergy(tEtot);
206   if      ( uNorm[0] )  ortho[0] = -(uNorm[1]+ << 113     }
207   else if ( uNorm[1] )  ortho[1] = -(uNorm[0]+ << 114     else
208   else if ( uNorm[2] )  ortho[2] = -(uNorm[0]+ << 115     {
209                                                << 116       theTarget.SetKineticEnergy(tMom*tMom/(2.*theTarget.GetMass()));
210   // Normalize the vector                      << 117     }    
211   ortho = (1/ortho.mag())*ortho;               << 118     return theTarget;
212                                                << 
213   // Find vector to draw a plan perpendicular  << 
214   G4ThreeVector orthoComp( uNorm[1]*ortho[2] - << 
215                            uNorm[2]*ortho[0] - << 
216                            uNorm[0]*ortho[1] - << 
217                                                << 
218   // Find the direction of the target velocity << 
219   G4ThreeVector directionTarget( cosTh*uNorm[0 << 
220                                  cosTh*uNorm[1 << 
221                                  cosTh*uNorm[2 << 
222                                                << 
223   // Normalize directionTarget                 << 
224   directionTarget = ( 1./directionTarget.mag() << 
225                                                << 
226   // Set momentum                              << 
227   G4double px = result.GetMass()*vT_norm*direc << 
228   G4double py = result.GetMass()*vT_norm*direc << 
229   G4double pz = result.GetMass()*vT_norm*direc << 
230   result.SetMomentum(px, py, pz);              << 
231                                                << 
232   G4double tMom = std::sqrt(px*px+py*py+pz*pz) << 
233   G4double tEtot = std::sqrt( (tMom+result.Get << 
234                     - 2.*tMom*result.GetMass() << 
235                                                << 
236   if ( tEtot/result.GetMass() - 1. > 0.001 ) { << 
237     // use relativistic energy for higher ener << 
238     result.SetTotalEnergy(tEtot);              << 
239   } else {                                     << 
240     // use p**2/2M for lower energies (to pres << 
241     result.SetKineticEnergy(tMom*tMom/(2.*resu << 
242   }                                               119   }
243                                                << 
244 }                                              << 
245                                                << 
246                                                << 
247 G4ReactionProduct                              << 
248 G4Nucleus::GetThermalNucleus(G4double targetMa << 
249 {                                              << 
250   G4double currentTemp = temp;                 << 
251   if (currentTemp < 0) currentTemp = theTemp;  << 
252   G4ReactionProduct theTarget;                 << 
253   theTarget.SetMass(targetMass*G4Neutron::Neut << 
254   G4double px, py, pz;                         << 
255   px = GetThermalPz(theTarget.GetMass(), curre << 
256   py = GetThermalPz(theTarget.GetMass(), curre << 
257   pz = GetThermalPz(theTarget.GetMass(), curre << 
258   theTarget.SetMomentum(px, py, pz);           << 
259   G4double tMom = std::sqrt(px*px+py*py+pz*pz) << 
260   G4double tEtot = std::sqrt((tMom+theTarget.G << 
261                              (tMom+theTarget.G << 
262                               2.*tMom*theTarge << 
263   //  if(1-tEtot/theTarget.GetMass()>0.001)  t << 
264   if (tEtot/theTarget.GetMass() - 1. > 0.001)  << 
265     // use relativistic energy for higher ener << 
266     theTarget.SetTotalEnergy(tEtot);           << 
267                                                << 
268   } else {                                     << 
269     // use p**2/2M for lower energies (to pres << 
270     theTarget.SetKineticEnergy(tMom*tMom/(2.*t << 
271   }                                            << 
272   return theTarget;                            << 
273 }                                              << 
274                                                << 
275                                                   120  
276 void                                           << 121  void
277 G4Nucleus::ChooseParameters(const G4Material*  << 122   G4Nucleus::ChooseParameters( const G4Material *aMaterial )
278 {                                              << 123   {
279   G4double random = G4UniformRand();           << 124     G4double random = G4UniformRand();
280   G4double sum = aMaterial->GetTotNbOfAtomsPer << 125     G4double sum = 0;
281   const G4ElementVector* theElementVector = aM << 126     const G4ElementVector *theElementVector = aMaterial->GetElementVector();
282   G4double running(0);                         << 127     unsigned int i;
283   //  G4Element* element(0);                   << 128     for(i=0; i<aMaterial->GetNumberOfElements(); ++i )
284   const G4Element* element = (*theElementVecto << 129     {
285                                                << 130       sum += aMaterial->GetAtomicNumDensityVector()[i];
286   for (unsigned int i = 0; i < aMaterial->GetN << 131     }
287     running += aMaterial->GetVecNbOfAtomsPerVo << 132     G4double running = 0;
288     if (running > random*sum) {                << 133     for(i=0; i<aMaterial->GetNumberOfElements(); ++i )
289       element = (*theElementVector)[i];        << 134     {
290       break;                                   << 135       running += aMaterial->GetAtomicNumDensityVector()[i];
                                                   >> 136       if( running/sum > random ) {
                                                   >> 137         aEff = (*theElementVector)[i]->GetA()*mole/g;
                                                   >> 138         zEff = (*theElementVector)[i]->GetZ();
                                                   >> 139         break;
                                                   >> 140       }
291     }                                             141     }
292   }                                               142   }
293                                                << 143  
294   if (element->GetNumberOfIsotopes() > 0) {    << 144  void
295     G4double randomAbundance = G4UniformRand() << 145   G4Nucleus::SetParameters( const G4double A, const G4double Z )
296     G4double sumAbundance = element->GetRelati << 146   {
297     unsigned int iso=0;                        << 147     G4int myZ = G4int(Z + 0.5);
298     while (iso < element->GetNumberOfIsotopes( << 148     G4int myA = G4int(A + 0.5);   
299            sumAbundance < randomAbundance) {   << 149     if( myA<1 || myZ<0 || myZ>myA )
300       ++iso;                                   << 
301       sumAbundance += element->GetRelativeAbun << 
302     }                                          << 
303     theA=element->GetIsotope(iso)->GetN();     << 
304     theZ=element->GetIsotope(iso)->GetZ();     << 
305     theL=0;                                    << 
306     aEff=theA;                                 << 
307     zEff=theZ;                                 << 
308   } else {                                     << 
309     aEff = element->GetN();                    << 
310     zEff = element->GetZ();                    << 
311     theZ = G4int(zEff + 0.5);                  << 
312     theA = G4int(aEff + 0.5);                  << 
313     theL=0;                                    << 
314   }                                            << 
315 }                                              << 
316                                                << 
317                                                << 
318 void                                           << 
319 G4Nucleus::SetParameters( const G4double A, co << 
320 {                                              << 
321   theZ = G4lrint(Z);                           << 
322   theA = G4lrint(A);                           << 
323   theL = std::max(numberOfLambdas, 0);         << 
324   if (theA<1 || theZ<0 || theZ>theA) {         << 
325     throw G4HadronicException(__FILE__, __LINE << 
326             "G4Nucleus::SetParameters called w << 
327   }                                            << 
328   aEff = A;  // atomic weight                  << 
329   zEff = Z;  // atomic number                  << 
330   fIsotope = 0;                                << 
331 }                                              << 
332                                                << 
333                                                << 
334 void                                           << 
335 G4Nucleus::SetParameters( const G4int A, const << 
336 {                                              << 
337   theZ = Z;                                    << 
338   theA = A;                                    << 
339   theL = std::max(numberOfLambdas, 0);         << 
340   if( theA<1 || theZ<0 || theZ>theA )          << 
341     {                                             150     {
342       throw G4HadronicException(__FILE__, __LI    151       throw G4HadronicException(__FILE__, __LINE__,
343         "G4Nucleus::SetParameters called with  << 152                                "G4Nucleus::SetParameters called with non-physical parameters");
344     }                                             153     }
345   aEff = A;  // atomic weight                  << 154     aEff = A;  // atomic weight
346   zEff = Z;  // atomic number                  << 155     zEff = Z;  // atomic number
347   fIsotope = 0;                                << 
348 }                                              << 
349                                                << 
350                                                << 
351 G4DynamicParticle *                            << 
352 G4Nucleus::ReturnTargetParticle() const        << 
353 {                                              << 
354   // choose a proton or a neutron (or a lamba  << 
355   G4DynamicParticle *targetParticle = new G4Dy << 
356   const G4double rnd = G4UniformRand();        << 
357   if ( rnd < zEff/aEff ) {                     << 
358     targetParticle->SetDefinition( G4Proton::P << 
359   } else if ( rnd < (zEff + theL*1.0)/aEff ) { << 
360     targetParticle->SetDefinition( G4Lambda::L << 
361   } else {                                     << 
362     targetParticle->SetDefinition( G4Neutron:: << 
363   }                                               156   }
364   return targetParticle;                       << 
365 }                                              << 
366                                                   157 
367                                                << 158  G4DynamicParticle *
368 G4double                                       << 159   G4Nucleus::ReturnTargetParticle() const
369 G4Nucleus::AtomicMass( const G4double A, const << 160   {
370 {                                              << 161     // choose a proton or a neutron as the target particle
371   // Now returns (atomic mass - electron masse << 162     
372   if ( numberOfLambdas > 0 ) {                 << 163     G4DynamicParticle *targetParticle = new G4DynamicParticle;
373     return G4HyperNucleiProperties::GetNuclear << 164     if( G4UniformRand() < zEff/aEff )
374   } else {                                     << 165       targetParticle->SetDefinition( G4Proton::Proton() );
375     return G4NucleiProperties::GetNuclearMass( << 166     else
                                                   >> 167       targetParticle->SetDefinition( G4Neutron::Neutron() );
                                                   >> 168     return targetParticle;
376   }                                               169   }
377 }                                              << 
378                                                << 
379                                                   170  
380 G4double                                       << 171  G4double
381 G4Nucleus::AtomicMass( const G4int A, const G4 << 172   G4Nucleus::AtomicMass( const G4double A, const G4double Z ) const
382 {                                              << 173   {
383   // Now returns (atomic mass - electron masse << 174     // derived from original FORTRAN code ATOMAS by H. Fesefeldt (2-Dec-1986)
384   if ( numberOfLambdas > 0 ) {                 << 175     //
385     return G4HyperNucleiProperties::GetNuclear << 176     // Computes atomic mass in MeV
386   } else {                                     << 177     // units for A example:  A = material->GetA()/(g/mole);
387     return G4NucleiProperties::GetNuclearMass( << 178     //
                                                   >> 179     // Note:  can't just use aEff and zEff since the Nuclear Reaction
                                                   >> 180     //        function needs to calculate atomic mass for various values of A and Z
                                                   >> 181 
                                                   >> 182     const G4double electron_mass = G4Electron::Electron()->GetPDGMass()/MeV;
                                                   >> 183     const G4double proton_mass = G4Proton::Proton()->GetPDGMass()/MeV;
                                                   >> 184     const G4double neutron_mass = G4Neutron::Neutron()->GetPDGMass()/MeV;
                                                   >> 185     const G4double deuteron_mass = G4Deuteron::Deuteron()->GetPDGMass()/MeV;
                                                   >> 186     const G4double alpha_mass = G4Alpha::Alpha()->GetPDGMass()/MeV;
                                                   >> 187     
                                                   >> 188     G4int myZ = G4int(Z + 0.5);
                                                   >> 189     G4int myA = G4int(A + 0.5);
                                                   >> 190     if( myA <= 0 )return DBL_MAX;
                                                   >> 191     if( myZ > myA)return DBL_MAX;
                                                   >> 192     if( myA == 1 )
                                                   >> 193     {
                                                   >> 194       if( myZ == 0 )return neutron_mass*MeV;
                                                   >> 195       if( myZ == 1 )return proton_mass*MeV + electron_mass*MeV;   // hydrogen
                                                   >> 196     }
                                                   >> 197     else if( myA == 2 && myZ == 1 )
                                                   >> 198     {
                                                   >> 199       return deuteron_mass*MeV;
                                                   >> 200     }
                                                   >> 201     else if( myA == 4 && myZ == 2 )
                                                   >> 202     {
                                                   >> 203       return alpha_mass*MeV;
                                                   >> 204     }
                                                   >> 205     //
                                                   >> 206     // Weitzsaecker's Mass formula
                                                   >> 207     //
                                                   >> 208     G4double mass =
                                                   >> 209       (A-Z)*neutron_mass + Z*proton_mass + Z*electron_mass
                                                   >> 210       - 15.67*A                                          // nuclear volume
                                                   >> 211       + 17.23*pow(A,2./3.)                               // surface energy
                                                   >> 212       + 93.15*pow(A/2.-Z,2.)/A                           // asymmetry
                                                   >> 213       + 0.6984523*pow(Z,2.)*pow(A,-1./3.);               // coulomb
                                                   >> 214     G4int ipp = (myA - myZ)%2;            // pairing
                                                   >> 215     G4int izz = myZ%2;
                                                   >> 216     if( ipp == izz )mass += (ipp+izz-1) * 12.0 * pow(A,-0.5);
                                                   >> 217     return mass*MeV;
388   }                                               218   }
389 }                                              << 
390                                                << 
391                                                << 
392 G4double                                       << 
393 G4Nucleus::GetThermalPz( const G4double mass,  << 
394 {                                              << 
395   G4double result = G4RandGauss::shoot();      << 
396   result *= std::sqrt(k_Boltzmann*temp*mass);  << 
397                                          // ni << 
398                                          // Ma << 
399   return result;                               << 
400 }                                              << 
401                                                   219  
402                                                << 220  G4double
403 G4double                                       << 221   G4Nucleus::GetThermalPz( const G4double mass, const G4double temp ) const
404 G4Nucleus::EvaporationEffects( G4double kineti << 222   {
405 {                                              << 223     G4double result = G4RandGauss::shoot();
406   // derived from original FORTRAN code EXNU b << 224     result *= sqrt(k_Boltzmann*temp*mass); // Das ist impuls (Pz),
407   //                                           << 225                                            // nichtrelativistische rechnung
408   // Nuclear evaporation as function of atomic << 226                                            // Maxwell verteilung angenommen
409   // and kinetic energy (MeV) of primary parti << 227     return result;
410   //                                           << 
411   // returns kinetic energy (MeV)              << 
412   //                                           << 
413   if( aEff < 1.5 )                             << 
414   {                                            << 
415     pnBlackTrackEnergy = dtaBlackTrackEnergy = << 
416     return 0.0;                                << 
417   }                                            << 
418   G4double ek = kineticEnergy/GeV;             << 
419   G4float ekin = std::min( 4.0, std::max( 0.1, << 
420   const G4float atno = std::min( 120., aEff ); << 
421   const G4float gfa = 2.0*((aEff-1.0)/70.)*G4E << 
422   //                                           << 
423   // 0.35 value at 1 GeV                       << 
424   // 0.05 value at 0.1 GeV                     << 
425   //                                           << 
426   G4float cfa = std::max( 0.15, 0.35 + ((0.35- << 
427   G4float exnu = 7.716 * cfa * G4Exp(-cfa)     << 
428     * ((atno-1.0)/120.)*G4Exp(-(atno-1.0)/120. << 
429   G4float fpdiv = std::max( 0.5, 1.0-0.25*ekin << 
430   //                                           << 
431   // pnBlackTrackEnergy  is the kinetic energy << 
432   //                     proton/neutron black  << 
433   // dtaBlackTrackEnergy is the kinetic energy << 
434   //                     deuteron/triton/alpha << 
435   //                                           << 
436   pnBlackTrackEnergy = exnu*fpdiv;             << 
437   dtaBlackTrackEnergy = exnu*(1.0-fpdiv);      << 
438                                                << 
439   if( G4int(zEff+0.1) != 82 )                  << 
440   {                                            << 
441     G4double ran1 = -6.0;                      << 
442     G4double ran2 = -6.0;                      << 
443     for( G4int i=0; i<12; ++i )                << 
444     {                                          << 
445       ran1 += G4UniformRand();                 << 
446       ran2 += G4UniformRand();                 << 
447     }                                          << 
448     pnBlackTrackEnergy *= 1.0 + ran1*gfa;      << 
449     dtaBlackTrackEnergy *= 1.0 + ran2*gfa;     << 
450   }                                            << 
451   pnBlackTrackEnergy = std::max( 0.0, pnBlackT << 
452   dtaBlackTrackEnergy = std::max( 0.0, dtaBlac << 
453   while( pnBlackTrackEnergy+dtaBlackTrackEnerg << 
454   {                                            << 
455     pnBlackTrackEnergy *= 1.0 - 0.5*G4UniformR << 
456     dtaBlackTrackEnergy *= 1.0 - 0.5*G4Uniform << 
457   }                                            << 
458   //G4cout << "EvaporationEffects "<<kineticEn << 
459   //       <<pnBlackTrackEnergy+dtaBlackTrackE << 
460   return (pnBlackTrackEnergy+dtaBlackTrackEner << 
461 }                                              << 
462                                                << 
463                                                << 
464 G4double                                       << 
465 G4Nucleus::AnnihilationEvaporationEffects(G4do << 
466 {                                              << 
467   // Nuclear evaporation as a function of atom << 
468   // energy (MeV) of primary particle.  Modifi << 
469   //                                           << 
470   if( aEff < 1.5 || ekOrg < 0.)                << 
471   {                                            << 
472     pnBlackTrackEnergyfromAnnihilation = 0.0;  << 
473     dtaBlackTrackEnergyfromAnnihilation = 0.0; << 
474     return 0.0;                                << 
475   }                                            << 
476   G4double ek = kineticEnergy/GeV;             << 
477   G4float ekin = std::min( 4.0, std::max( 0.1, << 
478   const G4float atno = std::min( 120., aEff ); << 
479   const G4float gfa = 2.0*((aEff-1.0)/70.)*G4E << 
480                                                << 
481   G4float cfa = std::max( 0.15, 0.35 + ((0.35- << 
482   G4float exnu = 7.716 * cfa * G4Exp(-cfa)     << 
483     * ((atno-1.0)/120.)*G4Exp(-(atno-1.0)/120. << 
484   G4float fpdiv = std::max( 0.5, 1.0-0.25*ekin << 
485                                                << 
486   pnBlackTrackEnergyfromAnnihilation = exnu*fp << 
487   dtaBlackTrackEnergyfromAnnihilation = exnu*( << 
488                                                << 
489   G4double ran1 = -6.0;                        << 
490   G4double ran2 = -6.0;                        << 
491   for( G4int i=0; i<12; ++i ) {                << 
492     ran1 += G4UniformRand();                   << 
493     ran2 += G4UniformRand();                   << 
494   }                                               228   }
495   pnBlackTrackEnergyfromAnnihilation *= 1.0 +  << 229  
496   dtaBlackTrackEnergyfromAnnihilation *= 1.0 + << 230  G4double 
497                                                << 231   G4Nucleus::EvaporationEffects( G4double kineticEnergy )
498   pnBlackTrackEnergyfromAnnihilation = std::ma << 232   {
499   dtaBlackTrackEnergyfromAnnihilation = std::m << 233     // derived from original FORTRAN code EXNU by H. Fesefeldt (10-Dec-1986)
500   G4double blackSum = pnBlackTrackEnergyfromAn << 234     //
501   if (blackSum >= ekOrg/GeV) {                 << 235     // Nuclear evaporation as function of atomic number
502     pnBlackTrackEnergyfromAnnihilation *= ekOr << 236     // and kinetic energy (MeV) of primary particle
503     dtaBlackTrackEnergyfromAnnihilation *= ekO << 237     //
                                                   >> 238     // returns kinetic energy (MeV)
                                                   >> 239     //
                                                   >> 240     if( aEff < 1.5 )
                                                   >> 241     {
                                                   >> 242       pnBlackTrackEnergy = dtaBlackTrackEnergy = 0.0;
                                                   >> 243       return 0.0;
                                                   >> 244     }
                                                   >> 245     G4double ek = kineticEnergy/GeV;
                                                   >> 246     G4float ekin = std::min( 4.0, std::max( 0.1, ek ) );
                                                   >> 247     const G4float atno = std::min( 120., aEff ); 
                                                   >> 248     const G4float gfa = 2.0*((aEff-1.0)/70.)*exp(-(aEff-1.0)/70.);
                                                   >> 249     //
                                                   >> 250     // 0.35 value at 1 GeV
                                                   >> 251     // 0.05 value at 0.1 GeV
                                                   >> 252     //
                                                   >> 253     G4float cfa = std::max( 0.15, 0.35 + ((0.35-0.05)/2.3)*log(ekin) );
                                                   >> 254     G4float exnu = 7.716 * cfa * exp(-cfa)
                                                   >> 255       * ((atno-1.0)/120.)*exp(-(atno-1.0)/120.);
                                                   >> 256     G4float fpdiv = std::max( 0.5, 1.0-0.25*ekin*ekin );
                                                   >> 257     //
                                                   >> 258     // pnBlackTrackEnergy  is the kinetic energy (in GeV) available for
                                                   >> 259     //                     proton/neutron black track particles
                                                   >> 260     // dtaBlackTrackEnergy is the kinetic energy (in GeV) available for
                                                   >> 261     //                     deuteron/triton/alpha black track particles
                                                   >> 262     //
                                                   >> 263     pnBlackTrackEnergy = exnu*fpdiv;
                                                   >> 264     dtaBlackTrackEnergy = exnu*(1.0-fpdiv);
                                                   >> 265     
                                                   >> 266     if( G4int(zEff+0.1) != 82 )
                                                   >> 267     { 
                                                   >> 268       //G4double ran1 = G4RandGauss::shoot();
                                                   >> 269       //G4double ran2 = G4RandGauss::shoot();
                                                   >> 270       G4double ran1 = -6.0;
                                                   >> 271       G4double ran2 = -6.0;
                                                   >> 272       for( G4int i=0; i<12; ++i )
                                                   >> 273       {
                                                   >> 274         ran1 += G4UniformRand();
                                                   >> 275         ran2 += G4UniformRand();
                                                   >> 276       }
                                                   >> 277       pnBlackTrackEnergy *= 1.0 + ran1*gfa;
                                                   >> 278       dtaBlackTrackEnergy *= 1.0 + ran2*gfa;
                                                   >> 279     }
                                                   >> 280     pnBlackTrackEnergy = std::max( 0.0, pnBlackTrackEnergy );
                                                   >> 281     dtaBlackTrackEnergy = std::max( 0.0, dtaBlackTrackEnergy );
                                                   >> 282     while( pnBlackTrackEnergy+dtaBlackTrackEnergy >= ek )
                                                   >> 283     {
                                                   >> 284       pnBlackTrackEnergy *= 1.0 - 0.5*G4UniformRand();
                                                   >> 285       dtaBlackTrackEnergy *= 1.0 - 0.5*G4UniformRand();
                                                   >> 286     }
                                                   >> 287 //    G4cout << "EvaporationEffects "<<kineticEnergy<<" "
                                                   >> 288 //           <<pnBlackTrackEnergy+dtaBlackTrackEnergy<<endl;
                                                   >> 289     return (pnBlackTrackEnergy+dtaBlackTrackEnergy)*GeV;
504   }                                               290   }
505                                                << 
506   return (pnBlackTrackEnergyfromAnnihilation+d << 
507 }                                              << 
508                                                << 
509                                                   291  
510 G4double                                       << 292  G4double 
511 G4Nucleus::Cinema( G4double kineticEnergy )    << 293   G4Nucleus::Cinema( G4double kineticEnergy )
512 {                                              << 294   {
513   // derived from original FORTRAN code CINEMA << 295     // derived from original FORTRAN code CINEMA by H. Fesefeldt (14-Oct-1987)
514   //                                           << 296     //
515   // input: kineticEnergy (MeV)                << 297     // input: kineticEnergy (MeV)
516   // returns modified kinetic energy (MeV)     << 298     // returns modified kinetic energy (MeV)
517   //                                           << 299     //
518   static const G4double expxu =  82.;          << 300     static const G4double expxu =  82.;           // upper bound for arg. of exp
519   static const G4double expxl = -expxu;        << 301     static const G4double expxl = -expxu;         // lower bound for arg. of exp
520                                                << 302     
521   G4double ek = kineticEnergy/GeV;             << 303     G4double ek = kineticEnergy/GeV;
522   G4double ekLog = G4Log( ek );                << 304     G4double ekLog = log( ek );
523   G4double aLog = G4Log( aEff );               << 305     G4double aLog = log( aEff );
524   G4double em = std::min( 1.0, 0.2390 + 0.0408 << 306     G4double em = std::min( 1.0, 0.2390 + 0.0408*aLog*aLog );
525   G4double temp1 = -ek * std::min( 0.15, 0.001 << 307     G4double temp1 = -ek * std::min( 0.15, 0.0019*aLog*aLog*aLog );
526   G4double temp2 = G4Exp( std::max( expxl, std << 308     G4double temp2 = exp( std::max( expxl, std::min( expxu, -(ekLog-em)*(ekLog-em)*2.0 ) ) );
527   G4double result = 0.0;                       << 309     G4double result = 0.0;
528   if( std::abs( temp1 ) < 1.0 )                << 310     if( abs( temp1 ) < 1.0 )
529   {                                            << 311     {
530     if( temp2 > 1.0e-10 )result = temp1*temp2; << 312       if( temp2 > 1.0e-10 )result = temp1*temp2;
531   }                                            << 313     }
532   else result = temp1*temp2;                   << 314     else result = temp1*temp2;
533   if( result < -ek )result = -ek;              << 315     if( result < -ek )result = -ek;
534   return result*GeV;                           << 316     return result*GeV;
535 }                                              << 317   }
536                                                   318 
                                                   >> 319  //
                                                   >> 320  // methods for class G4Nucleus  ... by Christian Volcker
                                                   >> 321  //
537                                                   322 
538 G4ThreeVector G4Nucleus::GetFermiMomentum()    << 323  G4ThreeVector G4Nucleus::GetFermiMomentum()
539 {                                              << 324   {
540   // chv: .. we assume zero temperature!       << 325     // chv: .. we assume zero temperature!
541                                                << 326     
542   // momentum is equally distributed in each p << 327     // momentum is equally distributed in each phasespace volume dpx, dpy, dpz.
543   G4double ranflat1=                           << 328     G4double ranflat1=RandFlat::shoot((HepDouble)0.,(HepDouble)fermiMomentum);   
544     G4RandFlat::shoot((G4double)0.,(G4double)f << 329     G4double ranflat2=RandFlat::shoot((HepDouble)0.,(HepDouble)fermiMomentum);   
545   G4double ranflat2=                           << 330     G4double ranflat3=RandFlat::shoot((HepDouble)0.,(HepDouble)fermiMomentum);   
546     G4RandFlat::shoot((G4double)0.,(G4double)f << 331     G4double ranmax = (ranflat1>ranflat2? ranflat1: ranflat2);
547   G4double ranflat3=                           << 332     ranmax = (ranmax>ranflat3? ranmax : ranflat3);
548     G4RandFlat::shoot((G4double)0.,(G4double)f << 333     
549   G4double ranmax = (ranflat1>ranflat2? ranfla << 334     // - random decay angle
550   ranmax = (ranmax>ranflat3? ranmax : ranflat3 << 335     G4double theta=pi*G4UniformRand();  // isotropic decay angle theta
551                                                << 336     G4double phi  =RandFlat::shoot((HepDouble)0.,(HepDouble)2*pi);  // isotropic decay angle phi
552   // Isotropic momentum distribution           << 337     
553   G4double costheta = 2.*G4UniformRand() - 1.0 << 338     // - setup ThreeVector
554   G4double sintheta = std::sqrt(1.0 - costheta << 339     G4double pz=cos(theta)*ranmax;
555   G4double phi = 2.0*pi*G4UniformRand();       << 340     G4double px=sin(theta)*cos(phi)*ranmax;
556                                                << 341     G4double py=sin(theta)*sin(phi)*ranmax;
557   G4double pz=costheta*ranmax;                 << 342     G4ThreeVector p(px,py,pz);
558   G4double px=sintheta*std::cos(phi)*ranmax;   << 343     return p;
559   G4double py=sintheta*std::sin(phi)*ranmax;   << 344   }
560   G4ThreeVector p(px,py,pz);                   << 
561   return p;                                    << 
562 }                                              << 
563                                                   345  
564                                                << 346  G4ReactionProductVector* G4Nucleus::Fragmentate()
565 G4ReactionProductVector* G4Nucleus::Fragmentat << 347   {
566 {                                              << 348     // needs implementation!
567   // needs implementation!                     << 349     return NULL;
568   return nullptr;                              << 350   }
569 }                                              << 
570                                                   351  
571                                                << 352  void G4Nucleus::AddMomentum(const G4ThreeVector aMomentum)
572 void G4Nucleus::AddMomentum(const G4ThreeVecto << 353   {
573 {                                              << 354     momentum+=(aMomentum);
574   momentum+=(aMomentum);                       << 355   }
575 }                                              << 
576                                                << 
577                                                   356  
578 void G4Nucleus::AddExcitationEnergy( G4double  << 357  void G4Nucleus::AddExcitationEnergy( G4double anEnergy )
579 {                                              << 358   {
580   excitationEnergy+=anEnergy;                  << 359     excitationEnergy+=anEnergy;
581 }                                              << 360   }
582                                                   361 
583  /* end of file */                                362  /* end of file */
584                                                   363 
585                                                   364