Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // Author: Zhuxin Li@CENBG 27 // 11 March 2020 28 // on the base of G4LivermoreGammaConv 29 // derives from G4BetheHeitler5DModel 30 // ------------------------------------------- 31 32 #include "G4LivermoreGammaConversion5DModel.hh 33 34 #include "G4AutoLock.hh" 35 #include "G4Electron.hh" 36 #include "G4EmParameters.hh" 37 #include "G4Exp.hh" 38 #include "G4ParticleChangeForGamma.hh" 39 #include "G4PhysicalConstants.hh" 40 #include "G4PhysicsFreeVector.hh" 41 #include "G4SystemOfUnits.hh" 42 43 namespace 44 { 45 G4Mutex LivermoreGammaConversion5DModelMutex = 46 } 47 48 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oo 50 51 G4PhysicsFreeVector* G4LivermoreGammaConversio 52 G4String G4LivermoreGammaConversion5DModel::gD 53 54 G4LivermoreGammaConversion5DModel::G4Livermore 55 56 : G4BetheHeitler5DModel(p, nam) 57 { 58 fParticleChange = nullptr; 59 lowEnergyLimit = 2. * CLHEP::electron_mass_c 60 verboseLevel = 0; 61 // Verbosity scale for debugging purposes: 62 // 0 = nothing 63 // 1 = calculation of cross sections, file o 64 // 2 = entering in methods 65 if (verboseLevel > 0) { 66 G4cout << "G4LivermoreGammaConversion5DMod 67 } 68 } 69 70 //....oooOO0OOooo........oooOO0OOooo........oo 71 72 G4LivermoreGammaConversion5DModel::~G4Livermor 73 { 74 if (IsMaster()) { 75 for (G4int i = 0; i < maxZ; ++i) { 76 if (data[i]) { 77 delete data[i]; 78 data[i] = nullptr; 79 } 80 } 81 } 82 } 83 84 //....oooOO0OOooo........oooOO0OOooo........oo 85 86 void G4LivermoreGammaConversion5DModel::Initia 87 88 { 89 G4BetheHeitler5DModel::Initialise(particle, 90 91 if (verboseLevel > 1) { 92 G4cout << "Calling Initialise() of G4Liver 93 << "Energy range: " << LowEnergyLim 94 << " GeV isMater: " << IsMaster() < 95 } 96 97 if (IsMaster()) { 98 // Initialise element selector 99 InitialiseElementSelectors(particle, cuts) 100 101 // Access to elements 102 const G4ElementTable* elemTable = G4Elemen 103 std::size_t numElems = (*elemTable).size() 104 for (std::size_t ie = 0; ie < numElems; ++ 105 const G4Element* elem = (*elemTable)[ie] 106 const G4int Z = std::min(maxZ, elem->Get 107 if (data[Z] == nullptr) { 108 ReadData(Z); 109 } 110 } 111 } 112 113 if (isInitialised) { 114 return; 115 } 116 fParticleChange = GetParticleChangeForGamma( 117 isInitialised = true; 118 } 119 120 //....oooOO0OOooo........oooOO0OOooo........oo 121 122 const G4String& G4LivermoreGammaConversion5DMo 123 { 124 // no check in this method - environment var 125 if (gDataDirectory.empty()) { 126 auto param = G4EmParameters::Instance(); 127 std::ostringstream ost; 128 if (param->LivermoreDataDir() == "livermor 129 ost << param->GetDirLEDATA() << "/liverm 130 useSpline = true; 131 } 132 else { 133 ost << param->GetDirLEDATA() << "/epics2 134 } 135 gDataDirectory = ost.str(); 136 } 137 return gDataDirectory; 138 } 139 140 //....oooOO0OOooo........oooOO0OOooo........oo 141 142 void G4LivermoreGammaConversion5DModel::ReadDa 143 { 144 if (verboseLevel > 1) { 145 G4cout << "Calling ReadData() of G4Livermo 146 } 147 148 if (data[Z]) { 149 return; 150 } 151 152 std::ostringstream ost; 153 ost << FindDirectoryPath() << "pp-cs-" << Z 154 155 data[Z] = new G4PhysicsFreeVector(useSpline) 156 157 std::ifstream fin(ost.str().c_str()); 158 159 if (!fin.is_open()) { 160 G4ExceptionDescription ed; 161 ed << "G4LivermoreGammaConversion5DModel d 162 << G4endl; 163 G4Exception("G4LivermoreGammaConversion5DM 164 "G4LEDATA version should be G4 165 return; 166 } 167 else { 168 if (verboseLevel > 1) { 169 G4cout << "File " << ost.str() << " is o 170 } 171 data[Z]->Retrieve(fin, true); 172 } 173 // Activation of spline interpolation 174 if (useSpline) data[Z]->FillSecondDerivative 175 } 176 177 //....oooOO0OOooo........oooOO0OOooo........oo 178 179 G4double 180 G4LivermoreGammaConversion5DModel::ComputeCros 181 182 183 { 184 if (verboseLevel > 1) { 185 G4cout << "G4LivermoreGammaConversion5DMod 186 } 187 G4double xs = 0.0; 188 if (GammaEnergy < lowEnergyLimit) { 189 return xs; 190 } 191 192 G4int intZ = std::max(1, std::min(G4lrint(Z) 193 G4PhysicsFreeVector* pv = data[intZ]; 194 // if element was not initialised 195 // do initialisation safely for MT mode 196 if (!pv) { 197 InitialiseForElement(particle, intZ); 198 pv = data[intZ]; 199 if (!pv) { 200 return xs; 201 } 202 } 203 // x-section is taken from the table 204 xs = pv->Value(GammaEnergy); 205 if (verboseLevel > 0) { 206 G4cout << "*** Gamma conversion xs for Z=" 207 << " cs=" << xs / millibarn << " m 208 } 209 return xs; 210 } 211 212 //....oooOO0OOooo........oooOO0OOooo........oo 213 214 void G4LivermoreGammaConversion5DModel::Initia 215 { 216 G4AutoLock l(&LivermoreGammaConversion5DMode 217 if (!data[Z]) { 218 ReadData(Z); 219 } 220 l.unlock(); 221 } 222 223 //....oooOO0OOooo........oooOO0OOooo........oo 224