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 // Author: Elena Guardincerri (Elena.Guardince 28 // Author: Elena Guardincerri (Elena.Guardincerri@ge.infn.it) 29 // 29 // 30 // History: 30 // History: 31 // ----------- 31 // ----------- 32 // 16 Sept 2001 First committed to cvs 32 // 16 Sept 2001 First committed to cvs 33 // 33 // 34 // ------------------------------------------- 34 // ------------------------------------------------------------------- 35 35 36 #include <fstream> 36 #include <fstream> 37 #include <sstream> 37 #include <sstream> 38 38 39 #include "G4RDFluoData.hh" 39 #include "G4RDFluoData.hh" 40 #include "G4SystemOfUnits.hh" 40 #include "G4SystemOfUnits.hh" 41 #include "G4DataVector.hh" 41 #include "G4DataVector.hh" 42 #include "G4RDFluoTransition.hh" 42 #include "G4RDFluoTransition.hh" 43 43 44 G4RDFluoData::G4RDFluoData() 44 G4RDFluoData::G4RDFluoData() 45 { 45 { 46 numberOfVacancies=0; 46 numberOfVacancies=0; 47 } 47 } 48 48 49 G4RDFluoData::~G4RDFluoData() 49 G4RDFluoData::~G4RDFluoData() 50 { 50 { 51 std::map<G4int,G4DataVector*,std::less<G4int> 51 std::map<G4int,G4DataVector*,std::less<G4int> >::iterator pos; 52 52 53 for (pos = idMap.begin(); pos != idMap.end() 53 for (pos = idMap.begin(); pos != idMap.end(); ++pos) 54 { 54 { 55 G4DataVector* dataSet = (*pos).second; 55 G4DataVector* dataSet = (*pos).second; 56 delete dataSet; 56 delete dataSet; 57 } 57 } 58 for (pos = energyMap.begin(); pos != energyM 58 for (pos = energyMap.begin(); pos != energyMap.end(); ++pos) 59 { 59 { 60 G4DataVector* dataSet = (*pos).second; 60 G4DataVector* dataSet = (*pos).second; 61 delete dataSet; 61 delete dataSet; 62 } 62 } 63 for (pos = probabilityMap.begin(); pos != pro 63 for (pos = probabilityMap.begin(); pos != probabilityMap.end(); ++pos) 64 { 64 { 65 G4DataVector* dataSet = (*pos).second; 65 G4DataVector* dataSet = (*pos).second; 66 delete dataSet; 66 delete dataSet; 67 } 67 } 68 } 68 } 69 69 70 size_t G4RDFluoData::NumberOfVacancies() const 70 size_t G4RDFluoData::NumberOfVacancies() const 71 { 71 { 72 return numberOfVacancies; 72 return numberOfVacancies; 73 } 73 } 74 74 75 G4int G4RDFluoData::VacancyId(G4int vacancyInd 75 G4int G4RDFluoData::VacancyId(G4int vacancyIndex) const 76 { 76 { 77 G4int n = -1; 77 G4int n = -1; 78 if (vacancyIndex<0 || vacancyIndex>=numberOf 78 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 79 {G4Exception("G4RDFluoData::VacancyId()", 79 {G4Exception("G4RDFluoData::VacancyId()", "OutOfRange", 80 FatalException, "VacancyIndex 80 FatalException, "VacancyIndex outside boundaries!");} 81 else 81 else 82 { 82 { 83 std::map<G4int,G4DataVector*,std::less<G 83 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos; 84 pos = idMap.find(vacancyIndex); 84 pos = idMap.find(vacancyIndex); 85 if (pos!= idMap.end()) 85 if (pos!= idMap.end()) 86 { G4DataVector dataSet = (*(*pos).second); 86 { G4DataVector dataSet = (*(*pos).second); 87 n = (G4int) dataSet[0]; 87 n = (G4int) dataSet[0]; 88 88 89 } 89 } 90 } 90 } 91 return n; 91 return n; 92 } 92 } 93 93 94 size_t G4RDFluoData::NumberOfTransitions(G4int 94 size_t G4RDFluoData::NumberOfTransitions(G4int vacancyIndex) const 95 { 95 { 96 G4int n = 0; 96 G4int n = 0; 97 if (vacancyIndex<0 || vacancyIndex>=numberOf 97 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 98 {G4Exception("G4RDFluoData::NumberOfTransi 98 {G4Exception("G4RDFluoData::NumberOfTransitions()", "OutOfRange", 99 FatalException, "VacancyIndex 99 FatalException, "VacancyIndex outside boundaries!");} 100 else 100 else 101 { 101 { 102 n = nInitShells[vacancyIndex]-1; 102 n = nInitShells[vacancyIndex]-1; 103 //-1 is necessary because the elements o 103 //-1 is necessary because the elements of the vector nInitShells 104 //include also the vacancy shell: 104 //include also the vacancy shell: 105 // -1 subtracts this last one 105 // -1 subtracts this last one 106 } 106 } 107 return n; 107 return n; 108 } 108 } 109 G4int G4RDFluoData::StartShellId(G4int initInd 109 G4int G4RDFluoData::StartShellId(G4int initIndex, G4int vacancyIndex) const 110 { 110 { 111 G4int n = -1; 111 G4int n = -1; 112 112 113 if (vacancyIndex<0 || vacancyIndex>=numberOfV 113 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 114 {G4Exception("G4RDFluoData::StartShellId() 114 {G4Exception("G4RDFluoData::StartShellId()", "OutOfRange", 115 FatalException, "VacancyIndex 115 FatalException, "VacancyIndex outside boundaries!");} 116 else 116 else 117 { 117 { 118 std::map<G4int,G4DataVector*,std::less<G4 118 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos; 119 119 120 pos = idMap.find(vacancyIndex); 120 pos = idMap.find(vacancyIndex); 121 121 122 G4DataVector dataSet = *((*pos).second); 122 G4DataVector dataSet = *((*pos).second); 123 123 124 G4int nData = dataSet.size(); 124 G4int nData = dataSet.size(); 125 //The first Element of idMap's dataSets i 125 //The first Element of idMap's dataSets is the original shell of the vacancy, 126 //so we must start from the first element 126 //so we must start from the first element of dataSet 127 if (initIndex >= 0 && initIndex < nData) 127 if (initIndex >= 0 && initIndex < nData) 128 { 128 { 129 n = (G4int) dataSet[initIndex+1]; 129 n = (G4int) dataSet[initIndex+1]; 130 130 131 } 131 } 132 } 132 } 133 return n; 133 return n; 134 } 134 } 135 135 136 G4double G4RDFluoData::StartShellEnergy(G4int 136 G4double G4RDFluoData::StartShellEnergy(G4int initIndex, G4int vacancyIndex) const 137 { 137 { 138 G4double n = -1; 138 G4double n = -1; 139 139 140 if (vacancyIndex<0 || vacancyIndex>=numberOf 140 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 141 {G4Exception("G4RDFluoData::StartShellEner 141 {G4Exception("G4RDFluoData::StartShellEnergy()", "OutOfRange", 142 FatalException, "VacancyIndex 142 FatalException, "VacancyIndex outside boundaries!");} 143 else 143 else 144 { 144 { 145 std::map<G4int,G4DataVector*,std::less<G4 145 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos; 146 146 147 pos = energyMap.find(vacancyIndex); 147 pos = energyMap.find(vacancyIndex); 148 148 149 G4DataVector dataSet = *((*pos).second); 149 G4DataVector dataSet = *((*pos).second); 150 150 151 G4int nData = dataSet.size(); 151 G4int nData = dataSet.size(); 152 if (initIndex >= 0 && initIndex < nData) 152 if (initIndex >= 0 && initIndex < nData) 153 { 153 { 154 n = dataSet[initIndex]; 154 n = dataSet[initIndex]; 155 155 156 } 156 } 157 } 157 } 158 return n; 158 return n; 159 } 159 } 160 160 161 G4double G4RDFluoData::StartShellProb(G4int in 161 G4double G4RDFluoData::StartShellProb(G4int initIndex, G4int vacancyIndex) const 162 { 162 { 163 G4double n = -1; 163 G4double n = -1; 164 164 165 if (vacancyIndex<0 || vacancyIndex>=numberOf 165 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 166 {G4Exception("G4RDFluoData::StartShellProb 166 {G4Exception("G4RDFluoData::StartShellProb()", "OutOfRange", 167 FatalException, "VacancyIndex 167 FatalException, "VacancyIndex outside boundaries!");} 168 else 168 else 169 { 169 { 170 std::map<G4int,G4DataVector*,std::less<G4 170 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos; 171 171 172 pos = probabilityMap.find(vacancyIndex); 172 pos = probabilityMap.find(vacancyIndex); 173 173 174 G4DataVector dataSet = *((*pos).second); 174 G4DataVector dataSet = *((*pos).second); 175 175 176 G4int nData = dataSet.size(); 176 G4int nData = dataSet.size(); 177 if (initIndex >= 0 && initIndex < nData) 177 if (initIndex >= 0 && initIndex < nData) 178 { 178 { 179 n = dataSet[initIndex]; 179 n = dataSet[initIndex]; 180 180 181 } 181 } 182 } 182 } 183 return n; 183 return n; 184 } 184 } 185 185 186 void G4RDFluoData::LoadData(G4int Z) 186 void G4RDFluoData::LoadData(G4int Z) 187 { 187 { 188 // Build the complete string identifying the 188 // Build the complete string identifying the file with the data set 189 189 190 std::ostringstream ost; 190 std::ostringstream ost; 191 if(Z != 0){ 191 if(Z != 0){ 192 ost << "fl-tr-pr-"<< Z << ".dat"; 192 ost << "fl-tr-pr-"<< Z << ".dat"; 193 } 193 } 194 else{ 194 else{ 195 ost << "fl-tr-pr-"<<".dat"; 195 ost << "fl-tr-pr-"<<".dat"; 196 } 196 } 197 G4String name(ost.str()); 197 G4String name(ost.str()); 198 198 199 const char* path = G4FindDataDir("G4LEDATA") << 199 char* path = getenv("G4LEDATA"); 200 if (!path) 200 if (!path) 201 { 201 { 202 G4String excep("G4LEDATA environment var 202 G4String excep("G4LEDATA environment variable not set!"); 203 G4Exception("G4RDEMDataSet::LoadData()", 203 G4Exception("G4RDEMDataSet::LoadData()", "InvalidSetup", 204 FatalException, excep); 204 FatalException, excep); 205 } 205 } 206 206 207 G4String pathString(path); 207 G4String pathString(path); 208 G4String fluor("/fluor/"); 208 G4String fluor("/fluor/"); 209 G4String dirFile = pathString + fluor + name 209 G4String dirFile = pathString + fluor + name; 210 std::ifstream file(dirFile); 210 std::ifstream file(dirFile); 211 std::filebuf* lsdp = file.rdbuf(); 211 std::filebuf* lsdp = file.rdbuf(); 212 212 213 if (! (lsdp->is_open()) ) 213 if (! (lsdp->is_open()) ) 214 { 214 { 215 G4String excep = "Data file: " + dirFile 215 G4String excep = "Data file: " + dirFile + " not found"; 216 G4Exception("G4RDEMDataSet::LoadData()", 216 G4Exception("G4RDEMDataSet::LoadData()", "DataNotFound", 217 FatalException, excep); 217 FatalException, excep); 218 } 218 } 219 219 220 G4double a = 0; 220 G4double a = 0; 221 G4int k = 1; 221 G4int k = 1; 222 G4int s = 0; 222 G4int s = 0; 223 223 224 G4int vacIndex = 0; 224 G4int vacIndex = 0; 225 G4DataVector* initIds = new G4DataVector; 225 G4DataVector* initIds = new G4DataVector; 226 G4DataVector* transEnergies = new G4DataVect 226 G4DataVector* transEnergies = new G4DataVector; 227 G4DataVector* transProbabilities = new G4Dat 227 G4DataVector* transProbabilities = new G4DataVector; 228 228 229 do { 229 do { 230 file >> a; 230 file >> a; 231 G4int nColumns = 3; 231 G4int nColumns = 3; 232 if (a == -1) 232 if (a == -1) 233 { 233 { 234 if (s == 0) 234 if (s == 0) 235 { 235 { 236 // End of a shell data set 236 // End of a shell data set 237 idMap[vacIndex] = initIds; 237 idMap[vacIndex] = initIds; 238 energyMap[vacIndex] = transEnergie 238 energyMap[vacIndex] = transEnergies; 239 probabilityMap[vacIndex] = transProbabil 239 probabilityMap[vacIndex] = transProbabilities; 240 // G4double size=transProbabilities 240 // G4double size=transProbabilities->size(); 241 G4int n = initIds->size(); 241 G4int n = initIds->size(); 242 242 243 nInitShells.push_back(n); 243 nInitShells.push_back(n); 244 numberOfVacancies++; 244 numberOfVacancies++; 245 // Start of new shell data set 245 // Start of new shell data set 246 initIds = new G4DataVector; 246 initIds = new G4DataVector; 247 transEnergies = new G4DataVector; 247 transEnergies = new G4DataVector; 248 transProbabilities = new G4DataVector; 248 transProbabilities = new G4DataVector; 249 vacIndex++; 249 vacIndex++; 250 } 250 } 251 s++; 251 s++; 252 if (s == nColumns) 252 if (s == nColumns) 253 { 253 { 254 s = 0; 254 s = 0; 255 } 255 } 256 } 256 } 257 else if (a == -2) 257 else if (a == -2) 258 { 258 { 259 // End of file; delete the empty vectors cre 259 // End of file; delete the empty vectors created 260 //when encountering the last -1 -1 row 260 //when encountering the last -1 -1 row 261 delete initIds; 261 delete initIds; 262 delete transEnergies; 262 delete transEnergies; 263 delete transProbabilities; 263 delete transProbabilities; 264 } 264 } 265 else 265 else 266 { 266 { 267 267 268 if(k%nColumns == 2) 268 if(k%nColumns == 2) 269 { 269 { 270 // 2nd column is transition probabiliti 270 // 2nd column is transition probabilities 271 271 272 if (a != -1) transProbabilities->push_bac 272 if (a != -1) transProbabilities->push_back(a); 273 273 274 k++; 274 k++; 275 } 275 } 276 else if (k%nColumns == 1) 276 else if (k%nColumns == 1) 277 { 277 { 278 // 1st column is shell id 278 // 1st column is shell id 279 // if this is the first data of the shel 279 // if this is the first data of the shell, all the colums are equal 280 // to the shell Id; so we skip the next 280 // to the shell Id; so we skip the next colums ang go to the next row 281 if(initIds->size() == 0) { 281 if(initIds->size() == 0) { 282 if (a != -1) initIds->push_back((G4int 282 if (a != -1) initIds->push_back((G4int)a); 283 file >> a; 283 file >> a; 284 file >> a; 284 file >> a; 285 k=k+2; 285 k=k+2; 286 } 286 } 287 else{ 287 else{ 288 if (a != -1) initIds->push_back(a); 288 if (a != -1) initIds->push_back(a); 289 } 289 } 290 k++; 290 k++; 291 } 291 } 292 else if (k%nColumns == 0) 292 else if (k%nColumns == 0) 293 293 294 {//third column is transition energies 294 {//third column is transition energies 295 295 296 if (a != -1) 296 if (a != -1) 297 {G4double e = a * MeV; 297 {G4double e = a * MeV; 298 transEnergies->push_back(e);} 298 transEnergies->push_back(e);} 299 299 300 k=1; 300 k=1; 301 } 301 } 302 } 302 } 303 } 303 } 304 while (a != -2); // end of file 304 while (a != -2); // end of file 305 file.close(); 305 file.close(); 306 } 306 } 307 307 308 void G4RDFluoData::PrintData() 308 void G4RDFluoData::PrintData() 309 { 309 { 310 310 311 for (G4int i = 0; i <numberOfVacancies; i++) 311 for (G4int i = 0; i <numberOfVacancies; i++) 312 { 312 { 313 G4cout << "---- TransitionData for the v 313 G4cout << "---- TransitionData for the vacancy nb " 314 <<i 314 <<i 315 <<" ----- " 315 <<" ----- " 316 <<G4endl; 316 <<G4endl; 317 317 318 for (size_t k = 0; k<NumberOfTransitions 318 for (size_t k = 0; k<NumberOfTransitions(i); k++) 319 { 319 { 320 G4int id = StartShellId(k,i); 320 G4int id = StartShellId(k,i); 321 // let's start from 1 because the first (ind 321 // let's start from 1 because the first (index = 0) element of the vector 322 // is the id of the intial vacancy 322 // is the id of the intial vacancy 323 G4double e = StartShellEnergy(k,i) /MeV; 323 G4double e = StartShellEnergy(k,i) /MeV; 324 G4double p = StartShellProb(k,i); 324 G4double p = StartShellProb(k,i); 325 G4cout << k <<") Shell id: " << id <<G4end 325 G4cout << k <<") Shell id: " << id <<G4endl; 326 G4cout << " - Transition energy = " << e < 326 G4cout << " - Transition energy = " << e << " MeV "<<G4endl; 327 G4cout << " - Transition probability = " 327 G4cout << " - Transition probability = " << p <<G4endl; 328 328 329 } 329 } 330 G4cout << "----------------------------- 330 G4cout << "-------------------------------------------------" 331 << G4endl; 331 << G4endl; 332 } 332 } 333 } 333 } 334 334