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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 11.2)


  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 //                                                 30 //
 31 // Modifications: Zhuxin Li@CENBG                  31 // Modifications: Zhuxin Li@CENBG
 32 //                11 March 2020                    32 //                11 March 2020
 33 //                derives from G4PairProductio     33 //                derives from G4PairProductionRelModel
 34 // -------------------------------------------     34 // -------------------------------------------------------------------
 35                                                    35 
 36 #include "G4LivermoreGammaConversionModel.hh"      36 #include "G4LivermoreGammaConversionModel.hh"
 37                                                    37 
 38 #include "G4AutoLock.hh"                           38 #include "G4AutoLock.hh"
 39 #include "G4Electron.hh"                           39 #include "G4Electron.hh"
 40 #include "G4EmParameters.hh"                       40 #include "G4EmParameters.hh"
 41 #include "G4Exp.hh"                                41 #include "G4Exp.hh"
 42 #include "G4ParticleChangeForGamma.hh"             42 #include "G4ParticleChangeForGamma.hh"
 43 #include "G4PhysicalConstants.hh"                  43 #include "G4PhysicalConstants.hh"
 44 #include "G4PhysicsFreeVector.hh"                  44 #include "G4PhysicsFreeVector.hh"
 45 #include "G4SystemOfUnits.hh"                      45 #include "G4SystemOfUnits.hh"
 46                                                    46 
 47 namespace                                          47 namespace
 48 {                                                  48 {
 49 G4Mutex LivermoreGammaConversionModelMutex = G     49 G4Mutex LivermoreGammaConversionModelMutex = G4MUTEX_INITIALIZER;
 50 }                                                  50 }
 51                                                    51 
 52 //....oooOO0OOooo........oooOO0OOooo........oo     52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 53 //....oooOO0OOooo........oooOO0OOooo........oo     53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 54                                                    54 
 55 G4PhysicsFreeVector* G4LivermoreGammaConversio     55 G4PhysicsFreeVector* G4LivermoreGammaConversionModel::data[] = {nullptr};
 56 G4String G4LivermoreGammaConversionModel::gDat     56 G4String G4LivermoreGammaConversionModel::gDataDirectory = "";
 57                                                    57 
 58 G4LivermoreGammaConversionModel::G4LivermoreGa     58 G4LivermoreGammaConversionModel::G4LivermoreGammaConversionModel(const G4ParticleDefinition* p,
 59                                                    59                                                                  const G4String& nam)
 60   : G4PairProductionRelModel(p, nam)               60   : G4PairProductionRelModel(p, nam)
 61 {                                                  61 {
 62   fParticleChange = nullptr;                       62   fParticleChange = nullptr;
 63   lowEnergyLimit = 2. * CLHEP::electron_mass_c     63   lowEnergyLimit = 2. * CLHEP::electron_mass_c2;
 64   verboseLevel = 0;                                64   verboseLevel = 0;
 65   // Verbosity scale for debugging purposes:       65   // Verbosity scale for debugging purposes:
 66   // 0 = nothing                                   66   // 0 = nothing
 67   // 1 = calculation of cross sections, file o     67   // 1 = calculation of cross sections, file openings...
 68   // 2 = entering in methods                       68   // 2 = entering in methods
 69   if (verboseLevel > 0) {                          69   if (verboseLevel > 0) {
 70     G4cout << "G4LivermoreGammaConversionModel     70     G4cout << "G4LivermoreGammaConversionModel is constructed " << G4endl;
 71   }                                                71   }
 72 }                                                  72 }
 73                                                    73 
 74 //....oooOO0OOooo........oooOO0OOooo........oo     74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 75                                                    75 
 76 G4LivermoreGammaConversionModel::~G4LivermoreG     76 G4LivermoreGammaConversionModel::~G4LivermoreGammaConversionModel()
 77 {                                                  77 {
 78   if (IsMaster()) {                                78   if (IsMaster()) {
 79     for (G4int i = 0; i <= maxZ; ++i) {            79     for (G4int i = 0; i <= maxZ; ++i) {
 80       if (data[i]) {                               80       if (data[i]) {
 81         delete data[i];                            81         delete data[i];
 82         data[i] = nullptr;                         82         data[i] = nullptr;
 83       }                                            83       }
 84     }                                              84     }
 85   }                                                85   }
 86 }                                                  86 }
 87                                                    87 
 88 //....oooOO0OOooo........oooOO0OOooo........oo     88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 89                                                    89 
 90 void G4LivermoreGammaConversionModel::Initiali     90 void G4LivermoreGammaConversionModel::Initialise(const G4ParticleDefinition* particle,
 91                                                    91                                                  const G4DataVector& cuts)
 92 {                                                  92 {
 93   G4PairProductionRelModel::Initialise(particl     93   G4PairProductionRelModel::Initialise(particle, cuts);
 94   if (verboseLevel > 1) {                          94   if (verboseLevel > 1) {
 95     G4cout << "Calling Initialise() of G4Liver     95     G4cout << "Calling Initialise() of G4LivermoreGammaConversionModel." << G4endl
 96            << "Energy range: " << LowEnergyLim     96            << "Energy range: " << LowEnergyLimit() / MeV << " MeV - " << HighEnergyLimit() / GeV
 97            << " GeV isMater: " << IsMaster() <     97            << " GeV isMater: " << IsMaster() << G4endl;
 98   }                                                98   }
 99                                                    99 
100   if (IsMaster()) {                               100   if (IsMaster()) {
101     // Initialise element selector                101     // Initialise element selector
102     InitialiseElementSelectors(particle, cuts)    102     InitialiseElementSelectors(particle, cuts);
103                                                   103 
104     // Access to elements                         104     // Access to elements
105     const G4ElementTable* elemTable = G4Elemen    105     const G4ElementTable* elemTable = G4Element::GetElementTable();
106     std::size_t numElems = (*elemTable).size()    106     std::size_t numElems = (*elemTable).size();
107     for (std::size_t ie = 0; ie < numElems; ++    107     for (std::size_t ie = 0; ie < numElems; ++ie) {
108       const G4Element* elem = (*elemTable)[ie]    108       const G4Element* elem = (*elemTable)[ie];
109       const G4int Z = std::min(maxZ, elem->Get    109       const G4int Z = std::min(maxZ, elem->GetZasInt());
110       if (data[Z] == nullptr) {                   110       if (data[Z] == nullptr) {
111         ReadData(Z);                              111         ReadData(Z);
112       }                                           112       }
113     }                                             113     }
114   }                                               114   }
115   if (isInitialised) {                            115   if (isInitialised) {
116     return;                                       116     return;
117   }                                               117   }
118   fParticleChange = GetParticleChangeForGamma(    118   fParticleChange = GetParticleChangeForGamma();
119   isInitialised = true;                           119   isInitialised = true;
120 }                                                 120 }
121                                                   121 
122 //....oooOO0OOooo........oooOO0OOooo........oo    122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
123                                                   123 
124 const G4String& G4LivermoreGammaConversionMode    124 const G4String& G4LivermoreGammaConversionModel::FindDirectoryPath()
125 {                                                 125 {
126   // no check in this method - environment var    126   // no check in this method - environment variable is check by utility
127   if (gDataDirectory.empty()) {                   127   if (gDataDirectory.empty()) {
128     auto param = G4EmParameters::Instance();      128     auto param = G4EmParameters::Instance();
129     std::ostringstream ost;                       129     std::ostringstream ost;
130     if (param->LivermoreDataDir() == "livermor    130     if (param->LivermoreDataDir() == "livermore") {
131       ost << param->GetDirLEDATA() << "/liverm    131       ost << param->GetDirLEDATA() << "/livermore/pair/";
132       useSpline = true;                           132       useSpline = true;
133     }                                             133     }
134     else {                                        134     else {
135       ost << param->GetDirLEDATA() << "/epics2    135       ost << param->GetDirLEDATA() << "/epics2017/pair/";
136     }                                             136     }
137     gDataDirectory = ost.str();                   137     gDataDirectory = ost.str();
138   }                                               138   }
139   return gDataDirectory;                          139   return gDataDirectory;
140 }                                                 140 }
141                                                   141 
142 //....oooOO0OOooo........oooOO0OOooo........oo    142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
143                                                   143 
144 void G4LivermoreGammaConversionModel::ReadData    144 void G4LivermoreGammaConversionModel::ReadData(const G4int Z)
145 {                                                 145 {
146   if (verboseLevel > 1) {                         146   if (verboseLevel > 1) {
147     G4cout << "Calling ReadData() of G4Livermo    147     G4cout << "Calling ReadData() of G4LivermoreGammaConversionModel" << G4endl;
148   }                                               148   }
149                                                   149 
150   if (data[Z] != nullptr) {                       150   if (data[Z] != nullptr) {
151     return;                                       151     return;
152   }                                               152   }
153                                                   153 
154   std::ostringstream ost;                         154   std::ostringstream ost;
155   ost << FindDirectoryPath() << "pp-cs-" << Z     155   ost << FindDirectoryPath() << "pp-cs-" << Z << ".dat";
156                                                   156 
157   data[Z] = new G4PhysicsFreeVector(useSpline)    157   data[Z] = new G4PhysicsFreeVector(useSpline);
158                                                   158 
159   std::ifstream fin(ost.str().c_str());           159   std::ifstream fin(ost.str().c_str());
160                                                   160 
161   if (!fin.is_open()) {                           161   if (!fin.is_open()) {
162     G4ExceptionDescription ed;                    162     G4ExceptionDescription ed;
163     ed << "G4LivermoreGammaConversionModel dat    163     ed << "G4LivermoreGammaConversionModel data file <" << ost.str().c_str() << "> is not opened!"
164        << G4endl;                                 164        << G4endl;
165     G4Exception("G4LivermoreGammaConversionMod    165     G4Exception("G4LivermoreGammaConversionModel::ReadData()", "em0003", FatalException, ed,
166                 "G4LEDATA version should be G4    166                 "G4LEDATA version should be G4EMLOW8.0 or later.");
167     return;                                       167     return;
168   }                                               168   }
169   else {                                          169   else {
170     if (verboseLevel > 1) {                       170     if (verboseLevel > 1) {
171       G4cout << "File " << ost.str() << " is o    171       G4cout << "File " << ost.str() << " is opened by G4LivermoreGammaConversionModel" << G4endl;
172     }                                             172     }
173                                                   173 
174     data[Z]->Retrieve(fin, true);                 174     data[Z]->Retrieve(fin, true);
175   }                                               175   }
176   // Activation of spline interpolation           176   // Activation of spline interpolation
177   if (useSpline) data[Z]->FillSecondDerivative    177   if (useSpline) data[Z]->FillSecondDerivatives();
178 }                                                 178 }
179                                                   179 
180 //....oooOO0OOooo........oooOO0OOooo........oo    180 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
181                                                   181 
182 G4double                                          182 G4double
183 G4LivermoreGammaConversionModel::ComputeCrossS    183 G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom(const G4ParticleDefinition* particle,
184                                                   184                                                             G4double GammaEnergy, G4double Z,
185                                                   185                                                             G4double, G4double, G4double)
186 {                                                 186 {
187   if (verboseLevel > 1) {                         187   if (verboseLevel > 1) {
188     G4cout << "G4LivermoreGammaConversionModel    188     G4cout << "G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom() Z= " << Z << G4endl;
189   }                                               189   }
190                                                   190 
191   if (GammaEnergy < lowEnergyLimit) {             191   if (GammaEnergy < lowEnergyLimit) {
192     return 0.0;                                   192     return 0.0;
193   }                                               193   }
194                                                   194 
195   G4double xs = 0.0;                              195   G4double xs = 0.0;
196                                                   196 
197   G4int intZ = std::max(1, std::min(G4lrint(Z)    197   G4int intZ = std::max(1, std::min(G4lrint(Z), maxZ));
198                                                   198 
199   G4PhysicsFreeVector* pv = data[intZ];           199   G4PhysicsFreeVector* pv = data[intZ];
200                                                   200 
201   // if element was not initialised               201   // if element was not initialised
202   // do initialisation safely for MT mode         202   // do initialisation safely for MT mode
203   if (pv == nullptr) {                            203   if (pv == nullptr) {
204     InitialiseForElement(particle, intZ);         204     InitialiseForElement(particle, intZ);
205     pv = data[intZ];                              205     pv = data[intZ];
206     if (pv == nullptr) {                          206     if (pv == nullptr) {
207       return xs;                                  207       return xs;
208     }                                             208     }
209   }                                               209   }
210   // x-section is taken from the table            210   // x-section is taken from the table
211   xs = pv->Value(GammaEnergy);                    211   xs = pv->Value(GammaEnergy);
212                                                   212 
213   if (verboseLevel > 0) {                         213   if (verboseLevel > 0) {
214     G4cout << "*** Gamma conversion xs for Z="    214     G4cout << "*** Gamma conversion xs for Z=" << Z << " at energy E(MeV)=" << GammaEnergy / MeV
215            << "  cs=" << xs / millibarn << " m    215            << "  cs=" << xs / millibarn << " mb" << G4endl;
216   }                                               216   }
217   return xs;                                      217   return xs;
218 }                                                 218 }
219                                                   219 
220 //....oooOO0OOooo........oooOO0OOooo........oo    220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
221                                                   221 
222 void G4LivermoreGammaConversionModel::Initiali    222 void G4LivermoreGammaConversionModel::InitialiseForElement(const G4ParticleDefinition*, G4int Z)
223 {                                                 223 {
224   G4AutoLock l(&LivermoreGammaConversionModelM    224   G4AutoLock l(&LivermoreGammaConversionModelMutex);
225   if (data[Z] == nullptr) {                       225   if (data[Z] == nullptr) {
226     ReadData(Z);                                  226     ReadData(Z);
227   }                                               227   }
228   l.unlock();                                     228   l.unlock();
229 }                                                 229 }
230                                                   230 
231 //....oooOO0OOooo........oooOO0OOooo........oo    231 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
232                                                   232