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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.1.3)


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