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 if (initIndex >= 0 && initIndex < nData) 138 // the vacancy, so we must start from the << 121 { 139 if (initIndex >= 0 && initIndex < nData) << 122 n = (G4int) dataSet[initIndex]; 140 n = (*dataSet)[initIndex+1]; << 123 141 } << 124 } 142 } 125 } 143 } << 144 return n; 126 return n; 145 } 127 } 146 << 147 //....oooOO0OOooo........oooOO0OOooo........oo << 148 128 149 G4double G4FluoData::StartShellEnergy(G4int in 129 G4double G4FluoData::StartShellEnergy(G4int initIndex, G4int vacancyIndex) const 150 { 130 { 151 G4double n = -1; 131 G4double n = -1; 152 132 153 if (vacancyIndex<0 || vacancyIndex>=numberOf 133 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 154 { << 134 {G4Exception("G4FluoData::vacancyIndex outside boundaries");} 155 G4Exception("G4FluoData::StartShellEnerg << 135 else 156 "vacancyIndex outside boundaries");} << 136 { 157 else << 137 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos; 158 { << 159 auto pos = energyMap.find(vacancyIndex); << 160 138 161 G4DataVector dataSet = *((*pos).second); << 139 pos = energyMap.find(vacancyIndex); 162 140 163 G4int nData = (G4int)dataSet.size(); << 141 G4DataVector dataSet = *((*pos).second); 164 if (initIndex >= 0 && initIndex < nData) << 142 165 { << 143 G4int nData = dataSet.size(); 166 n = dataSet[initIndex]; << 144 if (initIndex >= 0 && initIndex < nData) 167 } << 145 { 168 } << 146 n = dataSet[initIndex]; >> 147 >> 148 } >> 149 } 169 return n; 150 return n; 170 } 151 } 171 152 172 //....oooOO0OOooo........oooOO0OOooo........oo << 173 << 174 G4double G4FluoData::StartShellProb(G4int init 153 G4double G4FluoData::StartShellProb(G4int initIndex, G4int vacancyIndex) const 175 { 154 { 176 G4double n = -1; 155 G4double n = -1; 177 156 178 if (vacancyIndex<0 || vacancyIndex>=numberOf 157 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies) 179 { << 158 {G4Exception("G4FluoData::vacancyIndex outside boundaries");} 180 G4Exception("G4FluoData::StartShellEnerg << 181 "vacancyIndex outside boundaries, energy << 182 return 0; << 183 } << 184 else 159 else 185 { 160 { 186 auto pos = probabilityMap.find(vacancyIn << 161 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos; 187 162 188 G4DataVector dataSet = *((*pos).second); << 163 pos = probabilityMap.find(vacancyIndex); 189 164 190 G4int nData = (G4int)dataSet.size(); << 165 G4DataVector dataSet = *((*pos).second); 191 if (initIndex >= 0 && initIndex < nData) << 166 192 { << 167 G4int nData = dataSet.size(); 193 n = dataSet[initIndex]; << 168 if (initIndex >= 0 && initIndex < nData) 194 } << 169 { >> 170 n = dataSet[initIndex]; >> 171 >> 172 } 195 } 173 } 196 return n; 174 return n; 197 } 175 } 198 176 199 //....oooOO0OOooo........oooOO0OOooo........oo << 200 << 201 void G4FluoData::LoadData(G4int Z) 177 void G4FluoData::LoadData(G4int Z) 202 { 178 { 203 // Build the complete string identifying the 179 // Build the complete string identifying the file with the data set >> 180 204 std::ostringstream ost; 181 std::ostringstream ost; 205 if(Z != 0){ 182 if(Z != 0){ 206 ost << "/fl-tr-pr-"<< Z << ".dat"; << 183 ost << "fl-tr-pr-"<< Z << ".dat"; 207 } 184 } 208 else{ 185 else{ 209 ost << "/fl-tr-pr-"<<".dat"; << 186 ost << "fl-tr-pr-"<<".dat"; 210 } 187 } 211 G4String name(ost.str()); 188 G4String name(ost.str()); 212 << 213 189 214 const char* path = G4FindDataDir("G4LEDATA") << 190 char* path = getenv("G4LEDATA"); 215 if (!path) 191 if (!path) 216 { 192 { 217 G4String excep("G4FluoData::LoadData()") << 193 G4String excep("G4EMDataSet - G4LEDATA environment variable not set"); 218 G4Exception(excep,"em0006",FatalExceptio << 194 G4Exception(excep); 219 return; << 220 } 195 } 221 196 222 G4String pathString(path); 197 G4String pathString(path); 223 << 198 G4String fluor("/fluor/"); 224 G4String dirFile = pathString + fluoDirector << 199 G4String dirFile = pathString + fluor + name; 225 << 226 //G4cout << "G4FluoData:: LoadData() name: " << 227 << 228 << 229 std::ifstream file(dirFile); 200 std::ifstream file(dirFile); 230 std::filebuf* lsdp = file.rdbuf(); 201 std::filebuf* lsdp = file.rdbuf(); 231 202 232 if (! (lsdp->is_open()) ) 203 if (! (lsdp->is_open()) ) 233 { 204 { 234 G4String excep = "G4FluoData::LoadData() << 205 G4String excep = "G4FluoData - data file: " + dirFile + " not found"; 235 G4String msg = "data file: " + dirFile + << 206 G4Exception(excep); 236 G4Exception(excep, "em0003",FatalExcepti << 237 return; << 238 } 207 } 239 208 240 G4double a = 0; 209 G4double a = 0; 241 G4int k = 1; 210 G4int k = 1; 242 G4int sLocal = 0; << 211 G4int s = 0; 243 212 244 G4int vacIndex = 0; << 213 G4int vacId = 0; 245 G4DataVector* initIds = new G4DataVector; 214 G4DataVector* initIds = new G4DataVector; 246 G4DataVector* transEnergies = new G4DataVect 215 G4DataVector* transEnergies = new G4DataVector; 247 G4DataVector* transProbabilities = new G4Dat 216 G4DataVector* transProbabilities = new G4DataVector; 248 217 249 do { 218 do { 250 file >> a; 219 file >> a; 251 G4int nColumns = 3; 220 G4int nColumns = 3; 252 if (a == -1) 221 if (a == -1) 253 { 222 { 254 if (sLocal == 0) << 223 if (s == 0) 255 { 224 { 256 // End of a shell data set 225 // End of a shell data set 257 idMap[vacIndex] = initIds; << 226 idMap[vacId] = initIds; 258 energyMap[vacIndex] = transEnergie << 227 energyMap[vacId] = transEnergies; 259 probabilityMap[vacIndex] = transPr << 228 probabilityMap[vacId] = transProbabilities; 260 G4int n = (G4int)initIds->size(); << 229 // G4double size=transProbabilities->size(); >> 230 G4int n = initIds->size(); 261 231 262 nInitShells.push_back(n); 232 nInitShells.push_back(n); 263 numberOfVacancies++; 233 numberOfVacancies++; 264 // Start of new shell data set 234 // Start of new shell data set 265 initIds = new G4DataVector; 235 initIds = new G4DataVector; 266 transEnergies = new G4DataVector; 236 transEnergies = new G4DataVector; 267 transProbabilities = new G4DataVector; 237 transProbabilities = new G4DataVector; 268 vacIndex++; << 238 vacId++; 269 } 239 } 270 sLocal++; << 240 s++; 271 if (sLocal == nColumns) << 241 if (s == nColumns) 272 { 242 { 273 sLocal = 0; << 243 s = 0; 274 } 244 } 275 } 245 } 276 // moved to the end in order to avoid poss << 246 else if (a == -2) 277 /* else if (a == -2) << 278 { 247 { 279 // End of file; delete the empty vectors cre 248 // End of file; delete the empty vectors created 280 //when encountering the last -1 -1 row 249 //when encountering the last -1 -1 row 281 delete initIds; 250 delete initIds; 282 delete transEnergies; 251 delete transEnergies; 283 delete transProbabilities; 252 delete transProbabilities; 284 }*/ << 253 } 285 else 254 else 286 { << 255 { >> 256 287 if(k%nColumns == 2) 257 if(k%nColumns == 2) 288 { 258 { 289 // 2nd column is transition probabiliti 259 // 2nd column is transition probabilities 290 260 291 if (a != -1) transProbabilities->push_bac << 261 transProbabilities->push_back(a); 292 262 293 k++; 263 k++; 294 } 264 } 295 else if (k%nColumns == 1) 265 else if (k%nColumns == 1) 296 { 266 { 297 // 1st column is shell id << 267 // 1st column is shell id 298 // if this is the first data of the shel << 268 299 // to the shell Id; so we skip the next << 269 initIds->push_back(a); 300 if(initIds->size() == 0) { << 301 if (a != -1) initIds->push_back((G4int << 302 file >> a; << 303 file >> a; << 304 k=k+2; << 305 } << 306 else{ << 307 if (a != -1) initIds->push_back(a); << 308 } << 309 k++; 270 k++; >> 271 310 } 272 } 311 else if (k%nColumns == 0) 273 else if (k%nColumns == 0) 312 274 313 {//third column is transition energies 275 {//third column is transition energies 314 276 315 if (a != -1) << 277 G4double e = a * MeV; 316 {G4double e = a * MeV; << 278 transEnergies->push_back(e); 317 transEnergies->push_back(e);} << 318 279 319 k=1; 280 k=1; 320 } 281 } 321 } 282 } 322 } 283 } 323 while (a != -2); // end of file 284 while (a != -2); // end of file 324 file.close(); 285 file.close(); 325 delete initIds; << 326 delete transEnergies; << 327 delete transProbabilities; << 328 } 286 } 329 287 330 //....oooOO0OOooo........oooOO0OOooo........oo << 331 << 332 void G4FluoData::PrintData() 288 void G4FluoData::PrintData() 333 { 289 { 334 for (G4int i = 0; i <numberOfVacancies; ++i) << 290 >> 291 for (G4int i = 0; i <numberOfVacancies; i++) 335 { 292 { 336 G4cout << "---- TransitionData for the v 293 G4cout << "---- TransitionData for the vacancy nb " 337 << i << 294 <<i 338 << " ----- " << 295 <<" ----- " 339 << G4endl; << 296 <<G4endl; 340 297 341 for (G4int k = 0; k<(G4int)NumberOfTrans << 298 for (size_t k = 0; k<=NumberOfTransitions(i); k++) 342 { 299 { 343 G4int id = StartShellId(k,i); 300 G4int id = StartShellId(k,i); 344 // let's start from 1 because the first (ind << 345 // is the id of the initial vacancy << 346 G4double e = StartShellEnergy(k,i) /MeV; 301 G4double e = StartShellEnergy(k,i) /MeV; 347 G4double p = StartShellProb(k,i); 302 G4double p = StartShellProb(k,i); 348 G4cout << k <<") Shell id: " << id <<G4end 303 G4cout << k <<") Shell id: " << id <<G4endl; 349 G4cout << " - Transition energy = " << e < 304 G4cout << " - Transition energy = " << e << " MeV "<<G4endl; 350 G4cout << " - Transition probability = " 305 G4cout << " - Transition probability = " << p <<G4endl; 351 306 352 } 307 } 353 G4cout << "----------------------------- 308 G4cout << "-------------------------------------------------" 354 << G4endl; 309 << G4endl; 355 } 310 } 356 } 311 } >> 312 >> 313 >> 314 >> 315 >> 316 >> 317 >> 318 >> 319 >> 320 >> 321 >> 322 >> 323 >> 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 357 351