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