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: G4CrossSectionDataStore 32 // File name: G4CrossSectionDataStore 33 // 33 // 34 // Modifications: 34 // Modifications: 35 // 23.01.2009 V.Ivanchenko add destruction of 35 // 23.01.2009 V.Ivanchenko add destruction of data sets 36 // 29.04.2010 G.Folger modifictaions for i 36 // 29.04.2010 G.Folger modifictaions for integer A & Z 37 // 14.03.2011 V.Ivanchenko fixed DumpPhysicsTa 37 // 14.03.2011 V.Ivanchenko fixed DumpPhysicsTable 38 // 15.08.2011 G.Folger, V.Ivanchenko, T.Koi, D 38 // 15.08.2011 G.Folger, V.Ivanchenko, T.Koi, D.Wright redesign the class 39 // 07.03.2013 M.Maire cosmetic in DumpPhysicsT 39 // 07.03.2013 M.Maire cosmetic in DumpPhysicsTable 40 // 40 // 41 //....oooOO0OOooo........oooOO0OOooo........oo 41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 42 //....oooOO0OOooo........oooOO0OOooo........oo 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 43 43 44 #include "G4CrossSectionDataStore.hh" 44 #include "G4CrossSectionDataStore.hh" 45 #include "G4SystemOfUnits.hh" 45 #include "G4SystemOfUnits.hh" 46 #include "G4UnitsTable.hh" 46 #include "G4UnitsTable.hh" 47 #include "Randomize.hh" 47 #include "Randomize.hh" 48 #include "G4Nucleus.hh" 48 #include "G4Nucleus.hh" 49 49 50 #include "G4DynamicParticle.hh" 50 #include "G4DynamicParticle.hh" 51 #include "G4Isotope.hh" 51 #include "G4Isotope.hh" 52 #include "G4Element.hh" 52 #include "G4Element.hh" 53 #include "G4Material.hh" 53 #include "G4Material.hh" 54 #include "G4MaterialTable.hh" 54 #include "G4MaterialTable.hh" 55 #include "G4NistManager.hh" 55 #include "G4NistManager.hh" 56 #include "G4HadronicParameters.hh" << 57 #include <algorithm> 56 #include <algorithm> 58 #include <typeinfo> 57 #include <typeinfo> 59 58 60 //....oooOO0OOooo........oooOO0OOooo........oo 59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 61 60 62 G4CrossSectionDataStore::G4CrossSectionDataSto 61 G4CrossSectionDataStore::G4CrossSectionDataStore() 63 : nist(G4NistManager::Instance()) 62 : nist(G4NistManager::Instance()) 64 {} 63 {} 65 64 66 //....oooOO0OOooo........oooOO0OOooo........oo 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 67 66 68 G4double 67 G4double 69 G4CrossSectionDataStore::ComputeCrossSection(c 68 G4CrossSectionDataStore::ComputeCrossSection(const G4DynamicParticle* dp, 70 const G4Material* mat) 69 const G4Material* mat) 71 { 70 { 72 currentMaterial = mat; 71 currentMaterial = mat; 73 matParticle = dp->GetDefinition(); 72 matParticle = dp->GetDefinition(); 74 matKinEnergy = dp->GetKineticEnergy(); 73 matKinEnergy = dp->GetKineticEnergy(); 75 matCrossSection = 0.0; 74 matCrossSection = 0.0; 76 75 77 std::size_t nElements = mat->GetNumberOfElem 76 std::size_t nElements = mat->GetNumberOfElements(); 78 const G4double* nAtomsPerVolume = mat->GetVe 77 const G4double* nAtomsPerVolume = mat->GetVecNbOfAtomsPerVolume(); 79 78 80 if(xsecelm.size() < nElements) { xsecelm.res 79 if(xsecelm.size() < nElements) { xsecelm.resize(nElements); } 81 80 82 for(G4int i=0; i<(G4int)nElements; ++i) { 81 for(G4int i=0; i<(G4int)nElements; ++i) { 83 G4double xs = 82 G4double xs = 84 nAtomsPerVolume[i]*GetCrossSection(dp, m 83 nAtomsPerVolume[i]*GetCrossSection(dp, mat->GetElement(i), mat); 85 matCrossSection += std::max(xs, 0.0); 84 matCrossSection += std::max(xs, 0.0); 86 xsecelm[i] = matCrossSection; 85 xsecelm[i] = matCrossSection; 87 } 86 } 88 return matCrossSection; 87 return matCrossSection; 89 } 88 } 90 89 91 //....oooOO0OOooo........oooOO0OOooo........oo 90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 92 91 93 G4double G4CrossSectionDataStore::GetCrossSect 92 G4double G4CrossSectionDataStore::GetCrossSection(const G4DynamicParticle* dp, 94 93 const G4Element* elm, 95 94 const G4Material* mat) 96 { 95 { 97 // first check the most last cross section 96 // first check the most last cross section 98 G4int i = nDataSetList-1; 97 G4int i = nDataSetList-1; 99 G4int Z = elm->GetZasInt(); 98 G4int Z = elm->GetZasInt(); 100 99 101 if(elm->GetNaturalAbundanceFlag() && 100 if(elm->GetNaturalAbundanceFlag() && 102 dataSetList[i]->IsElementApplicable(dp, Z 101 dataSetList[i]->IsElementApplicable(dp, Z, mat)) 103 { 102 { 104 // element wise cross section 103 // element wise cross section 105 return dataSetList[i]->GetElementCrossSect 104 return dataSetList[i]->GetElementCrossSection(dp, Z, mat); 106 } 105 } 107 106 108 // isotope wise cross section 107 // isotope wise cross section 109 G4int nIso = (G4int)elm->GetNumberOfIsotopes 108 G4int nIso = (G4int)elm->GetNumberOfIsotopes(); 110 109 111 // user-defined isotope abundances 110 // user-defined isotope abundances 112 const G4double* abundVector = elm->GetRelati 111 const G4double* abundVector = elm->GetRelativeAbundanceVector(); 113 112 114 G4double sigma = 0.0; 113 G4double sigma = 0.0; 115 114 116 // isotope and element wise cross sections 115 // isotope and element wise cross sections 117 for(G4int j = 0; j < nIso; ++j) 116 for(G4int j = 0; j < nIso; ++j) 118 { 117 { 119 const G4Isotope* iso = elm->GetIsotope(j); 118 const G4Isotope* iso = elm->GetIsotope(j); 120 sigma += abundVector[j] * 119 sigma += abundVector[j] * 121 GetIsoCrossSection(dp, Z, iso->GetN(), i 120 GetIsoCrossSection(dp, Z, iso->GetN(), iso, elm, mat, i); 122 } 121 } 123 return sigma; 122 return sigma; 124 } 123 } 125 124 126 //....oooOO0OOooo........oooOO0OOooo........oo 125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 127 126 128 G4double 127 G4double 129 G4CrossSectionDataStore::GetIsoCrossSection(co 128 G4CrossSectionDataStore::GetIsoCrossSection(const G4DynamicParticle* dp, 130 G4int Z, G4int A, 129 G4int Z, G4int A, 131 const G4Isotope* iso, 130 const G4Isotope* iso, 132 const G4Element* elm, 131 const G4Element* elm, 133 const G4Material* mat, 132 const G4Material* mat, 134 G4int idx) 133 G4int idx) 135 { 134 { 136 // this methods is called after the check th 135 // this methods is called after the check that dataSetList[idx] 137 // depend on isotopes, so first isotopes are 136 // depend on isotopes, so first isotopes are checked 138 if(dataSetList[idx]->IsIsoApplicable(dp, Z, 137 if(dataSetList[idx]->IsIsoApplicable(dp, Z, A, elm, mat) ) { 139 return dataSetList[idx]->GetIsoCrossSectio 138 return dataSetList[idx]->GetIsoCrossSection(dp, Z, A, iso, elm, mat); 140 } 139 } 141 140 142 // no isotope wise cross section - check oth 141 // no isotope wise cross section - check other datasets 143 for (G4int j = nDataSetList-1; j >= 0; --j) 142 for (G4int j = nDataSetList-1; j >= 0; --j) { 144 if(dataSetList[j]->IsElementApplicable(dp, 143 if(dataSetList[j]->IsElementApplicable(dp, Z, mat)) { 145 return dataSetList[j]->GetElementCrossSe 144 return dataSetList[j]->GetElementCrossSection(dp, Z, mat); 146 } else if (dataSetList[j]->IsIsoApplicable 145 } else if (dataSetList[j]->IsIsoApplicable(dp, Z, A, elm, mat)) { 147 return dataSetList[j]->GetIsoCrossSectio 146 return dataSetList[j]->GetIsoCrossSection(dp, Z, A, iso, elm, mat); 148 } 147 } 149 } 148 } 150 G4ExceptionDescription ed; 149 G4ExceptionDescription ed; 151 ed << "No isotope cross section found for " 150 ed << "No isotope cross section found for " 152 << dp->GetDefinition()->GetParticleName() 151 << dp->GetDefinition()->GetParticleName() 153 << " off target Element " << elm->GetName 152 << " off target Element " << elm->GetName() 154 << " Z= " << Z << " A= " << A; 153 << " Z= " << Z << " A= " << A; 155 if(nullptr != mat) ed << " from " << mat->Ge 154 if(nullptr != mat) ed << " from " << mat->GetName(); 156 ed << " E(MeV)=" << dp->GetKineticEnergy()/M 155 ed << " E(MeV)=" << dp->GetKineticEnergy()/MeV << G4endl; 157 G4Exception("G4CrossSectionDataStore::GetIso 156 G4Exception("G4CrossSectionDataStore::GetIsoCrossSection", "had001", 158 FatalException, ed); 157 FatalException, ed); 159 return 0.0; 158 return 0.0; 160 } 159 } 161 160 162 //....oooOO0OOooo........oooOO0OOooo........oo 161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 163 162 164 G4double 163 G4double 165 G4CrossSectionDataStore::GetCrossSection(const 164 G4CrossSectionDataStore::GetCrossSection(const G4DynamicParticle* dp, 166 G4int 165 G4int Z, G4int A, 167 const G4Isotope* iso, 166 const G4Isotope* iso, 168 const 167 const G4Element* elm, 169 const G4Material* mat) 168 const G4Material* mat) 170 { 169 { 171 for (G4int i = nDataSetList-1; i >= 0; --i) 170 for (G4int i = nDataSetList-1; i >= 0; --i) { 172 if (dataSetList[i]->IsIsoApplicable(dp, Z, 171 if (dataSetList[i]->IsIsoApplicable(dp, Z, A, elm, mat) ) { 173 return dataSetList[i]->GetIsoCrossSectio 172 return dataSetList[i]->GetIsoCrossSection(dp, Z, A, iso, elm, mat); 174 } else if(dataSetList[i]->IsElementApplica 173 } else if(dataSetList[i]->IsElementApplicable(dp, Z, mat)) { 175 return dataSetList[i]->GetElementCrossSe 174 return dataSetList[i]->GetElementCrossSection(dp, Z, mat); 176 } 175 } 177 } 176 } 178 G4ExceptionDescription ed; 177 G4ExceptionDescription ed; 179 ed << "No isotope cross section found for " 178 ed << "No isotope cross section found for " 180 << dp->GetDefinition()->GetParticleName() 179 << dp->GetDefinition()->GetParticleName() 181 << " off target Element " << elm->GetName 180 << " off target Element " << elm->GetName() 182 << " Z= " << Z << " A= " << A; 181 << " Z= " << Z << " A= " << A; 183 if(nullptr != mat) ed << " from " << mat->Ge 182 if(nullptr != mat) ed << " from " << mat->GetName(); 184 ed << " E(MeV)=" << dp->GetKineticEnergy()/M 183 ed << " E(MeV)=" << dp->GetKineticEnergy()/MeV << G4endl; 185 G4Exception("G4CrossSectionDataStore::GetCro 184 G4Exception("G4CrossSectionDataStore::GetCrossSection", "had001", 186 FatalException, ed); 185 FatalException, ed); 187 return 0.0; 186 return 0.0; 188 } 187 } 189 188 190 //....oooOO0OOooo........oooOO0OOooo........oo 189 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 191 190 192 const G4Element* 191 const G4Element* 193 G4CrossSectionDataStore::SampleZandA(const G4D 192 G4CrossSectionDataStore::SampleZandA(const G4DynamicParticle* dp, 194 const G4M 193 const G4Material* mat, 195 G4Nucleus& target) 194 G4Nucleus& target) 196 { 195 { 197 if(nullptr != forcedElement) { return forced 196 if(nullptr != forcedElement) { return forcedElement; } 198 std::size_t nElements = mat->GetNumberOfElem 197 std::size_t nElements = mat->GetNumberOfElements(); 199 const G4Element* anElement = mat->GetElement 198 const G4Element* anElement = mat->GetElement(0); 200 199 201 // select element from a compound 200 // select element from a compound 202 if(1 < nElements) { 201 if(1 < nElements) { 203 G4double cross = matCrossSection*G4Uniform 202 G4double cross = matCrossSection*G4UniformRand(); 204 for(G4int i=0; i<(G4int)nElements; ++i) { 203 for(G4int i=0; i<(G4int)nElements; ++i) { 205 if(cross <= xsecelm[i]) { 204 if(cross <= xsecelm[i]) { 206 anElement = mat->GetElement(i); 205 anElement = mat->GetElement(i); 207 break; 206 break; 208 } 207 } 209 } 208 } 210 } 209 } 211 210 212 G4int Z = anElement->GetZasInt(); 211 G4int Z = anElement->GetZasInt(); 213 const G4Isotope* iso = nullptr; 212 const G4Isotope* iso = nullptr; 214 213 215 G4int i = nDataSetList-1; 214 G4int i = nDataSetList-1; 216 if (dataSetList[i]->IsElementApplicable(dp, 215 if (dataSetList[i]->IsElementApplicable(dp, Z, mat)) { 217 216 218 //---------------------------------------- 217 //---------------------------------------------------------------- 219 // element-wise cross section 218 // element-wise cross section 220 // isotope cross section is not computed 219 // isotope cross section is not computed 221 //---------------------------------------- 220 //---------------------------------------------------------------- 222 std::size_t nIso = anElement->GetNumberOfI 221 std::size_t nIso = anElement->GetNumberOfIsotopes(); 223 iso = anElement->GetIsotope(0); 222 iso = anElement->GetIsotope(0); 224 223 225 // more than 1 isotope 224 // more than 1 isotope 226 if(1 < nIso) { 225 if(1 < nIso) { 227 iso = dataSetList[i]->SelectIsotope(anEl 226 iso = dataSetList[i]->SelectIsotope(anElement, 228 dp-> 227 dp->GetKineticEnergy(), 229 dp->GetLogKineticEnergy()); 228 dp->GetLogKineticEnergy()); 230 } 229 } 231 } else { 230 } else { 232 231 233 //---------------------------------------- 232 //---------------------------------------------------------------- 234 // isotope-wise cross section 233 // isotope-wise cross section 235 // isotope cross section is computed 234 // isotope cross section is computed 236 //---------------------------------------- 235 //---------------------------------------------------------------- 237 std::size_t nIso = anElement->GetNumberOfI 236 std::size_t nIso = anElement->GetNumberOfIsotopes(); 238 iso = anElement->GetIsotope(0); 237 iso = anElement->GetIsotope(0); 239 238 240 // more than 1 isotope 239 // more than 1 isotope 241 if(1 < nIso) { 240 if(1 < nIso) { 242 const G4double* abundVector = anElement- 241 const G4double* abundVector = anElement->GetRelativeAbundanceVector(); 243 if(xseciso.size() < nIso) { xseciso.resi 242 if(xseciso.size() < nIso) { xseciso.resize(nIso); } 244 243 245 G4double cross = 0.0; 244 G4double cross = 0.0; 246 G4int j; 245 G4int j; 247 for (j = 0; j<(G4int)nIso; ++j) { 246 for (j = 0; j<(G4int)nIso; ++j) { 248 G4double xsec = 0.0; 247 G4double xsec = 0.0; 249 if(abundVector[j] > 0.0) { 248 if(abundVector[j] > 0.0) { 250 iso = anElement->GetIsotope(j); 249 iso = anElement->GetIsotope(j); 251 xsec = abundVector[j]* 250 xsec = abundVector[j]* 252 GetIsoCrossSection(dp, Z, iso->GetN(), i 251 GetIsoCrossSection(dp, Z, iso->GetN(), iso, anElement, mat, i); 253 } 252 } 254 cross += xsec; 253 cross += xsec; 255 xseciso[j] = cross; 254 xseciso[j] = cross; 256 } 255 } 257 cross *= G4UniformRand(); 256 cross *= G4UniformRand(); 258 for (j = 0; j<(G4int)nIso; ++j) { 257 for (j = 0; j<(G4int)nIso; ++j) { 259 if(cross <= xseciso[j]) { 258 if(cross <= xseciso[j]) { 260 iso = anElement->GetIsotope(j); 259 iso = anElement->GetIsotope(j); 261 break; 260 break; 262 } 261 } 263 } 262 } 264 } 263 } 265 } 264 } 266 target.SetIsotope(iso); 265 target.SetIsotope(iso); 267 return anElement; 266 return anElement; 268 } 267 } 269 268 270 //....oooOO0OOooo........oooOO0OOooo........oo 269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 271 270 272 void 271 void 273 G4CrossSectionDataStore::BuildPhysicsTable(con 272 G4CrossSectionDataStore::BuildPhysicsTable(const G4ParticleDefinition& part) 274 { 273 { 275 if (nDataSetList == 0) { 274 if (nDataSetList == 0) { 276 G4ExceptionDescription ed; 275 G4ExceptionDescription ed; 277 ed << "No cross section is registered for 276 ed << "No cross section is registered for " 278 << part.GetParticleName() << G4endl; 277 << part.GetParticleName() << G4endl; 279 G4Exception("G4CrossSectionDataStore::Buil 278 G4Exception("G4CrossSectionDataStore::BuildPhysicsTable", "had001", 280 FatalException, ed); 279 FatalException, ed); 281 return; 280 return; 282 } 281 } 283 matParticle = ∂ 282 matParticle = ∂ 284 for (G4int i=0; i<nDataSetList; ++i) { 283 for (G4int i=0; i<nDataSetList; ++i) { 285 dataSetList[i]->BuildPhysicsTable(part); 284 dataSetList[i]->BuildPhysicsTable(part); 286 } 285 } 287 const G4MaterialTable* theMatTable = G4Mater 286 const G4MaterialTable* theMatTable = G4Material::GetMaterialTable(); 288 std::size_t nelm = 0; 287 std::size_t nelm = 0; 289 std::size_t niso = 0; 288 std::size_t niso = 0; 290 for(auto mat : *theMatTable) { 289 for(auto mat : *theMatTable) { 291 std::size_t nElements = mat->GetNumberOfEl 290 std::size_t nElements = mat->GetNumberOfElements(); 292 nelm = std::max(nelm, nElements); 291 nelm = std::max(nelm, nElements); 293 for(G4int j=0; j<(G4int)nElements; ++j) { 292 for(G4int j=0; j<(G4int)nElements; ++j) { 294 niso = std::max(niso, mat->GetElement(j) 293 niso = std::max(niso, mat->GetElement(j)->GetNumberOfIsotopes()); 295 } 294 } 296 } 295 } 297 // define vectors for a run 296 // define vectors for a run 298 xsecelm.resize(nelm, 0.0); 297 xsecelm.resize(nelm, 0.0); 299 xseciso.resize(niso, 0.0); 298 xseciso.resize(niso, 0.0); 300 } 299 } 301 300 302 //....oooOO0OOooo........oooOO0OOooo........oo 301 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 303 302 304 void 303 void 305 G4CrossSectionDataStore::DumpPhysicsTable(cons 304 G4CrossSectionDataStore::DumpPhysicsTable(const G4ParticleDefinition& part) 306 { 305 { 307 // Print out all cross section data sets use 306 // Print out all cross section data sets used and the energies at 308 // which they apply 307 // which they apply 309 308 310 if (nDataSetList == 0) { 309 if (nDataSetList == 0) { 311 G4cout << "WARNING - G4CrossSectionDataSto 310 G4cout << "WARNING - G4CrossSectionDataStore::DumpPhysicsTable: " 312 << " no data sets registered" << G4endl; 311 << " no data sets registered" << G4endl; 313 return; 312 return; 314 } 313 } 315 314 316 for (G4int i = nDataSetList-1; i >= 0; --i) 315 for (G4int i = nDataSetList-1; i >= 0; --i) { 317 G4double e1 = dataSetList[i]->GetMinKinEne 316 G4double e1 = dataSetList[i]->GetMinKinEnergy(); 318 G4double e2 = dataSetList[i]->GetMaxKinEne 317 G4double e2 = dataSetList[i]->GetMaxKinEnergy(); 319 G4cout 318 G4cout 320 << " Cr_sctns: " << std::setw(25) << 319 << " Cr_sctns: " << std::setw(25) << dataSetList[i]->GetName() << ": " 321 << G4BestUnit(e1, "Energy") << " ---> " 320 << G4BestUnit(e1, "Energy") << " ---> " 322 << G4BestUnit(e2, "Energy") << "\n"; << 321 << G4BestUnit(e2, "Energy") << "\n"; 323 if (dataSetList[i]->GetName() == "G4CrossS 322 if (dataSetList[i]->GetName() == "G4CrossSectionPairGG") { 324 dataSetList[i]->DumpPhysicsTable(part); 323 dataSetList[i]->DumpPhysicsTable(part); 325 G4cout << G4endl; << 326 } 324 } >> 325 G4cout << G4endl; 327 } 326 } 328 } 327 } 329 328 330 //....oooOO0OOooo........oooOO0OOooo........oo 329 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 331 330 332 void G4CrossSectionDataStore::DumpHtml(const G 331 void G4CrossSectionDataStore::DumpHtml(const G4ParticleDefinition& /* pD */, 333 std::of 332 std::ofstream& outFile) const 334 { 333 { 335 // Write cross section data set info to html 334 // Write cross section data set info to html physics list 336 // documentation page 335 // documentation page 337 336 338 G4double ehi = 0; 337 G4double ehi = 0; 339 G4double elo = 0; 338 G4double elo = 0; 340 auto param = G4HadronicParameters::Instance( << 339 G4String physListName(std::getenv("G4PhysListName")); 341 G4String physListName = param->GetPhysListNa << 342 G4String dirName = param->GetPhysListDocDir( << 343 << 344 for (G4int i = nDataSetList-1; i > 0; i--) { 340 for (G4int i = nDataSetList-1; i > 0; i--) { 345 elo = dataSetList[i]->GetMinKinEnergy()/Ge 341 elo = dataSetList[i]->GetMinKinEnergy()/GeV; 346 ehi = dataSetList[i]->GetMaxKinEnergy()/Ge 342 ehi = dataSetList[i]->GetMaxKinEnergy()/GeV; 347 outFile << " <li><b><a href=\"" << ph 343 outFile << " <li><b><a href=\"" << physListName << "_" 348 << dataSetList[i]->GetName() << ".html\" 344 << dataSetList[i]->GetName() << ".html\"> " 349 << dataSetList[i]->GetName() << "< 345 << dataSetList[i]->GetName() << "</a> from " 350 << elo << " GeV to " << ehi << " G 346 << elo << " GeV to " << ehi << " GeV </b></li>\n"; 351 PrintCrossSectionHtml(dataSetList[i], phys << 347 PrintCrossSectionHtml(dataSetList[i]); 352 } 348 } 353 349 354 G4double defaultHi = dataSetList[0]->GetMaxK 350 G4double defaultHi = dataSetList[0]->GetMaxKinEnergy()/GeV; 355 if (ehi < defaultHi) { 351 if (ehi < defaultHi) { 356 outFile << " <li><b><a href=\"" << da 352 outFile << " <li><b><a href=\"" << dataSetList[0]->GetName() 357 << ".html\"> " 353 << ".html\"> " 358 << dataSetList[0]->GetName() << "< 354 << dataSetList[0]->GetName() << "</a> from " 359 << ehi << " GeV to " << defaultHi 355 << ehi << " GeV to " << defaultHi << " GeV </b></li>\n"; 360 PrintCrossSectionHtml(dataSetList[0], phys << 356 PrintCrossSectionHtml(dataSetList[0]); 361 } 357 } 362 } 358 } 363 359 364 //....oooOO0OOooo........oooOO0OOooo........oo 360 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 365 361 366 void G4CrossSectionDataStore::PrintCrossSectio << 362 void G4CrossSectionDataStore::PrintCrossSectionHtml(const G4VCrossSectionDataSet *cs) const 367 << 368 << 369 { 363 { >> 364 G4String dirName(std::getenv("G4PhysListDocDir")); >> 365 G4String physListName(std::getenv("G4PhysListName")); 370 366 371 G4String pathName = dirName + "/" + physList 367 G4String pathName = dirName + "/" + physListName + "_" + HtmlFileName(cs->GetName()); 372 std::ofstream outCS; 368 std::ofstream outCS; 373 outCS.open(pathName); 369 outCS.open(pathName); 374 outCS << "<html>\n"; 370 outCS << "<html>\n"; 375 outCS << "<head>\n"; 371 outCS << "<head>\n"; 376 outCS << "<title>Description of " << cs->Get 372 outCS << "<title>Description of " << cs->GetName() 377 << "</title>\n"; 373 << "</title>\n"; 378 outCS << "</head>\n"; 374 outCS << "</head>\n"; 379 outCS << "<body>\n"; 375 outCS << "<body>\n"; 380 376 381 cs->CrossSectionDescription(outCS); 377 cs->CrossSectionDescription(outCS); 382 378 383 outCS << "</body>\n"; 379 outCS << "</body>\n"; 384 outCS << "</html>\n"; 380 outCS << "</html>\n"; 385 } 381 } 386 382 387 //....oooOO0OOooo........oooOO0OOooo........oo 383 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 388 384 389 G4String G4CrossSectionDataStore::HtmlFileName 385 G4String G4CrossSectionDataStore::HtmlFileName(const G4String & in) const 390 { 386 { 391 G4String str(in); 387 G4String str(in); 392 // replace blanks by _ C++11 version: 388 // replace blanks by _ C++11 version: 393 std::transform(str.begin(), str.end(), str. 389 std::transform(str.begin(), str.end(), str.begin(), [](char ch) { 394 return ch == ' ' ? '_' : ch; 390 return ch == ' ' ? '_' : ch; 395 }); 391 }); 396 str=str + ".html"; 392 str=str + ".html"; 397 return str; 393 return str; 398 } 394 } 399 395 400 //....oooOO0OOooo........oooOO0OOooo........oo 396 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 401 397 402 void G4CrossSectionDataStore::AddDataSet(G4VCr 398 void G4CrossSectionDataStore::AddDataSet(G4VCrossSectionDataSet* p) 403 { 399 { 404 if(p->ForAllAtomsAndEnergies()) { 400 if(p->ForAllAtomsAndEnergies()) { 405 dataSetList.clear(); 401 dataSetList.clear(); 406 nDataSetList = 0; 402 nDataSetList = 0; 407 } 403 } 408 dataSetList.push_back(p); 404 dataSetList.push_back(p); 409 ++nDataSetList; 405 ++nDataSetList; 410 } 406 } 411 407 412 //....oooOO0OOooo........oooOO0OOooo........oo 408 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 413 409 414 void G4CrossSectionDataStore::AddDataSet(G4VCr 410 void G4CrossSectionDataStore::AddDataSet(G4VCrossSectionDataSet* p, std::size_t i) 415 { 411 { 416 if(p->ForAllAtomsAndEnergies()) { 412 if(p->ForAllAtomsAndEnergies()) { 417 dataSetList.clear(); 413 dataSetList.clear(); 418 dataSetList.push_back(p); 414 dataSetList.push_back(p); 419 nDataSetList = 1; 415 nDataSetList = 1; 420 } else if ( i >= dataSetList.size() ) { 416 } else if ( i >= dataSetList.size() ) { 421 dataSetList.push_back(p); 417 dataSetList.push_back(p); 422 ++nDataSetList; 418 ++nDataSetList; 423 } else { 419 } else { 424 std::vector< G4VCrossSectionDataSet* >::it 420 std::vector< G4VCrossSectionDataSet* >::iterator it = dataSetList.end() - i; 425 dataSetList.insert(it , p); 421 dataSetList.insert(it , p); 426 ++nDataSetList; 422 ++nDataSetList; 427 } 423 } 428 } 424 } 429 425 430 //....oooOO0OOooo........oooOO0OOooo........oo 426 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 431 427