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