Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 // Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it) 28 // 29 // History: 30 // ----------- 31 // Based on G4FluoData by Elena Guardincerri 32 // 33 // Modified: 34 // 30.07.02 VI Add select active Z + clean up against pedantic compiler 35 // 36 // ------------------------------------------------------------------- 37 38 #include <fstream> 39 #include <sstream> 40 41 #include "G4AugerData.hh" 42 #include "G4SystemOfUnits.hh" 43 #include "G4DataVector.hh" 44 #include "G4Material.hh" 45 #include "G4Element.hh" 46 #include "G4ElementVector.hh" 47 48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 49 50 G4AugerData::G4AugerData() 51 { 52 numberOfVacancies.resize(105, 0); 53 BuildAugerTransitionTable(); 54 } 55 56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 57 58 std::size_t G4AugerData::NumberOfVacancies(G4int Z) const 59 { 60 return numberOfVacancies[Z]; 61 } 62 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 64 65 G4int G4AugerData::VacancyId(G4int Z, G4int vacancyIndex) const 66 { 67 G4int n = 0; 68 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z]) 69 { 70 G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,""); 71 } 72 else { 73 trans_Table::const_iterator element = augerTransitionTable.find(Z); 74 if (element == augerTransitionTable.end()) { 75 G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element"); 76 return 0; 77 } 78 std::vector<G4AugerTransition> dataSet = (*element).second; 79 n = (G4int) dataSet[vacancyIndex].FinalShellId(); 80 } 81 return n; 82 } 83 84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 85 86 // Attention: this method wants the vacancy index, not the Id 87 std::size_t G4AugerData::NumberOfTransitions(G4int Z, G4int vacancyIndex) const 88 { 89 std::size_t n = 0; 90 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z]) 91 { 92 G4Exception("G4AugerData::VacancyId()","de0002", JustWarning, "Energy deposited locally"); 93 return 0; 94 } 95 else { 96 trans_Table::const_iterator element = augerTransitionTable.find(Z); 97 if (element == augerTransitionTable.end()) 98 { 99 G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element"); 100 return 0; 101 } 102 std::vector<G4AugerTransition> dataSet = (*element).second; 103 n = dataSet[vacancyIndex].TransitionOriginatingShellIds()->size(); 104 } 105 return n; 106 } 107 108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 109 110 std::size_t G4AugerData::NumberOfAuger(G4int Z, G4int initIndex, G4int vacancyId) const 111 { 112 std::size_t n = 0; 113 if (initIndex<0 || initIndex>=numberOfVacancies[Z]) 114 { 115 G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,""); 116 return 0; 117 } 118 else { 119 trans_Table::const_iterator element = augerTransitionTable.find(Z); 120 if (element == augerTransitionTable.end()) { 121 G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element"); 122 return 0; 123 } 124 std::vector<G4AugerTransition> dataSet = (*element).second; 125 const std::vector<G4int>* temp = 126 dataSet[initIndex].AugerOriginatingShellIds(vacancyId); 127 n = temp->size(); 128 } 129 return n; 130 } 131 132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 133 134 std::size_t G4AugerData::AugerShellId(G4int Z, G4int vacancyIndex, G4int transId, G4int augerIndex) const 135 { 136 std::size_t n = 0; 137 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z]) 138 { 139 G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,""); 140 return 0; 141 } 142 else { 143 trans_Table::const_iterator element = augerTransitionTable.find(Z); 144 if (element == augerTransitionTable.end()) { 145 G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element"); 146 return 0; 147 } 148 std::vector<G4AugerTransition> dataSet = (*element).second; 149 n = dataSet[vacancyIndex].AugerOriginatingShellId(augerIndex,transId); 150 } 151 return n; 152 } 153 154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 155 156 G4int G4AugerData::StartShellId(G4int Z, G4int vacancyIndex, G4int transitionShellIndex) const 157 { 158 G4int n = 0; 159 160 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z]) { 161 G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,""); 162 return 0; 163 } 164 else { 165 trans_Table::const_iterator element = augerTransitionTable.find(Z); 166 if (element == augerTransitionTable.end()) { 167 G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element"); 168 return 0; 169 } 170 std::vector<G4AugerTransition> dataSet = (*element).second; 171 n = dataSet[vacancyIndex].TransitionOriginatingShellId(transitionShellIndex); 172 } 173 return n; 174 } 175 176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 177 178 G4double G4AugerData::StartShellEnergy(G4int Z, G4int vacancyIndex, G4int transitionId, G4int augerIndex) const 179 { 180 G4double energy = 0; 181 182 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z]) 183 { 184 G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,""); 185 return 0; 186 } 187 else { 188 trans_Table::const_iterator element = augerTransitionTable.find(Z); 189 if (element == augerTransitionTable.end()) { 190 G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element"); 191 return 0; 192 } 193 std::vector<G4AugerTransition> dataSet = (*element).second; 194 energy = dataSet[vacancyIndex].AugerTransitionEnergy(augerIndex,transitionId); 195 196 } 197 return energy; 198 } 199 200 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 201 202 G4double G4AugerData::StartShellProb(G4int Z, G4int vacancyIndex,G4int transitionId,G4int augerIndex) const 203 { 204 G4double prob = 0; 205 206 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies[Z]) 207 { 208 G4Exception("G4AugerData::VacancyId()","de0002", FatalErrorInArgument,""); 209 return 0; 210 } 211 else { 212 trans_Table::const_iterator element = augerTransitionTable.find(Z); 213 if (element == augerTransitionTable.end()) { 214 G4Exception("G4AugerData::VacancyId()","de0004", FatalErrorInArgument, "Check element"); 215 return 0; 216 } 217 std::vector<G4AugerTransition> dataSet = (*element).second; 218 prob = dataSet[vacancyIndex].AugerTransitionProbability(augerIndex, transitionId); 219 } 220 return prob; 221 } 222 223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 224 225 std::vector<G4AugerTransition> G4AugerData::LoadData(G4int Z) 226 { 227 // Build the complete string identifying the file with the data set 228 std::ostringstream ost; 229 if(Z != 0){ 230 ost << "au-tr-pr-"<< Z << ".dat"; 231 } 232 else{ 233 ost << "au-tr-pr-"<<".dat"; 234 } 235 G4String name(ost.str()); 236 237 const char* path = G4FindDataDir("G4LEDATA"); 238 if (nullptr == path) 239 { 240 G4String excep = "G4AugerData::LoadData"; 241 G4Exception(excep,"em0006", FatalException,"" ); 242 std::vector<G4AugerTransition> a; 243 return a; 244 } 245 246 G4String pathString(path); 247 G4String dirFile = pathString + "/auger/" + name; 248 std::ifstream file(dirFile); 249 std::filebuf* lsdp = file.rdbuf(); 250 251 if (! (lsdp->is_open()) ) 252 { 253 G4String excep = "G4AugerData::LoadData"; 254 G4String msg = "Missing" + dirFile; 255 G4Exception(excep,"em0003", FatalException, msg); 256 } 257 258 G4double a = 0; 259 G4int k = 1; 260 G4int sLocal = 0; 261 262 G4int vacId = 0; 263 std::vector<G4int>* initIds = new std::vector<G4int>; 264 std::vector<G4int>* newIds = new std::vector<G4int>; 265 G4DataVector* transEnergies = new G4DataVector; 266 G4DataVector* transProbabilities = new G4DataVector; 267 std::vector<G4AugerTransition> augerTransitionVector; 268 std::map<G4int,std::vector<G4int>,std::less<G4int> >* newIdMap = 269 new std::map<G4int,std::vector<G4int>,std::less<G4int> >; 270 std::map<G4int,G4DataVector,std::less<G4int> >* newEnergyMap = 271 new std::map<G4int,G4DataVector,std::less<G4int> >; 272 std::map<G4int,G4DataVector,std::less<G4int> >* newProbabilityMap = 273 new std::map<G4int,G4DataVector,std::less<G4int> >; 274 275 do { 276 file >> a; 277 G4int nColumns = 4; 278 if (a == -1) 279 { 280 if (sLocal == 0) 281 { 282 // End of a shell data set 283 std::vector<G4int>::iterator vectorIndex = initIds->begin(); 284 285 vacId = *vectorIndex; 286 std::vector<G4int> identifiers; 287 for (vectorIndex = initIds->begin()+1 ; vectorIndex != initIds->end(); ++vectorIndex){ 288 identifiers.push_back(*vectorIndex); 289 } 290 vectorIndex = (initIds->end())-1; 291 G4int augerShellId = *(vectorIndex); 292 293 (*newIdMap)[augerShellId] = *newIds; 294 (*newEnergyMap)[augerShellId] = *transEnergies; 295 (*newProbabilityMap)[augerShellId] = *transProbabilities; 296 297 augerTransitionVector.push_back(G4AugerTransition(vacId, std::move(identifiers), 298 newIdMap, newEnergyMap, newProbabilityMap)); 299 // Now deleting all the variables I used, and creating new ones for the next shell 300 delete newIdMap; 301 delete newEnergyMap; 302 delete newProbabilityMap; 303 304 G4int n = (G4int)initIds->size(); 305 nInitShells.push_back(n); 306 numberOfVacancies[Z]++; 307 delete initIds; 308 delete newIds; 309 delete transEnergies; 310 delete transProbabilities; 311 initIds = new std::vector<G4int>; 312 newIds = new std::vector<G4int>; 313 transEnergies = new G4DataVector; 314 transProbabilities = new G4DataVector; 315 newIdMap = 316 new std::map<G4int,std::vector<G4int>,std::less<G4int> >; 317 newEnergyMap = new std::map<G4int,G4DataVector,std::less<G4int> >; 318 newProbabilityMap = 319 new std::map<G4int,G4DataVector,std::less<G4int> >; 320 } 321 ++sLocal; 322 if (sLocal == nColumns) 323 { 324 sLocal = 0; 325 } 326 } 327 else 328 { 329 330 if (k%nColumns == 3){ 331 // 3rd column is the transition probabilities 332 transProbabilities->push_back(a); 333 ++k; 334 } 335 else if(k%nColumns == 2){ 336 // 2nd column is new auger vacancy 337 G4int l = (G4int)a; 338 newIds->push_back(l); 339 ++k; 340 } 341 else if (k%nColumns == 1) 342 { 343 // 1st column is shell id 344 if(initIds->size() == 0) { 345 // if this is the first data of the shell, all the colums are equal 346 // to the shell Id; so we skip the next colums ang go to the next row 347 initIds->push_back((G4int)a); 348 // first line of initIds is the original shell of the vacancy 349 file >> a; 350 file >> a; 351 file >> a; 352 k = k+3; 353 } 354 else { 355 if((G4int)a != initIds->back()){ 356 if((initIds->size()) == 1) { 357 initIds->push_back((G4int)a); 358 } 359 else { 360 361 362 G4int augerShellId = 0; 363 augerShellId = initIds->back(); 364 365 (*newIdMap)[augerShellId] = *newIds; 366 (*newEnergyMap)[augerShellId] = *transEnergies; 367 (*newProbabilityMap)[augerShellId] = *transProbabilities; 368 delete newIds; 369 delete transEnergies; 370 delete transProbabilities; 371 newIds = new std::vector<G4int>; 372 transEnergies = new G4DataVector; 373 transProbabilities = new G4DataVector; 374 initIds->push_back((G4int)a); 375 } 376 } 377 } 378 k++; 379 } 380 else if (k%nColumns == 0) 381 {//fourth column is transition energies 382 G4double e = a * MeV; 383 transEnergies->push_back(e); 384 k=1; 385 } 386 } 387 } 388 while (a != -2); // end of file 389 file.close(); 390 delete initIds; 391 delete newIds; 392 delete transEnergies; 393 delete transProbabilities; 394 delete newIdMap ; 395 delete newEnergyMap; 396 delete newProbabilityMap; 397 return augerTransitionVector; 398 } 399 400 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 401 402 void G4AugerData::BuildAugerTransitionTable() 403 { 404 for (G4int element = 6; element < 105; ++element) { 405 augerTransitionTable.insert(trans_Table::value_type(element,LoadData(element))); 406 } 407 } 408 409 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 410 411 void G4AugerData::PrintData(G4int Z) 412 { 413 for (G4int i = 0; i < numberOfVacancies[Z]; ++i) 414 { 415 G4cout << "---- TransitionData for the vacancy nb " 416 <<i 417 <<" of the atomic number elemnt " 418 << Z 419 <<"----- " 420 <<G4endl; 421 422 for (G4int k = 0; k<=(G4int)NumberOfTransitions(Z,i); ++k) 423 { 424 G4int id = StartShellId(Z,i,k); 425 426 for (G4int a = 0; a <= (G4int)NumberOfAuger(Z,i,id); ++a) { 427 G4double e = StartShellEnergy(Z,i,id,a)/MeV; 428 G4double p = StartShellProb(Z,i,id,a); 429 std::size_t augerId = AugerShellId(Z, i, id, a); 430 G4cout << k <<") Shell id: " << id <<G4endl; 431 G4cout << " Auger Originatig Shell Id :"<< augerId <<G4endl; 432 G4cout << " - Transition energy = " << e << " MeV "<<G4endl; 433 G4cout << " - Transition probability = " << p <<G4endl; 434 } 435 } 436 G4cout << "-------------------------------------------------" 437 << G4endl; 438 } 439 } 440 441 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 442 443 G4AugerTransition* 444 G4AugerData::GetAugerTransition(G4int Z, G4int vacancyShellIndex) 445 { 446 std::vector<G4AugerTransition>* dataSet = &augerTransitionTable[Z]; 447 std::vector<G4AugerTransition>::iterator vectorIndex = 448 dataSet->begin() + vacancyShellIndex; 449 450 G4AugerTransition* augerTransition = &(*vectorIndex); 451 return augerTransition; 452 } 453 454 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 455 456 std::vector<G4AugerTransition>* G4AugerData::GetAugerTransitions(G4int Z) 457 { 458 std::vector<G4AugerTransition>* dataSet = &augerTransitionTable[Z]; 459 return dataSet; 460 } 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482