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