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: Sebastien Incerti 27 // 31 March 2012 28 // on base of G4LivermoreRayleighModel 29 // 30 31 #include "G4LivermoreRayleighModel.hh" 32 33 #include "G4AutoLock.hh" 34 #include "G4EmParameters.hh" 35 #include "G4RayleighAngularGenerator.hh" 36 #include "G4SystemOfUnits.hh" 37 38 //....oooOO0OOooo........oooOO0OOooo........oo 39 40 namespace 41 { 42 G4Mutex LivermoreRayleighModelMutex = G4MUTEX_ 43 } 44 45 G4PhysicsFreeVector* G4LivermoreRayleighModel: 46 G4String G4LivermoreRayleighModel::gDataDirect 47 48 //....oooOO0OOooo........oooOO0OOooo........oo 49 50 G4LivermoreRayleighModel::G4LivermoreRayleighM 51 { 52 fParticleChange = nullptr; 53 lowEnergyLimit = 10 * CLHEP::eV; 54 55 SetAngularDistribution(new G4RayleighAngular 56 57 verboseLevel = 0; 58 // Verbosity scale for debugging purposes: 59 // 0 = nothing 60 // 1 = calculation of cross sections, file o 61 // 2 = entering in methods 62 63 if (verboseLevel > 0) { 64 G4cout << "G4LivermoreRayleighModel is con 65 } 66 } 67 68 //....oooOO0OOooo........oooOO0OOooo........oo 69 70 G4LivermoreRayleighModel::~G4LivermoreRayleigh 71 { 72 if (IsMaster()) { 73 for (G4int i = 0; i <= maxZ; ++i) { 74 if (nullptr != dataCS[i]) { 75 delete dataCS[i]; 76 dataCS[i] = nullptr; 77 } 78 } 79 } 80 } 81 82 //....oooOO0OOooo........oooOO0OOooo........oo 83 84 void G4LivermoreRayleighModel::Initialise(cons 85 cons 86 { 87 if (verboseLevel > 1) { 88 G4cout << "Calling Initialise() of G4Liver 89 << "Energy range: " << LowEnergyLim 90 << " GeV" << G4endl; 91 } 92 93 if (IsMaster()) { 94 // Initialise element selector 95 InitialiseElementSelectors(particle, cuts) 96 97 // Access to elements 98 const G4ElementTable* elemTable = G4Elemen 99 std::size_t numElems = (*elemTable).size() 100 for (std::size_t ie = 0; ie < numElems; ++ 101 const G4Element* elem = (*elemTable)[ie] 102 const G4int Z = std::min(maxZ, elem->Get 103 if (dataCS[Z] == nullptr) { 104 ReadData(Z); 105 } 106 } 107 } 108 if (isInitialised) { 109 return; 110 } 111 fParticleChange = GetParticleChangeForGamma( 112 isInitialised = true; 113 } 114 115 //....oooOO0OOooo........oooOO0OOooo........oo 116 117 void G4LivermoreRayleighModel::InitialiseLocal 118 { 119 SetElementSelectors(masterModel->GetElementS 120 } 121 122 //....oooOO0OOooo........oooOO0OOooo........oo 123 124 const G4String& G4LivermoreRayleighModel::Find 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 } 133 else { 134 ost << param->GetDirLEDATA() << "/epics2 135 } 136 gDataDirectory = ost.str(); 137 } 138 return gDataDirectory; 139 } 140 141 //....oooOO0OOooo........oooOO0OOooo........oo 142 143 void G4LivermoreRayleighModel::ReadData(const 144 { 145 if (verboseLevel > 1) { 146 G4cout << "Calling ReadData() of G4Livermo 147 } 148 const G4int Z = std::min(ZZ, maxZ); 149 150 if (nullptr != dataCS[Z]) { 151 return; 152 } 153 154 dataCS[Z] = new G4PhysicsFreeVector(); 155 156 std::ostringstream ostCS; 157 ostCS << FindDirectoryPath() << "re-cs-" << 158 159 std::ifstream finCS(ostCS.str().c_str()); 160 161 if (!finCS.is_open()) { 162 G4ExceptionDescription ed; 163 ed << "G4LivermoreRayleighModel data file 164 << G4endl; 165 G4Exception("G4LivermoreRayleighModel::Rea 166 "G4LEDATA version should be G4 167 return; 168 } 169 else { 170 if (verboseLevel > 3) { 171 G4cout << "File " << ostCS.str() << " is 172 } 173 dataCS[Z]->Retrieve(finCS, true); 174 } 175 } 176 177 //....oooOO0OOooo........oooOO0OOooo........oo 178 179 G4double G4LivermoreRayleighModel::ComputeCros 180 181 182 { 183 if (verboseLevel > 1) { 184 G4cout << "G4LivermoreRayleighModel::Compu 185 } 186 187 if (GammaEnergy < lowEnergyLimit) { 188 return 0.0; 189 } 190 191 G4double xs = 0.0; 192 G4int intZ = G4lrint(Z); 193 if (intZ < 1 || intZ > maxZ) { 194 return xs; 195 } 196 197 G4PhysicsFreeVector* pv = dataCS[intZ]; 198 199 // if element was not initialised 200 // do initialisation safely for MT mode 201 if (nullptr == pv) { 202 InitialiseForElement(nullptr, intZ); 203 pv = dataCS[intZ]; 204 if (nullptr == pv) { 205 return xs; 206 } 207 } 208 209 auto n = G4int(pv->GetVectorLength() - 1); 210 G4double e = GammaEnergy / MeV; 211 if (e >= pv->Energy(n)) { 212 xs = (*pv)[n] / (e * e); 213 } 214 else if (e >= pv->Energy(0)) { 215 xs = pv->Value(e) / (e * e); 216 } 217 218 if (verboseLevel > 1) { 219 G4cout << "****** DEBUG: tcs value for Z=" 220 G4cout << " cs (Geant4 internal unit)=" < 221 G4cout << " -> first E*E*cs value in CS 222 G4cout << " -> last E*E*cs value in CS 223 G4cout << "******************************* 224 } 225 return xs; 226 } 227 228 //....oooOO0OOooo........oooOO0OOooo........oo 229 230 void G4LivermoreRayleighModel::SampleSecondari 231 232 233 234 { 235 if (verboseLevel > 1) { 236 G4cout << "Calling SampleSecondaries() of 237 } 238 G4double photonEnergy0 = aDynamicGamma->GetK 239 240 // Select randomly one element in the curren 241 const G4ParticleDefinition* particle = aDyna 242 const G4Element* elm = SelectRandomAtom(coup 243 G4int Z = elm->GetZasInt(); 244 245 // Sample the angle of the scattered photon 246 G4ThreeVector photonDirection = GetAngularDi 247 aDynamicGamma, photonEnergy0, Z, couple->G 248 fParticleChange->ProposeMomentumDirection(ph 249 } 250 251 //....oooOO0OOooo........oooOO0OOooo........oo 252 253 void G4LivermoreRayleighModel::InitialiseForEl 254 { 255 if (nullptr != dataCS[Z]) { 256 return; 257 } 258 G4AutoLock l(&LivermoreRayleighModelMutex); 259 if (nullptr == dataCS[Z]) { 260 ReadData(Z); 261 } 262 l.unlock(); 263 } 264 265 //....oooOO0OOooo........oooOO0OOooo........oo 266