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 // ------------------------------------------- 27 // ------------------------------------------------------------------- 28 // 28 // 29 // GEANT4 Class file 29 // GEANT4 Class file 30 // 30 // 31 // 31 // 32 // File name: G4EmSaturation 32 // File name: G4EmSaturation 33 // 33 // 34 // Author: Vladimir Ivanchenko 34 // Author: Vladimir Ivanchenko 35 // 35 // 36 // Creation date: 18.02.2008 36 // Creation date: 18.02.2008 37 // 37 // 38 // Modifications: 38 // Modifications: 39 // 39 // 40 // ------------------------------------------- 40 // ------------------------------------------------------------- 41 41 42 //....oooOO0OOooo........oooOO0OOooo........oo 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 43 //....oooOO0OOooo........oooOO0OOooo........oo 43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 44 44 45 #include "G4EmSaturation.hh" 45 #include "G4EmSaturation.hh" 46 #include "G4PhysicalConstants.hh" 46 #include "G4PhysicalConstants.hh" 47 #include "G4SystemOfUnits.hh" 47 #include "G4SystemOfUnits.hh" 48 #include "G4LossTableManager.hh" 48 #include "G4LossTableManager.hh" 49 #include "G4NistManager.hh" 49 #include "G4NistManager.hh" 50 #include "G4Material.hh" 50 #include "G4Material.hh" 51 #include "G4MaterialCutsCouple.hh" 51 #include "G4MaterialCutsCouple.hh" 52 #include "G4ParticleTable.hh" 52 #include "G4ParticleTable.hh" 53 53 54 //....oooOO0OOooo........oooOO0OOooo........oo 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 55 55 56 std::size_t G4EmSaturation::nMaterials = 0; << 56 G4int G4EmSaturation::nMaterials = 0; 57 std::vector<G4double> G4EmSaturation::massFact 57 std::vector<G4double> G4EmSaturation::massFactors; 58 std::vector<G4double> G4EmSaturation::effCharg 58 std::vector<G4double> G4EmSaturation::effCharges; 59 std::vector<G4double> G4EmSaturation::g4MatDat 59 std::vector<G4double> G4EmSaturation::g4MatData; 60 std::vector<G4String> G4EmSaturation::g4MatNam 60 std::vector<G4String> G4EmSaturation::g4MatNames; 61 61 62 G4EmSaturation::G4EmSaturation(G4int verb) 62 G4EmSaturation::G4EmSaturation(G4int verb) 63 { 63 { 64 verbose = verb; 64 verbose = verb; >> 65 65 nWarnings = nG4Birks = 0; 66 nWarnings = nG4Birks = 0; 66 67 67 electron = nullptr; 68 electron = nullptr; 68 proton = nullptr; 69 proton = nullptr; 69 nist = G4NistManager::Instance(); 70 nist = G4NistManager::Instance(); 70 InitialiseG4Saturation(); << 71 } 71 } 72 72 73 //....oooOO0OOooo........oooOO0OOooo........oo 73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 74 74 75 G4EmSaturation::~G4EmSaturation() = default; << 75 G4EmSaturation::~G4EmSaturation() >> 76 {} 76 77 77 //....oooOO0OOooo........oooOO0OOooo........oo 78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 78 79 79 G4double G4EmSaturation::VisibleEnergyDepositi 80 G4double G4EmSaturation::VisibleEnergyDeposition( 80 const G4 81 const G4ParticleDefinition* p, 81 const G4 82 const G4MaterialCutsCouple* couple, 82 G4double 83 G4double length, 83 G4double 84 G4double edep, 84 G4double 85 G4double niel) const 85 { 86 { 86 // no energy deposition 87 // no energy deposition 87 if(edep <= 0.0) { return 0.0; } 88 if(edep <= 0.0) { return 0.0; } 88 89 89 // zero step length may happens only if step 90 // zero step length may happens only if step limiter process 90 // is applied, in that case saturation shoul 91 // is applied, in that case saturation should not be applied 91 if(length <= 0.0) { return edep; } 92 if(length <= 0.0) { return edep; } 92 93 93 G4double evis = edep; 94 G4double evis = edep; 94 G4double bfactor = couple->GetMaterial()->Ge 95 G4double bfactor = couple->GetMaterial()->GetIonisation()->GetBirksConstant(); 95 96 96 if(bfactor > 0.0) { 97 if(bfactor > 0.0) { 97 98 98 // atomic relaxations for gamma incident 99 // atomic relaxations for gamma incident 99 if(22 == p->GetPDGEncoding()) { 100 if(22 == p->GetPDGEncoding()) { 100 //G4cout << "%% gamma edep= " << edep/ke << 101 //G4cout << "%% gamma edep= " << edep/keV << " keV " <<manager << G4endl; 101 evis /= (1.0 + bfactor*edep/ 102 evis /= (1.0 + bfactor*edep/ 102 G4LossTableManager::Instance()->GetRan 103 G4LossTableManager::Instance()->GetRange(electron,edep,couple)); 103 104 104 // energy loss 105 // energy loss 105 } else { 106 } else { 106 107 107 // protections 108 // protections 108 G4double nloss = std::max(niel, 0.0); 109 G4double nloss = std::max(niel, 0.0); 109 G4double eloss = edep - nloss; 110 G4double eloss = edep - nloss; 110 111 111 // neutrons and neutral hadrons 112 // neutrons and neutral hadrons 112 if(0.0 == p->GetPDGCharge() || eloss < 0 113 if(0.0 == p->GetPDGCharge() || eloss < 0.0) { 113 nloss = edep; 114 nloss = edep; 114 eloss = 0.0; 115 eloss = 0.0; 115 } else { 116 } else { 116 117 117 // continues energy loss 118 // continues energy loss 118 eloss /= (1.0 + bfactor*eloss/length); 119 eloss /= (1.0 + bfactor*eloss/length); 119 } 120 } 120 // non-ionizing energy loss 121 // non-ionizing energy loss 121 if(nloss > 0.0) { 122 if(nloss > 0.0) { 122 std::size_t idx = couple->GetMaterial( << 123 G4int idx = couple->GetMaterial()->GetIndex(); 123 G4double escaled = nloss*massFactors[i 124 G4double escaled = nloss*massFactors[idx]; 124 /* << 125 /* 125 G4cout << "%% p edep= " << nloss/keV < 126 G4cout << "%% p edep= " << nloss/keV << " keV Escaled= " 126 << escaled << " MeV in " << co 127 << escaled << " MeV in " << couple->GetMaterial()->GetName() 127 << " " << p->GetParticleName() << 128 << " " << p->GetParticleName() 128 << G4endl; << 129 << G4endl; 129 G4cout << proton->GetParticleName() << G4end << 130 */ 130 */ << 131 G4double range = G4LossTableManager::I 131 G4double range = G4LossTableManager::Instance() 132 ->GetRange(proton,escaled,couple)/ef 132 ->GetRange(proton,escaled,couple)/effCharges[idx]; 133 nloss /= (1.0 + bfactor*nloss/range); 133 nloss /= (1.0 + bfactor*nloss/range); 134 } 134 } 135 evis = eloss + nloss; 135 evis = eloss + nloss; 136 } 136 } 137 } 137 } 138 return evis; 138 return evis; 139 } 139 } 140 140 141 //....oooOO0OOooo........oooOO0OOooo........oo 141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 142 142 143 void G4EmSaturation::InitialiseG4Saturation() 143 void G4EmSaturation::InitialiseG4Saturation() 144 { 144 { 145 if(nMaterials == G4Material::GetNumberOfMate << 146 nMaterials = G4Material::GetNumberOfMaterial 145 nMaterials = G4Material::GetNumberOfMaterials(); 147 massFactors.resize(nMaterials, 1.0); 146 massFactors.resize(nMaterials, 1.0); 148 effCharges.resize(nMaterials, 1.0); 147 effCharges.resize(nMaterials, 1.0); 149 148 150 if(0 == nG4Birks) { InitialiseG4materials() 149 if(0 == nG4Birks) { InitialiseG4materials(); } 151 150 152 for(std::size_t i=0; i<nMaterials; ++i) { << 151 for(G4int i=0; i<nMaterials; ++i) { 153 InitialiseBirksCoefficient((*G4Material::G 152 InitialiseBirksCoefficient((*G4Material::GetMaterialTable())[i]); 154 } 153 } 155 if(verbose > 0) { DumpBirksCoefficients(); } 154 if(verbose > 0) { DumpBirksCoefficients(); } 156 } 155 } 157 156 158 //....oooOO0OOooo........oooOO0OOooo........oo 157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 159 158 160 G4double G4EmSaturation::FindG4BirksCoefficien 159 G4double G4EmSaturation::FindG4BirksCoefficient(const G4Material* mat) 161 { 160 { 162 if(0 == nG4Birks) { InitialiseG4materials() 161 if(0 == nG4Birks) { InitialiseG4materials(); } 163 162 164 G4String name = mat->GetName(); 163 G4String name = mat->GetName(); 165 // is this material in the vector? 164 // is this material in the vector? 166 165 167 for(G4int j=0; j<nG4Birks; ++j) { 166 for(G4int j=0; j<nG4Birks; ++j) { 168 if(name == g4MatNames[j]) { 167 if(name == g4MatNames[j]) { 169 if(verbose > 0) 168 if(verbose > 0) 170 G4cout << "### G4EmSaturation::FindG4B 169 G4cout << "### G4EmSaturation::FindG4BirksCoefficient for " 171 << name << " is " << g4MatData[ 170 << name << " is " << g4MatData[j]*MeV/mm << " mm/MeV " 172 << G4endl; 171 << G4endl; 173 return g4MatData[j]; 172 return g4MatData[j]; 174 } 173 } 175 } 174 } 176 return 0.0; 175 return 0.0; 177 } 176 } 178 177 179 //....oooOO0OOooo........oooOO0OOooo........oo 178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 180 179 181 void G4EmSaturation::InitialiseBirksCoefficien 180 void G4EmSaturation::InitialiseBirksCoefficient(const G4Material* mat) 182 { 181 { 183 // electron and proton should exist in any c 182 // electron and proton should exist in any case 184 if(nullptr == electron) { << 183 if(!electron) { 185 electron = G4ParticleTable::GetParticleTab 184 electron = G4ParticleTable::GetParticleTable()->FindParticle("e-"); 186 proton = G4ParticleTable::GetParticleTable 185 proton = G4ParticleTable::GetParticleTable()->FindParticle("proton"); 187 if(nullptr == electron) { << 186 if(!electron || !proton) { 188 G4Exception("G4EmSaturation::InitialiseB 187 G4Exception("G4EmSaturation::InitialiseBirksCoefficient", "em0001", 189 FatalException, "electron should exist") << 188 FatalException, "both electron and proton should exist"); 190 } 189 } 191 } 190 } 192 191 193 G4double curBirks = mat->GetIonisation()->Ge 192 G4double curBirks = mat->GetIonisation()->GetBirksConstant(); 194 193 195 G4String name = mat->GetName(); 194 G4String name = mat->GetName(); 196 195 197 // material has no Birks coeffitient defined 196 // material has no Birks coeffitient defined 198 // seach in the Geant4 list 197 // seach in the Geant4 list 199 if(curBirks == 0.0) { 198 if(curBirks == 0.0) { 200 for(G4int j=0; j<nG4Birks; ++j) { 199 for(G4int j=0; j<nG4Birks; ++j) { 201 if(name == g4MatNames[j]) { 200 if(name == g4MatNames[j]) { 202 mat->GetIonisation()->SetBirksConstant 201 mat->GetIonisation()->SetBirksConstant(g4MatData[j]); 203 curBirks = g4MatData[j]; 202 curBirks = g4MatData[j]; 204 break; 203 break; 205 } 204 } 206 } 205 } 207 } 206 } 208 207 209 if(curBirks == 0.0) { return; } 208 if(curBirks == 0.0) { return; } 210 209 211 // compute mean mass ratio 210 // compute mean mass ratio 212 G4double curRatio = 0.0; 211 G4double curRatio = 0.0; 213 G4double curChargeSq = 0.0; 212 G4double curChargeSq = 0.0; 214 G4double norm = 0.0; 213 G4double norm = 0.0; 215 const G4ElementVector* theElementVector = ma 214 const G4ElementVector* theElementVector = mat->GetElementVector(); 216 const G4double* theAtomNumDensityVector = ma 215 const G4double* theAtomNumDensityVector = mat->GetVecNbOfAtomsPerVolume(); 217 std::size_t nelm = mat->GetNumberOfElements( << 216 size_t nelm = mat->GetNumberOfElements(); 218 for (std::size_t i=0; i<nelm; ++i) { << 217 for (size_t i=0; i<nelm; ++i) { 219 const G4Element* elm = (*theElementVector) 218 const G4Element* elm = (*theElementVector)[i]; 220 G4int Z = elm->GetZasInt(); << 219 G4double Z = elm->GetZ(); 221 G4double w = theAtomNumDensityVector[i]; << 220 G4double w = Z*Z*theAtomNumDensityVector[i]; 222 curRatio += w/nist->GetAtomicMassAmu(Z); << 221 curRatio += w/nist->GetAtomicMassAmu(G4int(Z)); 223 curChargeSq += (Z*Z)*w; << 222 curChargeSq = Z*Z*w; 224 norm += w; 223 norm += w; 225 } 224 } 226 if ( norm > 0.0) { norm = 1.0/norm; } << 225 curRatio *= proton_mass_c2/norm; 227 curRatio *= (CLHEP::proton_mass_c2*norm); << 226 curChargeSq /= norm; 228 curChargeSq *= norm; << 229 227 230 // store results 228 // store results 231 std::size_t idx = mat->GetIndex(); << 229 G4int idx = mat->GetIndex(); 232 massFactors[idx] = curRatio; 230 massFactors[idx] = curRatio; 233 effCharges[idx] = curChargeSq; 231 effCharges[idx] = curChargeSq; 234 } 232 } 235 233 236 //....oooOO0OOooo........oooOO0OOooo........oo 234 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 237 235 238 void G4EmSaturation::DumpBirksCoefficients() 236 void G4EmSaturation::DumpBirksCoefficients() 239 { 237 { 240 G4cout << "### Birks coefficients used in ru 238 G4cout << "### Birks coefficients used in run time" << G4endl; 241 const G4MaterialTable* mtable = G4Material:: 239 const G4MaterialTable* mtable = G4Material::GetMaterialTable(); 242 for(std::size_t i=0; i<nMaterials; ++i) { << 240 for(G4int i=0; i<nMaterials; ++i) { 243 const G4Material* mat = (*mtable)[i]; 241 const G4Material* mat = (*mtable)[i]; 244 G4double br = mat->GetIonisation()->GetBir 242 G4double br = mat->GetIonisation()->GetBirksConstant(); 245 if(br > 0.0) { 243 if(br > 0.0) { 246 G4cout << " " << mat->GetName() << " 244 G4cout << " " << mat->GetName() << " " 247 << br*MeV/mm << " mm/MeV" << " " 245 << br*MeV/mm << " mm/MeV" << " " 248 << br*mat->GetDensity()*MeV*cm2/g 246 << br*mat->GetDensity()*MeV*cm2/g 249 << " g/cm^2/MeV massFactor= " << mass 247 << " g/cm^2/MeV massFactor= " << massFactors[i] 250 << " effCharge= " << effCharges[i] << G 248 << " effCharge= " << effCharges[i] << G4endl; 251 } 249 } 252 } 250 } 253 } 251 } 254 252 255 //....oooOO0OOooo........oooOO0OOooo........oo 253 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 256 254 257 void G4EmSaturation::DumpG4BirksCoefficients() 255 void G4EmSaturation::DumpG4BirksCoefficients() 258 { 256 { 259 if(nG4Birks > 0) { 257 if(nG4Birks > 0) { 260 G4cout << "### Birks coefficients for Gean 258 G4cout << "### Birks coefficients for Geant4 materials" << G4endl; 261 for(G4int i=0; i<nG4Birks; ++i) { 259 for(G4int i=0; i<nG4Birks; ++i) { 262 G4cout << " " << g4MatNames[i] << " 260 G4cout << " " << g4MatNames[i] << " " 263 << g4MatData[i]*MeV/mm << " mm/Me 261 << g4MatData[i]*MeV/mm << " mm/MeV" << G4endl; 264 } 262 } 265 } 263 } 266 } 264 } 267 265 268 //....oooOO0OOooo........oooOO0OOooo........oo 266 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 269 267 270 void G4EmSaturation::InitialiseG4materials() 268 void G4EmSaturation::InitialiseG4materials() 271 { 269 { 272 nG4Birks = 4; 270 nG4Birks = 4; 273 g4MatData.reserve(nG4Birks); 271 g4MatData.reserve(nG4Birks); 274 272 275 // M.Hirschberg et al., IEEE Trans. Nuc. Sci 273 // M.Hirschberg et al., IEEE Trans. Nuc. Sci. 39 (1992) 511 276 // SCSN-38 kB = 0.00842 g/cm^2/MeV; rho = 1. 274 // SCSN-38 kB = 0.00842 g/cm^2/MeV; rho = 1.06 g/cm^3 277 g4MatNames.push_back("G4_POLYSTYRENE"); 275 g4MatNames.push_back("G4_POLYSTYRENE"); 278 g4MatData.push_back(0.07943*mm/MeV); 276 g4MatData.push_back(0.07943*mm/MeV); 279 277 280 // C.Fabjan (private communication) 278 // C.Fabjan (private communication) 281 // kB = 0.006 g/cm^2/MeV; rho = 7.13 g/cm^3 279 // kB = 0.006 g/cm^2/MeV; rho = 7.13 g/cm^3 282 g4MatNames.push_back("G4_BGO"); 280 g4MatNames.push_back("G4_BGO"); 283 g4MatData.push_back(0.008415*mm/MeV); 281 g4MatData.push_back(0.008415*mm/MeV); 284 282 285 // A.Ribon analysis of publications 283 // A.Ribon analysis of publications 286 // Scallettar et al., Phys. Rev. A25 (1982) 284 // Scallettar et al., Phys. Rev. A25 (1982) 2419. 287 // NIM A 523 (2004) 275. 285 // NIM A 523 (2004) 275. 288 // kB = 0.022 g/cm^2/MeV; rho = 1.396 g/cm^3 286 // kB = 0.022 g/cm^2/MeV; rho = 1.396 g/cm^3; 289 // ATLAS Efield = 10 kV/cm provide the stron 287 // ATLAS Efield = 10 kV/cm provide the strongest effect 290 // kB = 0.1576*mm/MeV 288 // kB = 0.1576*mm/MeV 291 // A. Kiryunin and P.Strizenec "Geant4 hadro 289 // A. Kiryunin and P.Strizenec "Geant4 hadronic 292 // working group meeting " kB = 0.041/9.13 g 290 // working group meeting " kB = 0.041/9.13 g/cm^2/MeV 293 g4MatNames.push_back("G4_lAr"); 291 g4MatNames.push_back("G4_lAr"); 294 g4MatData.push_back(0.032*mm/MeV); 292 g4MatData.push_back(0.032*mm/MeV); 295 293 296 //G4_BARIUM_FLUORIDE 294 //G4_BARIUM_FLUORIDE 297 //G4_CESIUM_IODIDE 295 //G4_CESIUM_IODIDE 298 //G4_GEL_PHOTO_EMULSION 296 //G4_GEL_PHOTO_EMULSION 299 //G4_PHOTO_EMULSION 297 //G4_PHOTO_EMULSION 300 //G4_PLASTIC_SC_VINYLTOLUENE 298 //G4_PLASTIC_SC_VINYLTOLUENE 301 //G4_SODIUM_IODIDE 299 //G4_SODIUM_IODIDE 302 //G4_STILBENE 300 //G4_STILBENE 303 //G4_lAr 301 //G4_lAr 304 302 305 //G4_PbWO4 - CMS value 303 //G4_PbWO4 - CMS value 306 g4MatNames.push_back("G4_PbWO4"); 304 g4MatNames.push_back("G4_PbWO4"); 307 g4MatData.push_back(0.0333333*mm/MeV); 305 g4MatData.push_back(0.0333333*mm/MeV); 308 306 309 //G4_Lucite 307 //G4_Lucite 310 308 311 } 309 } 312 310 313 //....oooOO0OOooo........oooOO0OOooo........oo 311 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 314 312