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