Geant4 Cross Reference |
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 char* path = std::getenv("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 >> 129 122 //....oooOO0OOooo........oooOO0OOooo........oo 130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 123 131 124 const G4String& G4LivermoreGammaConversionMode << 132 void G4LivermoreGammaConversionModel::ReadData(size_t Z, const char* path) 125 { 133 { 126 // no check in this method - environment var << 134 if (verboseLevel > 1) 127 if (gDataDirectory.empty()) { << 135 { 128 auto param = G4EmParameters::Instance(); << 136 G4cout << "Calling ReadData() of G4LivermoreGammaConversionModel" 129 std::ostringstream ost; << 137 << G4endl; 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 } 138 } 139 return gDataDirectory; << 140 } << 141 139 142 //....oooOO0OOooo........oooOO0OOooo........oo << 140 if(data[Z]!= nullptr) { return; } 143 141 144 void G4LivermoreGammaConversionModel::ReadData << 142 const char* datadir = path; 145 { << 146 if (verboseLevel > 1) { << 147 G4cout << "Calling ReadData() of G4Livermo << 148 } << 149 143 150 if (data[Z] != nullptr) { << 144 if(datadir == nullptr) 151 return; << 145 { >> 146 datadir = std::getenv("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 data[Z] = new G4PhysicsFreeVector(); 154 std::ostringstream ost; 156 std::ostringstream ost; 155 ost << FindDirectoryPath() << "pp-cs-" << Z << 157 if(G4EmParameters::Instance()->LivermoreDataDir() == "livermore"){ 156 << 158 ost << datadir << "/livermore/pair/pp-cs-" << Z <<".dat"; 157 data[Z] = new G4PhysicsFreeVector(useSpline) << 159 }else{ >> 160 ost << datadir << "/epics2017/pair/pp-cs-" << Z <<".dat"; >> 161 } 158 162 159 std::ifstream fin(ost.str().c_str()); 163 std::ifstream fin(ost.str().c_str()); 160 164 161 if (!fin.is_open()) { << 165 if( !fin.is_open()) >> 166 { 162 G4ExceptionDescription ed; 167 G4ExceptionDescription ed; 163 ed << "G4LivermoreGammaConversionModel dat << 168 ed << "G4LivermoreGammaConversionModel data file <" << ost.str().c_str() 164 << G4endl; << 169 << "> is not opened!" << G4endl; 165 G4Exception("G4LivermoreGammaConversionMod << 170 G4Exception("G4LivermoreGammaConversionModel::ReadData()", 166 "G4LEDATA version should be G4 << 171 "em0003",FatalException, >> 172 ed,"G4LEDATA version should be G4EMLOW6.27 or later."); 167 return; 173 return; 168 } 174 } 169 else { << 175 else 170 if (verboseLevel > 1) { << 176 { 171 G4cout << "File " << ost.str() << " is o << 177 172 } << 178 if(verboseLevel > 1) { G4cout << "File " << ost.str() >> 179 << " is opened by G4LivermoreGammaConversionModel" << G4endl;} 173 180 174 data[Z]->Retrieve(fin, true); 181 data[Z]->Retrieve(fin, true); 175 } 182 } 176 // Activation of spline interpolation << 177 if (useSpline) data[Z]->FillSecondDerivative << 178 } 183 } 179 184 180 //....oooOO0OOooo........oooOO0OOooo........oo 185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 181 186 182 G4double << 187 G4double G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom( 183 G4LivermoreGammaConversionModel::ComputeCrossS << 188 const G4ParticleDefinition* particle, 184 << 189 G4double GammaEnergy, G4double Z, G4double, G4double, G4double) 185 << 186 { 190 { 187 if (verboseLevel > 1) { << 191 if (verboseLevel > 1) 188 G4cout << "G4LivermoreGammaConversionModel << 192 { >> 193 G4cout << "G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom() Z= " >> 194 << Z << G4endl; 189 } 195 } 190 196 191 if (GammaEnergy < lowEnergyLimit) { << 197 if (GammaEnergy < lowEnergyLimit) { return 0.0; } 192 return 0.0; << 193 } << 194 198 195 G4double xs = 0.0; 199 G4double xs = 0.0; 196 200 197 G4int intZ = std::max(1, std::min(G4lrint(Z) 201 G4int intZ = std::max(1, std::min(G4lrint(Z), maxZ)); 198 202 199 G4PhysicsFreeVector* pv = data[intZ]; 203 G4PhysicsFreeVector* pv = data[intZ]; 200 204 201 // if element was not initialised 205 // if element was not initialised 202 // do initialisation safely for MT mode 206 // do initialisation safely for MT mode 203 if (pv == nullptr) { << 207 if(pv == nullptr) >> 208 { 204 InitialiseForElement(particle, intZ); 209 InitialiseForElement(particle, intZ); 205 pv = data[intZ]; 210 pv = data[intZ]; 206 if (pv == nullptr) { << 211 if(pv == nullptr) { return xs; } 207 return xs; << 208 } << 209 } 212 } 210 // x-section is taken from the table 213 // x-section is taken from the table 211 xs = pv->Value(GammaEnergy); 214 xs = pv->Value(GammaEnergy); 212 215 213 if (verboseLevel > 0) { << 216 if(verboseLevel > 0) 214 G4cout << "*** Gamma conversion xs for Z=" << 217 { 215 << " cs=" << xs / millibarn << " m << 218 G4cout << "*** Gamma conversion xs for Z=" << Z << " at energy E(MeV)=" 216 } << 219 << GammaEnergy/MeV << " cs=" << xs/millibarn << " mb" << G4endl; >> 220 } 217 return xs; 221 return xs; 218 } 222 } 219 223 220 //....oooOO0OOooo........oooOO0OOooo........oo 224 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 221 225 222 void G4LivermoreGammaConversionModel::Initiali << 226 void G4LivermoreGammaConversionModel::InitialiseForElement( >> 227 const G4ParticleDefinition*, >> 228 G4int Z) 223 { 229 { 224 G4AutoLock l(&LivermoreGammaConversionModelM 230 G4AutoLock l(&LivermoreGammaConversionModelMutex); 225 if (data[Z] == nullptr) { << 231 if(data[Z] == nullptr) { ReadData(Z); } 226 ReadData(Z); << 227 } << 228 l.unlock(); 232 l.unlock(); 229 } 233 } 230 234 231 //....oooOO0OOooo........oooOO0OOooo........oo 235 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 232 236