Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/lowenergy/src/G4LivermoreGammaConversionModel.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/electromagnetic/lowenergy/src/G4LivermoreGammaConversionModel.cc (Version 11.3.0) and /processes/electromagnetic/lowenergy/src/G4LivermoreGammaConversionModel.cc (Version 10.0.p2)


  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 // Author: Sebastien Incerti                       26 // Author: Sebastien Incerti
 27 //         22 January 2012                         27 //         22 January 2012
 28 //         on base of G4LivermoreGammaConversi     28 //         on base of G4LivermoreGammaConversionModel (original version)
 29 //         and G4LivermoreRayleighModel (MT ve     29 //         and G4LivermoreRayleighModel (MT version)
 30 //                                             << 
 31 // Modifications: Zhuxin Li@CENBG              << 
 32 //                11 March 2020                << 
 33 //                derives from G4PairProductio << 
 34 // ------------------------------------------- << 
 35                                                    30 
 36 #include "G4LivermoreGammaConversionModel.hh"      31 #include "G4LivermoreGammaConversionModel.hh"
 37                                                << 
 38 #include "G4AutoLock.hh"                       << 
 39 #include "G4Electron.hh"                       << 
 40 #include "G4EmParameters.hh"                   << 
 41 #include "G4Exp.hh"                            << 
 42 #include "G4ParticleChangeForGamma.hh"         << 
 43 #include "G4PhysicalConstants.hh"                  32 #include "G4PhysicalConstants.hh"
 44 #include "G4PhysicsFreeVector.hh"              << 
 45 #include "G4SystemOfUnits.hh"                      33 #include "G4SystemOfUnits.hh"
 46                                                <<  34 #include "G4Log.hh"
 47 namespace                                      <<  35 #include "G4Exp.hh"
 48 {                                              << 
 49 G4Mutex LivermoreGammaConversionModelMutex = G << 
 50 }                                              << 
 51                                                    36 
 52 //....oooOO0OOooo........oooOO0OOooo........oo     37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >>  38 
                                                   >>  39 using namespace std;
                                                   >>  40 
 53 //....oooOO0OOooo........oooOO0OOooo........oo     41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 54                                                    42 
 55 G4PhysicsFreeVector* G4LivermoreGammaConversio <<  43 G4int G4LivermoreGammaConversionModel::maxZ = 99;
 56 G4String G4LivermoreGammaConversionModel::gDat <<  44 G4LPhysicsFreeVector* G4LivermoreGammaConversionModel::data[] = {0};
 57                                                    45 
 58 G4LivermoreGammaConversionModel::G4LivermoreGa <<  46 G4LivermoreGammaConversionModel::G4LivermoreGammaConversionModel
 59                                                <<  47 (const G4ParticleDefinition*, const G4String& nam)
 60   : G4PairProductionRelModel(p, nam)           <<  48 :G4VEmModel(nam),isInitialised(false),smallEnergy(2.*MeV)
 61 {                                                  49 {
 62   fParticleChange = nullptr;                   <<  50   fParticleChange = 0;
 63   lowEnergyLimit = 2. * CLHEP::electron_mass_c <<  51 
 64   verboseLevel = 0;                            <<  52   lowEnergyLimit = 2.0*electron_mass_c2;
                                                   >>  53      
                                                   >>  54   verboseLevel= 0;
 65   // Verbosity scale for debugging purposes:       55   // Verbosity scale for debugging purposes:
 66   // 0 = nothing                               <<  56   // 0 = nothing 
 67   // 1 = calculation of cross sections, file o     57   // 1 = calculation of cross sections, file openings...
 68   // 2 = entering in methods                       58   // 2 = entering in methods
 69   if (verboseLevel > 0) {                      <<  59 
                                                   >>  60   if(verboseLevel > 0) 
                                                   >>  61   {
 70     G4cout << "G4LivermoreGammaConversionModel     62     G4cout << "G4LivermoreGammaConversionModel is constructed " << G4endl;
 71   }                                                63   }
 72 }                                                  64 }
 73                                                    65 
 74 //....oooOO0OOooo........oooOO0OOooo........oo     66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 75                                                    67 
 76 G4LivermoreGammaConversionModel::~G4LivermoreG     68 G4LivermoreGammaConversionModel::~G4LivermoreGammaConversionModel()
 77 {                                              <<  69 {}
 78   if (IsMaster()) {                            << 
 79     for (G4int i = 0; i <= maxZ; ++i) {        << 
 80       if (data[i]) {                           << 
 81         delete data[i];                        << 
 82         data[i] = nullptr;                     << 
 83       }                                        << 
 84     }                                          << 
 85   }                                            << 
 86 }                                              << 
 87                                                    70 
 88 //....oooOO0OOooo........oooOO0OOooo........oo     71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 89                                                    72 
 90 void G4LivermoreGammaConversionModel::Initiali <<  73 void G4LivermoreGammaConversionModel::Initialise(
 91                                                <<  74                                 const G4ParticleDefinition* particle,
                                                   >>  75         const G4DataVector& cuts)
 92 {                                                  76 {
 93   G4PairProductionRelModel::Initialise(particl <<  77   if (verboseLevel > 1) 
 94   if (verboseLevel > 1) {                      <<  78   {
 95     G4cout << "Calling Initialise() of G4Liver <<  79     G4cout << "Calling Initialise() of G4LivermoreGammaConversionModel." 
 96            << "Energy range: " << LowEnergyLim <<  80      << G4endl
 97            << " GeV isMater: " << IsMaster() < <<  81      << "Energy range: "
                                                   >>  82      << LowEnergyLimit() / MeV << " MeV - "
                                                   >>  83      << HighEnergyLimit() / GeV << " GeV"
                                                   >>  84      << G4endl;
 98   }                                                85   }
 99                                                    86 
100   if (IsMaster()) {                            <<  87   if(IsMaster()) 
                                                   >>  88   {
                                                   >>  89 
101     // Initialise element selector                 90     // Initialise element selector
                                                   >>  91 
102     InitialiseElementSelectors(particle, cuts)     92     InitialiseElementSelectors(particle, cuts);
103                                                    93 
104     // Access to elements                          94     // Access to elements
105     const G4ElementTable* elemTable = G4Elemen <<  95   
106     std::size_t numElems = (*elemTable).size() <<  96     char* path = getenv("G4LEDATA");
107     for (std::size_t ie = 0; ie < numElems; ++ <<  97 
108       const G4Element* elem = (*elemTable)[ie] <<  98     G4ProductionCutsTable* theCoupleTable =
109       const G4int Z = std::min(maxZ, elem->Get <<  99       G4ProductionCutsTable::GetProductionCutsTable();
110       if (data[Z] == nullptr) {                << 100   
111         ReadData(Z);                           << 101     G4int numOfCouples = theCoupleTable->GetTableSize();
                                                   >> 102   
                                                   >> 103     for(G4int i=0; i<numOfCouples; ++i) 
                                                   >> 104     {
                                                   >> 105       const G4Material* material = 
                                                   >> 106         theCoupleTable->GetMaterialCutsCouple(i)->GetMaterial();
                                                   >> 107       const G4ElementVector* theElementVector = material->GetElementVector();
                                                   >> 108       G4int nelm = material->GetNumberOfElements();
                                                   >> 109     
                                                   >> 110       for (G4int j=0; j<nelm; ++j) 
                                                   >> 111       {
                                                   >> 112         G4int Z = (G4int)(*theElementVector)[j]->GetZ();
                                                   >> 113         if(Z < 1)          { Z = 1; }
                                                   >> 114         else if(Z > maxZ)  { Z = maxZ; }
                                                   >> 115         if(!data[Z]) { ReadData(Z, path); }
112       }                                           116       }
113     }                                             117     }
114   }                                               118   }
115   if (isInitialised) {                         << 119   
116     return;                                    << 120   //
117   }                                            << 121   
                                                   >> 122   if(isInitialised) { return; }
118   fParticleChange = GetParticleChangeForGamma(    123   fParticleChange = GetParticleChangeForGamma();
119   isInitialised = true;                           124   isInitialised = true;
120 }                                                 125 }
121                                                   126 
122 //....oooOO0OOooo........oooOO0OOooo........oo    127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
123                                                   128 
124 const G4String& G4LivermoreGammaConversionMode << 129 void G4LivermoreGammaConversionModel::InitialiseLocal(const G4ParticleDefinition*,
                                                   >> 130                         G4VEmModel* masterModel)
125 {                                                 131 {
126   // no check in this method - environment var << 132   SetElementSelectors(masterModel->GetElementSelectors());
127   if (gDataDirectory.empty()) {                << 
128     auto param = G4EmParameters::Instance();   << 
129     std::ostringstream ost;                    << 
130     if (param->LivermoreDataDir() == "livermor << 
131       ost << param->GetDirLEDATA() << "/liverm << 
132       useSpline = true;                        << 
133     }                                          << 
134     else {                                     << 
135       ost << param->GetDirLEDATA() << "/epics2 << 
136     }                                          << 
137     gDataDirectory = ost.str();                << 
138   }                                            << 
139   return gDataDirectory;                       << 
140 }                                                 133 }
141                                                   134 
142 //....oooOO0OOooo........oooOO0OOooo........oo    135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
143                                                   136 
144 void G4LivermoreGammaConversionModel::ReadData << 137 G4double 
                                                   >> 138 G4LivermoreGammaConversionModel::MinPrimaryEnergy(const G4Material*,
                                                   >> 139               const G4ParticleDefinition*,
                                                   >> 140               G4double)
145 {                                                 141 {
146   if (verboseLevel > 1) {                      << 142   return lowEnergyLimit;
147     G4cout << "Calling ReadData() of G4Livermo << 143 }
148   }                                            << 
149                                                   144 
150   if (data[Z] != nullptr) {                    << 145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
151     return;                                    << 146 
                                                   >> 147 void G4LivermoreGammaConversionModel::ReadData(size_t Z, const char* path)
                                                   >> 148 {
                                                   >> 149   if (verboseLevel > 1) 
                                                   >> 150   {
                                                   >> 151     G4cout << "Calling ReadData() of G4LivermoreGammaConversionModel" 
                                                   >> 152      << G4endl;
                                                   >> 153   }
                                                   >> 154 
                                                   >> 155   if(data[Z]) { return; }
                                                   >> 156   
                                                   >> 157   const char* datadir = path;
                                                   >> 158 
                                                   >> 159   if(!datadir) 
                                                   >> 160   {
                                                   >> 161     datadir = getenv("G4LEDATA");
                                                   >> 162     if(!datadir) 
                                                   >> 163     {
                                                   >> 164       G4Exception("G4LivermoreGammaConversionModel::ReadData()",
                                                   >> 165       "em0006",FatalException,
                                                   >> 166       "Environment variable G4LEDATA not defined");
                                                   >> 167       return;
                                                   >> 168     }
152   }                                               169   }
153                                                   170 
                                                   >> 171   //
                                                   >> 172   
                                                   >> 173   data[Z] = new G4LPhysicsFreeVector();
                                                   >> 174   
                                                   >> 175   //
                                                   >> 176   
154   std::ostringstream ost;                         177   std::ostringstream ost;
155   ost << FindDirectoryPath() << "pp-cs-" << Z  << 178   ost << datadir << "/livermore/pair/pp-cs-" << Z <<".dat";
156                                                << 
157   data[Z] = new G4PhysicsFreeVector(useSpline) << 
158                                                << 
159   std::ifstream fin(ost.str().c_str());           179   std::ifstream fin(ost.str().c_str());
160                                                << 180   
161   if (!fin.is_open()) {                        << 181   if( !fin.is_open()) 
                                                   >> 182   {
162     G4ExceptionDescription ed;                    183     G4ExceptionDescription ed;
163     ed << "G4LivermoreGammaConversionModel dat << 184     ed << "G4LivermoreGammaConversionModel data file <" << ost.str().c_str()
164        << G4endl;                              << 185        << "> is not opened!" << G4endl;
165     G4Exception("G4LivermoreGammaConversionMod << 186     G4Exception("G4LivermoreGammaConversionModel::ReadData()",
166                 "G4LEDATA version should be G4 << 187     "em0003",FatalException,
                                                   >> 188     ed,"G4LEDATA version should be G4EMLOW6.27 or later.");
167     return;                                       189     return;
168   }                                            << 190   } 
169   else {                                       << 191   
170     if (verboseLevel > 1) {                    << 192   else 
171       G4cout << "File " << ost.str() << " is o << 193   {
172     }                                          << 194     
173                                                << 195     if(verboseLevel > 3) { G4cout << "File " << ost.str() 
                                                   >> 196        << " is opened by G4LivermoreGammaConversionModel" << G4endl;}
                                                   >> 197     
174     data[Z]->Retrieve(fin, true);                 198     data[Z]->Retrieve(fin, true);
175   }                                            << 199   } 
                                                   >> 200 
176   // Activation of spline interpolation           201   // Activation of spline interpolation
177   if (useSpline) data[Z]->FillSecondDerivative << 202   data[Z] ->SetSpline(true);  
                                                   >> 203   
178 }                                                 204 }
179                                                   205 
180 //....oooOO0OOooo........oooOO0OOooo........oo    206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
181                                                   207 
182 G4double                                       << 208 G4double 
183 G4LivermoreGammaConversionModel::ComputeCrossS << 209 G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom(const G4ParticleDefinition*,
184                                                << 210                   G4double GammaEnergy,
185                                                << 211                   G4double Z, G4double,
                                                   >> 212                   G4double, G4double)
186 {                                                 213 {
187   if (verboseLevel > 1) {                      << 214   if (verboseLevel > 1) 
188     G4cout << "G4LivermoreGammaConversionModel << 215   {
                                                   >> 216     G4cout << "Calling ComputeCrossSectionPerAtom() of G4LivermoreGammaConversionModel" 
                                                   >> 217      << G4endl;
189   }                                               218   }
190                                                   219 
191   if (GammaEnergy < lowEnergyLimit) {          << 220   if (GammaEnergy < lowEnergyLimit) { return 0.0; } 
192     return 0.0;                                << 
193   }                                            << 
194                                                   221 
195   G4double xs = 0.0;                              222   G4double xs = 0.0;
                                                   >> 223   
                                                   >> 224   G4int intZ=G4int(Z);
196                                                   225 
197   G4int intZ = std::max(1, std::min(G4lrint(Z) << 226   if(intZ < 1 || intZ > maxZ) { return xs; }
198                                                   227 
199   G4PhysicsFreeVector* pv = data[intZ];        << 228   G4LPhysicsFreeVector* pv = data[intZ];
200                                                   229 
201   // if element was not initialised               230   // if element was not initialised
202   // do initialisation safely for MT mode         231   // do initialisation safely for MT mode
203   if (pv == nullptr) {                         << 232   if(!pv) 
204     InitialiseForElement(particle, intZ);      << 233   {
                                                   >> 234     InitialiseForElement(0, intZ);
205     pv = data[intZ];                              235     pv = data[intZ];
206     if (pv == nullptr) {                       << 236     if(!pv) { return xs; }
207       return xs;                               << 
208     }                                          << 
209   }                                               237   }
210   // x-section is taken from the table            238   // x-section is taken from the table
211   xs = pv->Value(GammaEnergy);                 << 239   xs = pv->Value(GammaEnergy); 
212                                                   240 
213   if (verboseLevel > 0) {                      << 241   if(verboseLevel > 0)
214     G4cout << "*** Gamma conversion xs for Z=" << 242   {
215            << "  cs=" << xs / millibarn << " m << 243     G4int n = pv->GetVectorLength() - 1;
                                                   >> 244     G4cout  <<  "****** DEBUG: tcs value for Z=" << Z << " at energy (MeV)=" 
                                                   >> 245       << GammaEnergy/MeV << G4endl;
                                                   >> 246     G4cout  <<  "  cs (Geant4 internal unit)=" << xs << G4endl;
                                                   >> 247     G4cout  <<  "    -> first cs value in EADL data file (iu) =" << (*pv)[0] << G4endl;
                                                   >> 248     G4cout  <<  "    -> last  cs value in EADL data file (iu) =" << (*pv)[n] << G4endl;
                                                   >> 249     G4cout  <<  "*********************************************************" << G4endl;
216   }                                               250   }
                                                   >> 251 
217   return xs;                                      252   return xs;
                                                   >> 253 
218 }                                                 254 }
219                                                   255 
                                                   >> 256 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 257 
                                                   >> 258 void G4LivermoreGammaConversionModel::SampleSecondaries(
                                                   >> 259                                  std::vector<G4DynamicParticle*>* fvect,
                                                   >> 260          const G4MaterialCutsCouple* couple,
                                                   >> 261          const G4DynamicParticle* aDynamicGamma,
                                                   >> 262          G4double, G4double)
                                                   >> 263 {
                                                   >> 264 
                                                   >> 265 // The energies of the e+ e- secondaries are sampled using the Bethe - Heitler
                                                   >> 266 // cross sections with Coulomb correction. A modified version of the random
                                                   >> 267 // number techniques of Butcher & Messel is used (Nuc Phys 20(1960),15).
                                                   >> 268 
                                                   >> 269 // Note 1 : Effects due to the breakdown of the Born approximation at low
                                                   >> 270 // energy are ignored.
                                                   >> 271 // Note 2 : The differential cross section implicitly takes account of
                                                   >> 272 // pair creation in both nuclear and atomic electron fields. However triplet
                                                   >> 273 // prodution is not generated.
                                                   >> 274 
                                                   >> 275   if (verboseLevel > 1) {
                                                   >> 276     G4cout << "Calling SampleSecondaries() of G4LivermoreGammaConversionModel" 
                                                   >> 277      << G4endl;
                                                   >> 278   }
                                                   >> 279 
                                                   >> 280   G4double photonEnergy = aDynamicGamma->GetKineticEnergy();
                                                   >> 281   G4ParticleMomentum photonDirection = aDynamicGamma->GetMomentumDirection();
                                                   >> 282 
                                                   >> 283   G4double epsilon ;
                                                   >> 284   G4double epsilon0Local = electron_mass_c2 / photonEnergy ;
                                                   >> 285 
                                                   >> 286   // Do it fast if photon energy < 2. MeV
                                                   >> 287   if (photonEnergy < smallEnergy )
                                                   >> 288   {
                                                   >> 289     epsilon = epsilon0Local + (0.5 - epsilon0Local) * G4UniformRand();
                                                   >> 290   }
                                                   >> 291   else
                                                   >> 292   {
                                                   >> 293     // Select randomly one element in the current material
                                                   >> 294 
                                                   >> 295     const G4ParticleDefinition* particle =  aDynamicGamma->GetDefinition();
                                                   >> 296     const G4Element* element = SelectRandomAtom(couple,particle,photonEnergy);
                                                   >> 297 
                                                   >> 298     if (element == 0)
                                                   >> 299       {
                                                   >> 300   G4cout << "G4LivermoreGammaConversionModel::SampleSecondaries - element = 0" 
                                                   >> 301          << G4endl;
                                                   >> 302   return;
                                                   >> 303       }
                                                   >> 304     G4IonisParamElm* ionisation = element->GetIonisation();
                                                   >> 305     if (ionisation == 0)
                                                   >> 306       {
                                                   >> 307   G4cout << "G4LivermoreGammaConversionModel::SampleSecondaries - ionisation = 0" 
                                                   >> 308          << G4endl;
                                                   >> 309   return;
                                                   >> 310       }
                                                   >> 311 
                                                   >> 312     // Extract Coulomb factor for this Element
                                                   >> 313     G4double fZ = 8. * (ionisation->GetlogZ3());
                                                   >> 314     if (photonEnergy > 50. * MeV) fZ += 8. * (element->GetfCoulomb());
                                                   >> 315 
                                                   >> 316     // Limits of the screening variable
                                                   >> 317     G4double screenFactor = 136. * epsilon0Local / (element->GetIonisation()->GetZ3()) ;
                                                   >> 318     G4double screenMax = G4Exp ((42.24 - fZ)/8.368) - 0.952 ;
                                                   >> 319     G4double screenMin = std::min(4.*screenFactor,screenMax) ;
                                                   >> 320 
                                                   >> 321     // Limits of the energy sampling
                                                   >> 322     G4double epsilon1 = 0.5 - 0.5 * std::sqrt(1. - screenMin / screenMax) ;
                                                   >> 323     G4double epsilonMin = std::max(epsilon0Local,epsilon1);
                                                   >> 324     G4double epsilonRange = 0.5 - epsilonMin ;
                                                   >> 325 
                                                   >> 326     // Sample the energy rate of the created electron (or positron)
                                                   >> 327     G4double screen;
                                                   >> 328     G4double gReject ;
                                                   >> 329 
                                                   >> 330     G4double f10 = ScreenFunction1(screenMin) - fZ;
                                                   >> 331     G4double f20 = ScreenFunction2(screenMin) - fZ;
                                                   >> 332     G4double normF1 = std::max(f10 * epsilonRange * epsilonRange,0.);
                                                   >> 333     G4double normF2 = std::max(1.5 * f20,0.);
                                                   >> 334 
                                                   >> 335     do 
                                                   >> 336       {
                                                   >> 337   if (normF1 / (normF1 + normF2) > G4UniformRand() )
                                                   >> 338     {
                                                   >> 339       epsilon = 0.5 - epsilonRange * std::pow(G4UniformRand(), 0.333333) ;
                                                   >> 340       screen = screenFactor / (epsilon * (1. - epsilon));
                                                   >> 341       gReject = (ScreenFunction1(screen) - fZ) / f10 ;
                                                   >> 342     }
                                                   >> 343   else
                                                   >> 344     {
                                                   >> 345       epsilon = epsilonMin + epsilonRange * G4UniformRand();
                                                   >> 346       screen = screenFactor / (epsilon * (1 - epsilon));
                                                   >> 347       gReject = (ScreenFunction2(screen) - fZ) / f20 ;
                                                   >> 348     }
                                                   >> 349       } while ( gReject < G4UniformRand() );
                                                   >> 350     
                                                   >> 351   }   //  End of epsilon sampling
                                                   >> 352 
                                                   >> 353   // Fix charges randomly
                                                   >> 354 
                                                   >> 355   G4double electronTotEnergy;
                                                   >> 356   G4double positronTotEnergy;
                                                   >> 357 
                                                   >> 358   if (G4UniformRand() > 0.5)
                                                   >> 359     {
                                                   >> 360       electronTotEnergy = (1. - epsilon) * photonEnergy;
                                                   >> 361       positronTotEnergy = epsilon * photonEnergy;
                                                   >> 362     }
                                                   >> 363   else
                                                   >> 364     {
                                                   >> 365       positronTotEnergy = (1. - epsilon) * photonEnergy;
                                                   >> 366       electronTotEnergy = epsilon * photonEnergy;
                                                   >> 367     }
                                                   >> 368 
                                                   >> 369   // Scattered electron (positron) angles. ( Z - axis along the parent photon)
                                                   >> 370   // Universal distribution suggested by L. Urban (Geant3 manual (1993) Phys211),
                                                   >> 371   // derived from Tsai distribution (Rev. Mod. Phys. 49, 421 (1977)
                                                   >> 372 
                                                   >> 373   G4double u;
                                                   >> 374   const G4double a1 = 0.625;
                                                   >> 375   G4double a2 = 3. * a1;
                                                   >> 376   //  G4double d = 27. ;
                                                   >> 377 
                                                   >> 378   //  if (9. / (9. + d) > G4UniformRand())
                                                   >> 379   if (0.25 > G4UniformRand())
                                                   >> 380     {
                                                   >> 381       u = - G4Log(G4UniformRand() * G4UniformRand()) / a1 ;
                                                   >> 382     }
                                                   >> 383   else
                                                   >> 384     {
                                                   >> 385       u = - G4Log(G4UniformRand() * G4UniformRand()) / a2 ;
                                                   >> 386     }
                                                   >> 387 
                                                   >> 388   G4double thetaEle = u*electron_mass_c2/electronTotEnergy;
                                                   >> 389   G4double thetaPos = u*electron_mass_c2/positronTotEnergy;
                                                   >> 390   G4double phi  = twopi * G4UniformRand();
                                                   >> 391 
                                                   >> 392   G4double dxEle= std::sin(thetaEle)*std::cos(phi),dyEle= std::sin(thetaEle)*std::sin(phi),dzEle=std::cos(thetaEle);
                                                   >> 393   G4double dxPos=-std::sin(thetaPos)*std::cos(phi),dyPos=-std::sin(thetaPos)*std::sin(phi),dzPos=std::cos(thetaPos);
                                                   >> 394   
                                                   >> 395   
                                                   >> 396   // Kinematics of the created pair:
                                                   >> 397   // the electron and positron are assumed to have a symetric angular 
                                                   >> 398   // distribution with respect to the Z axis along the parent photon
                                                   >> 399   
                                                   >> 400   G4double electronKineEnergy = std::max(0.,electronTotEnergy - electron_mass_c2) ;
                                                   >> 401   
                                                   >> 402   G4ThreeVector electronDirection (dxEle, dyEle, dzEle);
                                                   >> 403   electronDirection.rotateUz(photonDirection);
                                                   >> 404       
                                                   >> 405   G4DynamicParticle* particle1 = new G4DynamicParticle (G4Electron::Electron(),
                                                   >> 406               electronDirection,
                                                   >> 407               electronKineEnergy);
                                                   >> 408 
                                                   >> 409   // The e+ is always created 
                                                   >> 410   G4double positronKineEnergy = std::max(0.,positronTotEnergy - electron_mass_c2) ;
                                                   >> 411 
                                                   >> 412   G4ThreeVector positronDirection (dxPos, dyPos, dzPos);
                                                   >> 413   positronDirection.rotateUz(photonDirection);   
                                                   >> 414   
                                                   >> 415   // Create G4DynamicParticle object for the particle2 
                                                   >> 416   G4DynamicParticle* particle2 = new G4DynamicParticle(G4Positron::Positron(),
                                                   >> 417                    positronDirection, 
                                                   >> 418                    positronKineEnergy);
                                                   >> 419   // Fill output vector
                                                   >> 420   fvect->push_back(particle1);
                                                   >> 421   fvect->push_back(particle2);
                                                   >> 422 
                                                   >> 423   // kill incident photon
                                                   >> 424   fParticleChange->SetProposedKineticEnergy(0.);
                                                   >> 425   fParticleChange->ProposeTrackStatus(fStopAndKill);   
                                                   >> 426 
                                                   >> 427 }
                                                   >> 428 
                                                   >> 429 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 430 
                                                   >> 431 G4double 
                                                   >> 432 G4LivermoreGammaConversionModel::ScreenFunction1(G4double screenVariable)
                                                   >> 433 {
                                                   >> 434   // Compute the value of the screening function 3*phi1 - phi2
                                                   >> 435 
                                                   >> 436   G4double value;
                                                   >> 437   
                                                   >> 438   if (screenVariable > 1.)
                                                   >> 439     value = 42.24 - 8.368 * G4Log(screenVariable + 0.952);
                                                   >> 440   else
                                                   >> 441     value = 42.392 - screenVariable * (7.796 - 1.961 * screenVariable);
                                                   >> 442   
                                                   >> 443   return value;
                                                   >> 444 } 
                                                   >> 445 
                                                   >> 446 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 447 
                                                   >> 448 G4double 
                                                   >> 449 G4LivermoreGammaConversionModel::ScreenFunction2(G4double screenVariable)
                                                   >> 450 {
                                                   >> 451   // Compute the value of the screening function 1.5*phi1 - 0.5*phi2
                                                   >> 452   
                                                   >> 453   G4double value;
                                                   >> 454   
                                                   >> 455   if (screenVariable > 1.)
                                                   >> 456     value = 42.24 - 8.368 * G4Log(screenVariable + 0.952);
                                                   >> 457   else
                                                   >> 458     value = 41.405 - screenVariable * (5.828 - 0.8945 * screenVariable);
                                                   >> 459   
                                                   >> 460   return value;
                                                   >> 461 } 
                                                   >> 462 
220 //....oooOO0OOooo........oooOO0OOooo........oo    463 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
221                                                   464 
222 void G4LivermoreGammaConversionModel::Initiali << 465 #include "G4AutoLock.hh"
                                                   >> 466 namespace { G4Mutex LivermoreGammaConversionModelMutex = G4MUTEX_INITIALIZER; }
                                                   >> 467 
                                                   >> 468 void G4LivermoreGammaConversionModel::InitialiseForElement(
                                                   >> 469               const G4ParticleDefinition*, 
                                                   >> 470               G4int Z)
223 {                                                 471 {
224   G4AutoLock l(&LivermoreGammaConversionModelM    472   G4AutoLock l(&LivermoreGammaConversionModelMutex);
225   if (data[Z] == nullptr) {                    << 473   //  G4cout << "G4LivermoreGammaConversionModel::InitialiseForElement Z= " 
226     ReadData(Z);                               << 474   //   << Z << G4endl;
227   }                                            << 475   if(!data[Z]) { ReadData(Z); }
228   l.unlock();                                     476   l.unlock();
229 }                                                 477 }
230                                                   478 
231 //....oooOO0OOooo........oooOO0OOooo........oo    479 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
232                                                   480