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 // 26 // 27 // Author: Luciano Pandola 27 // Author: Luciano Pandola 28 // 28 // 29 // History: 29 // History: 30 // -------- 30 // -------- 31 // 13 Jan 2010 L Pandola First implementa 31 // 13 Jan 2010 L Pandola First implementation (updated to Penelope08) 32 // 24 May 2011 L Pandola Renamed (make v2 32 // 24 May 2011 L Pandola Renamed (make v2008 as default Penelope) 33 // 18 Sep 2013 L Pandola Migration to MT 33 // 18 Sep 2013 L Pandola Migration to MT paradigm. Only master model deals with 34 // data and create 34 // data and creates shared tables 35 // 35 // 36 36 37 #include "G4PenelopeGammaConversionModel.hh" 37 #include "G4PenelopeGammaConversionModel.hh" 38 #include "G4PhysicalConstants.hh" 38 #include "G4PhysicalConstants.hh" 39 #include "G4SystemOfUnits.hh" 39 #include "G4SystemOfUnits.hh" 40 #include "G4ParticleDefinition.hh" 40 #include "G4ParticleDefinition.hh" 41 #include "G4MaterialCutsCouple.hh" 41 #include "G4MaterialCutsCouple.hh" 42 #include "G4ProductionCutsTable.hh" 42 #include "G4ProductionCutsTable.hh" 43 #include "G4DynamicParticle.hh" 43 #include "G4DynamicParticle.hh" 44 #include "G4Element.hh" 44 #include "G4Element.hh" 45 #include "G4Gamma.hh" 45 #include "G4Gamma.hh" 46 #include "G4Electron.hh" 46 #include "G4Electron.hh" 47 #include "G4Positron.hh" 47 #include "G4Positron.hh" 48 #include "G4PhysicsFreeVector.hh" 48 #include "G4PhysicsFreeVector.hh" 49 #include "G4MaterialCutsCouple.hh" 49 #include "G4MaterialCutsCouple.hh" 50 #include "G4AutoLock.hh" 50 #include "G4AutoLock.hh" 51 #include "G4Exp.hh" 51 #include "G4Exp.hh" 52 52 53 //....oooOO0OOooo........oooOO0OOooo........oo 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 54 const G4int G4PenelopeGammaConversionModel::fM << 55 G4PhysicsFreeVector* G4PenelopeGammaConversion << 56 G4double G4PenelopeGammaConversionModel::fAtom << 57 1.2281e+02,7.3167e+01,6.9 << 58 6.4696e+01,6.1228e+01,5.7 << 59 5.0787e+01,4.7851e+01,4.6 << 60 4.4503e+01,4.3815e+01,4.3 << 61 4.1586e+01,4.0953e+01,4.0 << 62 3.9756e+01,3.9144e+01,3.8 << 63 3.7174e+01,3.6663e+01,3.5 << 64 3.4688e+01,3.4197e+01,3.3 << 65 3.3068e+01,3.2740e+01,3.2 << 66 3.1884e+01,3.1622e+01,3.1 << 67 3.0950e+01,3.0758e+01,3.0 << 68 3.0097e+01,2.9832e+01,2.9 << 69 2.9247e+01,2.9085e+01,2.8 << 70 2.8580e+01,2.8442e+01,2.8 << 71 2.7973e+01,2.7819e+01,2.7 << 72 2.7285e+01,2.7093e+01,2.6 << 73 2.6516e+01,2.6304e+01,2.6 << 74 2.5730e+01,2.5577e+01,2.5 << 75 2.5100e+01,2.4941e+01,2.4 << 76 2.4506e+01,2.4391e+01,2.4 << 77 2.4039e+01,2.3922e+01,2.3 << 78 2.3621e+01,2.3523e+01,2.3 << 79 2.3238e+01,2.3139e+01,2.3 << 80 2.2833e+01,2.2694e+01,2.2 << 81 2.2446e+01,2.2358e+01,2.2 << 82 << 83 //....oooOO0OOooo........oooOO0OOooo........oo << 84 54 85 G4PenelopeGammaConversionModel::G4PenelopeGamm 55 G4PenelopeGammaConversionModel::G4PenelopeGammaConversionModel(const G4ParticleDefinition* part, 86 const G4String& nam) 56 const G4String& nam) 87 :G4VEmModel(nam),fParticleChange(nullptr),fP << 57 :G4VEmModel(nam),fParticleChange(0),fParticle(0), 88 fEffectiveCharge(nullptr),fMaterialInvScree << 58 logAtomicCrossSection(0), 89 fScreeningFunction(nullptr),fIsInitialised( << 59 fEffectiveCharge(0),fMaterialInvScreeningRadius(0), >> 60 fScreeningFunction(0),isInitialised(false),fLocalTable(false) >> 61 90 { 62 { 91 fIntrinsicLowEnergyLimit = 2.0*electron_mass 63 fIntrinsicLowEnergyLimit = 2.0*electron_mass_c2; 92 fIntrinsicHighEnergyLimit = 100.0*GeV; 64 fIntrinsicHighEnergyLimit = 100.0*GeV; 93 fSmallEnergy = 1.1*MeV; 65 fSmallEnergy = 1.1*MeV; 94 66 >> 67 InitializeScreeningRadii(); >> 68 95 if (part) 69 if (part) 96 SetParticle(part); 70 SetParticle(part); 97 71 98 // SetLowEnergyLimit(fIntrinsicLowEnergyLim 72 // SetLowEnergyLimit(fIntrinsicLowEnergyLimit); 99 SetHighEnergyLimit(fIntrinsicHighEnergyLimit 73 SetHighEnergyLimit(fIntrinsicHighEnergyLimit); 100 // 74 // 101 fVerboseLevel= 0; << 75 verboseLevel= 0; 102 // Verbosity scale: 76 // Verbosity scale: 103 // 0 = nothing 77 // 0 = nothing 104 // 1 = warning for energy non-conservation 78 // 1 = warning for energy non-conservation 105 // 2 = details of energy budget 79 // 2 = details of energy budget 106 // 3 = calculation of cross sections, file o 80 // 3 = calculation of cross sections, file openings, sampling of atoms 107 // 4 = entering in methods 81 // 4 = entering in methods 108 } 82 } 109 83 110 //....oooOO0OOooo........oooOO0OOooo........oo 84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 111 85 112 G4PenelopeGammaConversionModel::~G4PenelopeGam 86 G4PenelopeGammaConversionModel::~G4PenelopeGammaConversionModel() 113 { 87 { 114 //Delete shared tables, they exist only in t 88 //Delete shared tables, they exist only in the master model 115 if (IsMaster() || fLocalTable) 89 if (IsMaster() || fLocalTable) 116 { 90 { 117 for(G4int i=0; i<=fMaxZ; ++i) << 91 if (logAtomicCrossSection) 118 { 92 { 119 if(fLogAtomicCrossSection[i]) { << 93 for (auto& item : (*logAtomicCrossSection)) 120 delete fLogAtomicCrossSection[i]; << 94 if (item.second) delete item.second; 121 fLogAtomicCrossSection[i] = nullptr; << 95 delete logAtomicCrossSection; 122 } << 123 } 96 } 124 if (fEffectiveCharge) 97 if (fEffectiveCharge) 125 delete fEffectiveCharge; 98 delete fEffectiveCharge; 126 if (fMaterialInvScreeningRadius) 99 if (fMaterialInvScreeningRadius) 127 delete fMaterialInvScreeningRadius; 100 delete fMaterialInvScreeningRadius; 128 if (fScreeningFunction) 101 if (fScreeningFunction) 129 delete fScreeningFunction; 102 delete fScreeningFunction; 130 } 103 } 131 } 104 } 132 105 >> 106 133 //....oooOO0OOooo........oooOO0OOooo........oo 107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 134 108 135 void G4PenelopeGammaConversionModel::Initialis 109 void G4PenelopeGammaConversionModel::Initialise(const G4ParticleDefinition* part, 136 const G4DataVector&) 110 const G4DataVector&) 137 { 111 { 138 if (fVerboseLevel > 3) << 112 if (verboseLevel > 3) 139 G4cout << "Calling G4PenelopeGammaConvers 113 G4cout << "Calling G4PenelopeGammaConversionModel::Initialise()" << G4endl; 140 114 141 SetParticle(part); 115 SetParticle(part); 142 116 143 //Only the master model creates/fills/destro 117 //Only the master model creates/fills/destroys the tables 144 if (IsMaster() && part == fParticle) 118 if (IsMaster() && part == fParticle) 145 { 119 { >> 120 // logAtomicCrossSection is created only once, since it is never cleared >> 121 if (!logAtomicCrossSection) >> 122 logAtomicCrossSection = new std::map<G4int,G4PhysicsFreeVector*>; >> 123 146 //delete old material data... 124 //delete old material data... 147 if (fEffectiveCharge) 125 if (fEffectiveCharge) 148 { 126 { 149 delete fEffectiveCharge; 127 delete fEffectiveCharge; 150 fEffectiveCharge = nullptr; 128 fEffectiveCharge = nullptr; 151 } 129 } 152 if (fMaterialInvScreeningRadius) 130 if (fMaterialInvScreeningRadius) 153 { 131 { 154 delete fMaterialInvScreeningRadius; 132 delete fMaterialInvScreeningRadius; 155 fMaterialInvScreeningRadius = nullptr; 133 fMaterialInvScreeningRadius = nullptr; 156 } 134 } 157 if (fScreeningFunction) 135 if (fScreeningFunction) 158 { 136 { 159 delete fScreeningFunction; 137 delete fScreeningFunction; 160 fScreeningFunction = nullptr; 138 fScreeningFunction = nullptr; 161 } 139 } 162 //and create new ones 140 //and create new ones 163 fEffectiveCharge = new std::map<const G4 141 fEffectiveCharge = new std::map<const G4Material*,G4double>; 164 fMaterialInvScreeningRadius = new std::m 142 fMaterialInvScreeningRadius = new std::map<const G4Material*,G4double>; 165 fScreeningFunction = new std::map<const 143 fScreeningFunction = new std::map<const G4Material*,std::pair<G4double,G4double> >; 166 144 167 G4ProductionCutsTable* theCoupleTable = 145 G4ProductionCutsTable* theCoupleTable = 168 G4ProductionCutsTable::GetProductionCutsTabl 146 G4ProductionCutsTable::GetProductionCutsTable(); 169 147 170 for (G4int i=0;i<(G4int)theCoupleTable-> << 148 for (size_t i=0;i<theCoupleTable->GetTableSize();i++) 171 { 149 { 172 const G4Material* material = 150 const G4Material* material = 173 theCoupleTable->GetMaterialCutsCouple(i) 151 theCoupleTable->GetMaterialCutsCouple(i)->GetMaterial(); 174 const G4ElementVector* theElementVector = 152 const G4ElementVector* theElementVector = material->GetElementVector(); 175 153 176 for (std::size_t j=0;j<material->GetNumber << 154 for (size_t j=0;j<material->GetNumberOfElements();j++) 177 { 155 { 178 G4int iZ = theElementVector->at(j)->Ge 156 G4int iZ = theElementVector->at(j)->GetZasInt(); 179 //read data files only in the master 157 //read data files only in the master 180 if (iZ <= fMaxZ && !fLogAtomicCrossSe << 158 if (!logAtomicCrossSection->count(iZ)) 181 ReadDataFile(iZ); 159 ReadDataFile(iZ); 182 } 160 } 183 161 184 //check if material data are available 162 //check if material data are available 185 if (!fEffectiveCharge->count(material)) 163 if (!fEffectiveCharge->count(material)) 186 InitializeScreeningFunctions(material); 164 InitializeScreeningFunctions(material); 187 } 165 } 188 if (fVerboseLevel > 0) { << 166 >> 167 >> 168 if (verboseLevel > 0) { 189 G4cout << "Penelope Gamma Conversion model v 169 G4cout << "Penelope Gamma Conversion model v2008 is initialized " << G4endl 190 << "Energy range: " 170 << "Energy range: " 191 << LowEnergyLimit() / MeV << " MeV - 171 << LowEnergyLimit() / MeV << " MeV - " 192 << HighEnergyLimit() / GeV << " GeV" 172 << HighEnergyLimit() / GeV << " GeV" 193 << G4endl; 173 << G4endl; 194 } 174 } >> 175 195 } 176 } 196 if(fIsInitialised) return; << 177 >> 178 >> 179 if(isInitialised) return; 197 fParticleChange = GetParticleChangeForGamma( 180 fParticleChange = GetParticleChangeForGamma(); 198 fIsInitialised = true; << 181 isInitialised = true; 199 } 182 } 200 183 201 //....oooOO0OOooo........oooOO0OOooo........oo 184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 202 185 203 void G4PenelopeGammaConversionModel::Initialis 186 void G4PenelopeGammaConversionModel::InitialiseLocal(const G4ParticleDefinition* part, 204 G4VEmModel *masterModel) 187 G4VEmModel *masterModel) 205 { 188 { 206 if (fVerboseLevel > 3) << 189 if (verboseLevel > 3) 207 G4cout << "Calling G4PenelopeGammaConvers 190 G4cout << "Calling G4PenelopeGammaConversionModel::InitialiseLocal()" << G4endl; >> 191 208 // 192 // 209 //Check that particle matches: one might hav 193 //Check that particle matches: one might have multiple master models (e.g. 210 //for e+ and e-). 194 //for e+ and e-). 211 // 195 // 212 if (part == fParticle) 196 if (part == fParticle) 213 { 197 { 214 //Get the const table pointers from the 198 //Get the const table pointers from the master to the workers 215 const G4PenelopeGammaConversionModel* th 199 const G4PenelopeGammaConversionModel* theModel = 216 static_cast<G4PenelopeGammaConversionModel*> 200 static_cast<G4PenelopeGammaConversionModel*> (masterModel); 217 201 218 //Copy pointers to the data tables 202 //Copy pointers to the data tables 219 fEffectiveCharge = theModel->fEffectiveC 203 fEffectiveCharge = theModel->fEffectiveCharge; 220 fMaterialInvScreeningRadius = theModel-> 204 fMaterialInvScreeningRadius = theModel->fMaterialInvScreeningRadius; 221 fScreeningFunction = theModel->fScreenin << 205 fScreeningFunction = theModel->fScreeningFunction; 222 for(G4int i=0; i<=fMaxZ; ++i) << 206 logAtomicCrossSection = theModel->logAtomicCrossSection; 223 fLogAtomicCrossSection[i] = theModel->fLogAt << 224 207 225 //Same verbosity for all workers, as the 208 //Same verbosity for all workers, as the master 226 fVerboseLevel = theModel->fVerboseLevel; << 209 verboseLevel = theModel->verboseLevel; 227 } 210 } 228 211 229 return; 212 return; 230 } 213 } 231 214 232 //....oooOO0OOooo........oooOO0OOooo........oo 215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 233 namespace { G4Mutex PenelopeGammaConversionMo 216 namespace { G4Mutex PenelopeGammaConversionModelMutex = G4MUTEX_INITIALIZER; } 234 217 235 G4double G4PenelopeGammaConversionModel::Compu 218 G4double G4PenelopeGammaConversionModel::ComputeCrossSectionPerAtom( 236 const G4ParticleDefinition 219 const G4ParticleDefinition*, 237 G4double energy, 220 G4double energy, 238 G4double Z, G4double, 221 G4double Z, G4double, 239 G4double, G4double) 222 G4double, G4double) 240 { 223 { 241 // 224 // 242 // Penelope model v2008. 225 // Penelope model v2008. 243 // Cross section (including triplet producti 226 // Cross section (including triplet production) read from database and managed 244 // through the G4CrossSectionHandler utility 227 // through the G4CrossSectionHandler utility. Cross section data are from 245 // M.J. Berger and J.H. Hubbel (XCOM), Repor 228 // M.J. Berger and J.H. Hubbel (XCOM), Report NBSIR 887-3598 246 // 229 // 247 230 248 if (energy < fIntrinsicLowEnergyLimit) 231 if (energy < fIntrinsicLowEnergyLimit) 249 return 0; 232 return 0; 250 233 251 G4int iZ = G4int(Z); << 234 G4int iZ = (G4int) Z; 252 235 253 if (!fLogAtomicCrossSection[iZ]) << 236 //Either Initialize() was not called, or we are in a slave and InitializeLocal() was >> 237 //not invoked >> 238 if (!logAtomicCrossSection) >> 239 { >> 240 //create a **thread-local** version of the table. Used only for G4EmCalculator and >> 241 //Unit Tests >> 242 fLocalTable = true; >> 243 logAtomicCrossSection = new std::map<G4int,G4PhysicsFreeVector*>; >> 244 } >> 245 //now it should be ok >> 246 if (!logAtomicCrossSection->count(iZ)) 254 { 247 { 255 //If we are here, it means that Initial 248 //If we are here, it means that Initialize() was inkoved, but the MaterialTable was 256 //not filled up. This can happen in a U 249 //not filled up. This can happen in a UnitTest or via G4EmCalculator 257 if (fVerboseLevel > 0) << 250 if (verboseLevel > 0) 258 { 251 { 259 //Issue a G4Exception (warning) only in v 252 //Issue a G4Exception (warning) only in verbose mode 260 G4ExceptionDescription ed; 253 G4ExceptionDescription ed; 261 ed << "Unable to retrieve the cross secti 254 ed << "Unable to retrieve the cross section table for Z=" << iZ << G4endl; 262 ed << "This can happen only in Unit Tests 255 ed << "This can happen only in Unit Tests or via G4EmCalculator" << G4endl; 263 G4Exception("G4PenelopeGammaConversionMod 256 G4Exception("G4PenelopeGammaConversionModel::ComputeCrossSectionPerAtom()", 264 "em2018",JustWarning,ed); 257 "em2018",JustWarning,ed); 265 } 258 } 266 //protect file reading via autolock 259 //protect file reading via autolock 267 G4AutoLock lock(&PenelopeGammaConversio 260 G4AutoLock lock(&PenelopeGammaConversionModelMutex); 268 ReadDataFile(iZ); 261 ReadDataFile(iZ); 269 lock.unlock(); 262 lock.unlock(); 270 fLocalTable = true; << 271 } 263 } >> 264 272 G4double cs = 0; 265 G4double cs = 0; 273 G4double logene = G4Log(energy); 266 G4double logene = G4Log(energy); 274 G4PhysicsFreeVector* theVec = fLogAtomicCros << 267 >> 268 G4PhysicsFreeVector* theVec = logAtomicCrossSection->find(iZ)->second; >> 269 275 G4double logXS = theVec->Value(logene); 270 G4double logXS = theVec->Value(logene); 276 cs = G4Exp(logXS); 271 cs = G4Exp(logXS); 277 272 278 if (fVerboseLevel > 2) << 273 if (verboseLevel > 2) 279 G4cout << "Gamma conversion cross section 274 G4cout << "Gamma conversion cross section at " << energy/MeV << " MeV for Z=" << Z << 280 " = " << cs/barn << " barn" << G4endl; 275 " = " << cs/barn << " barn" << G4endl; 281 return cs; 276 return cs; 282 } 277 } 283 278 284 //....oooOO0OOooo........oooOO0OOooo........oo 279 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 285 280 286 void 281 void 287 G4PenelopeGammaConversionModel::SampleSecondar 282 G4PenelopeGammaConversionModel::SampleSecondaries(std::vector<G4DynamicParticle*>* fvect, 288 const G4MaterialCutsCouple* coup 283 const G4MaterialCutsCouple* couple, 289 const G4DynamicParticle* aDynami 284 const G4DynamicParticle* aDynamicGamma, 290 G4double, 285 G4double, 291 G4double) 286 G4double) 292 { 287 { 293 // 288 // 294 // Penelope model v2008. 289 // Penelope model v2008. 295 // Final state is sampled according to the B 290 // Final state is sampled according to the Bethe-Heitler model with Coulomb 296 // corrections, according to the semi-empiri 291 // corrections, according to the semi-empirical model of 297 // J. Baro' et al., Radiat. Phys. Chem. 44 292 // J. Baro' et al., Radiat. Phys. Chem. 44 (1994) 531. 298 // 293 // 299 // The model uses the high energy Coulomb co 294 // The model uses the high energy Coulomb correction from 300 // H. Davies et al., Phys. Rev. 93 (1954) 7 295 // H. Davies et al., Phys. Rev. 93 (1954) 788 301 // and atomic screening radii tabulated from 296 // and atomic screening radii tabulated from 302 // J.H. Hubbel et al., J. Phys. Chem. Ref. 297 // J.H. Hubbel et al., J. Phys. Chem. Ref. Data 9 (1980) 1023 303 // for Z= 1 to 92. 298 // for Z= 1 to 92. 304 // 299 // 305 if (fVerboseLevel > 3) << 300 if (verboseLevel > 3) 306 G4cout << "Calling SamplingSecondaries() o 301 G4cout << "Calling SamplingSecondaries() of G4PenelopeGammaConversionModel" << G4endl; 307 302 308 G4double photonEnergy = aDynamicGamma->GetKi 303 G4double photonEnergy = aDynamicGamma->GetKineticEnergy(); 309 304 310 // Always kill primary 305 // Always kill primary 311 fParticleChange->ProposeTrackStatus(fStopAnd 306 fParticleChange->ProposeTrackStatus(fStopAndKill); 312 fParticleChange->SetProposedKineticEnergy(0. 307 fParticleChange->SetProposedKineticEnergy(0.); 313 308 314 if (photonEnergy <= fIntrinsicLowEnergyLimit 309 if (photonEnergy <= fIntrinsicLowEnergyLimit) 315 { 310 { 316 fParticleChange->ProposeLocalEnergyDepos 311 fParticleChange->ProposeLocalEnergyDeposit(photonEnergy); 317 return ; 312 return ; 318 } 313 } 319 314 320 G4ParticleMomentum photonDirection = aDynami 315 G4ParticleMomentum photonDirection = aDynamicGamma->GetMomentumDirection(); 321 const G4Material* mat = couple->GetMaterial( 316 const G4Material* mat = couple->GetMaterial(); 322 317 323 //Either Initialize() was not called, or we 318 //Either Initialize() was not called, or we are in a slave and InitializeLocal() was 324 //not invoked 319 //not invoked 325 if (!fEffectiveCharge) 320 if (!fEffectiveCharge) 326 { 321 { 327 //create a **thread-local** version of t 322 //create a **thread-local** version of the table. Used only for G4EmCalculator and 328 //Unit Tests 323 //Unit Tests 329 fLocalTable = true; 324 fLocalTable = true; 330 fEffectiveCharge = new std::map<const G4 325 fEffectiveCharge = new std::map<const G4Material*,G4double>; 331 fMaterialInvScreeningRadius = new std::m 326 fMaterialInvScreeningRadius = new std::map<const G4Material*,G4double>; 332 fScreeningFunction = new std::map<const 327 fScreeningFunction = new std::map<const G4Material*,std::pair<G4double,G4double> >; 333 } 328 } 334 329 335 if (!fEffectiveCharge->count(mat)) 330 if (!fEffectiveCharge->count(mat)) 336 { 331 { 337 //If we are here, it means that Initiali 332 //If we are here, it means that Initialize() was inkoved, but the MaterialTable was 338 //not filled up. This can happen in a Un 333 //not filled up. This can happen in a UnitTest or via G4EmCalculator 339 if (fVerboseLevel > 0) << 334 if (verboseLevel > 0) 340 { 335 { 341 //Issue a G4Exception (warning) only in ve 336 //Issue a G4Exception (warning) only in verbose mode 342 G4ExceptionDescription ed; 337 G4ExceptionDescription ed; 343 ed << "Unable to allocate the EffectiveCha 338 ed << "Unable to allocate the EffectiveCharge data for " << 344 mat->GetName() << G4endl; 339 mat->GetName() << G4endl; 345 ed << "This can happen only in Unit Tests" 340 ed << "This can happen only in Unit Tests" << G4endl; 346 G4Exception("G4PenelopeGammaConversionMode 341 G4Exception("G4PenelopeGammaConversionModel::SampleSecondaries()", 347 "em2019",JustWarning,ed); 342 "em2019",JustWarning,ed); 348 } 343 } 349 //protect file reading via autolock 344 //protect file reading via autolock 350 G4AutoLock lock(&PenelopeGammaConversion 345 G4AutoLock lock(&PenelopeGammaConversionModelMutex); 351 InitializeScreeningFunctions(mat); 346 InitializeScreeningFunctions(mat); 352 lock.unlock(); 347 lock.unlock(); 353 } 348 } 354 349 355 // eps is the fraction of the photon energy 350 // eps is the fraction of the photon energy assigned to e- (including rest mass) 356 G4double eps = 0; 351 G4double eps = 0; 357 G4double eki = electron_mass_c2/photonEnergy 352 G4double eki = electron_mass_c2/photonEnergy; 358 353 359 //Do it fast for photon energy < 1.1 MeV (cl 354 //Do it fast for photon energy < 1.1 MeV (close to threshold) 360 if (photonEnergy < fSmallEnergy) 355 if (photonEnergy < fSmallEnergy) 361 eps = eki + (1.0-2.0*eki)*G4UniformRand(); 356 eps = eki + (1.0-2.0*eki)*G4UniformRand(); 362 else 357 else 363 { 358 { 364 //Complete calculation 359 //Complete calculation 365 G4double effC = fEffectiveCharge->find(m 360 G4double effC = fEffectiveCharge->find(mat)->second; 366 G4double alz = effC*fine_structure_const 361 G4double alz = effC*fine_structure_const; 367 G4double T = std::sqrt(2.0*eki); 362 G4double T = std::sqrt(2.0*eki); 368 G4double F00=(-1.774-1.210e1*alz+1.118e1 363 G4double F00=(-1.774-1.210e1*alz+1.118e1*alz*alz)*T 369 +(8.523+7.326e1*alz-4.441e1*alz*alz)* 364 +(8.523+7.326e1*alz-4.441e1*alz*alz)*T*T 370 -(1.352e1+1.211e2*alz-9.641e1*alz*alz 365 -(1.352e1+1.211e2*alz-9.641e1*alz*alz)*T*T*T 371 +(8.946+6.205e1*alz-6.341e1*alz*alz)*T*T*T*T 366 +(8.946+6.205e1*alz-6.341e1*alz*alz)*T*T*T*T; 372 367 373 G4double F0b = fScreeningFunction->find( 368 G4double F0b = fScreeningFunction->find(mat)->second.second; 374 G4double g0 = F0b + F00; 369 G4double g0 = F0b + F00; 375 G4double invRad = fMaterialInvScreeningR 370 G4double invRad = fMaterialInvScreeningRadius->find(mat)->second; 376 G4double bmin = 4.0*eki/invRad; 371 G4double bmin = 4.0*eki/invRad; 377 std::pair<G4double,G4double> scree = Ge 372 std::pair<G4double,G4double> scree = GetScreeningFunctions(bmin); 378 G4double g1 = scree.first; 373 G4double g1 = scree.first; 379 G4double g2 = scree.second; 374 G4double g2 = scree.second; 380 G4double g1min = g1+g0; 375 G4double g1min = g1+g0; 381 G4double g2min = g2+g0; 376 G4double g2min = g2+g0; 382 G4double xr = 0.5-eki; 377 G4double xr = 0.5-eki; 383 G4double a1 = 2.*g1min*xr*xr/3.; 378 G4double a1 = 2.*g1min*xr*xr/3.; 384 G4double p1 = a1/(a1+g2min); 379 G4double p1 = a1/(a1+g2min); 385 380 386 G4bool loopAgain = false; 381 G4bool loopAgain = false; 387 //Random sampling of eps 382 //Random sampling of eps 388 do{ 383 do{ 389 loopAgain = false; 384 loopAgain = false; 390 if (G4UniformRand() <= p1) 385 if (G4UniformRand() <= p1) 391 { 386 { 392 G4double ru2m1 = 2.0*G4UniformRand()-1. 387 G4double ru2m1 = 2.0*G4UniformRand()-1.0; 393 if (ru2m1 < 0) 388 if (ru2m1 < 0) 394 eps = 0.5-xr*std::pow(std::abs(ru2m1), 389 eps = 0.5-xr*std::pow(std::abs(ru2m1),1./3.); 395 else 390 else 396 eps = 0.5+xr*std::pow(ru2m1,1./3.); 391 eps = 0.5+xr*std::pow(ru2m1,1./3.); 397 G4double B = eki/(invRad*eps*(1.0-eps)); 392 G4double B = eki/(invRad*eps*(1.0-eps)); 398 scree = GetScreeningFunctions(B); 393 scree = GetScreeningFunctions(B); 399 g1 = scree.first; 394 g1 = scree.first; 400 g1 = std::max(g1+g0,0.); 395 g1 = std::max(g1+g0,0.); 401 if (G4UniformRand()*g1min > g1) 396 if (G4UniformRand()*g1min > g1) 402 loopAgain = true; 397 loopAgain = true; 403 } 398 } 404 else 399 else 405 { 400 { 406 eps = eki+2.0*xr*G4UniformRand(); 401 eps = eki+2.0*xr*G4UniformRand(); 407 G4double B = eki/(invRad*eps*(1.0-eps)); 402 G4double B = eki/(invRad*eps*(1.0-eps)); 408 scree = GetScreeningFunctions(B); 403 scree = GetScreeningFunctions(B); 409 g2 = scree.second; 404 g2 = scree.second; 410 g2 = std::max(g2+g0,0.); 405 g2 = std::max(g2+g0,0.); 411 if (G4UniformRand()*g2min > g2) 406 if (G4UniformRand()*g2min > g2) 412 loopAgain = true; 407 loopAgain = true; 413 } 408 } 414 }while(loopAgain); 409 }while(loopAgain); >> 410 415 } 411 } 416 if (fVerboseLevel > 4) << 412 if (verboseLevel > 4) 417 G4cout << "Sampled eps = " << eps << G4end 413 G4cout << "Sampled eps = " << eps << G4endl; 418 414 419 G4double electronTotEnergy = eps*photonEnerg 415 G4double electronTotEnergy = eps*photonEnergy; 420 G4double positronTotEnergy = (1.0-eps)*photo 416 G4double positronTotEnergy = (1.0-eps)*photonEnergy; 421 417 422 // Scattered electron (positron) angles. ( Z 418 // Scattered electron (positron) angles. ( Z - axis along the parent photon) 423 419 424 //electron kinematics 420 //electron kinematics 425 G4double electronKineEnergy = std::max(0.,el 421 G4double electronKineEnergy = std::max(0.,electronTotEnergy - electron_mass_c2) ; 426 G4double costheta_el = G4UniformRand()*2.0-1 422 G4double costheta_el = G4UniformRand()*2.0-1.0; 427 G4double kk = std::sqrt(electronKineEnergy*( 423 G4double kk = std::sqrt(electronKineEnergy*(electronKineEnergy+2.*electron_mass_c2)); 428 costheta_el = (costheta_el*electronTotEnergy 424 costheta_el = (costheta_el*electronTotEnergy+kk)/(electronTotEnergy+costheta_el*kk); 429 G4double phi_el = twopi * G4UniformRand() ; 425 G4double phi_el = twopi * G4UniformRand() ; 430 G4double dirX_el = std::sqrt(1.-costheta_el* 426 G4double dirX_el = std::sqrt(1.-costheta_el*costheta_el) * std::cos(phi_el); 431 G4double dirY_el = std::sqrt(1.-costheta_el* 427 G4double dirY_el = std::sqrt(1.-costheta_el*costheta_el) * std::sin(phi_el); 432 G4double dirZ_el = costheta_el; 428 G4double dirZ_el = costheta_el; 433 429 434 //positron kinematics 430 //positron kinematics 435 G4double positronKineEnergy = std::max(0.,po 431 G4double positronKineEnergy = std::max(0.,positronTotEnergy - electron_mass_c2) ; 436 G4double costheta_po = G4UniformRand()*2.0-1 432 G4double costheta_po = G4UniformRand()*2.0-1.0; 437 kk = std::sqrt(positronKineEnergy*(positronK 433 kk = std::sqrt(positronKineEnergy*(positronKineEnergy+2.*electron_mass_c2)); 438 costheta_po = (costheta_po*positronTotEnergy 434 costheta_po = (costheta_po*positronTotEnergy+kk)/(positronTotEnergy+costheta_po*kk); 439 G4double phi_po = twopi * G4UniformRand() ; 435 G4double phi_po = twopi * G4UniformRand() ; 440 G4double dirX_po = std::sqrt(1.-costheta_po* 436 G4double dirX_po = std::sqrt(1.-costheta_po*costheta_po) * std::cos(phi_po); 441 G4double dirY_po = std::sqrt(1.-costheta_po* 437 G4double dirY_po = std::sqrt(1.-costheta_po*costheta_po) * std::sin(phi_po); 442 G4double dirZ_po = costheta_po; 438 G4double dirZ_po = costheta_po; 443 439 444 // Kinematics of the created pair: 440 // Kinematics of the created pair: 445 // the electron and positron are assumed to 441 // the electron and positron are assumed to have a symetric angular 446 // distribution with respect to the Z axis a 442 // distribution with respect to the Z axis along the parent photon 447 G4double localEnergyDeposit = 0. ; 443 G4double localEnergyDeposit = 0. ; 448 444 449 if (electronKineEnergy > 0.0) 445 if (electronKineEnergy > 0.0) 450 { 446 { 451 G4ThreeVector electronDirection ( dirX_e 447 G4ThreeVector electronDirection ( dirX_el, dirY_el, dirZ_el); 452 electronDirection.rotateUz(photonDirecti 448 electronDirection.rotateUz(photonDirection); 453 G4DynamicParticle* electron = new G4Dyna 449 G4DynamicParticle* electron = new G4DynamicParticle (G4Electron::Electron(), 454 electronDirection, 450 electronDirection, 455 electronKineEnergy); 451 electronKineEnergy); 456 fvect->push_back(electron); 452 fvect->push_back(electron); 457 } 453 } 458 else 454 else 459 { 455 { 460 localEnergyDeposit += electronKineEnergy 456 localEnergyDeposit += electronKineEnergy; 461 electronKineEnergy = 0; 457 electronKineEnergy = 0; 462 } 458 } 463 459 464 //Generate the positron. Real particle in an 460 //Generate the positron. Real particle in any case, because it will annihilate. If below 465 //threshold, produce it at rest 461 //threshold, produce it at rest 466 if (positronKineEnergy < 0.0) 462 if (positronKineEnergy < 0.0) 467 { 463 { 468 localEnergyDeposit += positronKineEnergy 464 localEnergyDeposit += positronKineEnergy; 469 positronKineEnergy = 0; //produce it at 465 positronKineEnergy = 0; //produce it at rest 470 } 466 } 471 G4ThreeVector positronDirection(dirX_po,dirY 467 G4ThreeVector positronDirection(dirX_po,dirY_po,dirZ_po); 472 positronDirection.rotateUz(photonDirection); 468 positronDirection.rotateUz(photonDirection); 473 G4DynamicParticle* positron = new G4DynamicP 469 G4DynamicParticle* positron = new G4DynamicParticle(G4Positron::Positron(), 474 positronDirection, positronK 470 positronDirection, positronKineEnergy); 475 fvect->push_back(positron); 471 fvect->push_back(positron); 476 472 477 //Add rest of energy to the local energy dep 473 //Add rest of energy to the local energy deposit 478 fParticleChange->ProposeLocalEnergyDeposit(l 474 fParticleChange->ProposeLocalEnergyDeposit(localEnergyDeposit); 479 475 480 if (fVerboseLevel > 1) << 476 if (verboseLevel > 1) 481 { 477 { 482 G4cout << "----------------------------- 478 G4cout << "-----------------------------------------------------------" << G4endl; 483 G4cout << "Energy balance from G4Penelop 479 G4cout << "Energy balance from G4PenelopeGammaConversion" << G4endl; 484 G4cout << "Incoming photon energy: " << 480 G4cout << "Incoming photon energy: " << photonEnergy/keV << " keV" << G4endl; 485 G4cout << "----------------------------- 481 G4cout << "-----------------------------------------------------------" << G4endl; 486 if (electronKineEnergy) 482 if (electronKineEnergy) 487 G4cout << "Electron (explicitly produced) " 483 G4cout << "Electron (explicitly produced) " << electronKineEnergy/keV << " keV" 488 << G4endl; 484 << G4endl; 489 if (positronKineEnergy) 485 if (positronKineEnergy) 490 G4cout << "Positron (not at rest) " << posit 486 G4cout << "Positron (not at rest) " << positronKineEnergy/keV << " keV" << G4endl; 491 G4cout << "Rest masses of e+/- " << 2.0* 487 G4cout << "Rest masses of e+/- " << 2.0*electron_mass_c2/keV << " keV" << G4endl; 492 if (localEnergyDeposit) 488 if (localEnergyDeposit) 493 G4cout << "Local energy deposit " << localEn 489 G4cout << "Local energy deposit " << localEnergyDeposit/keV << " keV" << G4endl; 494 G4cout << "Total final state: " << (elec 490 G4cout << "Total final state: " << (electronKineEnergy+positronKineEnergy+ 495 localEnergyDeposit+2.0*electron_ma 491 localEnergyDeposit+2.0*electron_mass_c2)/keV << 496 " keV" << G4endl; 492 " keV" << G4endl; 497 G4cout << "----------------------------- 493 G4cout << "-----------------------------------------------------------" << G4endl; 498 } 494 } 499 if (fVerboseLevel > 0) << 495 if (verboseLevel > 0) 500 { 496 { 501 G4double energyDiff = std::fabs(electron 497 G4double energyDiff = std::fabs(electronKineEnergy+positronKineEnergy+ 502 localEnergyDeposit+2.0*electron_ 498 localEnergyDeposit+2.0*electron_mass_c2-photonEnergy); 503 if (energyDiff > 0.05*keV) 499 if (energyDiff > 0.05*keV) 504 G4cout << "Warning from G4PenelopeGammaConve 500 G4cout << "Warning from G4PenelopeGammaConversion: problem with energy conservation: " 505 << (electronKineEnergy+positronKineEn 501 << (electronKineEnergy+positronKineEnergy+ 506 localEnergyDeposit+2.0*electron_mass_c2 502 localEnergyDeposit+2.0*electron_mass_c2)/keV 507 << " keV (final) vs. " << photonEnerg 503 << " keV (final) vs. " << photonEnergy/keV << " keV (initial)" << G4endl; 508 } 504 } 509 } 505 } 510 506 511 //....oooOO0OOooo........oooOO0OOooo........oo 507 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 512 508 513 void G4PenelopeGammaConversionModel::ReadDataF 509 void G4PenelopeGammaConversionModel::ReadDataFile(const G4int Z) 514 { 510 { 515 if (!IsMaster()) 511 if (!IsMaster()) 516 //Should not be here! 512 //Should not be here! 517 G4Exception("G4PenelopeGammaConversionMode 513 G4Exception("G4PenelopeGammaConversionModel::ReadDataFile()", 518 "em0100",FatalException,"Worker thread in 514 "em0100",FatalException,"Worker thread in this method"); 519 515 520 if (fVerboseLevel > 2) << 516 if (verboseLevel > 2) 521 { 517 { 522 G4cout << "G4PenelopeGammaConversionMode 518 G4cout << "G4PenelopeGammaConversionModel::ReadDataFile()" << G4endl; 523 G4cout << "Going to read Gamma Conversio 519 G4cout << "Going to read Gamma Conversion data files for Z=" << Z << G4endl; 524 } 520 } 525 521 526 const char* path = G4FindDataDir("G4LEDATA << 522 char* path = std::getenv("G4LEDATA"); 527 if(!path) << 523 if (!path) 528 { 524 { 529 G4String excep = 525 G4String excep = 530 "G4PenelopeGammaConversionModel - G4LEDATA e 526 "G4PenelopeGammaConversionModel - G4LEDATA environment variable not set!"; 531 G4Exception("G4PenelopeGammaConversionMo 527 G4Exception("G4PenelopeGammaConversionModel::ReadDataFile()", 532 "em0006",FatalException,excep); 528 "em0006",FatalException,excep); 533 return; 529 return; 534 } 530 } 535 531 536 /* 532 /* 537 Read the cross section file 533 Read the cross section file 538 */ 534 */ 539 std::ostringstream ost; 535 std::ostringstream ost; 540 if (Z>9) 536 if (Z>9) 541 ost << path << "/penelope/pairproduction/p 537 ost << path << "/penelope/pairproduction/pdgpp" << Z << ".p08"; 542 else 538 else 543 ost << path << "/penelope/pairproduction/p 539 ost << path << "/penelope/pairproduction/pdgpp0" << Z << ".p08"; 544 std::ifstream file(ost.str().c_str()); 540 std::ifstream file(ost.str().c_str()); 545 if (!file.is_open()) 541 if (!file.is_open()) 546 { 542 { 547 G4String excep = "G4PenelopeGammaConvers 543 G4String excep = "G4PenelopeGammaConversionModel - data file " + 548 G4String(ost.str()) + " not found!"; 544 G4String(ost.str()) + " not found!"; 549 G4Exception("G4PenelopeGammaConversionMo 545 G4Exception("G4PenelopeGammaConversionModel::ReadDataFile()", 550 "em0003",FatalException,excep); 546 "em0003",FatalException,excep); 551 } 547 } 552 548 553 //I have to know in advance how many points 549 //I have to know in advance how many points are in the data list 554 //to initialize the G4PhysicsFreeVector() 550 //to initialize the G4PhysicsFreeVector() 555 std::size_t ndata=0; << 551 size_t ndata=0; 556 G4String line; 552 G4String line; 557 while( getline(file, line) ) 553 while( getline(file, line) ) 558 ndata++; 554 ndata++; 559 ndata -= 1; //remove one header line 555 ndata -= 1; //remove one header line >> 556 //G4cout << "Found: " << ndata << " lines" << G4endl; 560 557 561 file.clear(); 558 file.clear(); 562 file.close(); 559 file.close(); 563 file.open(ost.str().c_str()); 560 file.open(ost.str().c_str()); 564 G4int readZ =0; 561 G4int readZ =0; 565 file >> readZ; 562 file >> readZ; 566 563 567 if (fVerboseLevel > 3) << 564 if (verboseLevel > 3) 568 G4cout << "Element Z=" << Z << G4endl; 565 G4cout << "Element Z=" << Z << G4endl; 569 566 570 //check the right file is opened. 567 //check the right file is opened. 571 if (readZ != Z) 568 if (readZ != Z) 572 { 569 { 573 G4ExceptionDescription ed; 570 G4ExceptionDescription ed; 574 ed << "Corrupted data file for Z=" << Z 571 ed << "Corrupted data file for Z=" << Z << G4endl; 575 G4Exception("G4PenelopeGammaConversionMo 572 G4Exception("G4PenelopeGammaConversionModel::ReadDataFile()", 576 "em0005",FatalException,ed); 573 "em0005",FatalException,ed); 577 } 574 } 578 575 579 fLogAtomicCrossSection[Z] = new G4PhysicsFre << 576 G4PhysicsFreeVector* theVec = new G4PhysicsFreeVector(ndata); 580 G4double ene=0,xs=0; 577 G4double ene=0,xs=0; 581 for (std::size_t i=0;i<ndata;++i) << 578 for (size_t i=0;i<ndata;i++) 582 { 579 { 583 file >> ene >> xs; 580 file >> ene >> xs; 584 //dimensional quantities 581 //dimensional quantities 585 ene *= eV; 582 ene *= eV; 586 xs *= barn; 583 xs *= barn; 587 if (xs < 1e-40*cm2) //protection against 584 if (xs < 1e-40*cm2) //protection against log(0) 588 xs = 1e-40*cm2; 585 xs = 1e-40*cm2; 589 fLogAtomicCrossSection[Z]->PutValue(i,G4 << 586 theVec->PutValue(i,G4Log(ene),G4Log(xs)); 590 } 587 } 591 file.close(); 588 file.close(); 592 589 >> 590 if (!logAtomicCrossSection) >> 591 { >> 592 G4ExceptionDescription ed; >> 593 ed << "Problem with allocation of logAtomicCrossSection data table " << G4endl; >> 594 G4Exception("G4PenelopeGammaConversionModel::ReadDataFile()", >> 595 "em2020",FatalException,ed); >> 596 delete theVec; >> 597 return; >> 598 } >> 599 logAtomicCrossSection->insert(std::make_pair(Z,theVec)); >> 600 593 return; 601 return; >> 602 >> 603 } >> 604 >> 605 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 606 >> 607 void G4PenelopeGammaConversionModel::InitializeScreeningRadii() >> 608 { >> 609 G4double temp[99] = {1.2281e+02,7.3167e+01,6.9228e+01,6.7301e+01,6.4696e+01, >> 610 6.1228e+01,5.7524e+01,5.4033e+01,5.0787e+01,4.7851e+01,4.6373e+01, >> 611 4.5401e+01,4.4503e+01,4.3815e+01,4.3074e+01,4.2321e+01,4.1586e+01, >> 612 4.0953e+01,4.0524e+01,4.0256e+01,3.9756e+01,3.9144e+01,3.8462e+01, >> 613 3.7778e+01,3.7174e+01,3.6663e+01,3.5986e+01,3.5317e+01,3.4688e+01, >> 614 3.4197e+01,3.3786e+01,3.3422e+01,3.3068e+01,3.2740e+01,3.2438e+01, >> 615 3.2143e+01,3.1884e+01,3.1622e+01,3.1438e+01,3.1142e+01,3.0950e+01, >> 616 3.0758e+01,3.0561e+01,3.0285e+01,3.0097e+01,2.9832e+01,2.9581e+01, >> 617 2.9411e+01,2.9247e+01,2.9085e+01,2.8930e+01,2.8721e+01,2.8580e+01, >> 618 2.8442e+01,2.8312e+01,2.8139e+01,2.7973e+01,2.7819e+01,2.7675e+01, >> 619 2.7496e+01,2.7285e+01,2.7093e+01,2.6911e+01,2.6705e+01,2.6516e+01, >> 620 2.6304e+01,2.6108e+01,2.5929e+01,2.5730e+01,2.5577e+01,2.5403e+01, >> 621 2.5245e+01,2.5100e+01,2.4941e+01,2.4790e+01,2.4655e+01,2.4506e+01, >> 622 2.4391e+01,2.4262e+01,2.4145e+01,2.4039e+01,2.3922e+01,2.3813e+01, >> 623 2.3712e+01,2.3621e+01,2.3523e+01,2.3430e+01,2.3331e+01,2.3238e+01, >> 624 2.3139e+01,2.3048e+01,2.2967e+01,2.2833e+01,2.2694e+01,2.2624e+01, >> 625 2.2545e+01,2.2446e+01,2.2358e+01,2.2264e+01}; >> 626 >> 627 //copy temporary vector in class data member >> 628 for (G4int i=0;i<99;i++) >> 629 fAtomicScreeningRadius[i] = temp[i]; 594 } 630 } 595 631 596 //....oooOO0OOooo........oooOO0OOooo........oo 632 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 597 633 598 void G4PenelopeGammaConversionModel::Initializ 634 void G4PenelopeGammaConversionModel::InitializeScreeningFunctions(const G4Material* material) 599 { 635 { >> 636 /* >> 637 if (!IsMaster()) >> 638 //Should not be here! >> 639 G4Exception("G4PenelopeGammaConversionModel::InitializeScreeningFunctions()", >> 640 "em01001",FatalException,"Worker thread in this method"); >> 641 */ >> 642 600 // This is subroutine GPPa0 of Penelope 643 // This is subroutine GPPa0 of Penelope 601 // 644 // 602 // 1) calculate the effective Z for the purp 645 // 1) calculate the effective Z for the purpose 603 // 646 // 604 G4double zeff = 0; 647 G4double zeff = 0; 605 G4int intZ = 0; 648 G4int intZ = 0; 606 G4int nElements = (G4int)material->GetNumber << 649 G4int nElements = material->GetNumberOfElements(); 607 const G4ElementVector* elementVector = mater 650 const G4ElementVector* elementVector = material->GetElementVector(); 608 651 609 //avoid calculations if only one building el 652 //avoid calculations if only one building element! 610 if (nElements == 1) 653 if (nElements == 1) 611 { 654 { 612 zeff = (*elementVector)[0]->GetZ(); 655 zeff = (*elementVector)[0]->GetZ(); 613 intZ = (G4int) zeff; 656 intZ = (G4int) zeff; 614 } 657 } 615 else // many elements...let's do the calcula 658 else // many elements...let's do the calculation 616 { 659 { 617 const G4double* fractionVector = materia 660 const G4double* fractionVector = material->GetVecNbOfAtomsPerVolume(); 618 661 619 G4double atot = 0; 662 G4double atot = 0; 620 for (G4int i=0;i<nElements;i++) 663 for (G4int i=0;i<nElements;i++) 621 { 664 { 622 G4double Zelement = (*elementVector)[i]->G 665 G4double Zelement = (*elementVector)[i]->GetZ(); 623 G4double Aelement = (*elementVector)[i]->G 666 G4double Aelement = (*elementVector)[i]->GetAtomicMassAmu(); 624 atot += Aelement*fractionVector[i]; 667 atot += Aelement*fractionVector[i]; 625 zeff += Zelement*Aelement*fractionVector[i 668 zeff += Zelement*Aelement*fractionVector[i]; //average with the number of nuclei 626 } 669 } 627 atot /= material->GetTotNbOfAtomsPerVolu 670 atot /= material->GetTotNbOfAtomsPerVolume(); 628 zeff /= (material->GetTotNbOfAtomsPerVol 671 zeff /= (material->GetTotNbOfAtomsPerVolume()*atot); 629 672 630 intZ = (G4int) (zeff+0.25); 673 intZ = (G4int) (zeff+0.25); 631 if (intZ <= 0) 674 if (intZ <= 0) 632 intZ = 1; 675 intZ = 1; 633 if (intZ > fMaxZ) << 676 if (intZ > 99) 634 intZ = fMaxZ; << 677 intZ = 99; 635 } 678 } 636 679 637 if (fEffectiveCharge) 680 if (fEffectiveCharge) 638 fEffectiveCharge->insert(std::make_pair(ma 681 fEffectiveCharge->insert(std::make_pair(material,zeff)); 639 682 640 // 683 // 641 // 2) Calculate Coulomb Correction 684 // 2) Calculate Coulomb Correction 642 // 685 // 643 G4double alz = fine_structure_const*zeff; 686 G4double alz = fine_structure_const*zeff; 644 G4double alzSquared = alz*alz; 687 G4double alzSquared = alz*alz; 645 G4double fc = alzSquared*(0.202059-alzSquar 688 G4double fc = alzSquared*(0.202059-alzSquared* 646 (0.03693-alzSquared* 689 (0.03693-alzSquared* 647 (0.00835-alzSquared*(0.00201-alzSq 690 (0.00835-alzSquared*(0.00201-alzSquared* 648 (0.00049-alzSquared* 691 (0.00049-alzSquared* 649 (0.00012-alzSquared*0.00003))) 692 (0.00012-alzSquared*0.00003))))) 650 +1.0/(alzSquared+1.0)); 693 +1.0/(alzSquared+1.0)); 651 // 694 // 652 // 3) Screening functions and low-energy cor 695 // 3) Screening functions and low-energy corrections 653 // 696 // 654 G4double matRadius = 2.0/ fAtomicScreeningRa << 697 G4double matRadius = 2.0/ fAtomicScreeningRadius[intZ-1]; 655 if (fMaterialInvScreeningRadius) 698 if (fMaterialInvScreeningRadius) 656 fMaterialInvScreeningRadius->insert(std::m 699 fMaterialInvScreeningRadius->insert(std::make_pair(material,matRadius)); 657 700 658 std::pair<G4double,G4double> myPair(0,0); 701 std::pair<G4double,G4double> myPair(0,0); 659 G4double f0a = 4.0*G4Log(fAtomicScreeningRad << 702 G4double f0a = 4.0*G4Log(fAtomicScreeningRadius[intZ-1]); 660 G4double f0b = f0a - 4.0*fc; 703 G4double f0b = f0a - 4.0*fc; 661 myPair.first = f0a; 704 myPair.first = f0a; 662 myPair.second = f0b; 705 myPair.second = f0b; 663 706 664 if (fScreeningFunction) 707 if (fScreeningFunction) 665 fScreeningFunction->insert(std::make_pair( 708 fScreeningFunction->insert(std::make_pair(material,myPair)); 666 709 667 if (fVerboseLevel > 2) << 710 if (verboseLevel > 2) 668 { 711 { 669 G4cout << "Average Z for material " << m 712 G4cout << "Average Z for material " << material->GetName() << " = " << 670 zeff << G4endl; 713 zeff << G4endl; 671 G4cout << "Effective radius for material 714 G4cout << "Effective radius for material " << material->GetName() << " = " << 672 fAtomicScreeningRadius[intZ] << " m_e*c/hbar << 715 fAtomicScreeningRadius[intZ-1] << " m_e*c/hbar --> BCB = " << 673 matRadius << G4endl; 716 matRadius << G4endl; 674 G4cout << "Screening parameters F0 for m 717 G4cout << "Screening parameters F0 for material " << material->GetName() << " = " << 675 f0a << "," << f0b << G4endl; 718 f0a << "," << f0b << G4endl; 676 } 719 } 677 return; 720 return; 678 } 721 } 679 722 680 //....oooOO0OOooo........oooOO0OOooo........oo 723 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 681 724 682 std::pair<G4double,G4double> 725 std::pair<G4double,G4double> 683 G4PenelopeGammaConversionModel::GetScreeningFu 726 G4PenelopeGammaConversionModel::GetScreeningFunctions(G4double B) 684 { 727 { 685 // This is subroutine SCHIFF of Penelope 728 // This is subroutine SCHIFF of Penelope 686 // 729 // 687 // Screening Functions F1(B) and F2(B) in th 730 // Screening Functions F1(B) and F2(B) in the Bethe-Heitler differential cross 688 // section for pair production 731 // section for pair production 689 // 732 // 690 std::pair<G4double,G4double> result(0.,0.); 733 std::pair<G4double,G4double> result(0.,0.); 691 G4double BSquared = B*B; 734 G4double BSquared = B*B; 692 G4double f1 = 2.0-2.0*G4Log(1.0+BSquared); 735 G4double f1 = 2.0-2.0*G4Log(1.0+BSquared); 693 G4double f2 = f1 - 6.66666666e-1; // (-2/3) 736 G4double f2 = f1 - 6.66666666e-1; // (-2/3) 694 if (B < 1.0e-10) 737 if (B < 1.0e-10) 695 f1 = f1-twopi*B; 738 f1 = f1-twopi*B; 696 else 739 else 697 { 740 { 698 G4double a0 = 4.0*B*std::atan(1./B); 741 G4double a0 = 4.0*B*std::atan(1./B); 699 f1 = f1 - a0; 742 f1 = f1 - a0; 700 f2 += 2.0*BSquared*(4.0-a0-3.0*G4Log((1. 743 f2 += 2.0*BSquared*(4.0-a0-3.0*G4Log((1.0+BSquared)/BSquared)); 701 } 744 } 702 G4double g1 = 0.5*(3.0*f1-f2); 745 G4double g1 = 0.5*(3.0*f1-f2); 703 G4double g2 = 0.25*(3.0*f1+f2); 746 G4double g2 = 0.25*(3.0*f1+f2); 704 747 705 result.first = g1; 748 result.first = g1; 706 result.second = g2; 749 result.second = g2; 707 750 708 return result; 751 return result; 709 } 752 } 710 753 711 //....oooOO0OOooo........oooOO0OOooo........oo 754 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo... 712 755 713 void G4PenelopeGammaConversionModel::SetPartic 756 void G4PenelopeGammaConversionModel::SetParticle(const G4ParticleDefinition* p) 714 { 757 { 715 if(!fParticle) { 758 if(!fParticle) { 716 fParticle = p; 759 fParticle = p; 717 } 760 } 718 } 761 } 719 762